@@ -80,7 +80,7 @@ |
||
80 | 80 | extract($attributes, EXTR_OVERWRITE); |
81 | 81 | $event_id = isset($event_id) ? $event_id : 0; |
82 | 82 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
83 | - if (! $event instanceof EE_Event) { |
|
83 | + if ( ! $event instanceof EE_Event) { |
|
84 | 84 | if (WP_DEBUG === true && current_user_can('edit_pages')) { |
85 | 85 | new ExceptionStackTraceDisplay( |
86 | 86 | new InvalidArgumentException( |
@@ -22,92 +22,92 @@ |
||
22 | 22 | */ |
23 | 23 | class EspressoTicketSelector extends EspressoShortcode |
24 | 24 | { |
25 | - /** |
|
26 | - * the actual shortcode tag that gets registered with WordPress |
|
27 | - * |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function getTag() |
|
31 | - { |
|
32 | - return 'ESPRESSO_TICKET_SELECTOR'; |
|
33 | - } |
|
25 | + /** |
|
26 | + * the actual shortcode tag that gets registered with WordPress |
|
27 | + * |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function getTag() |
|
31 | + { |
|
32 | + return 'ESPRESSO_TICKET_SELECTOR'; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * the time in seconds to cache the results of the processShortcode() method |
|
38 | - * 0 means the processShortcode() results will NOT be cached at all |
|
39 | - * |
|
40 | - * @return int |
|
41 | - */ |
|
42 | - public function cacheExpiration() |
|
43 | - { |
|
44 | - return 0; |
|
45 | - } |
|
36 | + /** |
|
37 | + * the time in seconds to cache the results of the processShortcode() method |
|
38 | + * 0 means the processShortcode() results will NOT be cached at all |
|
39 | + * |
|
40 | + * @return int |
|
41 | + */ |
|
42 | + public function cacheExpiration() |
|
43 | + { |
|
44 | + return 0; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | - * this may be required for shortcodes that utilize a corresponding module, |
|
51 | - * and need to enqueue assets for that module |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function initializeShortcode() |
|
56 | - { |
|
57 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
58 | - $this->shortcodeHasBeenInitialized(); |
|
59 | - } |
|
48 | + /** |
|
49 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | + * this may be required for shortcodes that utilize a corresponding module, |
|
51 | + * and need to enqueue assets for that module |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function initializeShortcode() |
|
56 | + { |
|
57 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
58 | + $this->shortcodeHasBeenInitialized(); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * callback that runs when the shortcode is encountered in post content. |
|
64 | - * IMPORTANT !!! |
|
65 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
66 | - * |
|
67 | - * @param array $attributes |
|
68 | - * @return string |
|
69 | - * @throws InvalidArgumentException |
|
70 | - * @throws EE_Error |
|
71 | - * @throws InvalidDataTypeException |
|
72 | - * @throws InvalidInterfaceException |
|
73 | - * @throws ReflectionException |
|
74 | - * @throws Exception |
|
75 | - */ |
|
76 | - public function processShortcode($attributes = array()) |
|
77 | - { |
|
78 | - extract($attributes, EXTR_OVERWRITE); |
|
79 | - $event_id = isset($event_id) ? $event_id : 0; |
|
80 | - $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
81 | - if (! $event instanceof EE_Event) { |
|
82 | - if (WP_DEBUG === true && current_user_can('edit_pages')) { |
|
83 | - new ExceptionStackTraceDisplay( |
|
84 | - new InvalidArgumentException( |
|
85 | - sprintf( |
|
86 | - esc_html__( |
|
87 | - 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.', |
|
88 | - 'event_espresso' |
|
89 | - ), |
|
90 | - $this->getTag(), |
|
91 | - $event_id, |
|
92 | - 'event_id', |
|
93 | - '<br />' |
|
94 | - ) |
|
95 | - ) |
|
96 | - ); |
|
97 | - return ''; |
|
98 | - } |
|
99 | - return sprintf( |
|
100 | - esc_html__( |
|
101 | - 'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.', |
|
102 | - 'event_espresso' |
|
103 | - ), |
|
104 | - $event_id |
|
105 | - ); |
|
106 | - } |
|
107 | - ob_start(); |
|
108 | - do_action('AHEE_event_details_before_post', $event_id); |
|
109 | - espresso_ticket_selector($event); |
|
110 | - do_action('AHEE_event_details_after_post'); |
|
111 | - return ob_get_clean(); |
|
112 | - } |
|
62 | + /** |
|
63 | + * callback that runs when the shortcode is encountered in post content. |
|
64 | + * IMPORTANT !!! |
|
65 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
66 | + * |
|
67 | + * @param array $attributes |
|
68 | + * @return string |
|
69 | + * @throws InvalidArgumentException |
|
70 | + * @throws EE_Error |
|
71 | + * @throws InvalidDataTypeException |
|
72 | + * @throws InvalidInterfaceException |
|
73 | + * @throws ReflectionException |
|
74 | + * @throws Exception |
|
75 | + */ |
|
76 | + public function processShortcode($attributes = array()) |
|
77 | + { |
|
78 | + extract($attributes, EXTR_OVERWRITE); |
|
79 | + $event_id = isset($event_id) ? $event_id : 0; |
|
80 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
81 | + if (! $event instanceof EE_Event) { |
|
82 | + if (WP_DEBUG === true && current_user_can('edit_pages')) { |
|
83 | + new ExceptionStackTraceDisplay( |
|
84 | + new InvalidArgumentException( |
|
85 | + sprintf( |
|
86 | + esc_html__( |
|
87 | + 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.', |
|
88 | + 'event_espresso' |
|
89 | + ), |
|
90 | + $this->getTag(), |
|
91 | + $event_id, |
|
92 | + 'event_id', |
|
93 | + '<br />' |
|
94 | + ) |
|
95 | + ) |
|
96 | + ); |
|
97 | + return ''; |
|
98 | + } |
|
99 | + return sprintf( |
|
100 | + esc_html__( |
|
101 | + 'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.', |
|
102 | + 'event_espresso' |
|
103 | + ), |
|
104 | + $event_id |
|
105 | + ); |
|
106 | + } |
|
107 | + ob_start(); |
|
108 | + do_action('AHEE_event_details_before_post', $event_id); |
|
109 | + espresso_ticket_selector($event); |
|
110 | + do_action('AHEE_event_details_after_post'); |
|
111 | + return ob_get_clean(); |
|
112 | + } |
|
113 | 113 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
260 | 260 | 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
261 | 261 | 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
262 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
262 | + 'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css', |
|
263 | 263 | 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
264 | 264 | ); |
265 | 265 | $this->_deregister_wp_hooks(); |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | $invoice_name = $this->_subject; |
324 | 324 | |
325 | 325 | // only load dompdf if nobody else has yet... |
326 | - if (! class_exists('Dompdf\Dompdf')) { |
|
327 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
326 | + if ( ! class_exists('Dompdf\Dompdf')) { |
|
327 | + require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php'); |
|
328 | 328 | Dompdf\Autoloader::register(); |
329 | 329 | } |
330 | 330 | $options = new Dompdf\Options(); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $dompdf->loadHtml($content); |
337 | 337 | $dompdf->render(); |
338 | 338 | // forcing the browser to open a download dialog. |
339 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
339 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => true)); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 |
@@ -13,349 +13,349 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Pdf_messenger extends EE_messenger |
15 | 15 | { |
16 | - /** |
|
17 | - * The following are the properties that this messenger requires for generating pdf |
|
18 | - */ |
|
19 | - |
|
20 | - /** |
|
21 | - * This is the pdf body generated by the template via the message type. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $_content; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - protected $_subject; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @return EE_Pdf_messenger |
|
38 | - */ |
|
39 | - public function __construct() |
|
40 | - { |
|
41 | - // set properties |
|
42 | - $this->name = 'pdf'; |
|
43 | - $this->description = esc_html__('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
44 | - $this->label = array( |
|
45 | - 'singular' => esc_html__('PDF', 'event_espresso'), |
|
46 | - 'plural' => esc_html__('PDFs', 'event_espresso') |
|
47 | - ); |
|
48 | - $this->activate_on_install = true; |
|
49 | - |
|
50 | - parent::__construct(); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * PDF Messenger desires execution immediately. |
|
56 | - * @see parent::send_now() for documentation. |
|
57 | - * @since 4.9.0 |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function send_now() |
|
61 | - { |
|
62 | - return true; |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * HTML Messenger allows an empty to field. |
|
68 | - * @see parent::allow_empty_to_field() for documentation |
|
69 | - * @since 4.9.0 |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function allow_empty_to_field() |
|
73 | - { |
|
74 | - return true; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @see abstract declaration in EE_messenger for details. |
|
80 | - */ |
|
81 | - protected function _set_admin_pages() |
|
82 | - { |
|
83 | - $this->admin_registered_pages = array('events_edit' => false); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @see abstract declaration in EE_messenger for details. |
|
89 | - */ |
|
90 | - protected function _set_valid_shortcodes() |
|
91 | - { |
|
92 | - $this->_valid_shortcodes = array(); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @see abstract declaration in EE_messenger for details. |
|
98 | - */ |
|
99 | - protected function _set_validator_config() |
|
100 | - { |
|
101 | - $this->_validator_config = array( |
|
102 | - 'subject' => array( |
|
103 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
104 | - ), |
|
105 | - 'content' => array( |
|
106 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
107 | - ), |
|
108 | - 'attendee_list' => array( |
|
109 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
110 | - 'required' => array('[ATTENDEE_LIST]') |
|
111 | - ), |
|
112 | - 'event_list' => array( |
|
113 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
114 | - 'required' => array('[EVENT_LIST]') |
|
115 | - ), |
|
116 | - 'ticket_list' => array( |
|
117 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
118 | - 'required' => array('[TICKET_LIST]') |
|
119 | - ), |
|
120 | - 'datetime_list' => array( |
|
121 | - 'shortcodes' => array('datetime'), |
|
122 | - 'required' => array('[DATETIME_LIST]') |
|
123 | - ), |
|
124 | - ); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
130 | - * |
|
131 | - * @return void. |
|
132 | - */ |
|
133 | - public function enqueue_scripts_styles() |
|
134 | - { |
|
135 | - parent::enqueue_scripts_styles(); |
|
136 | - do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * _set_template_fields |
|
142 | - * This sets up the fields that a messenger requires for the message to go out. |
|
143 | - * |
|
144 | - * @access protected |
|
145 | - * @return void |
|
146 | - */ |
|
147 | - protected function _set_template_fields() |
|
148 | - { |
|
149 | - // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
150 | - $this->_template_fields = array( |
|
151 | - 'subject' => array( |
|
152 | - 'input' => 'text', |
|
153 | - 'label' => esc_html__('Page Title', 'event_espresso'), |
|
154 | - 'type' => 'string', |
|
155 | - 'required' => true, |
|
156 | - 'validation' => true, |
|
157 | - 'css_class' => 'large-text', |
|
158 | - 'format' => '%s' |
|
159 | - ), |
|
160 | - 'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
161 | - 'extra' => array( |
|
162 | - 'content' => array( |
|
163 | - 'main' => array( |
|
164 | - 'input' => 'wp_editor', |
|
165 | - 'label' => esc_html__('Main Content', 'event_espresso'), |
|
166 | - 'type' => 'string', |
|
167 | - 'required' => true, |
|
168 | - 'validation' => true, |
|
169 | - 'format' => '%s', |
|
170 | - 'rows' => '15' |
|
171 | - ), |
|
172 | - 'event_list' => array( |
|
173 | - 'input' => 'wp_editor', |
|
174 | - 'label' => '[EVENT_LIST]', |
|
175 | - 'type' => 'string', |
|
176 | - 'required' => true, |
|
177 | - 'validation' => true, |
|
178 | - 'format' => '%s', |
|
179 | - 'rows' => '15', |
|
180 | - 'shortcodes_required' => array('[EVENT_LIST]') |
|
181 | - ), |
|
182 | - 'attendee_list' => array( |
|
183 | - 'input' => 'textarea', |
|
184 | - 'label' => '[ATTENDEE_LIST]', |
|
185 | - 'type' => 'string', |
|
186 | - 'required' => true, |
|
187 | - 'validation' => true, |
|
188 | - 'format' => '%s', |
|
189 | - 'css_class' => 'large-text', |
|
190 | - 'rows' => '5', |
|
191 | - 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
192 | - ), |
|
193 | - 'ticket_list' => array( |
|
194 | - 'input' => 'textarea', |
|
195 | - 'label' => '[TICKET_LIST]', |
|
196 | - 'type' => 'string', |
|
197 | - 'required' => true, |
|
198 | - 'validation' => true, |
|
199 | - 'format' => '%s', |
|
200 | - 'css_class' => 'large-text', |
|
201 | - 'rows' => '10', |
|
202 | - 'shortcodes_required' => array('[TICKET_LIST]') |
|
203 | - ), |
|
204 | - 'datetime_list' => array( |
|
205 | - 'input' => 'textarea', |
|
206 | - 'label' => '[DATETIME_LIST]', |
|
207 | - 'type' => 'string', |
|
208 | - 'required' => true, |
|
209 | - 'validation' => true, |
|
210 | - 'format' => '%s', |
|
211 | - 'css_class' => 'large-text', |
|
212 | - 'rows' => '10', |
|
213 | - 'shortcodes_required' => array('[DATETIME_LIST]') |
|
214 | - ) |
|
215 | - ) |
|
216 | - ) |
|
217 | - ); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * @see definition of this method in parent |
|
223 | - * |
|
224 | - * @since 4.5.0 |
|
225 | - * |
|
226 | - */ |
|
227 | - protected function _set_default_message_types() |
|
228 | - { |
|
229 | - // note currently PDF is only a secondary messenger so it never has any associated message types. |
|
230 | - $this->_default_message_types = array(); |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * @see definition of this method in parent |
|
236 | - * |
|
237 | - * @since 4.5.0 |
|
238 | - */ |
|
239 | - protected function _set_valid_message_types() |
|
240 | - { |
|
241 | - $this->_valid_message_types = array(); |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * Generates html version of the message content and then sends it to the pdf generator. |
|
247 | - * |
|
248 | - * |
|
249 | - * @since 4.5.0 |
|
250 | - * |
|
251 | - * @return string. |
|
252 | - */ |
|
253 | - protected function _send_message() |
|
254 | - { |
|
255 | - $this->_template_args = array( |
|
256 | - 'page_title' => $this->_subject, |
|
257 | - 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
|
258 | - 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
|
259 | - 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
|
260 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
261 | - 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
|
262 | - ); |
|
263 | - $this->_deregister_wp_hooks(); |
|
264 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
265 | - $content = $this->_get_main_template(); |
|
16 | + /** |
|
17 | + * The following are the properties that this messenger requires for generating pdf |
|
18 | + */ |
|
19 | + |
|
20 | + /** |
|
21 | + * This is the pdf body generated by the template via the message type. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $_content; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + protected $_subject; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @return EE_Pdf_messenger |
|
38 | + */ |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + // set properties |
|
42 | + $this->name = 'pdf'; |
|
43 | + $this->description = esc_html__('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
44 | + $this->label = array( |
|
45 | + 'singular' => esc_html__('PDF', 'event_espresso'), |
|
46 | + 'plural' => esc_html__('PDFs', 'event_espresso') |
|
47 | + ); |
|
48 | + $this->activate_on_install = true; |
|
49 | + |
|
50 | + parent::__construct(); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * PDF Messenger desires execution immediately. |
|
56 | + * @see parent::send_now() for documentation. |
|
57 | + * @since 4.9.0 |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function send_now() |
|
61 | + { |
|
62 | + return true; |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * HTML Messenger allows an empty to field. |
|
68 | + * @see parent::allow_empty_to_field() for documentation |
|
69 | + * @since 4.9.0 |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function allow_empty_to_field() |
|
73 | + { |
|
74 | + return true; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @see abstract declaration in EE_messenger for details. |
|
80 | + */ |
|
81 | + protected function _set_admin_pages() |
|
82 | + { |
|
83 | + $this->admin_registered_pages = array('events_edit' => false); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @see abstract declaration in EE_messenger for details. |
|
89 | + */ |
|
90 | + protected function _set_valid_shortcodes() |
|
91 | + { |
|
92 | + $this->_valid_shortcodes = array(); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @see abstract declaration in EE_messenger for details. |
|
98 | + */ |
|
99 | + protected function _set_validator_config() |
|
100 | + { |
|
101 | + $this->_validator_config = array( |
|
102 | + 'subject' => array( |
|
103 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
104 | + ), |
|
105 | + 'content' => array( |
|
106 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
107 | + ), |
|
108 | + 'attendee_list' => array( |
|
109 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
110 | + 'required' => array('[ATTENDEE_LIST]') |
|
111 | + ), |
|
112 | + 'event_list' => array( |
|
113 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
114 | + 'required' => array('[EVENT_LIST]') |
|
115 | + ), |
|
116 | + 'ticket_list' => array( |
|
117 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
118 | + 'required' => array('[TICKET_LIST]') |
|
119 | + ), |
|
120 | + 'datetime_list' => array( |
|
121 | + 'shortcodes' => array('datetime'), |
|
122 | + 'required' => array('[DATETIME_LIST]') |
|
123 | + ), |
|
124 | + ); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
130 | + * |
|
131 | + * @return void. |
|
132 | + */ |
|
133 | + public function enqueue_scripts_styles() |
|
134 | + { |
|
135 | + parent::enqueue_scripts_styles(); |
|
136 | + do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * _set_template_fields |
|
142 | + * This sets up the fields that a messenger requires for the message to go out. |
|
143 | + * |
|
144 | + * @access protected |
|
145 | + * @return void |
|
146 | + */ |
|
147 | + protected function _set_template_fields() |
|
148 | + { |
|
149 | + // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
150 | + $this->_template_fields = array( |
|
151 | + 'subject' => array( |
|
152 | + 'input' => 'text', |
|
153 | + 'label' => esc_html__('Page Title', 'event_espresso'), |
|
154 | + 'type' => 'string', |
|
155 | + 'required' => true, |
|
156 | + 'validation' => true, |
|
157 | + 'css_class' => 'large-text', |
|
158 | + 'format' => '%s' |
|
159 | + ), |
|
160 | + 'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
161 | + 'extra' => array( |
|
162 | + 'content' => array( |
|
163 | + 'main' => array( |
|
164 | + 'input' => 'wp_editor', |
|
165 | + 'label' => esc_html__('Main Content', 'event_espresso'), |
|
166 | + 'type' => 'string', |
|
167 | + 'required' => true, |
|
168 | + 'validation' => true, |
|
169 | + 'format' => '%s', |
|
170 | + 'rows' => '15' |
|
171 | + ), |
|
172 | + 'event_list' => array( |
|
173 | + 'input' => 'wp_editor', |
|
174 | + 'label' => '[EVENT_LIST]', |
|
175 | + 'type' => 'string', |
|
176 | + 'required' => true, |
|
177 | + 'validation' => true, |
|
178 | + 'format' => '%s', |
|
179 | + 'rows' => '15', |
|
180 | + 'shortcodes_required' => array('[EVENT_LIST]') |
|
181 | + ), |
|
182 | + 'attendee_list' => array( |
|
183 | + 'input' => 'textarea', |
|
184 | + 'label' => '[ATTENDEE_LIST]', |
|
185 | + 'type' => 'string', |
|
186 | + 'required' => true, |
|
187 | + 'validation' => true, |
|
188 | + 'format' => '%s', |
|
189 | + 'css_class' => 'large-text', |
|
190 | + 'rows' => '5', |
|
191 | + 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
192 | + ), |
|
193 | + 'ticket_list' => array( |
|
194 | + 'input' => 'textarea', |
|
195 | + 'label' => '[TICKET_LIST]', |
|
196 | + 'type' => 'string', |
|
197 | + 'required' => true, |
|
198 | + 'validation' => true, |
|
199 | + 'format' => '%s', |
|
200 | + 'css_class' => 'large-text', |
|
201 | + 'rows' => '10', |
|
202 | + 'shortcodes_required' => array('[TICKET_LIST]') |
|
203 | + ), |
|
204 | + 'datetime_list' => array( |
|
205 | + 'input' => 'textarea', |
|
206 | + 'label' => '[DATETIME_LIST]', |
|
207 | + 'type' => 'string', |
|
208 | + 'required' => true, |
|
209 | + 'validation' => true, |
|
210 | + 'format' => '%s', |
|
211 | + 'css_class' => 'large-text', |
|
212 | + 'rows' => '10', |
|
213 | + 'shortcodes_required' => array('[DATETIME_LIST]') |
|
214 | + ) |
|
215 | + ) |
|
216 | + ) |
|
217 | + ); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * @see definition of this method in parent |
|
223 | + * |
|
224 | + * @since 4.5.0 |
|
225 | + * |
|
226 | + */ |
|
227 | + protected function _set_default_message_types() |
|
228 | + { |
|
229 | + // note currently PDF is only a secondary messenger so it never has any associated message types. |
|
230 | + $this->_default_message_types = array(); |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * @see definition of this method in parent |
|
236 | + * |
|
237 | + * @since 4.5.0 |
|
238 | + */ |
|
239 | + protected function _set_valid_message_types() |
|
240 | + { |
|
241 | + $this->_valid_message_types = array(); |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * Generates html version of the message content and then sends it to the pdf generator. |
|
247 | + * |
|
248 | + * |
|
249 | + * @since 4.5.0 |
|
250 | + * |
|
251 | + * @return string. |
|
252 | + */ |
|
253 | + protected function _send_message() |
|
254 | + { |
|
255 | + $this->_template_args = array( |
|
256 | + 'page_title' => $this->_subject, |
|
257 | + 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
|
258 | + 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
|
259 | + 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
|
260 | + 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
261 | + 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
|
262 | + ); |
|
263 | + $this->_deregister_wp_hooks(); |
|
264 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
265 | + $content = $this->_get_main_template(); |
|
266 | 266 | // die( $content ); |
267 | - $this->_do_pdf($content); |
|
268 | - exit(0); |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - /** |
|
273 | - * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
274 | - * |
|
275 | - * @since 4.5.0 |
|
276 | - * |
|
277 | - * @return void |
|
278 | - */ |
|
279 | - protected function _deregister_wp_hooks() |
|
280 | - { |
|
281 | - remove_all_actions('wp_head'); |
|
282 | - remove_all_actions('wp_footer'); |
|
283 | - remove_all_actions('wp_print_footer_scripts'); |
|
284 | - remove_all_actions('wp_enqueue_scripts'); |
|
285 | - global $wp_scripts, $wp_styles; |
|
286 | - $wp_scripts = $wp_styles = array(); |
|
287 | - |
|
288 | - // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
289 | - add_action('wp_head', 'wp_enqueue_scripts'); |
|
290 | - add_action('wp_footer', 'wp_print_footer_scripts'); |
|
291 | - add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * Overwrite parent _get_main_template for pdf purposes. |
|
297 | - * |
|
298 | - * @since 4.5.0 |
|
299 | - * |
|
300 | - * @param bool $preview |
|
301 | - * @return string |
|
302 | - */ |
|
303 | - protected function _get_main_template($preview = false) |
|
304 | - { |
|
305 | - $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
306 | - // add message type to template_args |
|
307 | - $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
308 | - return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * This takes care of loading the dompdf library and generating the actual pdf |
|
314 | - * |
|
315 | - * @param string $content This is the generated html content being converted into a pdf. |
|
316 | - * |
|
317 | - * @return void |
|
318 | - */ |
|
319 | - protected function _do_pdf($content = '') |
|
320 | - { |
|
321 | - $invoice_name = $this->_subject; |
|
322 | - |
|
323 | - // only load dompdf if nobody else has yet... |
|
324 | - if (! class_exists('Dompdf\Dompdf')) { |
|
325 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
326 | - Dompdf\Autoloader::register(); |
|
327 | - } |
|
328 | - $options = new Dompdf\Options(); |
|
329 | - $options->set('isRemoteEnabled', true); |
|
330 | - $options->set('isJavascriptEnabled', false); |
|
331 | - if (defined('DOMPDF_FONT_DIR')) { |
|
332 | - $options->setFontDir(DOMPDF_FONT_DIR); |
|
333 | - $options->setFontCache(DOMPDF_FONT_DIR); |
|
334 | - } |
|
335 | - // Allow changing the paper size. |
|
336 | - if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
337 | - $options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE); |
|
338 | - } |
|
339 | - $dompdf = new Dompdf\Dompdf($options); |
|
340 | - // Remove all spaces between HTML tags |
|
341 | - $content = preg_replace('/>\s+</', '><', $content); |
|
342 | - $dompdf->loadHtml($content); |
|
343 | - $dompdf->render(); |
|
344 | - // forcing the browser to open a download dialog. |
|
345 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * @return string |
|
351 | - */ |
|
352 | - protected function _preview() |
|
353 | - { |
|
354 | - return $this->_send_message(); |
|
355 | - } |
|
356 | - |
|
357 | - |
|
358 | - protected function _set_admin_settings_fields() |
|
359 | - { |
|
360 | - } |
|
267 | + $this->_do_pdf($content); |
|
268 | + exit(0); |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + /** |
|
273 | + * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
274 | + * |
|
275 | + * @since 4.5.0 |
|
276 | + * |
|
277 | + * @return void |
|
278 | + */ |
|
279 | + protected function _deregister_wp_hooks() |
|
280 | + { |
|
281 | + remove_all_actions('wp_head'); |
|
282 | + remove_all_actions('wp_footer'); |
|
283 | + remove_all_actions('wp_print_footer_scripts'); |
|
284 | + remove_all_actions('wp_enqueue_scripts'); |
|
285 | + global $wp_scripts, $wp_styles; |
|
286 | + $wp_scripts = $wp_styles = array(); |
|
287 | + |
|
288 | + // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
289 | + add_action('wp_head', 'wp_enqueue_scripts'); |
|
290 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
291 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * Overwrite parent _get_main_template for pdf purposes. |
|
297 | + * |
|
298 | + * @since 4.5.0 |
|
299 | + * |
|
300 | + * @param bool $preview |
|
301 | + * @return string |
|
302 | + */ |
|
303 | + protected function _get_main_template($preview = false) |
|
304 | + { |
|
305 | + $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
306 | + // add message type to template_args |
|
307 | + $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
308 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * This takes care of loading the dompdf library and generating the actual pdf |
|
314 | + * |
|
315 | + * @param string $content This is the generated html content being converted into a pdf. |
|
316 | + * |
|
317 | + * @return void |
|
318 | + */ |
|
319 | + protected function _do_pdf($content = '') |
|
320 | + { |
|
321 | + $invoice_name = $this->_subject; |
|
322 | + |
|
323 | + // only load dompdf if nobody else has yet... |
|
324 | + if (! class_exists('Dompdf\Dompdf')) { |
|
325 | + require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
326 | + Dompdf\Autoloader::register(); |
|
327 | + } |
|
328 | + $options = new Dompdf\Options(); |
|
329 | + $options->set('isRemoteEnabled', true); |
|
330 | + $options->set('isJavascriptEnabled', false); |
|
331 | + if (defined('DOMPDF_FONT_DIR')) { |
|
332 | + $options->setFontDir(DOMPDF_FONT_DIR); |
|
333 | + $options->setFontCache(DOMPDF_FONT_DIR); |
|
334 | + } |
|
335 | + // Allow changing the paper size. |
|
336 | + if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
337 | + $options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE); |
|
338 | + } |
|
339 | + $dompdf = new Dompdf\Dompdf($options); |
|
340 | + // Remove all spaces between HTML tags |
|
341 | + $content = preg_replace('/>\s+</', '><', $content); |
|
342 | + $dompdf->loadHtml($content); |
|
343 | + $dompdf->render(); |
|
344 | + // forcing the browser to open a download dialog. |
|
345 | + $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * @return string |
|
351 | + */ |
|
352 | + protected function _preview() |
|
353 | + { |
|
354 | + return $this->_send_message(); |
|
355 | + } |
|
356 | + |
|
357 | + |
|
358 | + protected function _set_admin_settings_fields() |
|
359 | + { |
|
360 | + } |
|
361 | 361 | } |
@@ -16,16 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | class URLValidator |
18 | 18 | { |
19 | - /** |
|
20 | - * Returns whether or not the URL is valid |
|
21 | - * @since 4.9.68.p |
|
22 | - * @param $url |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function isValid($url) |
|
26 | - { |
|
27 | - return esc_url_raw($url) === $url; |
|
28 | - } |
|
19 | + /** |
|
20 | + * Returns whether or not the URL is valid |
|
21 | + * @since 4.9.68.p |
|
22 | + * @param $url |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function isValid($url) |
|
26 | + { |
|
27 | + return esc_url_raw($url) === $url; |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | // End of file URLValidator.php |
31 | 31 | // Location: ${NAMESPACE}/URLValidator.php |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function isValid($file, $func, $line) |
34 | 34 | { |
35 | - if (! defined('JSON_ERROR_RECURSION')) { |
|
35 | + if ( ! defined('JSON_ERROR_RECURSION')) { |
|
36 | 36 | define('JSON_ERROR_RECURSION', 6); |
37 | 37 | } |
38 | - if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
38 | + if ( ! defined('JSON_ERROR_INF_OR_NAN')) { |
|
39 | 39 | define('JSON_ERROR_INF_OR_NAN', 7); |
40 | 40 | } |
41 | - if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
41 | + if ( ! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
42 | 42 | define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
43 | 43 | } |
44 | - if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
44 | + if ( ! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
45 | 45 | define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
46 | 46 | } |
47 | - if (! defined('JSON_ERROR_UTF16')) { |
|
47 | + if ( ! defined('JSON_ERROR_UTF16')) { |
|
48 | 48 | define('JSON_ERROR_UTF16', 10); |
49 | 49 | } |
50 | 50 | switch (json_last_error()) { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $error = ': Unknown error'; |
85 | 85 | break; |
86 | 86 | } |
87 | - EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
87 | + EE_Error::add_error('JSON decoding failed'.$error, $file, $func, $line); |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | } |
@@ -17,76 +17,76 @@ |
||
17 | 17 | */ |
18 | 18 | class JsonValidator |
19 | 19 | { |
20 | - /** |
|
21 | - * Call this method IMMEDIATELY after json_decode() and |
|
22 | - * it will will return true if the decoded JSON was valid, |
|
23 | - * or return false after adding an error if not valid. |
|
24 | - * The actual JSON file does not need to be supplied, |
|
25 | - * but details re: code execution location are required. |
|
26 | - * ex: |
|
27 | - * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__) |
|
28 | - * |
|
29 | - * @param string $file |
|
30 | - * @param string $func |
|
31 | - * @param string $line |
|
32 | - * @return boolean |
|
33 | - * @since 4.9.70.p |
|
34 | - */ |
|
35 | - public function isValid($file, $func, $line) |
|
36 | - { |
|
37 | - if (! defined('JSON_ERROR_RECURSION')) { |
|
38 | - define('JSON_ERROR_RECURSION', 6); |
|
39 | - } |
|
40 | - if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
41 | - define('JSON_ERROR_INF_OR_NAN', 7); |
|
42 | - } |
|
43 | - if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
44 | - define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
|
45 | - } |
|
46 | - if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
47 | - define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
|
48 | - } |
|
49 | - if (! defined('JSON_ERROR_UTF16')) { |
|
50 | - define('JSON_ERROR_UTF16', 10); |
|
51 | - } |
|
52 | - switch (json_last_error()) { |
|
53 | - case JSON_ERROR_NONE: |
|
54 | - return true; |
|
55 | - case JSON_ERROR_DEPTH: |
|
56 | - $error = ': Maximum stack depth exceeded'; |
|
57 | - break; |
|
58 | - case JSON_ERROR_STATE_MISMATCH: |
|
59 | - $error = ': Invalid or malformed JSON'; |
|
60 | - break; |
|
61 | - case JSON_ERROR_CTRL_CHAR: |
|
62 | - $error = ': Control character error, possible malformed JSON'; |
|
63 | - break; |
|
64 | - case JSON_ERROR_SYNTAX: |
|
65 | - $error = ': Syntax error, malformed JSON'; |
|
66 | - break; |
|
67 | - case JSON_ERROR_UTF8: |
|
68 | - $error = ': Malformed UTF-8 characters, possible malformed JSON'; |
|
69 | - break; |
|
70 | - case JSON_ERROR_RECURSION: |
|
71 | - $error = ': One or more recursive references in the value to be encoded'; |
|
72 | - break; |
|
73 | - case JSON_ERROR_INF_OR_NAN: |
|
74 | - $error = ': One or more NAN or INF values in the value to be encoded'; |
|
75 | - break; |
|
76 | - case JSON_ERROR_UNSUPPORTED_TYPE: |
|
77 | - $error = ': A value of a type that cannot be encoded was given'; |
|
78 | - break; |
|
79 | - case JSON_ERROR_INVALID_PROPERTY_NAME: |
|
80 | - $error = ': A property name that cannot be encoded was given'; |
|
81 | - break; |
|
82 | - case JSON_ERROR_UTF16: |
|
83 | - $error = ': Malformed UTF-16 characters, possibly incorrectly encoded'; |
|
84 | - break; |
|
85 | - default: |
|
86 | - $error = ': Unknown error'; |
|
87 | - break; |
|
88 | - } |
|
89 | - EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
90 | - return false; |
|
91 | - } |
|
20 | + /** |
|
21 | + * Call this method IMMEDIATELY after json_decode() and |
|
22 | + * it will will return true if the decoded JSON was valid, |
|
23 | + * or return false after adding an error if not valid. |
|
24 | + * The actual JSON file does not need to be supplied, |
|
25 | + * but details re: code execution location are required. |
|
26 | + * ex: |
|
27 | + * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__) |
|
28 | + * |
|
29 | + * @param string $file |
|
30 | + * @param string $func |
|
31 | + * @param string $line |
|
32 | + * @return boolean |
|
33 | + * @since 4.9.70.p |
|
34 | + */ |
|
35 | + public function isValid($file, $func, $line) |
|
36 | + { |
|
37 | + if (! defined('JSON_ERROR_RECURSION')) { |
|
38 | + define('JSON_ERROR_RECURSION', 6); |
|
39 | + } |
|
40 | + if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
41 | + define('JSON_ERROR_INF_OR_NAN', 7); |
|
42 | + } |
|
43 | + if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
44 | + define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
|
45 | + } |
|
46 | + if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
47 | + define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
|
48 | + } |
|
49 | + if (! defined('JSON_ERROR_UTF16')) { |
|
50 | + define('JSON_ERROR_UTF16', 10); |
|
51 | + } |
|
52 | + switch (json_last_error()) { |
|
53 | + case JSON_ERROR_NONE: |
|
54 | + return true; |
|
55 | + case JSON_ERROR_DEPTH: |
|
56 | + $error = ': Maximum stack depth exceeded'; |
|
57 | + break; |
|
58 | + case JSON_ERROR_STATE_MISMATCH: |
|
59 | + $error = ': Invalid or malformed JSON'; |
|
60 | + break; |
|
61 | + case JSON_ERROR_CTRL_CHAR: |
|
62 | + $error = ': Control character error, possible malformed JSON'; |
|
63 | + break; |
|
64 | + case JSON_ERROR_SYNTAX: |
|
65 | + $error = ': Syntax error, malformed JSON'; |
|
66 | + break; |
|
67 | + case JSON_ERROR_UTF8: |
|
68 | + $error = ': Malformed UTF-8 characters, possible malformed JSON'; |
|
69 | + break; |
|
70 | + case JSON_ERROR_RECURSION: |
|
71 | + $error = ': One or more recursive references in the value to be encoded'; |
|
72 | + break; |
|
73 | + case JSON_ERROR_INF_OR_NAN: |
|
74 | + $error = ': One or more NAN or INF values in the value to be encoded'; |
|
75 | + break; |
|
76 | + case JSON_ERROR_UNSUPPORTED_TYPE: |
|
77 | + $error = ': A value of a type that cannot be encoded was given'; |
|
78 | + break; |
|
79 | + case JSON_ERROR_INVALID_PROPERTY_NAME: |
|
80 | + $error = ': A property name that cannot be encoded was given'; |
|
81 | + break; |
|
82 | + case JSON_ERROR_UTF16: |
|
83 | + $error = ': Malformed UTF-16 characters, possibly incorrectly encoded'; |
|
84 | + break; |
|
85 | + default: |
|
86 | + $error = ': Unknown error'; |
|
87 | + break; |
|
88 | + } |
|
89 | + EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
90 | + return false; |
|
91 | + } |
|
92 | 92 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $template_args['attributes'] = $attributes; |
47 | 47 | $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
48 | 48 | return EEH_Template::display_template( |
49 | - $this->templateRootPath() . 'event-attendees.php', |
|
49 | + $this->templateRootPath().'event-attendees.php', |
|
50 | 50 | $template_args, |
51 | 51 | true |
52 | 52 | ); |
@@ -19,133 +19,133 @@ |
||
19 | 19 | */ |
20 | 20 | class EventAttendeesBlockRenderer extends BlockRenderer |
21 | 21 | { |
22 | - /** |
|
23 | - * @var EEM_Attendee |
|
24 | - */ |
|
25 | - private $attendee_model; |
|
22 | + /** |
|
23 | + * @var EEM_Attendee |
|
24 | + */ |
|
25 | + private $attendee_model; |
|
26 | 26 | |
27 | - public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model) |
|
28 | - { |
|
29 | - $this->attendee_model = $attendee_model; |
|
30 | - parent::__construct($domain); |
|
31 | - } |
|
27 | + public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model) |
|
28 | + { |
|
29 | + $this->attendee_model = $attendee_model; |
|
30 | + parent::__construct($domain); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Renders the block. |
|
36 | - * |
|
37 | - * @param array $attributes Expect already validated and sanitized array of attributes for use in generating the |
|
38 | - * query and the template output. |
|
39 | - * @return string |
|
40 | - * @throws DomainException |
|
41 | - * @throws EE_Error |
|
42 | - */ |
|
43 | - public function render(array $attributes) |
|
44 | - { |
|
45 | - $attributes = $this->parseGlobalIDs($attributes); |
|
46 | - $template_args['attributes'] = $attributes; |
|
47 | - $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
|
48 | - return EEH_Template::display_template( |
|
49 | - $this->templateRootPath() . 'event-attendees.php', |
|
50 | - $template_args, |
|
51 | - true |
|
52 | - ); |
|
53 | - } |
|
34 | + /** |
|
35 | + * Renders the block. |
|
36 | + * |
|
37 | + * @param array $attributes Expect already validated and sanitized array of attributes for use in generating the |
|
38 | + * query and the template output. |
|
39 | + * @return string |
|
40 | + * @throws DomainException |
|
41 | + * @throws EE_Error |
|
42 | + */ |
|
43 | + public function render(array $attributes) |
|
44 | + { |
|
45 | + $attributes = $this->parseGlobalIDs($attributes); |
|
46 | + $template_args['attributes'] = $attributes; |
|
47 | + $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
|
48 | + return EEH_Template::display_template( |
|
49 | + $this->templateRootPath() . 'event-attendees.php', |
|
50 | + $template_args, |
|
51 | + true |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Get query parameters for model query. |
|
58 | - * |
|
59 | - * @param array $attributes |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - private function parseGlobalIDs(array $attributes) |
|
63 | - { |
|
64 | - // if ticket ID is set, then that's all we need to run the query |
|
65 | - $ticket = isset($attributes['ticket']) ? $attributes['ticket'] : ''; |
|
66 | - $datetime = isset($attributes['datetime']) ? $attributes['datetime'] : ''; |
|
67 | - $event = isset($attributes['event']) ? $attributes['event'] : ''; |
|
68 | - if ($ticket !== '') { |
|
69 | - $ticketId = $this->parseGUID($ticket); |
|
70 | - $attributes['ticketId'] = $ticketId; |
|
71 | - } elseif ($datetime !== '') { |
|
72 | - $datetimeId = $this->parseGUID($datetime); |
|
73 | - $attributes['datetimeId'] = $datetimeId; |
|
74 | - } elseif ($event !== '') { |
|
75 | - $eventId = $this->parseGUID($event); |
|
76 | - $attributes['eventId'] = $eventId; |
|
77 | - } |
|
78 | - // remove unnecessary data so it doesn't get added to the query vars |
|
79 | - unset($attributes['ticket'], $attributes['datetime'], $attributes['event']); |
|
80 | - return $attributes; |
|
81 | - } |
|
56 | + /** |
|
57 | + * Get query parameters for model query. |
|
58 | + * |
|
59 | + * @param array $attributes |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + private function parseGlobalIDs(array $attributes) |
|
63 | + { |
|
64 | + // if ticket ID is set, then that's all we need to run the query |
|
65 | + $ticket = isset($attributes['ticket']) ? $attributes['ticket'] : ''; |
|
66 | + $datetime = isset($attributes['datetime']) ? $attributes['datetime'] : ''; |
|
67 | + $event = isset($attributes['event']) ? $attributes['event'] : ''; |
|
68 | + if ($ticket !== '') { |
|
69 | + $ticketId = $this->parseGUID($ticket); |
|
70 | + $attributes['ticketId'] = $ticketId; |
|
71 | + } elseif ($datetime !== '') { |
|
72 | + $datetimeId = $this->parseGUID($datetime); |
|
73 | + $attributes['datetimeId'] = $datetimeId; |
|
74 | + } elseif ($event !== '') { |
|
75 | + $eventId = $this->parseGUID($event); |
|
76 | + $attributes['eventId'] = $eventId; |
|
77 | + } |
|
78 | + // remove unnecessary data so it doesn't get added to the query vars |
|
79 | + unset($attributes['ticket'], $attributes['datetime'], $attributes['event']); |
|
80 | + return $attributes; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * Get query parameters for model query. |
|
86 | - * |
|
87 | - * @param array $attributes |
|
88 | - * @return array |
|
89 | - */ |
|
90 | - private function getQueryParams(array $attributes) |
|
91 | - { |
|
92 | - return array( |
|
93 | - 0 => $this->getWhereQueryPart($attributes), |
|
94 | - 'default_where_conditions' => 'this_model_only', |
|
95 | - 'limit' => $attributes['limit'], |
|
96 | - 'group_by' => array('ATT_ID'), |
|
97 | - 'order_by' => $this->getOrderByQueryPart($attributes) |
|
98 | - ); |
|
99 | - } |
|
84 | + /** |
|
85 | + * Get query parameters for model query. |
|
86 | + * |
|
87 | + * @param array $attributes |
|
88 | + * @return array |
|
89 | + */ |
|
90 | + private function getQueryParams(array $attributes) |
|
91 | + { |
|
92 | + return array( |
|
93 | + 0 => $this->getWhereQueryPart($attributes), |
|
94 | + 'default_where_conditions' => 'this_model_only', |
|
95 | + 'limit' => $attributes['limit'], |
|
96 | + 'group_by' => array('ATT_ID'), |
|
97 | + 'order_by' => $this->getOrderByQueryPart($attributes) |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * Get where query part for query parameters for model query. |
|
104 | - * |
|
105 | - * @param array $attributes |
|
106 | - * @return array |
|
107 | - */ |
|
108 | - private function getWhereQueryPart(array $attributes) |
|
109 | - { |
|
110 | - $where = array(); |
|
111 | - if ($attributes['ticketId'] > 0) { |
|
112 | - $where['Registration.TKT_ID'] = $attributes['ticketId']; |
|
113 | - } elseif ($attributes['datetimeId'] > 0) { |
|
114 | - $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId']; |
|
115 | - } else { |
|
116 | - $where['Registration.EVT_ID'] = $attributes['eventId']; |
|
117 | - } |
|
118 | - $where['Registration.STS_ID'] = $attributes['status']; |
|
119 | - return $where; |
|
120 | - } |
|
102 | + /** |
|
103 | + * Get where query part for query parameters for model query. |
|
104 | + * |
|
105 | + * @param array $attributes |
|
106 | + * @return array |
|
107 | + */ |
|
108 | + private function getWhereQueryPart(array $attributes) |
|
109 | + { |
|
110 | + $where = array(); |
|
111 | + if ($attributes['ticketId'] > 0) { |
|
112 | + $where['Registration.TKT_ID'] = $attributes['ticketId']; |
|
113 | + } elseif ($attributes['datetimeId'] > 0) { |
|
114 | + $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId']; |
|
115 | + } else { |
|
116 | + $where['Registration.EVT_ID'] = $attributes['eventId']; |
|
117 | + } |
|
118 | + $where['Registration.STS_ID'] = $attributes['status']; |
|
119 | + return $where; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * Get order by query part for query parameters for model query. |
|
125 | - * |
|
126 | - * @param array $attributes |
|
127 | - * @return array |
|
128 | - */ |
|
129 | - private function getOrderByQueryPart(array $attributes) |
|
130 | - { |
|
131 | - $order = $attributes['order']; |
|
132 | - switch ($attributes['orderBy']) { |
|
133 | - case 'id': |
|
134 | - $order_by = array('ATT_ID' => $order); |
|
135 | - break; |
|
136 | - case 'lastNameOnly': |
|
137 | - $order_by = array('ATT_lname' => $order); |
|
138 | - break; |
|
139 | - case 'firstNameOnly': |
|
140 | - $order_by = array('ATT_fname' => $order); |
|
141 | - break; |
|
142 | - case 'firstThenLastName': |
|
143 | - $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order); |
|
144 | - break; |
|
145 | - default: |
|
146 | - $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order); |
|
147 | - break; |
|
148 | - } |
|
149 | - return $order_by; |
|
150 | - } |
|
123 | + /** |
|
124 | + * Get order by query part for query parameters for model query. |
|
125 | + * |
|
126 | + * @param array $attributes |
|
127 | + * @return array |
|
128 | + */ |
|
129 | + private function getOrderByQueryPart(array $attributes) |
|
130 | + { |
|
131 | + $order = $attributes['order']; |
|
132 | + switch ($attributes['orderBy']) { |
|
133 | + case 'id': |
|
134 | + $order_by = array('ATT_ID' => $order); |
|
135 | + break; |
|
136 | + case 'lastNameOnly': |
|
137 | + $order_by = array('ATT_lname' => $order); |
|
138 | + break; |
|
139 | + case 'firstNameOnly': |
|
140 | + $order_by = array('ATT_fname' => $order); |
|
141 | + break; |
|
142 | + case 'firstThenLastName': |
|
143 | + $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order); |
|
144 | + break; |
|
145 | + default: |
|
146 | + $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order); |
|
147 | + break; |
|
148 | + } |
|
149 | + return $order_by; |
|
150 | + } |
|
151 | 151 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | private function setTemplateRootPath() |
44 | 44 | { |
45 | - $this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/'; |
|
45 | + $this->template_root_path = $this->domain->pluginPath().'ui/blocks/'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -15,57 +15,57 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class BlockRenderer implements BlockRendererInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var DomainInterface |
|
20 | - */ |
|
21 | - protected $domain; |
|
18 | + /** |
|
19 | + * @var DomainInterface |
|
20 | + */ |
|
21 | + protected $domain; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - private $template_root_path; |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + private $template_root_path; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * BlockRenderer constructor. |
|
31 | - * |
|
32 | - * @param DomainInterface $domain |
|
33 | - */ |
|
34 | - public function __construct(DomainInterface $domain) |
|
35 | - { |
|
36 | - $this->domain = $domain; |
|
37 | - $this->setTemplateRootPath(); |
|
38 | - } |
|
29 | + /** |
|
30 | + * BlockRenderer constructor. |
|
31 | + * |
|
32 | + * @param DomainInterface $domain |
|
33 | + */ |
|
34 | + public function __construct(DomainInterface $domain) |
|
35 | + { |
|
36 | + $this->domain = $domain; |
|
37 | + $this->setTemplateRootPath(); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Sets the root path to the main block template. |
|
43 | - */ |
|
44 | - private function setTemplateRootPath() |
|
45 | - { |
|
46 | - $this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/'; |
|
47 | - } |
|
41 | + /** |
|
42 | + * Sets the root path to the main block template. |
|
43 | + */ |
|
44 | + private function setTemplateRootPath() |
|
45 | + { |
|
46 | + $this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/'; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Exposes the root path for the main block template. |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function templateRootPath() |
|
55 | - { |
|
56 | - return $this->template_root_path; |
|
57 | - } |
|
50 | + /** |
|
51 | + * Exposes the root path for the main block template. |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function templateRootPath() |
|
55 | + { |
|
56 | + return $this->template_root_path; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * converts GraphQL GUID into EE DB ID |
|
62 | - * |
|
63 | - * @param string $GUID |
|
64 | - * @return int |
|
65 | - */ |
|
66 | - protected function parseGUID($GUID) |
|
67 | - { |
|
68 | - $parts = Relay::fromGlobalId($GUID); |
|
69 | - return ! empty($parts['id']) ? $parts['id'] : 0; |
|
70 | - } |
|
60 | + /** |
|
61 | + * converts GraphQL GUID into EE DB ID |
|
62 | + * |
|
63 | + * @param string $GUID |
|
64 | + * @return int |
|
65 | + */ |
|
66 | + protected function parseGUID($GUID) |
|
67 | + { |
|
68 | + $parts = Relay::fromGlobalId($GUID); |
|
69 | + return ! empty($parts['id']) ? $parts['id'] : 0; |
|
70 | + } |
|
71 | 71 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | public static function instance() |
40 | 40 | { |
41 | 41 | // check if class object is instantiated, and instantiated properly |
42 | - if (! self::$_instance instanceof EE_Network_Config) { |
|
42 | + if ( ! self::$_instance instanceof EE_Network_Config) { |
|
43 | 43 | self::$_instance = new self(); |
44 | 44 | } |
45 | 45 | return self::$_instance; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | // need to bust cache for comparing original if this is a multisite install |
137 | 137 | if (is_multisite()) { |
138 | 138 | global $current_site; |
139 | - $cache_key = $current_site->id . ':ee_network_config'; |
|
139 | + $cache_key = $current_site->id.':ee_network_config'; |
|
140 | 140 | wp_cache_delete($cache_key, 'site-options'); |
141 | 141 | } |
142 | 142 |
@@ -13,180 +13,180 @@ discard block |
||
13 | 13 | */ |
14 | 14 | final class EE_Network_Config |
15 | 15 | { |
16 | - /** |
|
17 | - * @var EE_Network_Config $_instance |
|
18 | - */ |
|
19 | - private static $_instance; |
|
20 | - |
|
21 | - /** |
|
22 | - * addons can add their specific network_config objects to this property |
|
23 | - * |
|
24 | - * @var EE_Config_Base[] $addons |
|
25 | - */ |
|
26 | - public $addons; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var EE_Network_Core_Config $core |
|
30 | - */ |
|
31 | - public $core; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @singleton method used to instantiate class object |
|
36 | - * @return EE_Network_Config instance |
|
37 | - */ |
|
38 | - public static function instance() |
|
39 | - { |
|
40 | - // check if class object is instantiated, and instantiated properly |
|
41 | - if (! self::$_instance instanceof EE_Network_Config) { |
|
42 | - self::$_instance = new self(); |
|
43 | - } |
|
44 | - return self::$_instance; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * class constructor |
|
50 | - */ |
|
51 | - private function __construct() |
|
52 | - { |
|
53 | - do_action('AHEE__EE_Network_Config__construct__begin', $this); |
|
54 | - // set defaults |
|
55 | - $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config()); |
|
56 | - $this->addons = array(); |
|
57 | - |
|
58 | - $this->_load_config(); |
|
59 | - |
|
60 | - // construct__end hook |
|
61 | - do_action('AHEE__EE_Network_Config__construct__end', $this); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * load EE Network Config options |
|
67 | - * |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - private function _load_config() |
|
71 | - { |
|
72 | - // load network config start hook |
|
73 | - do_action('AHEE__EE_Network_Config___load_config__start', $this); |
|
74 | - $config = $this->get_config(); |
|
75 | - foreach ($config as $config_prop => $settings) { |
|
76 | - if ($config_prop === 'core' && ! $settings instanceof EE_Network_Core_Config) { |
|
77 | - $core = new EE_Network_Core_Config(); |
|
78 | - foreach ($settings as $prop => $setting) { |
|
79 | - if (property_exists($core, $prop)) { |
|
80 | - $core->{$prop} = $setting; |
|
81 | - } |
|
82 | - } |
|
83 | - $settings = $core; |
|
84 | - add_filter('FHEE__EE_Network_Config___load_config__update_network_config', '__return_true'); |
|
85 | - } |
|
86 | - if (is_object($settings) && property_exists($this, $config_prop)) { |
|
87 | - $this->{$config_prop} = apply_filters( |
|
88 | - 'FHEE__EE_Network_Config___load_config__config_settings', |
|
89 | - $settings, |
|
90 | - $config_prop, |
|
91 | - $this |
|
92 | - ); |
|
93 | - if (method_exists($settings, 'populate')) { |
|
94 | - $this->{$config_prop}->populate(); |
|
95 | - } |
|
96 | - if (method_exists($settings, 'do_hooks')) { |
|
97 | - $this->{$config_prop}->do_hooks(); |
|
98 | - } |
|
99 | - } |
|
100 | - } |
|
101 | - if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) { |
|
102 | - $this->update_config(); |
|
103 | - } |
|
104 | - |
|
105 | - // load network config end hook |
|
106 | - do_action('AHEE__EE_Network_Config___load_config__end', $this); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * get_config |
|
112 | - * |
|
113 | - * @return array of network config stuff |
|
114 | - */ |
|
115 | - public function get_config() |
|
116 | - { |
|
117 | - // grab network configuration |
|
118 | - $CFG = get_site_option('ee_network_config', array()); |
|
119 | - $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG); |
|
120 | - return $CFG; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * update_config |
|
126 | - * |
|
127 | - * @param bool $add_success |
|
128 | - * @param bool $add_error |
|
129 | - * @return bool success |
|
130 | - */ |
|
131 | - public function update_config($add_success = false, $add_error = true) |
|
132 | - { |
|
133 | - do_action('AHEE__EE_Network_Config__update_config__begin', $this); |
|
134 | - |
|
135 | - // need to bust cache for comparing original if this is a multisite install |
|
136 | - if (is_multisite()) { |
|
137 | - global $current_site; |
|
138 | - $cache_key = $current_site->id . ':ee_network_config'; |
|
139 | - wp_cache_delete($cache_key, 'site-options'); |
|
140 | - } |
|
141 | - |
|
142 | - // we have to compare existing saved config with config in memory because if there is no difference that means |
|
143 | - // that the method executed fine but there just was no update. WordPress doesn't distinguish between false because |
|
144 | - // there were 0 records updated because of no change vs false because some error produced problems with the update. |
|
145 | - $original = get_site_option('ee_network_config'); |
|
146 | - |
|
147 | - if ($original == $this) { |
|
148 | - return true; |
|
149 | - } |
|
150 | - // update |
|
151 | - $saved = update_site_option('ee_network_config', $this); |
|
152 | - |
|
153 | - do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved); |
|
154 | - // if config remains the same or was updated successfully |
|
155 | - if ($saved) { |
|
156 | - if ($add_success) { |
|
157 | - $msg = is_multisite() ? esc_html__( |
|
158 | - 'The Event Espresso Network Configuration Settings have been successfully updated.', |
|
159 | - 'event_espresso' |
|
160 | - ) : esc_html__('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso'); |
|
161 | - EE_Error::add_success($msg); |
|
162 | - } |
|
163 | - return true; |
|
164 | - } |
|
165 | - if ($add_error) { |
|
166 | - $msg = is_multisite() ? esc_html__( |
|
167 | - 'The Event Espresso Network Configuration Settings were not updated.', |
|
168 | - 'event_espresso' |
|
169 | - ) : esc_html__('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso'); |
|
170 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
171 | - } |
|
172 | - return false; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * __sleep |
|
178 | - * |
|
179 | - * @return array |
|
180 | - */ |
|
181 | - public function __sleep() |
|
182 | - { |
|
183 | - return apply_filters( |
|
184 | - 'FHEE__EE_Network_Config__sleep', |
|
185 | - array( |
|
186 | - 'core', |
|
187 | - ) |
|
188 | - ); |
|
189 | - } |
|
16 | + /** |
|
17 | + * @var EE_Network_Config $_instance |
|
18 | + */ |
|
19 | + private static $_instance; |
|
20 | + |
|
21 | + /** |
|
22 | + * addons can add their specific network_config objects to this property |
|
23 | + * |
|
24 | + * @var EE_Config_Base[] $addons |
|
25 | + */ |
|
26 | + public $addons; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var EE_Network_Core_Config $core |
|
30 | + */ |
|
31 | + public $core; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @singleton method used to instantiate class object |
|
36 | + * @return EE_Network_Config instance |
|
37 | + */ |
|
38 | + public static function instance() |
|
39 | + { |
|
40 | + // check if class object is instantiated, and instantiated properly |
|
41 | + if (! self::$_instance instanceof EE_Network_Config) { |
|
42 | + self::$_instance = new self(); |
|
43 | + } |
|
44 | + return self::$_instance; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * class constructor |
|
50 | + */ |
|
51 | + private function __construct() |
|
52 | + { |
|
53 | + do_action('AHEE__EE_Network_Config__construct__begin', $this); |
|
54 | + // set defaults |
|
55 | + $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config()); |
|
56 | + $this->addons = array(); |
|
57 | + |
|
58 | + $this->_load_config(); |
|
59 | + |
|
60 | + // construct__end hook |
|
61 | + do_action('AHEE__EE_Network_Config__construct__end', $this); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * load EE Network Config options |
|
67 | + * |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + private function _load_config() |
|
71 | + { |
|
72 | + // load network config start hook |
|
73 | + do_action('AHEE__EE_Network_Config___load_config__start', $this); |
|
74 | + $config = $this->get_config(); |
|
75 | + foreach ($config as $config_prop => $settings) { |
|
76 | + if ($config_prop === 'core' && ! $settings instanceof EE_Network_Core_Config) { |
|
77 | + $core = new EE_Network_Core_Config(); |
|
78 | + foreach ($settings as $prop => $setting) { |
|
79 | + if (property_exists($core, $prop)) { |
|
80 | + $core->{$prop} = $setting; |
|
81 | + } |
|
82 | + } |
|
83 | + $settings = $core; |
|
84 | + add_filter('FHEE__EE_Network_Config___load_config__update_network_config', '__return_true'); |
|
85 | + } |
|
86 | + if (is_object($settings) && property_exists($this, $config_prop)) { |
|
87 | + $this->{$config_prop} = apply_filters( |
|
88 | + 'FHEE__EE_Network_Config___load_config__config_settings', |
|
89 | + $settings, |
|
90 | + $config_prop, |
|
91 | + $this |
|
92 | + ); |
|
93 | + if (method_exists($settings, 'populate')) { |
|
94 | + $this->{$config_prop}->populate(); |
|
95 | + } |
|
96 | + if (method_exists($settings, 'do_hooks')) { |
|
97 | + $this->{$config_prop}->do_hooks(); |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | + if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) { |
|
102 | + $this->update_config(); |
|
103 | + } |
|
104 | + |
|
105 | + // load network config end hook |
|
106 | + do_action('AHEE__EE_Network_Config___load_config__end', $this); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * get_config |
|
112 | + * |
|
113 | + * @return array of network config stuff |
|
114 | + */ |
|
115 | + public function get_config() |
|
116 | + { |
|
117 | + // grab network configuration |
|
118 | + $CFG = get_site_option('ee_network_config', array()); |
|
119 | + $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG); |
|
120 | + return $CFG; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * update_config |
|
126 | + * |
|
127 | + * @param bool $add_success |
|
128 | + * @param bool $add_error |
|
129 | + * @return bool success |
|
130 | + */ |
|
131 | + public function update_config($add_success = false, $add_error = true) |
|
132 | + { |
|
133 | + do_action('AHEE__EE_Network_Config__update_config__begin', $this); |
|
134 | + |
|
135 | + // need to bust cache for comparing original if this is a multisite install |
|
136 | + if (is_multisite()) { |
|
137 | + global $current_site; |
|
138 | + $cache_key = $current_site->id . ':ee_network_config'; |
|
139 | + wp_cache_delete($cache_key, 'site-options'); |
|
140 | + } |
|
141 | + |
|
142 | + // we have to compare existing saved config with config in memory because if there is no difference that means |
|
143 | + // that the method executed fine but there just was no update. WordPress doesn't distinguish between false because |
|
144 | + // there were 0 records updated because of no change vs false because some error produced problems with the update. |
|
145 | + $original = get_site_option('ee_network_config'); |
|
146 | + |
|
147 | + if ($original == $this) { |
|
148 | + return true; |
|
149 | + } |
|
150 | + // update |
|
151 | + $saved = update_site_option('ee_network_config', $this); |
|
152 | + |
|
153 | + do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved); |
|
154 | + // if config remains the same or was updated successfully |
|
155 | + if ($saved) { |
|
156 | + if ($add_success) { |
|
157 | + $msg = is_multisite() ? esc_html__( |
|
158 | + 'The Event Espresso Network Configuration Settings have been successfully updated.', |
|
159 | + 'event_espresso' |
|
160 | + ) : esc_html__('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso'); |
|
161 | + EE_Error::add_success($msg); |
|
162 | + } |
|
163 | + return true; |
|
164 | + } |
|
165 | + if ($add_error) { |
|
166 | + $msg = is_multisite() ? esc_html__( |
|
167 | + 'The Event Espresso Network Configuration Settings were not updated.', |
|
168 | + 'event_espresso' |
|
169 | + ) : esc_html__('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso'); |
|
170 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
171 | + } |
|
172 | + return false; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * __sleep |
|
178 | + * |
|
179 | + * @return array |
|
180 | + */ |
|
181 | + public function __sleep() |
|
182 | + { |
|
183 | + return apply_filters( |
|
184 | + 'FHEE__EE_Network_Config__sleep', |
|
185 | + array( |
|
186 | + 'core', |
|
187 | + ) |
|
188 | + ); |
|
189 | + } |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -195,27 +195,27 @@ discard block |
||
195 | 195 | */ |
196 | 196 | class EE_Network_Core_Config extends EE_Config_Base |
197 | 197 | { |
198 | - /** |
|
199 | - * PUE site license key |
|
200 | - * |
|
201 | - * @var string $site_license_key |
|
202 | - */ |
|
203 | - public $site_license_key; |
|
204 | - |
|
205 | - /** |
|
206 | - * This indicates whether messages system processing should be done on the same request or not. |
|
207 | - * |
|
208 | - * @var boolean $do_messages_on_same_request |
|
209 | - */ |
|
210 | - public $do_messages_on_same_request; |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * EE_Network_Core_Config constructor. |
|
215 | - */ |
|
216 | - public function __construct() |
|
217 | - { |
|
218 | - $this->site_license_key = ''; |
|
219 | - $this->do_messages_on_same_request = false; |
|
220 | - } |
|
198 | + /** |
|
199 | + * PUE site license key |
|
200 | + * |
|
201 | + * @var string $site_license_key |
|
202 | + */ |
|
203 | + public $site_license_key; |
|
204 | + |
|
205 | + /** |
|
206 | + * This indicates whether messages system processing should be done on the same request or not. |
|
207 | + * |
|
208 | + * @var boolean $do_messages_on_same_request |
|
209 | + */ |
|
210 | + public $do_messages_on_same_request; |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * EE_Network_Core_Config constructor. |
|
215 | + */ |
|
216 | + public function __construct() |
|
217 | + { |
|
218 | + $this->site_license_key = ''; |
|
219 | + $this->do_messages_on_same_request = false; |
|
220 | + } |
|
221 | 221 | } |
@@ -12,42 +12,42 @@ |
||
12 | 12 | */ |
13 | 13 | interface BlockAssetManagerInterface |
14 | 14 | { |
15 | - /** |
|
16 | - * @since 4.9.71.p |
|
17 | - * @return string |
|
18 | - */ |
|
19 | - public function assetNamespace(); |
|
20 | - |
|
21 | - /** |
|
22 | - * @since 4.9.71.p |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function setAssetHandles(); |
|
26 | - |
|
27 | - /** |
|
28 | - * @since 4.9.71.p |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - public function getEditorScriptHandle(); |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @since 4.9.71.p |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function getEditorStyleHandle(); |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * @since 4.9.71.p |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function getScriptHandle(); |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @since 4.9.71.p |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function getStyleHandle(); |
|
15 | + /** |
|
16 | + * @since 4.9.71.p |
|
17 | + * @return string |
|
18 | + */ |
|
19 | + public function assetNamespace(); |
|
20 | + |
|
21 | + /** |
|
22 | + * @since 4.9.71.p |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function setAssetHandles(); |
|
26 | + |
|
27 | + /** |
|
28 | + * @since 4.9.71.p |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + public function getEditorScriptHandle(); |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @since 4.9.71.p |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function getEditorStyleHandle(); |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * @since 4.9.71.p |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function getScriptHandle(); |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @since 4.9.71.p |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function getStyleHandle(); |
|
53 | 53 | } |
54 | 54 | \ No newline at end of file |
@@ -15,16 +15,16 @@ |
||
15 | 15 | */ |
16 | 16 | interface DependencyResolverInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * Used to configure and/or setup any aliases or recursions required by the DependencyResolver |
|
20 | - * |
|
21 | - * @since 4.9.71.p |
|
22 | - */ |
|
23 | - public function initialize(); |
|
18 | + /** |
|
19 | + * Used to configure and/or setup any aliases or recursions required by the DependencyResolver |
|
20 | + * |
|
21 | + * @since 4.9.71.p |
|
22 | + */ |
|
23 | + public function initialize(); |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param string $fqcn Fully Qualified Class Name |
|
27 | - * @since 4.9.71.p |
|
28 | - */ |
|
29 | - public function resolveDependenciesForClass($fqcn); |
|
25 | + /** |
|
26 | + * @param string $fqcn Fully Qualified Class Name |
|
27 | + * @since 4.9.71.p |
|
28 | + */ |
|
29 | + public function resolveDependenciesForClass($fqcn); |
|
30 | 30 | } |