@@ -135,7 +135,7 @@ |
||
135 | 135 | $this->template_args['ticket_row_html'] = $ticket_row_html; |
136 | 136 | $this->template_args['taxable_tickets'] = $taxable_tickets; |
137 | 137 | $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
138 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
138 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php'; |
|
139 | 139 | remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
140 | 140 | } |
141 | 141 |
@@ -17,126 +17,126 @@ |
||
17 | 17 | class TicketSelectorStandard extends TicketSelector |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string $date_format |
|
22 | - */ |
|
23 | - protected $date_format; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string $time_format |
|
27 | - */ |
|
28 | - protected $time_format; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | - */ |
|
33 | - protected $ticket_selector_config; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var \EE_Tax_Config $tax_config |
|
37 | - */ |
|
38 | - protected $tax_config; |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * TicketSelectorSimple constructor. |
|
44 | - * |
|
45 | - * @param \EE_Event $event |
|
46 | - * @param \EE_Ticket[] $tickets |
|
47 | - * @param int $max_attendees |
|
48 | - * @param array $template_args |
|
49 | - * @param string $date_format |
|
50 | - * @param string $time_format |
|
51 | - * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | - * @param \EE_Tax_Config $tax_config |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - \EE_Event $event, |
|
56 | - array $tickets, |
|
57 | - $max_attendees, |
|
58 | - array $template_args, |
|
59 | - $date_format = 'Y-m-d', |
|
60 | - $time_format = 'g:i a', |
|
61 | - \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | - \EE_Tax_Config $tax_config = null |
|
63 | - ) { |
|
64 | - $this->date_format = $date_format; |
|
65 | - $this->time_format = $time_format; |
|
66 | - // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | - $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | - ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | - : new \EE_Ticket_Selector_Config(); |
|
70 | - // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | - // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | - // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | - $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | - ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | - : new \EE_Tax_Config(); |
|
76 | - parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * sets any and all template args that are required for this Ticket Selector |
|
83 | - * |
|
84 | - * @return void |
|
85 | - * @throws \EE_Error |
|
86 | - */ |
|
87 | - protected function addTemplateArgs() |
|
88 | - { |
|
89 | - $row = 1; |
|
90 | - $ticket_row_html = ''; |
|
91 | - $required_ticket_sold_out = false; |
|
92 | - // flag to indicate that at least one taxable ticket has been encountered |
|
93 | - $taxable_tickets = false; |
|
94 | - $datetime_selector = null; |
|
95 | - $this->template_args['datetime_selector'] = ''; |
|
96 | - if ( |
|
97 | - $this->ticket_selector_config->getShowDatetimeSelector() |
|
98 | - !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
99 | - ) { |
|
100 | - $datetime_selector = new DatetimeSelector( |
|
101 | - $this->event, |
|
102 | - $this->tickets, |
|
103 | - $this->ticket_selector_config, |
|
104 | - $this->date_format, |
|
105 | - $this->time_format |
|
106 | - ); |
|
107 | - $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
108 | - } |
|
109 | - $total_tickets = count($this->tickets); |
|
110 | - // loop through tickets |
|
111 | - foreach ($this->tickets as $TKT_ID => $ticket) { |
|
112 | - if ($ticket instanceof \EE_Ticket) { |
|
113 | - $cols = 2; |
|
114 | - $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
115 | - $ticket_selector_row = new TicketSelectorRowStandard( |
|
116 | - new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
117 | - $this->tax_config, |
|
118 | - $total_tickets, |
|
119 | - $this->max_attendees, |
|
120 | - $row, |
|
121 | - $cols, |
|
122 | - $required_ticket_sold_out, |
|
123 | - $this->template_args['event_status'], |
|
124 | - $datetime_selector instanceof DatetimeSelector |
|
125 | - ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
126 | - : '' |
|
127 | - ); |
|
128 | - $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
129 | - $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
130 | - $row++; |
|
131 | - } |
|
132 | - } |
|
133 | - $this->template_args['row'] = $row; |
|
134 | - $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
135 | - $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
136 | - $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
137 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
138 | - remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
139 | - } |
|
20 | + /** |
|
21 | + * @var string $date_format |
|
22 | + */ |
|
23 | + protected $date_format; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string $time_format |
|
27 | + */ |
|
28 | + protected $time_format; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | + */ |
|
33 | + protected $ticket_selector_config; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var \EE_Tax_Config $tax_config |
|
37 | + */ |
|
38 | + protected $tax_config; |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * TicketSelectorSimple constructor. |
|
44 | + * |
|
45 | + * @param \EE_Event $event |
|
46 | + * @param \EE_Ticket[] $tickets |
|
47 | + * @param int $max_attendees |
|
48 | + * @param array $template_args |
|
49 | + * @param string $date_format |
|
50 | + * @param string $time_format |
|
51 | + * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | + * @param \EE_Tax_Config $tax_config |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + \EE_Event $event, |
|
56 | + array $tickets, |
|
57 | + $max_attendees, |
|
58 | + array $template_args, |
|
59 | + $date_format = 'Y-m-d', |
|
60 | + $time_format = 'g:i a', |
|
61 | + \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | + \EE_Tax_Config $tax_config = null |
|
63 | + ) { |
|
64 | + $this->date_format = $date_format; |
|
65 | + $this->time_format = $time_format; |
|
66 | + // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | + $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | + ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | + : new \EE_Ticket_Selector_Config(); |
|
70 | + // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | + // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | + // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | + $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | + ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | + : new \EE_Tax_Config(); |
|
76 | + parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * sets any and all template args that are required for this Ticket Selector |
|
83 | + * |
|
84 | + * @return void |
|
85 | + * @throws \EE_Error |
|
86 | + */ |
|
87 | + protected function addTemplateArgs() |
|
88 | + { |
|
89 | + $row = 1; |
|
90 | + $ticket_row_html = ''; |
|
91 | + $required_ticket_sold_out = false; |
|
92 | + // flag to indicate that at least one taxable ticket has been encountered |
|
93 | + $taxable_tickets = false; |
|
94 | + $datetime_selector = null; |
|
95 | + $this->template_args['datetime_selector'] = ''; |
|
96 | + if ( |
|
97 | + $this->ticket_selector_config->getShowDatetimeSelector() |
|
98 | + !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
99 | + ) { |
|
100 | + $datetime_selector = new DatetimeSelector( |
|
101 | + $this->event, |
|
102 | + $this->tickets, |
|
103 | + $this->ticket_selector_config, |
|
104 | + $this->date_format, |
|
105 | + $this->time_format |
|
106 | + ); |
|
107 | + $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
108 | + } |
|
109 | + $total_tickets = count($this->tickets); |
|
110 | + // loop through tickets |
|
111 | + foreach ($this->tickets as $TKT_ID => $ticket) { |
|
112 | + if ($ticket instanceof \EE_Ticket) { |
|
113 | + $cols = 2; |
|
114 | + $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
115 | + $ticket_selector_row = new TicketSelectorRowStandard( |
|
116 | + new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
117 | + $this->tax_config, |
|
118 | + $total_tickets, |
|
119 | + $this->max_attendees, |
|
120 | + $row, |
|
121 | + $cols, |
|
122 | + $required_ticket_sold_out, |
|
123 | + $this->template_args['event_status'], |
|
124 | + $datetime_selector instanceof DatetimeSelector |
|
125 | + ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
126 | + : '' |
|
127 | + ); |
|
128 | + $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
129 | + $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
130 | + $row++; |
|
131 | + } |
|
132 | + } |
|
133 | + $this->template_args['row'] = $row; |
|
134 | + $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
135 | + $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
136 | + $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
137 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
138 | + remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
139 | + } |
|
140 | 140 | |
141 | 141 | |
142 | 142 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @subpackage plugin api, messages |
7 | 7 | * @since 4.3.0 |
8 | 8 | */ |
9 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | 10 | exit('No direct script access allowed'); |
11 | 11 | } |
12 | 12 | |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | * Required. |
94 | 94 | * @type string |
95 | 95 | */ |
96 | - 'mtfilename' => (string)$setup_args['mtfilename'], |
|
96 | + 'mtfilename' => (string) $setup_args['mtfilename'], |
|
97 | 97 | /** |
98 | 98 | * Autoload paths for classes used by the message type. |
99 | 99 | * Required. |
100 | 100 | * @type array |
101 | 101 | */ |
102 | - 'autoloadpaths' => (array)$setup_args['autoloadpaths'], |
|
102 | + 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
103 | 103 | /** |
104 | 104 | * Messengers that the message type should be able to activate with. |
105 | 105 | * Use messenger slugs. |
106 | 106 | * @type array |
107 | 107 | */ |
108 | 108 | 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
109 | - ? (array)$setup_args['messengers_to_activate_with'] |
|
109 | + ? (array) $setup_args['messengers_to_activate_with'] |
|
110 | 110 | : array(), |
111 | 111 | /** |
112 | 112 | * Messengers that the message type should validate with. |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * @type array |
115 | 115 | */ |
116 | 116 | 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
117 | - ? (array)$setup_args['messengers_to_validate_with'] |
|
117 | + ? (array) $setup_args['messengers_to_validate_with'] |
|
118 | 118 | : array(), |
119 | 119 | /** |
120 | 120 | * Whether to force activate this message type the first time it is registered. |
121 | 121 | * @type bool False means its not activated by default and left up to the end user to activate. |
122 | 122 | */ |
123 | 123 | 'force_activation' => ! empty($setup_args['force_activation']) |
124 | - ? (bool)$setup_args['force_activation'] |
|
124 | + ? (bool) $setup_args['force_activation'] |
|
125 | 125 | : false, |
126 | 126 | /** |
127 | 127 | * What messengers this message type supports the default template pack for. |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @type array Expect an array of messengers this supports default template packs for. |
137 | 137 | */ |
138 | 138 | 'messengers_supporting_default_template_pack_with' => isset($setup_args['messengers_supporting_default_template_pack_with']) |
139 | - ? (array)$setup_args['messengers_supporting_default_template_pack_with'] |
|
139 | + ? (array) $setup_args['messengers_supporting_default_template_pack_with'] |
|
140 | 140 | : array(), |
141 | 141 | /** |
142 | 142 | * The base path where the default templates for this message type can be found. |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | ); |
163 | 163 | //add filters but only if they haven't already been set (these filters only need to be registered ONCE because |
164 | 164 | //the callback handles all registered message types. |
165 | - if ( false === has_filter( |
|
165 | + if (false === has_filter( |
|
166 | 166 | 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
167 | 167 | array('EE_Register_Message_Type', 'register_msgs_autoload_paths') |
168 | 168 | )) { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | if ($settings['force_activation']) { |
237 | 237 | foreach ($settings['messengers_to_activate_with'] as $messenger) { |
238 | 238 | //DO not force activation if this message type has already been activated in the system |
239 | - if (! $message_resource_manager->has_message_type_been_activated_for_messenger($message_type_name, |
|
239 | + if ( ! $message_resource_manager->has_message_type_been_activated_for_messenger($message_type_name, |
|
240 | 240 | $messenger) |
241 | 241 | ) { |
242 | 242 | $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public static function deregister($message_type_name = null) |
258 | 258 | { |
259 | - if (! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
259 | + if ( ! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
260 | 260 | //let's make sure that we remove any place this message type was made active |
261 | 261 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
262 | 262 | $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | */ |
298 | 298 | public static function register_msgs_autoload_paths($paths) |
299 | 299 | { |
300 | - if (! empty(self::$_ee_message_type_registry)) { |
|
300 | + if ( ! empty(self::$_ee_message_type_registry)) { |
|
301 | 301 | foreach (self::$_ee_message_type_registry as $mt_reg) { |
302 | 302 | if (empty($mt_reg['autoloadpaths'])) { |
303 | 303 | continue; |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | $context, |
414 | 414 | $template_pack |
415 | 415 | ) { |
416 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
416 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
417 | 417 | || ! $message_type instanceof EE_message_type |
418 | 418 | ) { |
419 | 419 | return $base_path; |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $file_extension, |
455 | 455 | $template_pack |
456 | 456 | ) { |
457 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
457 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
458 | 458 | return $base_path_or_url; |
459 | 459 | } |
460 | 460 | foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | && ! empty($mt_reg['base_url_for_default_variation']) |
465 | 465 | ) { |
466 | 466 | return $mt_reg['base_url_for_default_variation']; |
467 | - } elseif (! $url |
|
467 | + } elseif ( ! $url |
|
468 | 468 | && ! empty($mt_reg['base_path_for_default_variation']) |
469 | 469 | ) { |
470 | 470 | return $mt_reg['base_path_for_default_variation']; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.3.0 |
8 | 8 | */ |
9 | 9 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -22,461 +22,461 @@ discard block |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Holds values for registered message types |
|
27 | - * |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected static $_ee_message_type_registry = array(); |
|
25 | + /** |
|
26 | + * Holds values for registered message types |
|
27 | + * |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected static $_ee_message_type_registry = array(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * Method for registering new message types in the EE_messages system. |
|
35 | - * Note: All message types must have the following files in order to work: |
|
36 | - * Template files for default templates getting setup. |
|
37 | - * See /core/libraries/messages/defaults/default/ for examples |
|
38 | - * (note that template files match a specific naming schema). |
|
39 | - * These templates will need to be registered with the default template pack. |
|
40 | - * - EE_Messages_Validator extended class(es). See /core/libraries/messages/validators/email/ |
|
41 | - * for examples. Note for any new message types, there will need to be a validator for each |
|
42 | - * messenger combo this message type can activate with. |
|
43 | - * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new |
|
44 | - * message type and its properties. |
|
45 | - * |
|
46 | - * @since 4.3.0 |
|
47 | - * @param string $mt_name Whatever is defined for the $name property of |
|
48 | - * the message type you are registering (eg. |
|
49 | - * declined_registration). Required. |
|
50 | - * @param array $setup_args An array of arguments provided for registering the message type. |
|
51 | - * @see inline docs in the register method for what can be passed in as arguments. |
|
52 | - * @throws \EE_Error |
|
53 | - * } |
|
54 | - */ |
|
55 | - public static function register($mt_name = null, $setup_args = array()) |
|
56 | - { |
|
57 | - //required fields MUST be present, so let's make sure they are. |
|
58 | - if ( |
|
59 | - ! isset($mt_name) |
|
60 | - || ! is_array($setup_args) |
|
61 | - || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
|
62 | - ) { |
|
63 | - throw new EE_Error( |
|
64 | - __('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', |
|
65 | - 'event_espresso') |
|
66 | - ); |
|
67 | - } |
|
33 | + /** |
|
34 | + * Method for registering new message types in the EE_messages system. |
|
35 | + * Note: All message types must have the following files in order to work: |
|
36 | + * Template files for default templates getting setup. |
|
37 | + * See /core/libraries/messages/defaults/default/ for examples |
|
38 | + * (note that template files match a specific naming schema). |
|
39 | + * These templates will need to be registered with the default template pack. |
|
40 | + * - EE_Messages_Validator extended class(es). See /core/libraries/messages/validators/email/ |
|
41 | + * for examples. Note for any new message types, there will need to be a validator for each |
|
42 | + * messenger combo this message type can activate with. |
|
43 | + * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new |
|
44 | + * message type and its properties. |
|
45 | + * |
|
46 | + * @since 4.3.0 |
|
47 | + * @param string $mt_name Whatever is defined for the $name property of |
|
48 | + * the message type you are registering (eg. |
|
49 | + * declined_registration). Required. |
|
50 | + * @param array $setup_args An array of arguments provided for registering the message type. |
|
51 | + * @see inline docs in the register method for what can be passed in as arguments. |
|
52 | + * @throws \EE_Error |
|
53 | + * } |
|
54 | + */ |
|
55 | + public static function register($mt_name = null, $setup_args = array()) |
|
56 | + { |
|
57 | + //required fields MUST be present, so let's make sure they are. |
|
58 | + if ( |
|
59 | + ! isset($mt_name) |
|
60 | + || ! is_array($setup_args) |
|
61 | + || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
|
62 | + ) { |
|
63 | + throw new EE_Error( |
|
64 | + __('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', |
|
65 | + 'event_espresso') |
|
66 | + ); |
|
67 | + } |
|
68 | 68 | |
69 | - //make sure we don't register twice |
|
70 | - if (isset(self::$_ee_message_type_registry[$mt_name])) { |
|
71 | - return; |
|
72 | - } |
|
69 | + //make sure we don't register twice |
|
70 | + if (isset(self::$_ee_message_type_registry[$mt_name])) { |
|
71 | + return; |
|
72 | + } |
|
73 | 73 | |
74 | - //make sure this was called in the right place! |
|
75 | - if ( |
|
76 | - ! did_action('EE_Brewing_Regular___messages_caf') |
|
77 | - || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
78 | - ) { |
|
79 | - EE_Error::doing_it_wrong( |
|
80 | - __METHOD__, |
|
81 | - sprintf( |
|
82 | - __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', |
|
83 | - 'event_espresso'), |
|
84 | - $mt_name |
|
85 | - ), |
|
86 | - '4.3.0' |
|
87 | - ); |
|
88 | - } |
|
89 | - //setup $__ee_message_type_registry array from incoming values. |
|
90 | - self::$_ee_message_type_registry[$mt_name] = array( |
|
91 | - /** |
|
92 | - * The file name for the message type being registered. |
|
93 | - * Required. |
|
94 | - * @type string |
|
95 | - */ |
|
96 | - 'mtfilename' => (string)$setup_args['mtfilename'], |
|
97 | - /** |
|
98 | - * Autoload paths for classes used by the message type. |
|
99 | - * Required. |
|
100 | - * @type array |
|
101 | - */ |
|
102 | - 'autoloadpaths' => (array)$setup_args['autoloadpaths'], |
|
103 | - /** |
|
104 | - * Messengers that the message type should be able to activate with. |
|
105 | - * Use messenger slugs. |
|
106 | - * @type array |
|
107 | - */ |
|
108 | - 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
|
109 | - ? (array)$setup_args['messengers_to_activate_with'] |
|
110 | - : array(), |
|
111 | - /** |
|
112 | - * Messengers that the message type should validate with. |
|
113 | - * Use messenger slugs. |
|
114 | - * @type array |
|
115 | - */ |
|
116 | - 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
|
117 | - ? (array)$setup_args['messengers_to_validate_with'] |
|
118 | - : array(), |
|
119 | - /** |
|
120 | - * Whether to force activate this message type the first time it is registered. |
|
121 | - * @type bool False means its not activated by default and left up to the end user to activate. |
|
122 | - */ |
|
123 | - 'force_activation' => ! empty($setup_args['force_activation']) |
|
124 | - ? (bool)$setup_args['force_activation'] |
|
125 | - : false, |
|
126 | - /** |
|
127 | - * What messengers this message type supports the default template pack for. |
|
128 | - * Note: If you do not set this (or any of the following template pack/variation related arguments) to true, |
|
129 | - * then it is expected that the message type being registered is doing its own custom default template |
|
130 | - * pack/variation registration. |
|
131 | - * |
|
132 | - * If this is set and has values, then it is expected that the following arguments are also set in the incoming options |
|
133 | - * $setup_arguments array as well: |
|
134 | - * - 'base_path_for_default_templates' |
|
135 | - * |
|
136 | - * @type array Expect an array of messengers this supports default template packs for. |
|
137 | - */ |
|
138 | - 'messengers_supporting_default_template_pack_with' => isset($setup_args['messengers_supporting_default_template_pack_with']) |
|
139 | - ? (array)$setup_args['messengers_supporting_default_template_pack_with'] |
|
140 | - : array(), |
|
141 | - /** |
|
142 | - * The base path where the default templates for this message type can be found. |
|
143 | - * @type string |
|
144 | - */ |
|
145 | - 'base_path_for_default_templates' => isset($setup_args['base_path_for_default_templates']) |
|
146 | - ? $setup_args['base_path_for_default_templates'] |
|
147 | - : '', |
|
148 | - /** |
|
149 | - * The base path where the default variations for this message type can be found. |
|
150 | - * @type string |
|
151 | - */ |
|
152 | - 'base_path_for_default_variation' => isset($setup_args['base_path_for_default_variation']) |
|
153 | - ? $setup_args['base_path_for_default_variation'] |
|
154 | - : '', |
|
155 | - /** |
|
156 | - * The base url for the default variations for this message type. |
|
157 | - * @type string |
|
158 | - */ |
|
159 | - 'base_url_for_default_variation' => isset($setup_args['base_url_for_default_variation']) |
|
160 | - ? $setup_args['base_url_for_default_variation'] |
|
161 | - : '' |
|
162 | - ); |
|
163 | - //add filters but only if they haven't already been set (these filters only need to be registered ONCE because |
|
164 | - //the callback handles all registered message types. |
|
165 | - if ( false === has_filter( |
|
166 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
167 | - array('EE_Register_Message_Type', 'register_msgs_autoload_paths') |
|
168 | - )) { |
|
169 | - add_filter( |
|
170 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
171 | - array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), |
|
172 | - 10 |
|
173 | - ); |
|
174 | - add_filter( |
|
175 | - 'FHEE__EE_messages__get_installed__messagetype_files', |
|
176 | - array('EE_Register_Message_Type', 'register_messagetype_files'), |
|
177 | - 10, |
|
178 | - 1 |
|
179 | - ); |
|
180 | - add_filter( |
|
181 | - 'FHEE__EE_messenger__get_default_message_types__default_types', |
|
182 | - array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), |
|
183 | - 10, |
|
184 | - 2 |
|
185 | - ); |
|
186 | - add_filter( |
|
187 | - 'FHEE__EE_messenger__get_valid_message_types__valid_types', |
|
188 | - array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), |
|
189 | - 10, |
|
190 | - 2 |
|
191 | - ); |
|
192 | - //actions |
|
193 | - add_action( |
|
194 | - 'AHEE__EE_Addon__initialize_default_data__begin', |
|
195 | - array('EE_Register_Message_Type', 'set_defaults') |
|
196 | - ); |
|
74 | + //make sure this was called in the right place! |
|
75 | + if ( |
|
76 | + ! did_action('EE_Brewing_Regular___messages_caf') |
|
77 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
78 | + ) { |
|
79 | + EE_Error::doing_it_wrong( |
|
80 | + __METHOD__, |
|
81 | + sprintf( |
|
82 | + __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', |
|
83 | + 'event_espresso'), |
|
84 | + $mt_name |
|
85 | + ), |
|
86 | + '4.3.0' |
|
87 | + ); |
|
88 | + } |
|
89 | + //setup $__ee_message_type_registry array from incoming values. |
|
90 | + self::$_ee_message_type_registry[$mt_name] = array( |
|
91 | + /** |
|
92 | + * The file name for the message type being registered. |
|
93 | + * Required. |
|
94 | + * @type string |
|
95 | + */ |
|
96 | + 'mtfilename' => (string)$setup_args['mtfilename'], |
|
97 | + /** |
|
98 | + * Autoload paths for classes used by the message type. |
|
99 | + * Required. |
|
100 | + * @type array |
|
101 | + */ |
|
102 | + 'autoloadpaths' => (array)$setup_args['autoloadpaths'], |
|
103 | + /** |
|
104 | + * Messengers that the message type should be able to activate with. |
|
105 | + * Use messenger slugs. |
|
106 | + * @type array |
|
107 | + */ |
|
108 | + 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
|
109 | + ? (array)$setup_args['messengers_to_activate_with'] |
|
110 | + : array(), |
|
111 | + /** |
|
112 | + * Messengers that the message type should validate with. |
|
113 | + * Use messenger slugs. |
|
114 | + * @type array |
|
115 | + */ |
|
116 | + 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
|
117 | + ? (array)$setup_args['messengers_to_validate_with'] |
|
118 | + : array(), |
|
119 | + /** |
|
120 | + * Whether to force activate this message type the first time it is registered. |
|
121 | + * @type bool False means its not activated by default and left up to the end user to activate. |
|
122 | + */ |
|
123 | + 'force_activation' => ! empty($setup_args['force_activation']) |
|
124 | + ? (bool)$setup_args['force_activation'] |
|
125 | + : false, |
|
126 | + /** |
|
127 | + * What messengers this message type supports the default template pack for. |
|
128 | + * Note: If you do not set this (or any of the following template pack/variation related arguments) to true, |
|
129 | + * then it is expected that the message type being registered is doing its own custom default template |
|
130 | + * pack/variation registration. |
|
131 | + * |
|
132 | + * If this is set and has values, then it is expected that the following arguments are also set in the incoming options |
|
133 | + * $setup_arguments array as well: |
|
134 | + * - 'base_path_for_default_templates' |
|
135 | + * |
|
136 | + * @type array Expect an array of messengers this supports default template packs for. |
|
137 | + */ |
|
138 | + 'messengers_supporting_default_template_pack_with' => isset($setup_args['messengers_supporting_default_template_pack_with']) |
|
139 | + ? (array)$setup_args['messengers_supporting_default_template_pack_with'] |
|
140 | + : array(), |
|
141 | + /** |
|
142 | + * The base path where the default templates for this message type can be found. |
|
143 | + * @type string |
|
144 | + */ |
|
145 | + 'base_path_for_default_templates' => isset($setup_args['base_path_for_default_templates']) |
|
146 | + ? $setup_args['base_path_for_default_templates'] |
|
147 | + : '', |
|
148 | + /** |
|
149 | + * The base path where the default variations for this message type can be found. |
|
150 | + * @type string |
|
151 | + */ |
|
152 | + 'base_path_for_default_variation' => isset($setup_args['base_path_for_default_variation']) |
|
153 | + ? $setup_args['base_path_for_default_variation'] |
|
154 | + : '', |
|
155 | + /** |
|
156 | + * The base url for the default variations for this message type. |
|
157 | + * @type string |
|
158 | + */ |
|
159 | + 'base_url_for_default_variation' => isset($setup_args['base_url_for_default_variation']) |
|
160 | + ? $setup_args['base_url_for_default_variation'] |
|
161 | + : '' |
|
162 | + ); |
|
163 | + //add filters but only if they haven't already been set (these filters only need to be registered ONCE because |
|
164 | + //the callback handles all registered message types. |
|
165 | + if ( false === has_filter( |
|
166 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
167 | + array('EE_Register_Message_Type', 'register_msgs_autoload_paths') |
|
168 | + )) { |
|
169 | + add_filter( |
|
170 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
171 | + array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), |
|
172 | + 10 |
|
173 | + ); |
|
174 | + add_filter( |
|
175 | + 'FHEE__EE_messages__get_installed__messagetype_files', |
|
176 | + array('EE_Register_Message_Type', 'register_messagetype_files'), |
|
177 | + 10, |
|
178 | + 1 |
|
179 | + ); |
|
180 | + add_filter( |
|
181 | + 'FHEE__EE_messenger__get_default_message_types__default_types', |
|
182 | + array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), |
|
183 | + 10, |
|
184 | + 2 |
|
185 | + ); |
|
186 | + add_filter( |
|
187 | + 'FHEE__EE_messenger__get_valid_message_types__valid_types', |
|
188 | + array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), |
|
189 | + 10, |
|
190 | + 2 |
|
191 | + ); |
|
192 | + //actions |
|
193 | + add_action( |
|
194 | + 'AHEE__EE_Addon__initialize_default_data__begin', |
|
195 | + array('EE_Register_Message_Type', 'set_defaults') |
|
196 | + ); |
|
197 | 197 | |
198 | - //default template packs and variations related |
|
199 | - add_filter( |
|
200 | - 'FHEE__EE_Messages_Template_Pack_Default__get_supports', |
|
201 | - array('EE_Register_Message_Type', 'register_default_template_pack_supports') |
|
202 | - ); |
|
203 | - add_filter( |
|
204 | - 'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', |
|
205 | - array('EE_Register_Message_Type', 'register_base_template_path'), |
|
206 | - 10, |
|
207 | - 6 |
|
208 | - ); |
|
209 | - add_filter( |
|
210 | - 'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', |
|
211 | - array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
212 | - 10, |
|
213 | - 8 |
|
214 | - ); |
|
215 | - add_filter( |
|
216 | - 'FHEE__EE_Messages_Template_Pack__get_variation__base_path', |
|
217 | - array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
218 | - 10, |
|
219 | - 8 |
|
220 | - ); |
|
221 | - } |
|
222 | - } |
|
198 | + //default template packs and variations related |
|
199 | + add_filter( |
|
200 | + 'FHEE__EE_Messages_Template_Pack_Default__get_supports', |
|
201 | + array('EE_Register_Message_Type', 'register_default_template_pack_supports') |
|
202 | + ); |
|
203 | + add_filter( |
|
204 | + 'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', |
|
205 | + array('EE_Register_Message_Type', 'register_base_template_path'), |
|
206 | + 10, |
|
207 | + 6 |
|
208 | + ); |
|
209 | + add_filter( |
|
210 | + 'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', |
|
211 | + array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
212 | + 10, |
|
213 | + 8 |
|
214 | + ); |
|
215 | + add_filter( |
|
216 | + 'FHEE__EE_Messages_Template_Pack__get_variation__base_path', |
|
217 | + array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
218 | + 10, |
|
219 | + 8 |
|
220 | + ); |
|
221 | + } |
|
222 | + } |
|
223 | 223 | |
224 | 224 | |
225 | - /** |
|
226 | - * This just ensures that when an addon registers a message type that on initial activation/reactivation the |
|
227 | - * defaults the addon sets are taken care of. |
|
228 | - */ |
|
229 | - public static function set_defaults() |
|
230 | - { |
|
231 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
232 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
225 | + /** |
|
226 | + * This just ensures that when an addon registers a message type that on initial activation/reactivation the |
|
227 | + * defaults the addon sets are taken care of. |
|
228 | + */ |
|
229 | + public static function set_defaults() |
|
230 | + { |
|
231 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
232 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
233 | 233 | |
234 | - //for any message types with force activation, let's ensure they are activated |
|
235 | - foreach (self::$_ee_message_type_registry as $message_type_name => $settings) { |
|
236 | - if ($settings['force_activation']) { |
|
237 | - foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
238 | - //DO not force activation if this message type has already been activated in the system |
|
239 | - if (! $message_resource_manager->has_message_type_been_activated_for_messenger($message_type_name, |
|
240 | - $messenger) |
|
241 | - ) { |
|
242 | - $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
|
243 | - } |
|
244 | - } |
|
245 | - } |
|
246 | - } |
|
247 | - } |
|
234 | + //for any message types with force activation, let's ensure they are activated |
|
235 | + foreach (self::$_ee_message_type_registry as $message_type_name => $settings) { |
|
236 | + if ($settings['force_activation']) { |
|
237 | + foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
238 | + //DO not force activation if this message type has already been activated in the system |
|
239 | + if (! $message_resource_manager->has_message_type_been_activated_for_messenger($message_type_name, |
|
240 | + $messenger) |
|
241 | + ) { |
|
242 | + $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
|
243 | + } |
|
244 | + } |
|
245 | + } |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * This deregisters a message type that was previously registered with a specific message_type_name. |
|
252 | - * |
|
253 | - * @since 4.3.0 |
|
254 | - * @param string $message_type_name the name for the message type that was previously registered |
|
255 | - * @return void |
|
256 | - */ |
|
257 | - public static function deregister($message_type_name = null) |
|
258 | - { |
|
259 | - if (! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
260 | - //let's make sure that we remove any place this message type was made active |
|
261 | - /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
|
262 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
263 | - //ensures that if this message type is registered again that it retains its previous active state vs |
|
264 | - //remaining inactive. |
|
265 | - $Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers( |
|
266 | - $message_type_name, |
|
267 | - true |
|
268 | - ); |
|
269 | - $Message_Resource_Manager->deactivate_message_type($message_type_name, false); |
|
270 | - unset(self::$_ee_message_type_registry[$message_type_name]); |
|
271 | - } |
|
272 | - } |
|
250 | + /** |
|
251 | + * This deregisters a message type that was previously registered with a specific message_type_name. |
|
252 | + * |
|
253 | + * @since 4.3.0 |
|
254 | + * @param string $message_type_name the name for the message type that was previously registered |
|
255 | + * @return void |
|
256 | + */ |
|
257 | + public static function deregister($message_type_name = null) |
|
258 | + { |
|
259 | + if (! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
260 | + //let's make sure that we remove any place this message type was made active |
|
261 | + /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
|
262 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
263 | + //ensures that if this message type is registered again that it retains its previous active state vs |
|
264 | + //remaining inactive. |
|
265 | + $Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers( |
|
266 | + $message_type_name, |
|
267 | + true |
|
268 | + ); |
|
269 | + $Message_Resource_Manager->deactivate_message_type($message_type_name, false); |
|
270 | + unset(self::$_ee_message_type_registry[$message_type_name]); |
|
271 | + } |
|
272 | + } |
|
273 | 273 | |
274 | 274 | |
275 | - /** |
|
276 | - * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
277 | - * |
|
278 | - * @since 4.3.0 |
|
279 | - * @param array $messagetype_files The current array of message type file names |
|
280 | - * @return array Array of message type file names |
|
281 | - */ |
|
282 | - public static function register_messagetype_files($messagetype_files) |
|
283 | - { |
|
284 | - if (empty(self::$_ee_message_type_registry)) { |
|
285 | - return $messagetype_files; |
|
286 | - } |
|
287 | - foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
288 | - if (empty($mt_reg['mtfilename'])) { |
|
289 | - continue; |
|
290 | - } |
|
291 | - $messagetype_files[] = $mt_reg['mtfilename']; |
|
292 | - } |
|
293 | - return $messagetype_files; |
|
294 | - } |
|
275 | + /** |
|
276 | + * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
277 | + * |
|
278 | + * @since 4.3.0 |
|
279 | + * @param array $messagetype_files The current array of message type file names |
|
280 | + * @return array Array of message type file names |
|
281 | + */ |
|
282 | + public static function register_messagetype_files($messagetype_files) |
|
283 | + { |
|
284 | + if (empty(self::$_ee_message_type_registry)) { |
|
285 | + return $messagetype_files; |
|
286 | + } |
|
287 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
288 | + if (empty($mt_reg['mtfilename'])) { |
|
289 | + continue; |
|
290 | + } |
|
291 | + $messagetype_files[] = $mt_reg['mtfilename']; |
|
292 | + } |
|
293 | + return $messagetype_files; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | - /** |
|
298 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
299 | - * |
|
300 | - * @since 4.3.0 |
|
301 | - * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
302 | - * @return array |
|
303 | - */ |
|
304 | - public static function register_msgs_autoload_paths($paths) |
|
305 | - { |
|
306 | - if (! empty(self::$_ee_message_type_registry)) { |
|
307 | - foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
308 | - if (empty($mt_reg['autoloadpaths'])) { |
|
309 | - continue; |
|
310 | - } |
|
311 | - $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
312 | - } |
|
313 | - } |
|
314 | - return $paths; |
|
315 | - } |
|
297 | + /** |
|
298 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
299 | + * |
|
300 | + * @since 4.3.0 |
|
301 | + * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
302 | + * @return array |
|
303 | + */ |
|
304 | + public static function register_msgs_autoload_paths($paths) |
|
305 | + { |
|
306 | + if (! empty(self::$_ee_message_type_registry)) { |
|
307 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
308 | + if (empty($mt_reg['autoloadpaths'])) { |
|
309 | + continue; |
|
310 | + } |
|
311 | + $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
312 | + } |
|
313 | + } |
|
314 | + return $paths; |
|
315 | + } |
|
316 | 316 | |
317 | 317 | |
318 | - /** |
|
319 | - * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
320 | - * |
|
321 | - * @since 4.3.0 |
|
322 | - * @param array $default_types array of message types activated with messenger ( |
|
323 | - * corresponds to the $name property of message type) |
|
324 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
325 | - * @return array |
|
326 | - */ |
|
327 | - public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) |
|
328 | - { |
|
329 | - if (empty(self::$_ee_message_type_registry)) { |
|
330 | - return $default_types; |
|
331 | - } |
|
332 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
333 | - if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) { |
|
334 | - continue; |
|
335 | - } |
|
336 | - // loop through each of the messengers and if it matches the loaded class |
|
337 | - // then we add this message type to the |
|
338 | - foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
339 | - if ($messenger->name == $msgr) { |
|
340 | - $default_types[] = $message_type_name; |
|
341 | - } |
|
342 | - } |
|
343 | - } |
|
318 | + /** |
|
319 | + * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
320 | + * |
|
321 | + * @since 4.3.0 |
|
322 | + * @param array $default_types array of message types activated with messenger ( |
|
323 | + * corresponds to the $name property of message type) |
|
324 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
325 | + * @return array |
|
326 | + */ |
|
327 | + public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) |
|
328 | + { |
|
329 | + if (empty(self::$_ee_message_type_registry)) { |
|
330 | + return $default_types; |
|
331 | + } |
|
332 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
333 | + if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) { |
|
334 | + continue; |
|
335 | + } |
|
336 | + // loop through each of the messengers and if it matches the loaded class |
|
337 | + // then we add this message type to the |
|
338 | + foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
339 | + if ($messenger->name == $msgr) { |
|
340 | + $default_types[] = $message_type_name; |
|
341 | + } |
|
342 | + } |
|
343 | + } |
|
344 | 344 | |
345 | - return $default_types; |
|
346 | - } |
|
345 | + return $default_types; |
|
346 | + } |
|
347 | 347 | |
348 | 348 | |
349 | - /** |
|
350 | - * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
351 | - * |
|
352 | - * @since 4.3.0 |
|
353 | - * @param array $valid_types array of message types valid with messenger ( |
|
354 | - * corresponds to the $name property of message type) |
|
355 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
356 | - * @return array |
|
357 | - */ |
|
358 | - public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) |
|
359 | - { |
|
360 | - if (empty(self::$_ee_message_type_registry)) { |
|
361 | - return $valid_types; |
|
362 | - } |
|
363 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
364 | - if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) { |
|
365 | - continue; |
|
366 | - } |
|
367 | - // loop through each of the messengers and if it matches the loaded class |
|
368 | - // then we add this message type to the |
|
369 | - foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
370 | - if ($messenger->name == $msgr) { |
|
371 | - $valid_types[] = $message_type_name; |
|
372 | - } |
|
373 | - } |
|
374 | - } |
|
349 | + /** |
|
350 | + * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
351 | + * |
|
352 | + * @since 4.3.0 |
|
353 | + * @param array $valid_types array of message types valid with messenger ( |
|
354 | + * corresponds to the $name property of message type) |
|
355 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
356 | + * @return array |
|
357 | + */ |
|
358 | + public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) |
|
359 | + { |
|
360 | + if (empty(self::$_ee_message_type_registry)) { |
|
361 | + return $valid_types; |
|
362 | + } |
|
363 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
364 | + if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) { |
|
365 | + continue; |
|
366 | + } |
|
367 | + // loop through each of the messengers and if it matches the loaded class |
|
368 | + // then we add this message type to the |
|
369 | + foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
370 | + if ($messenger->name == $msgr) { |
|
371 | + $valid_types[] = $message_type_name; |
|
372 | + } |
|
373 | + } |
|
374 | + } |
|
375 | 375 | |
376 | - return $valid_types; |
|
377 | - } |
|
376 | + return $valid_types; |
|
377 | + } |
|
378 | 378 | |
379 | 379 | |
380 | - /** |
|
381 | - * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as |
|
382 | - * supporting the default template pack |
|
383 | - * |
|
384 | - * @param array $supports |
|
385 | - * |
|
386 | - * @return array |
|
387 | - */ |
|
388 | - public static function register_default_template_pack_supports($supports) |
|
389 | - { |
|
390 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
391 | - if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) { |
|
392 | - continue; |
|
393 | - } |
|
394 | - foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) { |
|
395 | - $supports[$messenger_slug][] = $message_type_name; |
|
396 | - } |
|
397 | - } |
|
398 | - return $supports; |
|
399 | - } |
|
380 | + /** |
|
381 | + * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as |
|
382 | + * supporting the default template pack |
|
383 | + * |
|
384 | + * @param array $supports |
|
385 | + * |
|
386 | + * @return array |
|
387 | + */ |
|
388 | + public static function register_default_template_pack_supports($supports) |
|
389 | + { |
|
390 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
391 | + if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) { |
|
392 | + continue; |
|
393 | + } |
|
394 | + foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) { |
|
395 | + $supports[$messenger_slug][] = $message_type_name; |
|
396 | + } |
|
397 | + } |
|
398 | + return $supports; |
|
399 | + } |
|
400 | 400 | |
401 | 401 | |
402 | - /** |
|
403 | - * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path |
|
404 | - * |
|
405 | - * @param string $base_path The original base path for message templates |
|
406 | - * @param EE_messenger $messenger |
|
407 | - * @param EE_message_type $message_type |
|
408 | - * @param string $field The field requesting a template |
|
409 | - * @param string $context The context requesting a template |
|
410 | - * @param EE_Messages_Template_Pack $template_pack |
|
411 | - * |
|
412 | - * @return string |
|
413 | - */ |
|
414 | - public static function register_base_template_path( |
|
415 | - $base_path, |
|
416 | - $messenger, |
|
417 | - $message_type, |
|
418 | - $field, |
|
419 | - $context, |
|
420 | - $template_pack |
|
421 | - ) { |
|
422 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
423 | - || ! $message_type instanceof EE_message_type |
|
424 | - ) { |
|
425 | - return $base_path; |
|
426 | - } |
|
427 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
428 | - if ($message_type->name === $message_type_name |
|
429 | - && ! empty($mt_reg['base_path_for_default_templates']) |
|
430 | - ) { |
|
431 | - return $mt_reg['base_path_for_default_templates']; |
|
432 | - } |
|
433 | - } |
|
434 | - return $base_path; |
|
435 | - } |
|
402 | + /** |
|
403 | + * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path |
|
404 | + * |
|
405 | + * @param string $base_path The original base path for message templates |
|
406 | + * @param EE_messenger $messenger |
|
407 | + * @param EE_message_type $message_type |
|
408 | + * @param string $field The field requesting a template |
|
409 | + * @param string $context The context requesting a template |
|
410 | + * @param EE_Messages_Template_Pack $template_pack |
|
411 | + * |
|
412 | + * @return string |
|
413 | + */ |
|
414 | + public static function register_base_template_path( |
|
415 | + $base_path, |
|
416 | + $messenger, |
|
417 | + $message_type, |
|
418 | + $field, |
|
419 | + $context, |
|
420 | + $template_pack |
|
421 | + ) { |
|
422 | + if (! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
423 | + || ! $message_type instanceof EE_message_type |
|
424 | + ) { |
|
425 | + return $base_path; |
|
426 | + } |
|
427 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
428 | + if ($message_type->name === $message_type_name |
|
429 | + && ! empty($mt_reg['base_path_for_default_templates']) |
|
430 | + ) { |
|
431 | + return $mt_reg['base_path_for_default_templates']; |
|
432 | + } |
|
433 | + } |
|
434 | + return $base_path; |
|
435 | + } |
|
436 | 436 | |
437 | 437 | |
438 | - /** |
|
439 | - * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and |
|
440 | - * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks |
|
441 | - * |
|
442 | - * @param string $base_path_or_url The original incoming base url or path |
|
443 | - * @param string $messenger_slug The slug of the messenger the template is being generated for. |
|
444 | - * @param string $message_type_slug The slug of the message type the template is being generated for. |
|
445 | - * @param string $type The "type" of css being requested. |
|
446 | - * @param string $variation The variation being requested. |
|
447 | - * @param string $file_extension What file extension is expected for the variation file. |
|
448 | - * @param bool $url whether a url or path is being requested. |
|
449 | - * @param EE_Messages_Template_Pack $template_pack |
|
450 | - * |
|
451 | - * @return string |
|
452 | - */ |
|
453 | - public static function register_variation_base_path_or_url( |
|
454 | - $base_path_or_url, |
|
455 | - $messenger_slug, |
|
456 | - $message_type_slug, |
|
457 | - $type, |
|
458 | - $variation, |
|
459 | - $url, |
|
460 | - $file_extension, |
|
461 | - $template_pack |
|
462 | - ) { |
|
463 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
464 | - return $base_path_or_url; |
|
465 | - } |
|
466 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
467 | - if ($message_type_name === $message_type_slug |
|
468 | - ) { |
|
469 | - if ($url |
|
470 | - && ! empty($mt_reg['base_url_for_default_variation']) |
|
471 | - ) { |
|
472 | - return $mt_reg['base_url_for_default_variation']; |
|
473 | - } elseif (! $url |
|
474 | - && ! empty($mt_reg['base_path_for_default_variation']) |
|
475 | - ) { |
|
476 | - return $mt_reg['base_path_for_default_variation']; |
|
477 | - } |
|
478 | - } |
|
479 | - } |
|
480 | - return $base_path_or_url; |
|
481 | - } |
|
438 | + /** |
|
439 | + * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and |
|
440 | + * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks |
|
441 | + * |
|
442 | + * @param string $base_path_or_url The original incoming base url or path |
|
443 | + * @param string $messenger_slug The slug of the messenger the template is being generated for. |
|
444 | + * @param string $message_type_slug The slug of the message type the template is being generated for. |
|
445 | + * @param string $type The "type" of css being requested. |
|
446 | + * @param string $variation The variation being requested. |
|
447 | + * @param string $file_extension What file extension is expected for the variation file. |
|
448 | + * @param bool $url whether a url or path is being requested. |
|
449 | + * @param EE_Messages_Template_Pack $template_pack |
|
450 | + * |
|
451 | + * @return string |
|
452 | + */ |
|
453 | + public static function register_variation_base_path_or_url( |
|
454 | + $base_path_or_url, |
|
455 | + $messenger_slug, |
|
456 | + $message_type_slug, |
|
457 | + $type, |
|
458 | + $variation, |
|
459 | + $url, |
|
460 | + $file_extension, |
|
461 | + $template_pack |
|
462 | + ) { |
|
463 | + if (! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
464 | + return $base_path_or_url; |
|
465 | + } |
|
466 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
467 | + if ($message_type_name === $message_type_slug |
|
468 | + ) { |
|
469 | + if ($url |
|
470 | + && ! empty($mt_reg['base_url_for_default_variation']) |
|
471 | + ) { |
|
472 | + return $mt_reg['base_url_for_default_variation']; |
|
473 | + } elseif (! $url |
|
474 | + && ! empty($mt_reg['base_path_for_default_variation']) |
|
475 | + ) { |
|
476 | + return $mt_reg['base_path_for_default_variation']; |
|
477 | + } |
|
478 | + } |
|
479 | + } |
|
480 | + return $base_path_or_url; |
|
481 | + } |
|
482 | 482 | } |
@@ -117,44 +117,44 @@ discard block |
||
117 | 117 | // remove last segment |
118 | 118 | array_pop($shortcode_path); |
119 | 119 | // glue it back together |
120 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
120 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
121 | 121 | } else { |
122 | 122 | // we need to generate the filename based off of the folder name |
123 | 123 | // grab and sanitize shortcode directory name |
124 | 124 | $shortcode = sanitize_key(basename($shortcode_path)); |
125 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
125 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
126 | 126 | } |
127 | 127 | // create classname from shortcode directory or file name |
128 | 128 | $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
129 | 129 | // add class prefix |
130 | - $shortcode_class = 'EES_' . $shortcode; |
|
130 | + $shortcode_class = 'EES_'.$shortcode; |
|
131 | 131 | // does the shortcode exist ? |
132 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
132 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
133 | 133 | $msg = sprintf( |
134 | 134 | esc_html__( |
135 | 135 | 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
136 | 136 | 'event_espresso' |
137 | 137 | ), |
138 | 138 | $shortcode_class, |
139 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
139 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
140 | 140 | ); |
141 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
141 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | // load the shortcode class file |
145 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
145 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
146 | 146 | // verify that class exists |
147 | 147 | if ( ! class_exists($shortcode_class)) { |
148 | 148 | $msg = sprintf( |
149 | 149 | esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), |
150 | 150 | $shortcode_class |
151 | 151 | ); |
152 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
152 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | $shortcode = strtoupper($shortcode); |
156 | 156 | // add to array of registered shortcodes |
157 | - $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
157 | + $this->registry->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
158 | 158 | return true; |
159 | 159 | } |
160 | 160 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | // cycle thru shortcode folders |
173 | 173 | foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { |
174 | 174 | // add class prefix |
175 | - $shortcode_class = 'EES_' . $shortcode; |
|
175 | + $shortcode_class = 'EES_'.$shortcode; |
|
176 | 176 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
177 | 177 | // which set hooks ? |
178 | 178 | if (is_admin()) { |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | { |
291 | 291 | $has_shortcode = false; |
292 | 292 | foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { |
293 | - if ($load_all || has_shortcode($content, $shortcode_class) ) { |
|
293 | + if ($load_all || has_shortcode($content, $shortcode_class)) { |
|
294 | 294 | // load up the shortcode |
295 | 295 | $this->initializeShortcode($shortcode_class); |
296 | 296 | $has_shortcode = true; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public static function addShortcodeClassPrefix($class_name) |
404 | 404 | { |
405 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
405 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_'.$class_name; |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | { |
415 | 415 | static $shortcode_tags = array(); |
416 | 416 | if (empty($shortcode_tags)) { |
417 | - $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
417 | + $shortcode_tags = array_keys((array) $this->registry->shortcodes); |
|
418 | 418 | } |
419 | 419 | return $shortcode_tags; |
420 | 420 | } |
@@ -25,429 +25,429 @@ |
||
25 | 25 | class LegacyShortcodesManager |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var EE_Registry $registry |
|
30 | - */ |
|
31 | - private $registry; |
|
32 | - |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * LegacyShortcodesManager constructor. |
|
38 | - * |
|
39 | - * @param \EE_Registry $registry |
|
40 | - */ |
|
41 | - public function __construct(EE_Registry $registry) |
|
42 | - { |
|
43 | - $this->registry = $registry; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @return EE_Registry |
|
50 | - */ |
|
51 | - public function registry() |
|
52 | - { |
|
53 | - return $this->registry; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * registerShortcodes |
|
60 | - * |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public function registerShortcodes() |
|
64 | - { |
|
65 | - $this->registry->shortcodes = $this->getShortcodes(); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * getShortcodes |
|
72 | - * |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function getShortcodes() |
|
76 | - { |
|
77 | - // previously this method would glob the shortcodes directory |
|
78 | - // then filter that list of shortcodes to register, |
|
79 | - // but now we are going to just supply an empty array. |
|
80 | - // this allows any shortcodes that have not yet been converted to the new system |
|
81 | - // to still get loaded and processed, albeit using the same legacy logic as before |
|
82 | - $shortcodes_to_register = apply_filters( |
|
83 | - 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
84 | - array() |
|
85 | - ); |
|
86 | - if ( ! empty($shortcodes_to_register)) { |
|
87 | - // cycle thru shortcode folders |
|
88 | - foreach ($shortcodes_to_register as $shortcode_path) { |
|
89 | - // add to list of installed shortcode modules |
|
90 | - $this->registerShortcode($shortcode_path); |
|
91 | - } |
|
92 | - } |
|
93 | - // filter list of installed modules |
|
94 | - return apply_filters( |
|
95 | - 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
96 | - ! empty($this->registry->shortcodes) |
|
97 | - ? $this->registry->shortcodes |
|
98 | - : array() |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * register_shortcode - makes core aware of this shortcode |
|
106 | - * |
|
107 | - * @access public |
|
108 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
109 | - * @return bool |
|
110 | - */ |
|
111 | - public function registerShortcode($shortcode_path = null) |
|
112 | - { |
|
113 | - do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
114 | - $shortcode_ext = '.shortcode.php'; |
|
115 | - // make all separators match |
|
116 | - $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
117 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
118 | - if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
119 | - // grab shortcode file name from directory name and break apart at dots |
|
120 | - $shortcode_file = explode('.', basename($shortcode_path)); |
|
121 | - // take first segment from file name pieces and remove class prefix if it exists |
|
122 | - $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
123 | - ? substr($shortcode_file[0], 4) |
|
124 | - : $shortcode_file[0]; |
|
125 | - // sanitize shortcode directory name |
|
126 | - $shortcode = sanitize_key($shortcode); |
|
127 | - // now we need to rebuild the shortcode path |
|
128 | - $shortcode_path = explode(DS, $shortcode_path); |
|
129 | - // remove last segment |
|
130 | - array_pop($shortcode_path); |
|
131 | - // glue it back together |
|
132 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
133 | - } else { |
|
134 | - // we need to generate the filename based off of the folder name |
|
135 | - // grab and sanitize shortcode directory name |
|
136 | - $shortcode = sanitize_key(basename($shortcode_path)); |
|
137 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
138 | - } |
|
139 | - // create classname from shortcode directory or file name |
|
140 | - $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
141 | - // add class prefix |
|
142 | - $shortcode_class = 'EES_' . $shortcode; |
|
143 | - // does the shortcode exist ? |
|
144 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
145 | - $msg = sprintf( |
|
146 | - esc_html__( |
|
147 | - 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
148 | - 'event_espresso' |
|
149 | - ), |
|
150 | - $shortcode_class, |
|
151 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
152 | - ); |
|
153 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
154 | - return false; |
|
155 | - } |
|
156 | - // load the shortcode class file |
|
157 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
158 | - // verify that class exists |
|
159 | - if ( ! class_exists($shortcode_class)) { |
|
160 | - $msg = sprintf( |
|
161 | - esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
162 | - $shortcode_class |
|
163 | - ); |
|
164 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
165 | - return false; |
|
166 | - } |
|
167 | - $shortcode = strtoupper($shortcode); |
|
168 | - // add to array of registered shortcodes |
|
169 | - $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
170 | - return true; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * _initialize_shortcodes |
|
177 | - * allow shortcodes to set hooks for the rest of the system |
|
178 | - * |
|
179 | - * @access private |
|
180 | - * @return void |
|
181 | - */ |
|
182 | - public function addShortcodes() |
|
183 | - { |
|
184 | - // cycle thru shortcode folders |
|
185 | - foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { |
|
186 | - // add class prefix |
|
187 | - $shortcode_class = 'EES_' . $shortcode; |
|
188 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
189 | - // which set hooks ? |
|
190 | - if (is_admin()) { |
|
191 | - // fire immediately |
|
192 | - call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
193 | - } else { |
|
194 | - // delay until other systems are online |
|
195 | - add_action( |
|
196 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
197 | - array($shortcode_class, 'set_hooks') |
|
198 | - ); |
|
199 | - // convert classname to UPPERCASE and create WP shortcode. |
|
200 | - $shortcode_tag = strtoupper($shortcode); |
|
201 | - // but first check if the shortcode has already |
|
202 | - // been added before assigning 'fallback_shortcode_processor' |
|
203 | - if ( ! shortcode_exists($shortcode_tag)) { |
|
204 | - // NOTE: this shortcode declaration will get overridden if the shortcode |
|
205 | - // is successfully detected in the post content in initializeShortcode() |
|
206 | - add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
207 | - } |
|
208 | - } |
|
209 | - } |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * callback for the WP "get_header" hook point |
|
216 | - * checks posts for EE shortcodes, and initializes them, |
|
217 | - * then toggles filter switch that loads core default assets |
|
218 | - * |
|
219 | - * @param \WP_Query $wp_query |
|
220 | - * @return void |
|
221 | - */ |
|
222 | - public function initializeShortcodes(WP_Query $wp_query) |
|
223 | - { |
|
224 | - if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) { |
|
225 | - return; |
|
226 | - } |
|
227 | - global $wp; |
|
228 | - /** @var EE_Front_controller $Front_Controller */ |
|
229 | - $Front_Controller = $this->registry->load_core('Front_Controller', array(), false); |
|
230 | - do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller); |
|
231 | - $Front_Controller->Request_Handler()->set_request_vars(); |
|
232 | - // grab post_name from request |
|
233 | - $current_post = apply_filters( |
|
234 | - 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', |
|
235 | - $Front_Controller->Request_Handler()->get('post_name') |
|
236 | - ); |
|
237 | - $show_on_front = get_option('show_on_front'); |
|
238 | - // if it's not set, then check if frontpage is blog |
|
239 | - if (empty($current_post)) { |
|
240 | - // yup.. this is the posts page, prepare to load all shortcode modules |
|
241 | - $current_post = 'posts'; |
|
242 | - // unless.. |
|
243 | - if ($show_on_front === 'page') { |
|
244 | - // some other page is set as the homepage |
|
245 | - $page_on_front = get_option('page_on_front'); |
|
246 | - if ($page_on_front) { |
|
247 | - // k now we need to find the post_name for this page |
|
248 | - global $wpdb; |
|
249 | - $page_on_front = $wpdb->get_var( |
|
250 | - $wpdb->prepare( |
|
251 | - "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d", |
|
252 | - $page_on_front |
|
253 | - ) |
|
254 | - ); |
|
255 | - // set the current post slug to what it actually is |
|
256 | - $current_post = $page_on_front ? $page_on_front : $current_post; |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
260 | - // in case $current_post is hierarchical like: /parent-page/current-page |
|
261 | - $current_post = basename($current_post); |
|
262 | - if ( |
|
263 | - // is current page/post the "blog" page ? |
|
264 | - $current_post === EE_Config::get_page_for_posts() |
|
265 | - // or are we on a category page? |
|
266 | - || ( |
|
267 | - is_array(term_exists($current_post, 'category')) |
|
268 | - || array_key_exists('category_name', $wp->query_vars) |
|
269 | - ) |
|
270 | - ) { |
|
271 | - // initialize all legacy shortcodes |
|
272 | - $load_assets = $this->parseContentForShortcodes('', true); |
|
273 | - } else { |
|
274 | - global $wpdb; |
|
275 | - $post_content = $wpdb->get_var( |
|
276 | - $wpdb->prepare( |
|
277 | - "SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s", |
|
278 | - $current_post |
|
279 | - ) |
|
280 | - ); |
|
281 | - $load_assets = $this->parseContentForShortcodes($post_content); |
|
282 | - } |
|
283 | - if ($load_assets) { |
|
284 | - $this->registry->REQ->set_espresso_page(true); |
|
285 | - add_filter('FHEE_load_css', '__return_true'); |
|
286 | - add_filter('FHEE_load_js', '__return_true'); |
|
287 | - } |
|
288 | - do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * checks supplied content against list of legacy shortcodes, |
|
295 | - * then initializes any found shortcodes, and returns true. |
|
296 | - * returns false if no shortcodes found. |
|
297 | - * |
|
298 | - * @param string $content |
|
299 | - * @param bool $load_all if true, then ALL active legacy shortcodes will be initialized |
|
300 | - * @return bool |
|
301 | - */ |
|
302 | - public function parseContentForShortcodes($content = '', $load_all = false) |
|
303 | - { |
|
304 | - $has_shortcode = false; |
|
305 | - foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { |
|
306 | - if ($load_all || has_shortcode($content, $shortcode_class) ) { |
|
307 | - // load up the shortcode |
|
308 | - $this->initializeShortcode($shortcode_class); |
|
309 | - $has_shortcode = true; |
|
310 | - } |
|
311 | - } |
|
312 | - return $has_shortcode; |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * given a shortcode name, will instantiate the shortcode and call it's run() method |
|
319 | - * |
|
320 | - * @param string $shortcode_class |
|
321 | - * @param WP $wp |
|
322 | - */ |
|
323 | - public function initializeShortcode($shortcode_class = '', WP $wp = null) |
|
324 | - { |
|
325 | - // don't do anything if shortcode is already initialized |
|
326 | - if ( |
|
327 | - empty($this->registry->shortcodes->{$shortcode_class}) |
|
328 | - || ! is_string($this->registry->shortcodes->{$shortcode_class}) |
|
329 | - ) { |
|
330 | - return; |
|
331 | - } |
|
332 | - // let's pause to reflect on this... |
|
333 | - $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class)); |
|
334 | - // ensure that class is actually a shortcode |
|
335 | - if ( |
|
336 | - defined('WP_DEBUG') |
|
337 | - && WP_DEBUG === true |
|
338 | - && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
339 | - ) { |
|
340 | - EE_Error::add_error( |
|
341 | - sprintf( |
|
342 | - esc_html__( |
|
343 | - 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
344 | - 'event_espresso' |
|
345 | - ), |
|
346 | - $shortcode_class |
|
347 | - ), |
|
348 | - __FILE__, |
|
349 | - __FUNCTION__, |
|
350 | - __LINE__ |
|
351 | - ); |
|
352 | - add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
353 | - return; |
|
354 | - } |
|
355 | - global $wp; |
|
356 | - // and pass the request object to the run method |
|
357 | - $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
358 | - // fire the shortcode class's run method, so that it can activate resources |
|
359 | - $this->registry->shortcodes->{$shortcode_class}->run($wp); |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * get classname, remove EES_prefix, and convert to UPPERCASE |
|
366 | - * |
|
367 | - * @param string $class_name |
|
368 | - * @return string |
|
369 | - */ |
|
370 | - public static function generateShortcodeTagFromClassName($class_name) |
|
371 | - { |
|
372 | - return strtoupper(str_replace('EES_', '', $class_name)); |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * add EES_prefix and Capitalize words |
|
379 | - * |
|
380 | - * @param string $tag |
|
381 | - * @return string |
|
382 | - */ |
|
383 | - public static function generateShortcodeClassNameFromTag($tag) |
|
384 | - { |
|
385 | - // order of operation runs from inside to out |
|
386 | - // 5) maybe add prefix |
|
387 | - return LegacyShortcodesManager::addShortcodeClassPrefix( |
|
388 | - // 4) find spaces, replace with underscores |
|
389 | - str_replace( |
|
390 | - ' ', |
|
391 | - '_', |
|
392 | - // 3) capitalize first letter of each word |
|
393 | - ucwords( |
|
394 | - // 2) also change to lowercase so ucwords() will work |
|
395 | - strtolower( |
|
396 | - // 1) find underscores, replace with spaces so ucwords() will work |
|
397 | - str_replace( |
|
398 | - '_', |
|
399 | - ' ', |
|
400 | - $tag |
|
401 | - ) |
|
402 | - ) |
|
403 | - ) |
|
404 | - ) |
|
405 | - ); |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * maybe add EES_prefix |
|
412 | - * |
|
413 | - * @param string $class_name |
|
414 | - * @return string |
|
415 | - */ |
|
416 | - public static function addShortcodeClassPrefix($class_name) |
|
417 | - { |
|
418 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - |
|
423 | - /** |
|
424 | - * @return array |
|
425 | - */ |
|
426 | - public function getEspressoShortcodeTags() |
|
427 | - { |
|
428 | - static $shortcode_tags = array(); |
|
429 | - if (empty($shortcode_tags)) { |
|
430 | - $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
431 | - } |
|
432 | - return $shortcode_tags; |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - |
|
437 | - /** |
|
438 | - * @param string $content |
|
439 | - * @return string |
|
440 | - */ |
|
441 | - public function doShortcode($content) |
|
442 | - { |
|
443 | - foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { |
|
444 | - if (strpos($content, $shortcode_tag) !== false) { |
|
445 | - $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag); |
|
446 | - $this->initializeShortcode($shortcode_class); |
|
447 | - } |
|
448 | - } |
|
449 | - return do_shortcode($content); |
|
450 | - } |
|
28 | + /** |
|
29 | + * @var EE_Registry $registry |
|
30 | + */ |
|
31 | + private $registry; |
|
32 | + |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * LegacyShortcodesManager constructor. |
|
38 | + * |
|
39 | + * @param \EE_Registry $registry |
|
40 | + */ |
|
41 | + public function __construct(EE_Registry $registry) |
|
42 | + { |
|
43 | + $this->registry = $registry; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @return EE_Registry |
|
50 | + */ |
|
51 | + public function registry() |
|
52 | + { |
|
53 | + return $this->registry; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * registerShortcodes |
|
60 | + * |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public function registerShortcodes() |
|
64 | + { |
|
65 | + $this->registry->shortcodes = $this->getShortcodes(); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * getShortcodes |
|
72 | + * |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function getShortcodes() |
|
76 | + { |
|
77 | + // previously this method would glob the shortcodes directory |
|
78 | + // then filter that list of shortcodes to register, |
|
79 | + // but now we are going to just supply an empty array. |
|
80 | + // this allows any shortcodes that have not yet been converted to the new system |
|
81 | + // to still get loaded and processed, albeit using the same legacy logic as before |
|
82 | + $shortcodes_to_register = apply_filters( |
|
83 | + 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
84 | + array() |
|
85 | + ); |
|
86 | + if ( ! empty($shortcodes_to_register)) { |
|
87 | + // cycle thru shortcode folders |
|
88 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
89 | + // add to list of installed shortcode modules |
|
90 | + $this->registerShortcode($shortcode_path); |
|
91 | + } |
|
92 | + } |
|
93 | + // filter list of installed modules |
|
94 | + return apply_filters( |
|
95 | + 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
96 | + ! empty($this->registry->shortcodes) |
|
97 | + ? $this->registry->shortcodes |
|
98 | + : array() |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * register_shortcode - makes core aware of this shortcode |
|
106 | + * |
|
107 | + * @access public |
|
108 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
109 | + * @return bool |
|
110 | + */ |
|
111 | + public function registerShortcode($shortcode_path = null) |
|
112 | + { |
|
113 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
114 | + $shortcode_ext = '.shortcode.php'; |
|
115 | + // make all separators match |
|
116 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
117 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
118 | + if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
119 | + // grab shortcode file name from directory name and break apart at dots |
|
120 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
121 | + // take first segment from file name pieces and remove class prefix if it exists |
|
122 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
123 | + ? substr($shortcode_file[0], 4) |
|
124 | + : $shortcode_file[0]; |
|
125 | + // sanitize shortcode directory name |
|
126 | + $shortcode = sanitize_key($shortcode); |
|
127 | + // now we need to rebuild the shortcode path |
|
128 | + $shortcode_path = explode(DS, $shortcode_path); |
|
129 | + // remove last segment |
|
130 | + array_pop($shortcode_path); |
|
131 | + // glue it back together |
|
132 | + $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
133 | + } else { |
|
134 | + // we need to generate the filename based off of the folder name |
|
135 | + // grab and sanitize shortcode directory name |
|
136 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
137 | + $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
138 | + } |
|
139 | + // create classname from shortcode directory or file name |
|
140 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
141 | + // add class prefix |
|
142 | + $shortcode_class = 'EES_' . $shortcode; |
|
143 | + // does the shortcode exist ? |
|
144 | + if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
145 | + $msg = sprintf( |
|
146 | + esc_html__( |
|
147 | + 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
148 | + 'event_espresso' |
|
149 | + ), |
|
150 | + $shortcode_class, |
|
151 | + $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
152 | + ); |
|
153 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
154 | + return false; |
|
155 | + } |
|
156 | + // load the shortcode class file |
|
157 | + require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
158 | + // verify that class exists |
|
159 | + if ( ! class_exists($shortcode_class)) { |
|
160 | + $msg = sprintf( |
|
161 | + esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
162 | + $shortcode_class |
|
163 | + ); |
|
164 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
165 | + return false; |
|
166 | + } |
|
167 | + $shortcode = strtoupper($shortcode); |
|
168 | + // add to array of registered shortcodes |
|
169 | + $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
170 | + return true; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * _initialize_shortcodes |
|
177 | + * allow shortcodes to set hooks for the rest of the system |
|
178 | + * |
|
179 | + * @access private |
|
180 | + * @return void |
|
181 | + */ |
|
182 | + public function addShortcodes() |
|
183 | + { |
|
184 | + // cycle thru shortcode folders |
|
185 | + foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { |
|
186 | + // add class prefix |
|
187 | + $shortcode_class = 'EES_' . $shortcode; |
|
188 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
189 | + // which set hooks ? |
|
190 | + if (is_admin()) { |
|
191 | + // fire immediately |
|
192 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
193 | + } else { |
|
194 | + // delay until other systems are online |
|
195 | + add_action( |
|
196 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
197 | + array($shortcode_class, 'set_hooks') |
|
198 | + ); |
|
199 | + // convert classname to UPPERCASE and create WP shortcode. |
|
200 | + $shortcode_tag = strtoupper($shortcode); |
|
201 | + // but first check if the shortcode has already |
|
202 | + // been added before assigning 'fallback_shortcode_processor' |
|
203 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
204 | + // NOTE: this shortcode declaration will get overridden if the shortcode |
|
205 | + // is successfully detected in the post content in initializeShortcode() |
|
206 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
207 | + } |
|
208 | + } |
|
209 | + } |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * callback for the WP "get_header" hook point |
|
216 | + * checks posts for EE shortcodes, and initializes them, |
|
217 | + * then toggles filter switch that loads core default assets |
|
218 | + * |
|
219 | + * @param \WP_Query $wp_query |
|
220 | + * @return void |
|
221 | + */ |
|
222 | + public function initializeShortcodes(WP_Query $wp_query) |
|
223 | + { |
|
224 | + if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) { |
|
225 | + return; |
|
226 | + } |
|
227 | + global $wp; |
|
228 | + /** @var EE_Front_controller $Front_Controller */ |
|
229 | + $Front_Controller = $this->registry->load_core('Front_Controller', array(), false); |
|
230 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller); |
|
231 | + $Front_Controller->Request_Handler()->set_request_vars(); |
|
232 | + // grab post_name from request |
|
233 | + $current_post = apply_filters( |
|
234 | + 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', |
|
235 | + $Front_Controller->Request_Handler()->get('post_name') |
|
236 | + ); |
|
237 | + $show_on_front = get_option('show_on_front'); |
|
238 | + // if it's not set, then check if frontpage is blog |
|
239 | + if (empty($current_post)) { |
|
240 | + // yup.. this is the posts page, prepare to load all shortcode modules |
|
241 | + $current_post = 'posts'; |
|
242 | + // unless.. |
|
243 | + if ($show_on_front === 'page') { |
|
244 | + // some other page is set as the homepage |
|
245 | + $page_on_front = get_option('page_on_front'); |
|
246 | + if ($page_on_front) { |
|
247 | + // k now we need to find the post_name for this page |
|
248 | + global $wpdb; |
|
249 | + $page_on_front = $wpdb->get_var( |
|
250 | + $wpdb->prepare( |
|
251 | + "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d", |
|
252 | + $page_on_front |
|
253 | + ) |
|
254 | + ); |
|
255 | + // set the current post slug to what it actually is |
|
256 | + $current_post = $page_on_front ? $page_on_front : $current_post; |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | + // in case $current_post is hierarchical like: /parent-page/current-page |
|
261 | + $current_post = basename($current_post); |
|
262 | + if ( |
|
263 | + // is current page/post the "blog" page ? |
|
264 | + $current_post === EE_Config::get_page_for_posts() |
|
265 | + // or are we on a category page? |
|
266 | + || ( |
|
267 | + is_array(term_exists($current_post, 'category')) |
|
268 | + || array_key_exists('category_name', $wp->query_vars) |
|
269 | + ) |
|
270 | + ) { |
|
271 | + // initialize all legacy shortcodes |
|
272 | + $load_assets = $this->parseContentForShortcodes('', true); |
|
273 | + } else { |
|
274 | + global $wpdb; |
|
275 | + $post_content = $wpdb->get_var( |
|
276 | + $wpdb->prepare( |
|
277 | + "SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s", |
|
278 | + $current_post |
|
279 | + ) |
|
280 | + ); |
|
281 | + $load_assets = $this->parseContentForShortcodes($post_content); |
|
282 | + } |
|
283 | + if ($load_assets) { |
|
284 | + $this->registry->REQ->set_espresso_page(true); |
|
285 | + add_filter('FHEE_load_css', '__return_true'); |
|
286 | + add_filter('FHEE_load_js', '__return_true'); |
|
287 | + } |
|
288 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * checks supplied content against list of legacy shortcodes, |
|
295 | + * then initializes any found shortcodes, and returns true. |
|
296 | + * returns false if no shortcodes found. |
|
297 | + * |
|
298 | + * @param string $content |
|
299 | + * @param bool $load_all if true, then ALL active legacy shortcodes will be initialized |
|
300 | + * @return bool |
|
301 | + */ |
|
302 | + public function parseContentForShortcodes($content = '', $load_all = false) |
|
303 | + { |
|
304 | + $has_shortcode = false; |
|
305 | + foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { |
|
306 | + if ($load_all || has_shortcode($content, $shortcode_class) ) { |
|
307 | + // load up the shortcode |
|
308 | + $this->initializeShortcode($shortcode_class); |
|
309 | + $has_shortcode = true; |
|
310 | + } |
|
311 | + } |
|
312 | + return $has_shortcode; |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * given a shortcode name, will instantiate the shortcode and call it's run() method |
|
319 | + * |
|
320 | + * @param string $shortcode_class |
|
321 | + * @param WP $wp |
|
322 | + */ |
|
323 | + public function initializeShortcode($shortcode_class = '', WP $wp = null) |
|
324 | + { |
|
325 | + // don't do anything if shortcode is already initialized |
|
326 | + if ( |
|
327 | + empty($this->registry->shortcodes->{$shortcode_class}) |
|
328 | + || ! is_string($this->registry->shortcodes->{$shortcode_class}) |
|
329 | + ) { |
|
330 | + return; |
|
331 | + } |
|
332 | + // let's pause to reflect on this... |
|
333 | + $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class)); |
|
334 | + // ensure that class is actually a shortcode |
|
335 | + if ( |
|
336 | + defined('WP_DEBUG') |
|
337 | + && WP_DEBUG === true |
|
338 | + && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
339 | + ) { |
|
340 | + EE_Error::add_error( |
|
341 | + sprintf( |
|
342 | + esc_html__( |
|
343 | + 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
344 | + 'event_espresso' |
|
345 | + ), |
|
346 | + $shortcode_class |
|
347 | + ), |
|
348 | + __FILE__, |
|
349 | + __FUNCTION__, |
|
350 | + __LINE__ |
|
351 | + ); |
|
352 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
353 | + return; |
|
354 | + } |
|
355 | + global $wp; |
|
356 | + // and pass the request object to the run method |
|
357 | + $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
358 | + // fire the shortcode class's run method, so that it can activate resources |
|
359 | + $this->registry->shortcodes->{$shortcode_class}->run($wp); |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * get classname, remove EES_prefix, and convert to UPPERCASE |
|
366 | + * |
|
367 | + * @param string $class_name |
|
368 | + * @return string |
|
369 | + */ |
|
370 | + public static function generateShortcodeTagFromClassName($class_name) |
|
371 | + { |
|
372 | + return strtoupper(str_replace('EES_', '', $class_name)); |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * add EES_prefix and Capitalize words |
|
379 | + * |
|
380 | + * @param string $tag |
|
381 | + * @return string |
|
382 | + */ |
|
383 | + public static function generateShortcodeClassNameFromTag($tag) |
|
384 | + { |
|
385 | + // order of operation runs from inside to out |
|
386 | + // 5) maybe add prefix |
|
387 | + return LegacyShortcodesManager::addShortcodeClassPrefix( |
|
388 | + // 4) find spaces, replace with underscores |
|
389 | + str_replace( |
|
390 | + ' ', |
|
391 | + '_', |
|
392 | + // 3) capitalize first letter of each word |
|
393 | + ucwords( |
|
394 | + // 2) also change to lowercase so ucwords() will work |
|
395 | + strtolower( |
|
396 | + // 1) find underscores, replace with spaces so ucwords() will work |
|
397 | + str_replace( |
|
398 | + '_', |
|
399 | + ' ', |
|
400 | + $tag |
|
401 | + ) |
|
402 | + ) |
|
403 | + ) |
|
404 | + ) |
|
405 | + ); |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * maybe add EES_prefix |
|
412 | + * |
|
413 | + * @param string $class_name |
|
414 | + * @return string |
|
415 | + */ |
|
416 | + public static function addShortcodeClassPrefix($class_name) |
|
417 | + { |
|
418 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + |
|
423 | + /** |
|
424 | + * @return array |
|
425 | + */ |
|
426 | + public function getEspressoShortcodeTags() |
|
427 | + { |
|
428 | + static $shortcode_tags = array(); |
|
429 | + if (empty($shortcode_tags)) { |
|
430 | + $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
431 | + } |
|
432 | + return $shortcode_tags; |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + |
|
437 | + /** |
|
438 | + * @param string $content |
|
439 | + * @return string |
|
440 | + */ |
|
441 | + public function doShortcode($content) |
|
442 | + { |
|
443 | + foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { |
|
444 | + if (strpos($content, $shortcode_tag) !== false) { |
|
445 | + $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag); |
|
446 | + $this->initializeShortcode($shortcode_class); |
|
447 | + } |
|
448 | + } |
|
449 | + return do_shortcode($content); |
|
450 | + } |
|
451 | 451 | |
452 | 452 | |
453 | 453 |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
25 | - */ |
|
26 | - final public function __construct() |
|
27 | - { |
|
28 | - $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
29 | - // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
30 | - add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
31 | - // make sure system knows this is an EE page |
|
32 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | - } |
|
23 | + /** |
|
24 | + * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
25 | + */ |
|
26 | + final public function __construct() |
|
27 | + { |
|
28 | + $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
29 | + // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
30 | + add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
31 | + // make sure system knows this is an EE page |
|
32 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | } |
78 | 78 | $shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class )); |
79 | 79 | $shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} ) |
80 | - ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
81 | - : null; |
|
80 | + ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
81 | + : null; |
|
82 | 82 | return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
83 | - ? $shortcode_obj |
|
84 | - : new $shortcode_class(); |
|
83 | + ? $shortcode_obj |
|
84 | + : new $shortcode_class(); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -135,59 +135,59 @@ discard block |
||
135 | 135 | |
136 | 136 | |
137 | 137 | |
138 | - /** |
|
139 | - * Performs basic sanitization on shortcode attributes |
|
140 | - * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
141 | - * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
142 | - * This can be overridden by supplying an array for the $custom_sanitization param, |
|
143 | - * where keys match keys in your attributes array, |
|
144 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
145 | - * So for example, if you had an integer attribute named "event_id" |
|
146 | - * that you wanted to be sanitized using absint(), |
|
147 | - * then you would pass the following for your $custom_sanitization array: |
|
148 | - * array('event_id' => 'absint') |
|
149 | - * all other attributes would be sanitized using the defaults in the switch statement below |
|
150 | - * |
|
151 | - * @param array $attributes |
|
152 | - * @param array $custom_sanitization |
|
153 | - * @return array |
|
154 | - */ |
|
155 | - public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
156 | - { |
|
157 | - foreach ($attributes as $key => $value) { |
|
158 | - // is a custom sanitization callback specified ? |
|
159 | - if ( isset($custom_sanitization[$key])) { |
|
160 | - $callback = $custom_sanitization[$key]; |
|
161 | - if ($callback === 'skip_sanitization') { |
|
162 | - $attributes[$key] = $value; |
|
163 | - continue; |
|
164 | - } else if (function_exists($callback)){ |
|
165 | - $attributes[$key] = $callback($value); |
|
166 | - continue; |
|
167 | - } |
|
168 | - } |
|
169 | - switch (true) { |
|
170 | - case $value === null : |
|
171 | - case is_int($value) : |
|
172 | - case is_float($value) : |
|
173 | - // typical booleans |
|
174 | - case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
175 | - $attributes[$key] = $value; |
|
176 | - break; |
|
177 | - case is_string($value) : |
|
178 | - $attributes[$key] = sanitize_text_field($value); |
|
179 | - break; |
|
180 | - case is_array($value) : |
|
181 | - $attributes[$key] = \EES_Shortcode::sanitize_attributes($value); |
|
182 | - break; |
|
183 | - default : |
|
184 | - // only remaining data types are Object and Resource |
|
185 | - // which are not allowed as shortcode attributes |
|
186 | - $attributes[$key] = null; |
|
187 | - break; |
|
188 | - } |
|
189 | - } |
|
190 | - return $attributes; |
|
138 | + /** |
|
139 | + * Performs basic sanitization on shortcode attributes |
|
140 | + * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
141 | + * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
142 | + * This can be overridden by supplying an array for the $custom_sanitization param, |
|
143 | + * where keys match keys in your attributes array, |
|
144 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
145 | + * So for example, if you had an integer attribute named "event_id" |
|
146 | + * that you wanted to be sanitized using absint(), |
|
147 | + * then you would pass the following for your $custom_sanitization array: |
|
148 | + * array('event_id' => 'absint') |
|
149 | + * all other attributes would be sanitized using the defaults in the switch statement below |
|
150 | + * |
|
151 | + * @param array $attributes |
|
152 | + * @param array $custom_sanitization |
|
153 | + * @return array |
|
154 | + */ |
|
155 | + public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
156 | + { |
|
157 | + foreach ($attributes as $key => $value) { |
|
158 | + // is a custom sanitization callback specified ? |
|
159 | + if ( isset($custom_sanitization[$key])) { |
|
160 | + $callback = $custom_sanitization[$key]; |
|
161 | + if ($callback === 'skip_sanitization') { |
|
162 | + $attributes[$key] = $value; |
|
163 | + continue; |
|
164 | + } else if (function_exists($callback)){ |
|
165 | + $attributes[$key] = $callback($value); |
|
166 | + continue; |
|
167 | + } |
|
168 | + } |
|
169 | + switch (true) { |
|
170 | + case $value === null : |
|
171 | + case is_int($value) : |
|
172 | + case is_float($value) : |
|
173 | + // typical booleans |
|
174 | + case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
175 | + $attributes[$key] = $value; |
|
176 | + break; |
|
177 | + case is_string($value) : |
|
178 | + $attributes[$key] = sanitize_text_field($value); |
|
179 | + break; |
|
180 | + case is_array($value) : |
|
181 | + $attributes[$key] = \EES_Shortcode::sanitize_attributes($value); |
|
182 | + break; |
|
183 | + default : |
|
184 | + // only remaining data types are Object and Resource |
|
185 | + // which are not allowed as shortcode attributes |
|
186 | + $attributes[$key] = null; |
|
187 | + break; |
|
188 | + } |
|
189 | + } |
|
190 | + return $attributes; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param WP $WP |
48 | 48 | * @return void |
49 | 49 | */ |
50 | - public abstract function run( WP $WP ); |
|
50 | + public abstract function run(WP $WP); |
|
51 | 51 | |
52 | 52 | |
53 | 53 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param array $attributes |
60 | 60 | * @return mixed |
61 | 61 | */ |
62 | - public abstract function process_shortcode( $attributes = array() ); |
|
62 | + public abstract function process_shortcode($attributes = array()); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | * @param string $shortcode_class |
71 | 71 | * @return \EES_Shortcode |
72 | 72 | */ |
73 | - final public static function instance( $shortcode_class = null ) { |
|
74 | - $shortcode_class = ! empty( $shortcode_class ) ? $shortcode_class : get_called_class(); |
|
75 | - if ( $shortcode_class === 'EES_Shortcode' || empty( $shortcode_class )) { |
|
73 | + final public static function instance($shortcode_class = null) { |
|
74 | + $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
75 | + if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) { |
|
76 | 76 | return null; |
77 | 77 | } |
78 | - $shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class )); |
|
79 | - $shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} ) |
|
78 | + $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
79 | + $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode} ) |
|
80 | 80 | ? EE_Registry::instance()->shortcodes->{$shortcode} |
81 | 81 | : null; |
82 | 82 | return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
@@ -95,23 +95,23 @@ discard block |
||
95 | 95 | * @param $attributes |
96 | 96 | * @return mixed |
97 | 97 | */ |
98 | - final public static function fallback_shortcode_processor( $attributes ) { |
|
99 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
98 | + final public static function fallback_shortcode_processor($attributes) { |
|
99 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
100 | 100 | return null; |
101 | 101 | } |
102 | 102 | // what shortcode was actually parsed ? |
103 | 103 | $shortcode_class = get_called_class(); |
104 | 104 | // notify rest of system that fallback processor was triggered |
105 | - add_filter( 'FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true' ); |
|
105 | + add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true'); |
|
106 | 106 | // get instance of actual shortcode |
107 | - $shortcode_obj = self::instance( $shortcode_class ); |
|
107 | + $shortcode_obj = self::instance($shortcode_class); |
|
108 | 108 | // verify class |
109 | - if ( $shortcode_obj instanceof EES_Shortcode ) { |
|
109 | + if ($shortcode_obj instanceof EES_Shortcode) { |
|
110 | 110 | global $wp; |
111 | - $shortcode_obj->run( $wp ); |
|
111 | + $shortcode_obj->run($wp); |
|
112 | 112 | // set attributes and run the shortcode |
113 | - $shortcode_obj->_attributes = (array)$attributes; |
|
114 | - return $shortcode_obj->process_shortcode( $shortcode_obj->_attributes ); |
|
113 | + $shortcode_obj->_attributes = (array) $attributes; |
|
114 | + return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
115 | 115 | } else { |
116 | 116 | return null; |
117 | 117 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param $attributes |
128 | 128 | * @return string |
129 | 129 | */ |
130 | - final public static function invalid_shortcode_processor( $attributes ) { |
|
130 | + final public static function invalid_shortcode_processor($attributes) { |
|
131 | 131 | return ''; |
132 | 132 | } |
133 | 133 | |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | { |
157 | 157 | foreach ($attributes as $key => $value) { |
158 | 158 | // is a custom sanitization callback specified ? |
159 | - if ( isset($custom_sanitization[$key])) { |
|
159 | + if (isset($custom_sanitization[$key])) { |
|
160 | 160 | $callback = $custom_sanitization[$key]; |
161 | 161 | if ($callback === 'skip_sanitization') { |
162 | 162 | $attributes[$key] = $value; |
163 | 163 | continue; |
164 | - } else if (function_exists($callback)){ |
|
164 | + } else if (function_exists($callback)) { |
|
165 | 165 | $attributes[$key] = $callback($value); |
166 | 166 | continue; |
167 | 167 | } |
@@ -108,7 +108,7 @@ |
||
108 | 108 | private function getAttributes(array $attributes) |
109 | 109 | { |
110 | 110 | return array_merge( |
111 | - (array)apply_filters( |
|
111 | + (array) apply_filters( |
|
112 | 112 | 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
113 | 113 | array( |
114 | 114 | 'title' => '', |
@@ -34,139 +34,139 @@ |
||
34 | 34 | |
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * the actual shortcode tag that gets registered with WordPress |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function getTag() |
|
43 | - { |
|
44 | - return 'ESPRESSO_EVENTS'; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * the time in seconds to cache the results of the processShortcode() method |
|
51 | - * 0 means the processShortcode() results will NOT be cached at all |
|
52 | - * |
|
53 | - * @return int |
|
54 | - */ |
|
55 | - public function cacheExpiration() |
|
56 | - { |
|
57 | - return 0; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
64 | - * this may be required for shortcodes that utilize a corresponding module, |
|
65 | - * and need to enqueue assets for that module |
|
66 | - * |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function initializeShortcode() |
|
70 | - { |
|
71 | - EED_Events_Archive::instance()->event_list(); |
|
72 | - $this->shortcodeHasBeenInitialized(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * callback that runs when the shortcode is encountered in post content. |
|
79 | - * IMPORTANT !!! |
|
80 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | - * |
|
82 | - * @param array $attributes |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function processShortcode($attributes = array()) |
|
86 | - { |
|
87 | - // grab attributes and merge with defaults |
|
88 | - $attributes = $this->getAttributes($attributes); |
|
89 | - // make sure we use the_excerpt() |
|
90 | - add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
91 | - // apply query filters |
|
92 | - add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
93 | - // run the query |
|
94 | - global $wp_query; |
|
95 | - // yes we have to overwrite the main wp query, but it's ok... |
|
96 | - // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
97 | - $wp_query = new EventListQuery($attributes); |
|
98 | - // check what template is loaded and load filters accordingly |
|
99 | - EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
100 | - // load our template |
|
101 | - $event_list = EEH_Template::locate_template( |
|
102 | - 'loop-espresso_events.php', |
|
103 | - array(), |
|
104 | - true, |
|
105 | - true |
|
106 | - ); |
|
107 | - // now reset the query and post data |
|
108 | - wp_reset_query(); |
|
109 | - wp_reset_postdata(); |
|
110 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
111 | - // remove query filters |
|
112 | - remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
113 | - // pull our content from the output buffer and return it |
|
114 | - return $event_list; |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * merge incoming attributes with filtered defaults |
|
121 | - * |
|
122 | - * @param array $attributes |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - private function getAttributes(array $attributes) |
|
126 | - { |
|
127 | - return array_merge( |
|
128 | - (array)apply_filters( |
|
129 | - 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
130 | - array( |
|
131 | - 'title' => '', |
|
132 | - 'limit' => 10, |
|
133 | - 'css_class' => '', |
|
134 | - 'show_expired' => false, |
|
135 | - 'month' => '', |
|
136 | - 'category_slug' => '', |
|
137 | - 'order_by' => 'start_date', |
|
138 | - 'sort' => 'ASC', |
|
139 | - 'show_title' => true, |
|
140 | - ) |
|
141 | - ), |
|
142 | - $attributes |
|
143 | - ); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * array for defining custom attribute sanitization callbacks, |
|
150 | - * where keys match keys in your attributes array, |
|
151 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
152 | - * So for example, if you had an integer attribute named "event_id" |
|
153 | - * that you wanted to be sanitized using absint(), |
|
154 | - * then you would pass the following for your $custom_sanitization array: |
|
155 | - * array('event_id' => 'absint') |
|
156 | - * |
|
157 | - * @return array |
|
158 | - */ |
|
159 | - protected function customAttributeSanitizationMap() |
|
160 | - { |
|
161 | - // the following get sanitized/whitelisted in EEH_Event_Query |
|
162 | - return array( |
|
163 | - 'category_slug' => 'skip_sanitization', |
|
164 | - 'show_expired' => 'skip_sanitization', |
|
165 | - 'order_by' => 'skip_sanitization', |
|
166 | - 'month' => 'skip_sanitization', |
|
167 | - 'sort' => 'skip_sanitization', |
|
168 | - ); |
|
169 | - } |
|
37 | + /** |
|
38 | + * the actual shortcode tag that gets registered with WordPress |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function getTag() |
|
43 | + { |
|
44 | + return 'ESPRESSO_EVENTS'; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * the time in seconds to cache the results of the processShortcode() method |
|
51 | + * 0 means the processShortcode() results will NOT be cached at all |
|
52 | + * |
|
53 | + * @return int |
|
54 | + */ |
|
55 | + public function cacheExpiration() |
|
56 | + { |
|
57 | + return 0; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
64 | + * this may be required for shortcodes that utilize a corresponding module, |
|
65 | + * and need to enqueue assets for that module |
|
66 | + * |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function initializeShortcode() |
|
70 | + { |
|
71 | + EED_Events_Archive::instance()->event_list(); |
|
72 | + $this->shortcodeHasBeenInitialized(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * callback that runs when the shortcode is encountered in post content. |
|
79 | + * IMPORTANT !!! |
|
80 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | + * |
|
82 | + * @param array $attributes |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function processShortcode($attributes = array()) |
|
86 | + { |
|
87 | + // grab attributes and merge with defaults |
|
88 | + $attributes = $this->getAttributes($attributes); |
|
89 | + // make sure we use the_excerpt() |
|
90 | + add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
91 | + // apply query filters |
|
92 | + add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
93 | + // run the query |
|
94 | + global $wp_query; |
|
95 | + // yes we have to overwrite the main wp query, but it's ok... |
|
96 | + // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
97 | + $wp_query = new EventListQuery($attributes); |
|
98 | + // check what template is loaded and load filters accordingly |
|
99 | + EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
100 | + // load our template |
|
101 | + $event_list = EEH_Template::locate_template( |
|
102 | + 'loop-espresso_events.php', |
|
103 | + array(), |
|
104 | + true, |
|
105 | + true |
|
106 | + ); |
|
107 | + // now reset the query and post data |
|
108 | + wp_reset_query(); |
|
109 | + wp_reset_postdata(); |
|
110 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
111 | + // remove query filters |
|
112 | + remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
113 | + // pull our content from the output buffer and return it |
|
114 | + return $event_list; |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * merge incoming attributes with filtered defaults |
|
121 | + * |
|
122 | + * @param array $attributes |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + private function getAttributes(array $attributes) |
|
126 | + { |
|
127 | + return array_merge( |
|
128 | + (array)apply_filters( |
|
129 | + 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
130 | + array( |
|
131 | + 'title' => '', |
|
132 | + 'limit' => 10, |
|
133 | + 'css_class' => '', |
|
134 | + 'show_expired' => false, |
|
135 | + 'month' => '', |
|
136 | + 'category_slug' => '', |
|
137 | + 'order_by' => 'start_date', |
|
138 | + 'sort' => 'ASC', |
|
139 | + 'show_title' => true, |
|
140 | + ) |
|
141 | + ), |
|
142 | + $attributes |
|
143 | + ); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * array for defining custom attribute sanitization callbacks, |
|
150 | + * where keys match keys in your attributes array, |
|
151 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
152 | + * So for example, if you had an integer attribute named "event_id" |
|
153 | + * that you wanted to be sanitized using absint(), |
|
154 | + * then you would pass the following for your $custom_sanitization array: |
|
155 | + * array('event_id' => 'absint') |
|
156 | + * |
|
157 | + * @return array |
|
158 | + */ |
|
159 | + protected function customAttributeSanitizationMap() |
|
160 | + { |
|
161 | + // the following get sanitized/whitelisted in EEH_Event_Query |
|
162 | + return array( |
|
163 | + 'category_slug' => 'skip_sanitization', |
|
164 | + 'show_expired' => 'skip_sanitization', |
|
165 | + 'order_by' => 'skip_sanitization', |
|
166 | + 'month' => 'skip_sanitization', |
|
167 | + 'sort' => 'skip_sanitization', |
|
168 | + ); |
|
169 | + } |
|
170 | 170 | |
171 | 171 | |
172 | 172 |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\services\commands\CommandHandler; |
7 | 7 | use EventEspresso\core\services\commands\CommandInterface; |
8 | 8 | |
9 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
50 | 50 | * @throws \EE_Error |
51 | 51 | */ |
52 | - public function handle( CommandInterface $command ) { |
|
52 | + public function handle(CommandInterface $command) { |
|
53 | 53 | /** @var CreateTicketLineItemCommand $command */ |
54 | - if ( ! $command instanceof CreateTicketLineItemCommand ) { |
|
55 | - throw new InvalidEntityException( get_class( $command ), 'CreateTicketLineItemCommand' ); |
|
54 | + if ( ! $command instanceof CreateTicketLineItemCommand) { |
|
55 | + throw new InvalidEntityException(get_class($command), 'CreateTicketLineItemCommand'); |
|
56 | 56 | } |
57 | 57 | // create new line item for ticket |
58 | 58 | return $this->factory->create( |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
22 | 22 | */ |
23 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
24 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
25 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
23 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
24 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @return EE_Payment |
35 | 35 | * @throws \EE_Error |
36 | 36 | */ |
37 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
38 | - return new self( $props_n_values, true, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
38 | + return new self($props_n_values, true, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param int $TXN_ID |
48 | 48 | * @throws \EE_Error |
49 | 49 | */ |
50 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
51 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
50 | + public function set_transaction_id($TXN_ID = 0) { |
|
51 | + $this->set('TXN_ID', $TXN_ID); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @throws \EE_Error |
61 | 61 | */ |
62 | 62 | public function transaction() { |
63 | - return $this->get_first_related( 'Transaction' ); |
|
63 | + return $this->get_first_related('Transaction'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param string $STS_ID |
73 | 73 | * @throws \EE_Error |
74 | 74 | */ |
75 | - public function set_status( $STS_ID = '' ) { |
|
76 | - $this->set( 'STS_ID', $STS_ID ); |
|
75 | + public function set_status($STS_ID = '') { |
|
76 | + $this->set('STS_ID', $STS_ID); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @param int $timestamp |
86 | 86 | * @throws \EE_Error |
87 | 87 | */ |
88 | - public function set_timestamp( $timestamp = 0 ) { |
|
89 | - $this->set( 'PAY_timestamp', $timestamp ); |
|
88 | + public function set_timestamp($timestamp = 0) { |
|
89 | + $this->set('PAY_timestamp', $timestamp); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @param string $PAY_source |
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | - public function set_source( $PAY_source = '' ) { |
|
102 | - $this->set( 'PAY_source', $PAY_source ); |
|
101 | + public function set_source($PAY_source = '') { |
|
102 | + $this->set('PAY_source', $PAY_source); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @param float $amount |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function set_amount( $amount = 0.00 ) { |
|
115 | - $this->set( 'PAY_amount', (float)$amount ); |
|
114 | + public function set_amount($amount = 0.00) { |
|
115 | + $this->set('PAY_amount', (float) $amount); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @param string $gateway_response |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - public function set_gateway_response( $gateway_response = '' ) { |
|
128 | - $this->set( 'PAY_gateway_response', $gateway_response ); |
|
127 | + public function set_gateway_response($gateway_response = '') { |
|
128 | + $this->set('PAY_gateway_response', $gateway_response); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ), |
149 | 149 | '4.6.0' |
150 | 150 | ); |
151 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
151 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param string $txn_id_chq_nmbr |
161 | 161 | * @throws \EE_Error |
162 | 162 | */ |
163 | - public function set_txn_id_chq_nmbr( $txn_id_chq_nmbr = '' ) { |
|
164 | - $this->set( 'PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr ); |
|
163 | + public function set_txn_id_chq_nmbr($txn_id_chq_nmbr = '') { |
|
164 | + $this->set('PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param string $po_number |
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | - public function set_po_number( $po_number = '' ) { |
|
177 | - $this->set( 'PAY_po_number', $po_number ); |
|
176 | + public function set_po_number($po_number = '') { |
|
177 | + $this->set('PAY_po_number', $po_number); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param string $extra_accntng |
187 | 187 | * @throws \EE_Error |
188 | 188 | */ |
189 | - public function set_extra_accntng( $extra_accntng = '' ) { |
|
190 | - $this->set( 'PAY_extra_accntng', $extra_accntng ); |
|
189 | + public function set_extra_accntng($extra_accntng = '') { |
|
190 | + $this->set('PAY_extra_accntng', $extra_accntng); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @param bool $via_admin |
200 | 200 | * @throws \EE_Error |
201 | 201 | */ |
202 | - public function set_payment_made_via_admin( $via_admin = false ) { |
|
203 | - if ( $via_admin ) { |
|
204 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_admin ); |
|
202 | + public function set_payment_made_via_admin($via_admin = false) { |
|
203 | + if ($via_admin) { |
|
204 | + $this->set('PAY_source', EEM_Payment_Method::scope_admin); |
|
205 | 205 | } else { |
206 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_cart ); |
|
206 | + $this->set('PAY_source', EEM_Payment_Method::scope_cart); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * @param string|array $details |
217 | 217 | * @throws \EE_Error |
218 | 218 | */ |
219 | - public function set_details( $details = '' ) { |
|
220 | - if ( is_array( $details ) ) { |
|
221 | - array_walk_recursive( $details, array( $this, '_strip_all_tags_within_array' ) ); |
|
219 | + public function set_details($details = '') { |
|
220 | + if (is_array($details)) { |
|
221 | + array_walk_recursive($details, array($this, '_strip_all_tags_within_array')); |
|
222 | 222 | } else { |
223 | - $details = wp_strip_all_tags( $details ); |
|
223 | + $details = wp_strip_all_tags($details); |
|
224 | 224 | } |
225 | - $this->set( 'PAY_details', $details ); |
|
225 | + $this->set('PAY_details', $details); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param string $redirect_url |
234 | 234 | * @throws \EE_Error |
235 | 235 | */ |
236 | - public function set_redirect_url( $redirect_url ) { |
|
237 | - $this->set( 'PAY_redirect_url', $redirect_url ); |
|
236 | + public function set_redirect_url($redirect_url) { |
|
237 | + $this->set('PAY_redirect_url', $redirect_url); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @param array $redirect_args |
246 | 246 | * @throws \EE_Error |
247 | 247 | */ |
248 | - public function set_redirect_args( $redirect_args ) { |
|
249 | - $this->set( 'PAY_redirect_args', $redirect_args ); |
|
248 | + public function set_redirect_args($redirect_args) { |
|
249 | + $this->set('PAY_redirect_args', $redirect_args); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @throws \EE_Error |
259 | 259 | */ |
260 | 260 | public function TXN_ID() { |
261 | - return $this->get( 'TXN_ID' ); |
|
261 | + return $this->get('TXN_ID'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @throws \EE_Error |
271 | 271 | */ |
272 | 272 | public function status() { |
273 | - return $this->get( 'STS_ID' ); |
|
273 | + return $this->get('STS_ID'); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @throws \EE_Error |
283 | 283 | */ |
284 | 284 | public function STS_ID() { |
285 | - return $this->get( 'STS_ID' ); |
|
285 | + return $this->get('STS_ID'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @return string |
297 | 297 | * @throws \EE_Error |
298 | 298 | */ |
299 | - public function timestamp( $dt_frmt = '', $tm_frmt = '' ) { |
|
300 | - return $this->get_i18n_datetime( 'PAY_timestamp', trim( $dt_frmt . ' ' . $tm_frmt) ); |
|
299 | + public function timestamp($dt_frmt = '', $tm_frmt = '') { |
|
300 | + return $this->get_i18n_datetime('PAY_timestamp', trim($dt_frmt.' '.$tm_frmt)); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @throws \EE_Error |
310 | 310 | */ |
311 | 311 | public function source() { |
312 | - return $this->get( 'PAY_source' ); |
|
312 | + return $this->get('PAY_source'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @throws \EE_Error |
323 | 323 | */ |
324 | 324 | public function amount() { |
325 | - return (float)$this->get( 'PAY_amount' ); |
|
325 | + return (float) $this->get('PAY_amount'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @throws \EE_Error |
333 | 333 | */ |
334 | 334 | public function amount_no_code() { |
335 | - return $this->get_pretty( 'PAY_amount', 'no_currency_code' ); |
|
335 | + return $this->get_pretty('PAY_amount', 'no_currency_code'); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @throws \EE_Error |
345 | 345 | */ |
346 | 346 | public function gateway_response() { |
347 | - return $this->get( 'PAY_gateway_response' ); |
|
347 | + return $this->get('PAY_gateway_response'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @throws \EE_Error |
357 | 357 | */ |
358 | 358 | public function txn_id_chq_nmbr() { |
359 | - return $this->get( 'PAY_txn_id_chq_nmbr' ); |
|
359 | + return $this->get('PAY_txn_id_chq_nmbr'); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @throws \EE_Error |
369 | 369 | */ |
370 | 370 | public function po_number() { |
371 | - return $this->get( 'PAY_po_number' ); |
|
371 | + return $this->get('PAY_po_number'); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @throws \EE_Error |
381 | 381 | */ |
382 | 382 | public function extra_accntng() { |
383 | - return $this->get( 'PAY_extra_accntng' ); |
|
383 | + return $this->get('PAY_extra_accntng'); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @throws \EE_Error |
393 | 393 | */ |
394 | 394 | public function payment_made_via_admin() { |
395 | - return ( $this->get( 'PAY_source' ) === EEM_Payment_Method::scope_admin ); |
|
395 | + return ($this->get('PAY_source') === EEM_Payment_Method::scope_admin); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @throws \EE_Error |
405 | 405 | */ |
406 | 406 | public function details() { |
407 | - return $this->get( 'PAY_details' ); |
|
407 | + return $this->get('PAY_details'); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function redirect_url() { |
419 | - return $this->get( 'PAY_redirect_url' ); |
|
419 | + return $this->get('PAY_redirect_url'); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @throws \EE_Error |
429 | 429 | */ |
430 | 430 | public function redirect_args() { |
431 | - return $this->get( 'PAY_redirect_args' ); |
|
431 | + return $this->get('PAY_redirect_args'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @return void |
441 | 441 | * @throws \EE_Error |
442 | 442 | */ |
443 | - public function e_pretty_status( $show_icons = false ) { |
|
444 | - echo $this->pretty_status( $show_icons ); |
|
443 | + public function e_pretty_status($show_icons = false) { |
|
444 | + echo $this->pretty_status($show_icons); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -453,14 +453,14 @@ discard block |
||
453 | 453 | * @return string |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - public function pretty_status( $show_icons = false ) { |
|
456 | + public function pretty_status($show_icons = false) { |
|
457 | 457 | $status = EEM_Status::instance()->localized_status( |
458 | - array( $this->STS_ID() => __( 'unknown', 'event_espresso' ) ), |
|
458 | + array($this->STS_ID() => __('unknown', 'event_espresso')), |
|
459 | 459 | false, |
460 | 460 | 'sentence' |
461 | 461 | ); |
462 | 462 | $icon = ''; |
463 | - switch ( $this->STS_ID() ) { |
|
463 | + switch ($this->STS_ID()) { |
|
464 | 464 | case EEM_Payment::status_id_approved: |
465 | 465 | $icon = $show_icons |
466 | 466 | ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | : ''; |
483 | 483 | break; |
484 | 484 | } |
485 | - return $icon . $status[ $this->STS_ID() ]; |
|
485 | + return $icon.$status[$this->STS_ID()]; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | 496 | public function is_approved() { |
497 | - return $this->status_is( EEM_Payment::status_id_approved ); |
|
497 | + return $this->status_is(EEM_Payment::status_id_approved); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return boolean whether the status of this payment equals the status id |
509 | 509 | * @throws \EE_Error |
510 | 510 | */ |
511 | - protected function status_is( $STS_ID ) { |
|
511 | + protected function status_is($STS_ID) { |
|
512 | 512 | return $STS_ID === $this->STS_ID() ? true : false; |
513 | 513 | } |
514 | 514 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @throws \EE_Error |
522 | 522 | */ |
523 | 523 | public function is_pending() { |
524 | - return $this->status_is( EEM_Payment::status_id_pending ); |
|
524 | + return $this->status_is(EEM_Payment::status_id_pending); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @throws \EE_Error |
534 | 534 | */ |
535 | 535 | public function is_cancelled() { |
536 | - return $this->status_is( EEM_Payment::status_id_cancelled ); |
|
536 | + return $this->status_is(EEM_Payment::status_id_cancelled); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @throws \EE_Error |
546 | 546 | */ |
547 | 547 | public function is_declined() { |
548 | - return $this->status_is( EEM_Payment::status_id_declined ); |
|
548 | + return $this->status_is(EEM_Payment::status_id_declined); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * @throws \EE_Error |
558 | 558 | */ |
559 | 559 | public function is_failed() { |
560 | - return $this->status_is( EEM_Payment::status_id_failed ); |
|
560 | + return $this->status_is(EEM_Payment::status_id_failed); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @throws \EE_Error |
582 | 582 | */ |
583 | 583 | public function status_obj() { |
584 | - return $this->get_first_related( 'Status' ); |
|
584 | + return $this->get_first_related('Status'); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | * @return EE_Extra_Meta |
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | - public function extra_meta( $query_params = array() ) { |
|
597 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
596 | + public function extra_meta($query_params = array()) { |
|
597 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @throws \EE_Error |
609 | 609 | */ |
610 | 610 | public function payment_method() { |
611 | - return $this->get_first_related( 'Payment_Method' ); |
|
611 | + return $this->get_first_related('Payment_Method'); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -626,18 +626,18 @@ discard block |
||
626 | 626 | * @return string html |
627 | 627 | * @throws \EE_Error |
628 | 628 | */ |
629 | - public function redirect_form( $inside_form_html = null ) { |
|
629 | + public function redirect_form($inside_form_html = null) { |
|
630 | 630 | $redirect_url = $this->redirect_url(); |
631 | - if ( ! empty( $redirect_url ) ) { |
|
631 | + if ( ! empty($redirect_url)) { |
|
632 | 632 | // what ? no inner form content? |
633 | - if ( $inside_form_html === null ) { |
|
633 | + if ($inside_form_html === null) { |
|
634 | 634 | $inside_form_html = EEH_HTML::p( |
635 | 635 | sprintf( |
636 | 636 | __( |
637 | 637 | 'If you are not automatically redirected to the payment website within 10 seconds... %1$s %2$s Click Here %3$s', |
638 | 638 | 'event_espresso' |
639 | 639 | ), |
640 | - EEH_HTML::br( 2 ), |
|
640 | + EEH_HTML::br(2), |
|
641 | 641 | '<input type="submit" value="', |
642 | 642 | '">' |
643 | 643 | ), |
@@ -653,22 +653,22 @@ discard block |
||
653 | 653 | ); |
654 | 654 | //if it's a GET request, we need to remove all the GET params in the querystring |
655 | 655 | //and put them into the form instead |
656 | - if ( $method === 'GET' ) { |
|
657 | - $querystring = parse_url( $redirect_url, PHP_URL_QUERY ); |
|
656 | + if ($method === 'GET') { |
|
657 | + $querystring = parse_url($redirect_url, PHP_URL_QUERY); |
|
658 | 658 | $get_params = null; |
659 | - parse_str( $querystring, $get_params ); |
|
660 | - $inside_form_html .= $this->_args_as_inputs( $get_params ); |
|
661 | - $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
|
659 | + parse_str($querystring, $get_params); |
|
660 | + $inside_form_html .= $this->_args_as_inputs($get_params); |
|
661 | + $redirect_url = str_replace('?'.$querystring, '', $redirect_url); |
|
662 | 662 | } |
663 | - $form = EEH_HTML::nl( 1 ) |
|
663 | + $form = EEH_HTML::nl(1) |
|
664 | 664 | . '<form method="' |
665 | 665 | . $method |
666 | 666 | . '" name="gateway_form" action="' |
667 | 667 | . $redirect_url |
668 | 668 | . '">'; |
669 | - $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
|
669 | + $form .= EEH_HTML::nl(1).$this->redirect_args_as_inputs(); |
|
670 | 670 | $form .= $inside_form_html; |
671 | - $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
|
671 | + $form .= EEH_HTML::nl( -1 ).'</form>'.EEH_HTML::nl( -1 ); |
|
672 | 672 | return $form; |
673 | 673 | } else { |
674 | 674 | return null; |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @throws \EE_Error |
686 | 686 | */ |
687 | 687 | public function redirect_args_as_inputs() { |
688 | - return $this->_args_as_inputs( $this->redirect_args() ); |
|
688 | + return $this->_args_as_inputs($this->redirect_args()); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -697,15 +697,15 @@ discard block |
||
697 | 697 | * @param array $args key-value pairs |
698 | 698 | * @return string |
699 | 699 | */ |
700 | - protected function _args_as_inputs( $args ) { |
|
700 | + protected function _args_as_inputs($args) { |
|
701 | 701 | $html = ''; |
702 | - if ( $args !== null && is_array( $args ) ) { |
|
703 | - foreach ( $args as $name => $value ) { |
|
704 | - $html .= EEH_HTML::nl( 0 ) |
|
702 | + if ($args !== null && is_array($args)) { |
|
703 | + foreach ($args as $name => $value) { |
|
704 | + $html .= EEH_HTML::nl(0) |
|
705 | 705 | . '<input type="hidden" name="' |
706 | 706 | . $name |
707 | 707 | . '" value="' |
708 | - . esc_attr( $value ) |
|
708 | + . esc_attr($value) |
|
709 | 709 | . '"/>'; |
710 | 710 | } |
711 | 711 | } |
@@ -734,14 +734,14 @@ discard block |
||
734 | 734 | * @access private |
735 | 735 | * @param mixed $item |
736 | 736 | */ |
737 | - private function _strip_all_tags_within_array( &$item ) { |
|
738 | - if ( is_object( $item ) ) { |
|
739 | - $item = (array)$item; |
|
737 | + private function _strip_all_tags_within_array(&$item) { |
|
738 | + if (is_object($item)) { |
|
739 | + $item = (array) $item; |
|
740 | 740 | } |
741 | - if ( is_array( $item ) ) { |
|
742 | - array_walk_recursive( $item, array( $this, '_strip_all_tags_within_array' ) ); |
|
741 | + if (is_array($item)) { |
|
742 | + array_walk_recursive($item, array($this, '_strip_all_tags_within_array')); |
|
743 | 743 | } else { |
744 | - $item = wp_strip_all_tags( $item ); |
|
744 | + $item = wp_strip_all_tags($item); |
|
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | $original_status = EEH_Array::is_set( |
759 | 759 | $this->_props_n_values_provided_in_constructor, |
760 | 760 | 'STS_ID', |
761 | - $this->get_model()->field_settings_for( 'STS_ID' )->get_default_value() |
|
761 | + $this->get_model()->field_settings_for('STS_ID')->get_default_value() |
|
762 | 762 | ); |
763 | 763 | $current_status = $this->status(); |
764 | 764 | if ( |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | * @return mixed |
785 | 785 | * @throws \EE_Error |
786 | 786 | */ |
787 | - public function get_pretty( $field_name, $extra_cache_ref = null ) { |
|
788 | - if ( $field_name === 'PAY_gateway' ) { |
|
789 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
787 | + public function get_pretty($field_name, $extra_cache_ref = null) { |
|
788 | + if ($field_name === 'PAY_gateway') { |
|
789 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
790 | 790 | } |
791 | - return $this->_get_cached_property( $field_name, true, $extra_cache_ref ); |
|
791 | + return $this->_get_cached_property($field_name, true, $extra_cache_ref); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | * @return EE_Registration_Payment[] |
801 | 801 | * @throws \EE_Error |
802 | 802 | */ |
803 | - public function registration_payments( $query_params = array() ) { |
|
804 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
803 | + public function registration_payments($query_params = array()) { |
|
804 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | public function get_primary_attendee() |
863 | 863 | { |
864 | 864 | $primary_reg = $this->get_primary_registration(); |
865 | - if( $primary_reg instanceof EE_Registration) { |
|
865 | + if ($primary_reg instanceof EE_Registration) { |
|
866 | 866 | return $primary_reg->attendee(); |
867 | 867 | } |
868 | 868 | return null; |
@@ -661,11 +661,11 @@ discard block |
||
661 | 661 | $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
662 | 662 | } |
663 | 663 | $form = EEH_HTML::nl( 1 ) |
664 | - . '<form method="' |
|
665 | - . $method |
|
666 | - . '" name="gateway_form" action="' |
|
667 | - . $redirect_url |
|
668 | - . '">'; |
|
664 | + . '<form method="' |
|
665 | + . $method |
|
666 | + . '" name="gateway_form" action="' |
|
667 | + . $redirect_url |
|
668 | + . '">'; |
|
669 | 669 | $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
670 | 670 | $form .= $inside_form_html; |
671 | 671 | $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
@@ -702,11 +702,11 @@ discard block |
||
702 | 702 | if ( $args !== null && is_array( $args ) ) { |
703 | 703 | foreach ( $args as $name => $value ) { |
704 | 704 | $html .= EEH_HTML::nl( 0 ) |
705 | - . '<input type="hidden" name="' |
|
706 | - . $name |
|
707 | - . '" value="' |
|
708 | - . esc_attr( $value ) |
|
709 | - . '"/>'; |
|
705 | + . '<input type="hidden" name="' |
|
706 | + . $name |
|
707 | + . '" value="' |
|
708 | + . esc_attr( $value ) |
|
709 | + . '"/>'; |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | return $html; |
@@ -806,64 +806,64 @@ discard block |
||
806 | 806 | |
807 | 807 | |
808 | 808 | |
809 | - /** |
|
810 | - * Gets the first event for this payment (it's possible that it could be for multiple) |
|
811 | - * |
|
812 | - * @return EE_Event|null |
|
813 | - */ |
|
814 | - public function get_first_event() |
|
815 | - { |
|
816 | - $transaction = $this->transaction(); |
|
817 | - if ($transaction instanceof EE_Transaction) { |
|
818 | - $primary_registrant = $transaction->primary_registration(); |
|
819 | - if ($primary_registrant instanceof EE_Registration) { |
|
820 | - return $primary_registrant->event_obj(); |
|
821 | - } |
|
822 | - } |
|
823 | - return null; |
|
824 | - } |
|
825 | - |
|
826 | - |
|
827 | - |
|
828 | - /** |
|
829 | - * Gets the name of the first event for which is being paid |
|
830 | - * |
|
831 | - * @return string |
|
832 | - */ |
|
833 | - public function get_first_event_name() |
|
834 | - { |
|
835 | - $event = $this->get_first_event(); |
|
836 | - return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
837 | - } |
|
838 | - |
|
839 | - |
|
840 | - |
|
841 | - /** |
|
842 | - * Returns the payment's transaction's primary registration |
|
843 | - * @return EE_Registration|null |
|
844 | - */ |
|
845 | - public function get_primary_registration() |
|
846 | - { |
|
847 | - if ($this->transaction() instanceof EE_Transaction) { |
|
848 | - return $this->transaction()->primary_registration(); |
|
849 | - } |
|
850 | - return null; |
|
851 | - } |
|
852 | - |
|
853 | - |
|
854 | - |
|
855 | - /** |
|
856 | - * Gets the payment's transaction's primary registration's attendee, or null |
|
857 | - * @return EE_Attendee|null |
|
858 | - */ |
|
859 | - public function get_primary_attendee() |
|
860 | - { |
|
861 | - $primary_reg = $this->get_primary_registration(); |
|
862 | - if( $primary_reg instanceof EE_Registration) { |
|
863 | - return $primary_reg->attendee(); |
|
864 | - } |
|
865 | - return null; |
|
866 | - } |
|
809 | + /** |
|
810 | + * Gets the first event for this payment (it's possible that it could be for multiple) |
|
811 | + * |
|
812 | + * @return EE_Event|null |
|
813 | + */ |
|
814 | + public function get_first_event() |
|
815 | + { |
|
816 | + $transaction = $this->transaction(); |
|
817 | + if ($transaction instanceof EE_Transaction) { |
|
818 | + $primary_registrant = $transaction->primary_registration(); |
|
819 | + if ($primary_registrant instanceof EE_Registration) { |
|
820 | + return $primary_registrant->event_obj(); |
|
821 | + } |
|
822 | + } |
|
823 | + return null; |
|
824 | + } |
|
825 | + |
|
826 | + |
|
827 | + |
|
828 | + /** |
|
829 | + * Gets the name of the first event for which is being paid |
|
830 | + * |
|
831 | + * @return string |
|
832 | + */ |
|
833 | + public function get_first_event_name() |
|
834 | + { |
|
835 | + $event = $this->get_first_event(); |
|
836 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
837 | + } |
|
838 | + |
|
839 | + |
|
840 | + |
|
841 | + /** |
|
842 | + * Returns the payment's transaction's primary registration |
|
843 | + * @return EE_Registration|null |
|
844 | + */ |
|
845 | + public function get_primary_registration() |
|
846 | + { |
|
847 | + if ($this->transaction() instanceof EE_Transaction) { |
|
848 | + return $this->transaction()->primary_registration(); |
|
849 | + } |
|
850 | + return null; |
|
851 | + } |
|
852 | + |
|
853 | + |
|
854 | + |
|
855 | + /** |
|
856 | + * Gets the payment's transaction's primary registration's attendee, or null |
|
857 | + * @return EE_Attendee|null |
|
858 | + */ |
|
859 | + public function get_primary_attendee() |
|
860 | + { |
|
861 | + $primary_reg = $this->get_primary_registration(); |
|
862 | + if( $primary_reg instanceof EE_Registration) { |
|
863 | + return $primary_reg->attendee(); |
|
864 | + } |
|
865 | + return null; |
|
866 | + } |
|
867 | 867 | } |
868 | 868 | /* End of file EE_Payment.class.php */ |
869 | 869 | /* Location: /includes/classes/EE_Payment.class.php */ |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param array $props_n_values incoming values |
16 | 16 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
17 | 17 | * used.) |
18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
18 | + * @param string[] $date_formats incoming date_formats in an array where the first value is the |
|
19 | 19 | * date_format and the second value is the time format |
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * Gets all the extra meta info on this payment |
591 | 591 | * |
592 | 592 | * @param array $query_params like EEM_Base::get_all |
593 | - * @return EE_Extra_Meta |
|
593 | + * @return EE_Base_Class[] |
|
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | 596 | public function extra_meta( $query_params = array() ) { |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | |
841 | 841 | /** |
842 | 842 | * Returns the payment's transaction's primary registration |
843 | - * @return EE_Registration|null |
|
843 | + * @return EE_Base_Class|null |
|
844 | 844 | */ |
845 | 845 | public function get_primary_registration() |
846 | 846 | { |
@@ -98,14 +98,14 @@ |
||
98 | 98 | </th> |
99 | 99 | <td> |
100 | 100 | <?php |
101 | - $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | - if( $disabled ){ |
|
103 | - $disabled_attr = 'disabled="disabled"'; |
|
104 | - $id = '_disabled'; |
|
105 | - } else { |
|
106 | - $disabled_attr = ''; |
|
107 | - $id = ''; |
|
108 | - } |
|
101 | + $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | + if( $disabled ){ |
|
103 | + $disabled_attr = 'disabled="disabled"'; |
|
104 | + $id = '_disabled'; |
|
105 | + } else { |
|
106 | + $disabled_attr = ''; |
|
107 | + $id = ''; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled_attr ); |
111 | 111 | if( $disabled ) { ?> |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | //does question have any answers? cause if it does then we have to disable type |
16 | 16 | $has_answers = $question->has_answers(); |
17 | 17 | |
18 | -if ( $QST_system === 'country' ) { |
|
18 | +if ($QST_system === 'country') { |
|
19 | 19 | echo EEH_HTML::div( |
20 | - EEH_HTML::h4( '<span class="dashicons dashicons-info"></span>' . esc_html__( 'Did you know...', 'event_espresso' ) ) . |
|
20 | + EEH_HTML::h4('<span class="dashicons dashicons-info"></span>'.esc_html__('Did you know...', 'event_espresso')). |
|
21 | 21 | EEH_HTML::p( |
22 | 22 | esc_html__( |
23 | 23 | 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.', |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | <tbody> |
35 | 35 | <tr> |
36 | 36 | <th> |
37 | - <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info');?> |
|
37 | + <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info'); ?> |
|
38 | 38 | </th> |
39 | 39 | <td> |
40 | 40 | <input type="text" class="regular-text" id="QST_display_text" name="QST_display_text" value="<?php $question->f('QST_display_text')?>"/> |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | |
45 | 45 | <tr> |
46 | 46 | <th> |
47 | - <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info');?> |
|
47 | + <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info'); ?> |
|
48 | 48 | </th> |
49 | 49 | <td> |
50 | 50 | <?php |
51 | - $disabled_attr = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
52 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
51 | + $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
52 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
53 | 53 | ?> |
54 | 54 | <input type="text" class="regular-text" id="QST_admin_label<?php echo $id?>" name="QST_admin_label<?php echo $id?>" value="<?php $question->f('QST_admin_label')?>"<?php echo $disabled_attr?>/> |
55 | 55 | <input class="QST_order" type="hidden" id="QST_order<?php echo $id; ?>" name = "QST_order<?php echo $id; ?>" value="<?php echo $question->get('QST_order'); ?>" /> |
56 | - <?php if ( ! empty( $QST_system )) { ?> |
|
56 | + <?php if ( ! empty($QST_system)) { ?> |
|
57 | 57 | <input type="hidden" id="QST_admin_label" name="QST_admin_label" value="<?php echo $question->admin_label()?>"/> |
58 | 58 | <?php } ?> |
59 | 59 | <br/> |
60 | 60 | <p class="description"> |
61 | - <?php if ( ! empty( $QST_system )) { ?> |
|
61 | + <?php if ( ! empty($QST_system)) { ?> |
|
62 | 62 | <span class="description" style="color:#D54E21;"> |
63 | - <?php esc_html_e('System question! This field cannot be changed.','event_espresso')?> |
|
63 | + <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?> |
|
64 | 64 | </span> |
65 | 65 | <?php } ?> |
66 | 66 | |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | |
71 | 71 | <tr> |
72 | 72 | <th> |
73 | - <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info');?> |
|
73 | + <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info'); ?> |
|
74 | 74 | </th> |
75 | 75 | <td> |
76 | 76 | <?php |
77 | - $disabled_attr = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
78 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
77 | + $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
78 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
79 | 79 | $admin_only = $question->get('QST_admin_only'); |
80 | - $checked = !empty( $admin_only ) ? ' checked="checked"' : ''; |
|
80 | + $checked = ! empty($admin_only) ? ' checked="checked"' : ''; |
|
81 | 81 | ?> |
82 | 82 | <input class="QST_admin_only" type="checkbox" id="QST_admin_only<?php echo $id; ?>" name = "QST_admin_only<?php echo $id; ?>" value="1"<?php echo $disabled_attr; echo $checked; ?>/> |
83 | 83 | <br/> |
84 | 84 | <p class="description"> |
85 | - <?php if ( ! empty( $QST_system )) { ?> |
|
85 | + <?php if ( ! empty($QST_system)) { ?> |
|
86 | 86 | <span class="description" style="color:#D54E21;"> |
87 | - <?php esc_html_e('System question! This field cannot be changed.','event_espresso')?> |
|
87 | + <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?> |
|
88 | 88 | </span> |
89 | 89 | <?php } ?> |
90 | 90 | |
@@ -94,28 +94,28 @@ discard block |
||
94 | 94 | |
95 | 95 | <tr> |
96 | 96 | <th> |
97 | - <label for="QST_type"><?php echo $fields['QST_type']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info');?> |
|
97 | + <label for="QST_type"><?php echo $fields['QST_type']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info'); ?> |
|
98 | 98 | </th> |
99 | 99 | <td> |
100 | 100 | <?php |
101 | - $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | - if( $disabled ){ |
|
103 | - $disabled_attr = 'disabled="disabled"'; |
|
104 | - $id = '_disabled'; |
|
101 | + $disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | + if ($disabled) { |
|
103 | + $disabled_attr = 'disabled="disabled"'; |
|
104 | + $id = '_disabled'; |
|
105 | 105 | } else { |
106 | 106 | $disabled_attr = ''; |
107 | 107 | $id = ''; |
108 | 108 | } |
109 | 109 | |
110 | - echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled_attr ); |
|
111 | - if( $disabled ) { ?> |
|
110 | + echo EEH_Form_Fields::select_input('QST_type'.$id, $question_types, $question->type(), 'id="QST_type'.$id.'"'.$disabled_attr); |
|
111 | + if ($disabled) { ?> |
|
112 | 112 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/> |
113 | 113 | <?php |
114 | - $explanatory_text = esc_html__('System question! This field cannot be changed.','event_espresso'); |
|
115 | - }else{ |
|
116 | - $explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso'); |
|
114 | + $explanatory_text = esc_html__('System question! This field cannot be changed.', 'event_espresso'); |
|
115 | + } else { |
|
116 | + $explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', 'event_espresso'); |
|
117 | 117 | } |
118 | - if ( $disabled || $has_answers ) { ?> |
|
118 | + if ($disabled || $has_answers) { ?> |
|
119 | 119 | <p><span class="description" style="color:#D54E21;"> |
120 | 120 | <?php echo $explanatory_text; ?> |
121 | 121 | </span></p> |
@@ -128,22 +128,22 @@ discard block |
||
128 | 128 | <tr id="text_input_question_options"> |
129 | 129 | <th> |
130 | 130 | <label> |
131 | - <?php esc_html_e( 'Maximum Allowed Response Size', 'event_espresso' );?> |
|
131 | + <?php esc_html_e('Maximum Allowed Response Size', 'event_espresso'); ?> |
|
132 | 132 | </label> |
133 | 133 | </th> |
134 | 134 | <td> |
135 | - <input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'";?> value="<?php $question->f( 'QST_max' );?>" min="1"> |
|
135 | + <input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'"; ?> value="<?php $question->f('QST_max'); ?>" min="1"> |
|
136 | 136 | <p> |
137 | 137 | <span class="description"> |
138 | - <?php esc_html_e( 'Maximum number of characters allowed when answering this question', 'event_espresso' );?> |
|
138 | + <?php esc_html_e('Maximum number of characters allowed when answering this question', 'event_espresso'); ?> |
|
139 | 139 | </span> |
140 | 140 | </p> |
141 | - <?php if ( $QST_system ) { ?> |
|
141 | + <?php if ($QST_system) { ?> |
|
142 | 142 | <p> |
143 | 143 | <span class="description" style="color:#D54E21;"> |
144 | 144 | <?php printf( |
145 | - esc_html__( 'System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso' ), |
|
146 | - $max_max );?> |
|
145 | + esc_html__('System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso'), |
|
146 | + $max_max ); ?> |
|
147 | 147 | </span> |
148 | 148 | </p> |
149 | 149 | <?php } ?> |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | <tr id="question_options"> |
153 | 153 | <th> |
154 | 154 | <label> |
155 | - <?php esc_html_e('Answer Options','event_espresso')?> |
|
155 | + <?php esc_html_e('Answer Options', 'event_espresso')?> |
|
156 | 156 | </label> |
157 | 157 | </th> |
158 | 158 | <td> |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | <thead> |
162 | 162 | <tr> |
163 | 163 | <th class="option-value-header"> |
164 | - <?php esc_html_e('Value','event_espresso')?> |
|
164 | + <?php esc_html_e('Value', 'event_espresso')?> |
|
165 | 165 | </th> |
166 | 166 | <th class="option-desc-header"> |
167 | - <?php esc_html_e('Description (optional, only shown on registration form)','event_espresso')?> |
|
167 | + <?php esc_html_e('Description (optional, only shown on registration form)', 'event_espresso')?> |
|
168 | 168 | </th> |
169 | 169 | <th> |
170 | 170 | </th> |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | </tr> |
188 | 188 | |
189 | 189 | <?php |
190 | - $count=0; |
|
190 | + $count = 0; |
|
191 | 191 | $question_options = $question->options(); |
192 | - if ( ! empty( $question_options )) { |
|
193 | - foreach( $question_options as $option_id => $option ) { |
|
194 | - $disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
192 | + if ( ! empty($question_options)) { |
|
193 | + foreach ($question_options as $option_id => $option) { |
|
194 | + $disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
195 | 195 | ?> |
196 | 196 | <tr class="question-option ee-options-sortable"> |
197 | 197 | <td class="option-value-cell"> |
198 | 198 | <input type="hidden" class="QSO_order" name="question_options[<?php echo $count; ?>][QSO_order]" value="<?php echo $count; ?>"> |
199 | 199 | <input type="text" class="option-value regular-text" name="question_options[<?php echo $count?>][QSO_value]" value="<?php $option->f('QSO_value')?>"<?php echo $disabled_attr; ?>> |
200 | - <?php if ( $has_answers ) : ?> |
|
200 | + <?php if ($has_answers) : ?> |
|
201 | 201 | <input type="hidden" name="question_options[<?php echo $count; ?>][QSO_value]" value="<?php echo $option->f('QSO_value'); ?>" > |
202 | 202 | <?php endif; ?> |
203 | 203 | </td> |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | <input type="text" class="option-desc regular-text" name="question_options[<?php echo $count?>][QSO_desc]" value="<?php $option->f('QSO_desc')?>"> |
206 | 206 | </td> |
207 | 207 | <td> |
208 | - <?php if ( ! $option->system() ) { ?> |
|
208 | + <?php if ( ! $option->system()) { ?> |
|
209 | 209 | <span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item"></span> |
210 | 210 | <?php } ?> |
211 | 211 | <span class="dashicons dashicons-image-flip-vertical sortable-drag-handle ee-icon-size-18"></span> |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | </table> |
245 | 245 | |
246 | 246 | <a id="new-question-option" class="button" style="margin:0 0 1em 3px;"> |
247 | - <?php esc_html_e('Add Another Answer Option','event_espresso')?> |
|
247 | + <?php esc_html_e('Add Another Answer Option', 'event_espresso')?> |
|
248 | 248 | </a><br/> |
249 | 249 | |
250 | 250 | <p class="description"> |
251 | - <?php esc_html_e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.','event_espresso')?> |
|
251 | + <?php esc_html_e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', 'event_espresso')?> |
|
252 | 252 | </p> |
253 | - <?php if ( $has_answers ) : ?> |
|
253 | + <?php if ($has_answers) : ?> |
|
254 | 254 | <p class="description" style="color:#D54E21;"> |
255 | 255 | <?php esc_html_e('Answer values that are uneditable are this way because there are registrations in the database that have answers for this question. If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes. This will ensure that the existing registrations that chose the original answer will preserve that answer.', 'event_espresso'); ?> |
256 | 256 | </p> |
@@ -261,32 +261,32 @@ discard block |
||
261 | 261 | |
262 | 262 | <tr> |
263 | 263 | <th> |
264 | - <label for="QST_required"><?php echo $fields['QST_required']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info');?> |
|
264 | + <label for="QST_required"><?php echo $fields['QST_required']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info'); ?> |
|
265 | 265 | </th> |
266 | 266 | <td> |
267 | 267 | <?php |
268 | - $system_required = array( 'fname', 'email' ); |
|
269 | - $disabled_attr = in_array( $QST_system, $system_required ) ? ' disabled="disabled"' : ''; |
|
268 | + $system_required = array('fname', 'email'); |
|
269 | + $disabled_attr = in_array($QST_system, $system_required) ? ' disabled="disabled"' : ''; |
|
270 | 270 | $required_on = $question->get('QST_admin_only'); |
271 | 271 | $show_required_msg = $required_on ? '' : ' display:none;'; |
272 | - $disabled_attr = $required_on || ! empty( $disabled_attr ) ? ' disabled="disabled"' : ''; |
|
273 | - $id = ! empty( $disabled_attr ) && in_array( $QST_system, $system_required) ? '_disabled' : ''; |
|
274 | - $requiredOptions=array( |
|
275 | - array( 'text'=> esc_html__( 'Optional', 'event_espresso' ), 'id'=>0 ), |
|
276 | - array( 'text'=> esc_html__( 'Required', 'event_espresso' ), 'id'=>1 ) |
|
272 | + $disabled_attr = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : ''; |
|
273 | + $id = ! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : ''; |
|
274 | + $requiredOptions = array( |
|
275 | + array('text'=> esc_html__('Optional', 'event_espresso'), 'id'=>0), |
|
276 | + array('text'=> esc_html__('Required', 'event_espresso'), 'id'=>1) |
|
277 | 277 | ); |
278 | - echo EEH_Form_Fields::select_input('QST_required' . $id, $requiredOptions, $question->required(), 'id="QST_required' . $id . '"' . $disabled_attr ); |
|
278 | + echo EEH_Form_Fields::select_input('QST_required'.$id, $requiredOptions, $question->required(), 'id="QST_required'.$id.'"'.$disabled_attr); |
|
279 | 279 | ?> |
280 | 280 | <p><span id="required_toggled_on" class="description" style="color:#D54E21;<?php echo $show_required_msg; ?>"> |
281 | - <?php esc_html_e('Required is set to optional, and this field is disabled, because the question is Admin-Only.','event_espresso')?> |
|
281 | + <?php esc_html_e('Required is set to optional, and this field is disabled, because the question is Admin-Only.', 'event_espresso')?> |
|
282 | 282 | </span></p> |
283 | 283 | <p><span id="required_toggled_off" class="description" style="color:#D54E21; display: none;"> |
284 | - <?php esc_html_e('Required option field is no longer disabled because the question is not Admin-Only','event_espresso')?> |
|
284 | + <?php esc_html_e('Required option field is no longer disabled because the question is not Admin-Only', 'event_espresso')?> |
|
285 | 285 | </span></p> |
286 | - <?php if (! empty( $disabled_attr ) && in_array( $QST_system, $system_required ) ) { ?> |
|
286 | + <?php if ( ! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?> |
|
287 | 287 | <input type="hidden" id="QST_required" name="QST_required" value="1"/> |
288 | 288 | <p><span class="description" style="color:#D54E21;"> |
289 | - <?php esc_html_e('System question! This field cannot be changed.','event_espresso')?> |
|
289 | + <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?> |
|
290 | 290 | </span></p> |
291 | 291 | <?php } ?> |
292 | 292 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | <tr> |
297 | 297 | <th> |
298 | - <label for="QST_required_text"><?php esc_html_e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info');?> |
|
298 | + <label for="QST_required_text"><?php esc_html_e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info'); ?> |
|
299 | 299 | </th> |
300 | 300 | <td> |
301 | 301 | <input type="text" maxlength="100" class="regular-text" id="QST_required_text" name="QST_required_text" value="<?php $question->f('QST_required_text')?>"/> |
@@ -112,7 +112,7 @@ |
||
112 | 112 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/> |
113 | 113 | <?php |
114 | 114 | $explanatory_text = esc_html__('System question! This field cannot be changed.','event_espresso'); |
115 | - }else{ |
|
115 | + } else{ |
|
116 | 116 | $explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso'); |
117 | 117 | } |
118 | 118 | if ( $disabled || $has_answers ) { ?> |
@@ -16,65 +16,65 @@ |
||
16 | 16 | interface GatewayDataFormatterInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Gets the text to use for a gateway's line item name when this is a partial payment |
|
21 | - * |
|
22 | - * @param \EEI_Payment $payment |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public function formatPartialPaymentLineItemName(\EEI_Payment $payment); |
|
19 | + /** |
|
20 | + * Gets the text to use for a gateway's line item name when this is a partial payment |
|
21 | + * |
|
22 | + * @param \EEI_Payment $payment |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public function formatPartialPaymentLineItemName(\EEI_Payment $payment); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * Gets the text to use for a gateway's line item description when this is a partial payment |
|
31 | - * |
|
32 | - * @param \EEI_Payment $payment |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function formatPartialPaymentLineItemDesc(\EEI_Payment $payment); |
|
29 | + /** |
|
30 | + * Gets the text to use for a gateway's line item description when this is a partial payment |
|
31 | + * |
|
32 | + * @param \EEI_Payment $payment |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function formatPartialPaymentLineItemDesc(\EEI_Payment $payment); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Gets the name to use for a line item when sending line items to the gateway |
|
41 | - * |
|
42 | - * @param \EEI_Line_Item $line_item |
|
43 | - * @param \EEI_Payment $payment |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function formatLineItemName(\EEI_Line_Item $line_item, \EEI_Payment $payment); |
|
39 | + /** |
|
40 | + * Gets the name to use for a line item when sending line items to the gateway |
|
41 | + * |
|
42 | + * @param \EEI_Line_Item $line_item |
|
43 | + * @param \EEI_Payment $payment |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function formatLineItemName(\EEI_Line_Item $line_item, \EEI_Payment $payment); |
|
47 | 47 | |
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Gets the description to use for a line item when sending line items to the gateway |
|
52 | - * |
|
53 | - * @param \EEI_Line_Item $line_item |
|
54 | - * @param \EEI_Payment $payment |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function formatLineItemDesc(\EEI_Line_Item $line_item, \EEI_Payment $payment); |
|
50 | + /** |
|
51 | + * Gets the description to use for a line item when sending line items to the gateway |
|
52 | + * |
|
53 | + * @param \EEI_Line_Item $line_item |
|
54 | + * @param \EEI_Payment $payment |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function formatLineItemDesc(\EEI_Line_Item $line_item, \EEI_Payment $payment); |
|
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * Gets the order description that should generally be sent to gateways |
|
63 | - * |
|
64 | - * @param \EEI_Payment $payment |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function formatOrderDescription(\EEI_Payment $payment); |
|
61 | + /** |
|
62 | + * Gets the order description that should generally be sent to gateways |
|
63 | + * |
|
64 | + * @param \EEI_Payment $payment |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function formatOrderDescription(\EEI_Payment $payment); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * Formats the amount so it can generally be sent to gateways |
|
73 | - * |
|
74 | - * @param float $amount |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function formatCurrency($amount); |
|
71 | + /** |
|
72 | + * Formats the amount so it can generally be sent to gateways |
|
73 | + * |
|
74 | + * @param float $amount |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function formatCurrency($amount); |
|
78 | 78 | } |
79 | 79 | // End of file GatewayDataFormatterInterface.php |
80 | 80 | // Location: core\services\payment_methods\gateways/GatewayDataFormatterInterface.php |
81 | 81 | \ No newline at end of file |