@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | ?> |
8 | 8 | <h2><?php esc_html_e('Event Registration Data', 'event_espresso'); ?></h2> |
9 | 9 | <p><?php |
10 | - esc_html_e( |
|
11 | - 'We collect information about you during event registration. This information may include but is not limited to:', |
|
12 | - 'event_espresso' |
|
13 | - ); ?></p> |
|
10 | + esc_html_e( |
|
11 | + 'We collect information about you during event registration. This information may include but is not limited to:', |
|
12 | + 'event_espresso' |
|
13 | + ); ?></p> |
|
14 | 14 | <ul> |
15 | 15 | <li><?php esc_html_e('Your names', 'event_espresso'); ?></li> |
16 | 16 | <li><?php esc_html_e('Billing address', 'event_espresso'); ?></li> |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | <li><?php esc_html_e('Phone number', 'event_espresso'); ?></li> |
20 | 20 | <li><?php esc_html_e('Location and traffic data (including partial IP address and browser type)', 'event_espresso'); ?></li> |
21 | 21 | <li><?php |
22 | - esc_html_e( |
|
23 | - 'Any other details that might be requested from you for the purpose of processing your registration or ticket purchase', |
|
24 | - 'event_espresso' |
|
25 | - ); ?></li> |
|
22 | + esc_html_e( |
|
23 | + 'Any other details that might be requested from you for the purpose of processing your registration or ticket purchase', |
|
24 | + 'event_espresso' |
|
25 | + ); ?></li> |
|
26 | 26 | </ul> |
27 | 27 | |
28 | 28 | <p><?php esc_html_e('Handling this data also allows us to:', 'event_espresso'); ?></p> |
@@ -30,102 +30,102 @@ discard block |
||
30 | 30 | <li><?php esc_html_e('Send you important account/purchase/service information.', 'event_espresso'); ?></li> |
31 | 31 | <li><?php esc_html_e('Respond to your queries, refund requests, or complaints.', 'event_espresso'); ?></li> |
32 | 32 | <li><?php |
33 | - esc_html_e( |
|
34 | - 'Process payments and prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', |
|
35 | - 'event_espresso' |
|
36 | - ); ?></li> |
|
33 | + esc_html_e( |
|
34 | + 'Process payments and prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', |
|
35 | + 'event_espresso' |
|
36 | + ); ?></li> |
|
37 | 37 | <li><?php |
38 | - esc_html_e( |
|
39 | - 'Set up and administer your account, provide technical and customer support, and to verify your identity.', |
|
40 | - 'event_espresso' |
|
41 | - ); ?></li> |
|
38 | + esc_html_e( |
|
39 | + 'Set up and administer your account, provide technical and customer support, and to verify your identity.', |
|
40 | + 'event_espresso' |
|
41 | + ); ?></li> |
|
42 | 42 | </ul> |
43 | 43 | |
44 | 44 | <?php if (! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?> |
45 | 45 | <h2><?php esc_html_e('Billing Information', 'event_espresso'); ?> </h2> |
46 | 46 | <?php |
47 | 47 | // if onsite or offsite payment methods are active |
48 | - if (! empty($active_onsite_payment_methods)) { ?> |
|
48 | + if (! empty($active_onsite_payment_methods)) { ?> |
|
49 | 49 | <p><?php |
50 | - esc_html_e( |
|
51 | - 'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.', |
|
52 | - 'event_espresso' |
|
53 | - ); ?></p> |
|
50 | + esc_html_e( |
|
51 | + 'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.', |
|
52 | + 'event_espresso' |
|
53 | + ); ?></p> |
|
54 | 54 | <p><?php |
55 | - printf( |
|
56 | - esc_html_x( |
|
57 | - 'Please see the privacy policy of %1$s.', |
|
58 | - 'Please see the privacy policy of PayPal Pro', |
|
59 | - 'event_espresso' |
|
60 | - ), |
|
61 | - implode( |
|
62 | - ', ', |
|
63 | - array_merge( |
|
64 | - $active_onsite_payment_methods, |
|
65 | - $active_offsite_payment_methods |
|
66 | - ) |
|
67 | - ) |
|
68 | - ); ?></p> |
|
55 | + printf( |
|
56 | + esc_html_x( |
|
57 | + 'Please see the privacy policy of %1$s.', |
|
58 | + 'Please see the privacy policy of PayPal Pro', |
|
59 | + 'event_espresso' |
|
60 | + ), |
|
61 | + implode( |
|
62 | + ', ', |
|
63 | + array_merge( |
|
64 | + $active_onsite_payment_methods, |
|
65 | + $active_offsite_payment_methods |
|
66 | + ) |
|
67 | + ) |
|
68 | + ); ?></p> |
|
69 | 69 | <p><?php |
70 | - esc_html_e( |
|
71 | - 'Masked billing information may be stored on our servers (eg only the last 4 digits of credit card numbers are stored: **** **** **** 1234).', |
|
72 | - 'event_espresso' |
|
73 | - ); ?></p> |
|
70 | + esc_html_e( |
|
71 | + 'Masked billing information may be stored on our servers (eg only the last 4 digits of credit card numbers are stored: **** **** **** 1234).', |
|
72 | + 'event_espresso' |
|
73 | + ); ?></p> |
|
74 | 74 | <?php } // IF OFFSITE PAYMENT METHOD ACTIVE |
75 | - elseif (! empty($active_offsite_payment_methods)) { ?> |
|
75 | + elseif (! empty($active_offsite_payment_methods)) { ?> |
|
76 | 76 | <p><?php |
77 | - printf( |
|
78 | - esc_html_x( |
|
79 | - 'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of %1$s.', |
|
80 | - 'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of PayPal Pro.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - implode(', ', $active_offsite_payment_methods) |
|
84 | - ); ?></p> |
|
77 | + printf( |
|
78 | + esc_html_x( |
|
79 | + 'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of %1$s.', |
|
80 | + 'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of PayPal Pro.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + implode(', ', $active_offsite_payment_methods) |
|
84 | + ); ?></p> |
|
85 | 85 | <?php } ?> |
86 | 86 | <h2><?php esc_html_e('Payment Logging', 'event_espresso'); ?></h2> |
87 | 87 | <p><?php |
88 | - esc_html_e( |
|
89 | - 'Site administrators may keep a log of communications with the payment processors in order to verify payments are being processed correctly. These logs are automatically deleted after a week.', |
|
90 | - 'event_espresso' |
|
91 | - ); ?></p> |
|
88 | + esc_html_e( |
|
89 | + 'Site administrators may keep a log of communications with the payment processors in order to verify payments are being processed correctly. These logs are automatically deleted after a week.', |
|
90 | + 'event_espresso' |
|
91 | + ); ?></p> |
|
92 | 92 | <?php } ?> |
93 | 93 | |
94 | 94 | <h2><?php esc_html_e('Event Registration Cookies', 'event_espresso'); ?></h2> |
95 | 95 | <p><?php |
96 | - printf( |
|
97 | - esc_html_x( |
|
98 | - 'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts %1$s.', |
|
99 | - 'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts 2 hours.', |
|
100 | - 'event_espresso' |
|
101 | - ), |
|
102 | - $session_lifespan |
|
103 | - ); ?></p> |
|
96 | + printf( |
|
97 | + esc_html_x( |
|
98 | + 'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts %1$s.', |
|
99 | + 'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts 2 hours.', |
|
100 | + 'event_espresso' |
|
101 | + ), |
|
102 | + $session_lifespan |
|
103 | + ); ?></p> |
|
104 | 104 | |
105 | 105 | <h2><?php esc_html_e('Email History Data', 'event_espresso'); ?></h2> |
106 | 106 | <p><?php |
107 | - esc_html_e( |
|
108 | - 'We keep a record of the emails sent to you. This is to ensure communication is successfully sent and its information is accurate.', |
|
109 | - 'event_espresso' |
|
110 | - ); ?></p> |
|
107 | + esc_html_e( |
|
108 | + 'We keep a record of the emails sent to you. This is to ensure communication is successfully sent and its information is accurate.', |
|
109 | + 'event_espresso' |
|
110 | + ); ?></p> |
|
111 | 111 | |
112 | 112 | <h2><?php esc_html_e('Event Check-In Record', 'event_espresso'); ?></h2> |
113 | 113 | <p><?php |
114 | - esc_html_e( |
|
115 | - 'When you attend an event, an event manager may record the time you check in or out of the event.', |
|
116 | - 'event_espresso' |
|
117 | - ); ?></p> |
|
114 | + esc_html_e( |
|
115 | + 'When you attend an event, an event manager may record the time you check in or out of the event.', |
|
116 | + 'event_espresso' |
|
117 | + ); ?></p> |
|
118 | 118 | |
119 | 119 | <h2><?php esc_html_e('Event Registration Data Retention', 'event_espresso'); ?></h2> |
120 | 120 | <p><?php |
121 | - esc_html_e( |
|
122 | - 'Personal data is stored at least until the date of the event, and may be kept indefinitely in case of future registrations.', |
|
123 | - 'event_espresso' |
|
124 | - ); ?></p> |
|
121 | + esc_html_e( |
|
122 | + 'Personal data is stored at least until the date of the event, and may be kept indefinitely in case of future registrations.', |
|
123 | + 'event_espresso' |
|
124 | + ); ?></p> |
|
125 | 125 | |
126 | 126 | <h2><?php esc_html_e('Event Registration Data Erasure and Export', 'event_espresso'); ?></h2> |
127 | 127 | <p><?php |
128 | - esc_html_e( |
|
129 | - 'You have the right to request your personal data be sent to you electronically, and the right to request your registration data be erased after the event. To do so, please contact the event manager or site administrator.', |
|
130 | - 'event_espresso' |
|
131 | - ); ?></p> |
|
128 | + esc_html_e( |
|
129 | + 'You have the right to request your personal data be sent to you electronically, and the right to request your registration data be erased after the event. To do so, please contact the event manager or site administrator.', |
|
130 | + 'event_espresso' |
|
131 | + ); ?></p> |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | ); ?></li> |
42 | 42 | </ul> |
43 | 43 | |
44 | -<?php if (! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?> |
|
44 | +<?php if ( ! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?> |
|
45 | 45 | <h2><?php esc_html_e('Billing Information', 'event_espresso'); ?> </h2> |
46 | 46 | <?php |
47 | 47 | // if onsite or offsite payment methods are active |
48 | - if (! empty($active_onsite_payment_methods)) { ?> |
|
48 | + if ( ! empty($active_onsite_payment_methods)) { ?> |
|
49 | 49 | <p><?php |
50 | 50 | esc_html_e( |
51 | 51 | 'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.', |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'event_espresso' |
73 | 73 | ); ?></p> |
74 | 74 | <?php } // IF OFFSITE PAYMENT METHOD ACTIVE |
75 | - elseif (! empty($active_offsite_payment_methods)) { ?> |
|
75 | + elseif ( ! empty($active_offsite_payment_methods)) { ?> |
|
76 | 76 | <p><?php |
77 | 77 | printf( |
78 | 78 | esc_html_x( |
@@ -16,153 +16,153 @@ |
||
16 | 16 | abstract class DomainBase implements DomainInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Equivalent to `__FILE__` for main plugin file. |
|
21 | - * |
|
22 | - * @var FilePath |
|
23 | - */ |
|
24 | - private $plugin_file; |
|
25 | - |
|
26 | - /** |
|
27 | - * String indicating version for plugin |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - private $version; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string $plugin_basename |
|
35 | - */ |
|
36 | - private $plugin_basename; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string $plugin_path |
|
40 | - */ |
|
41 | - private $plugin_path; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var string $plugin_url |
|
45 | - */ |
|
46 | - private $plugin_url; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var string $asset_namespace |
|
50 | - */ |
|
51 | - private $asset_namespace; |
|
52 | - |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Initializes internal properties. |
|
57 | - * |
|
58 | - * @param FilePath $plugin_file |
|
59 | - * @param Version $version |
|
60 | - */ |
|
61 | - public function __construct(FilePath $plugin_file, Version $version) |
|
62 | - { |
|
63 | - $this->plugin_file = $plugin_file; |
|
64 | - $this->version = $version; |
|
65 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
66 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
67 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
68 | - $this->setAssetNamespace(); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function pluginFile() |
|
76 | - { |
|
77 | - return (string) $this->plugin_file; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function pluginBasename() |
|
86 | - { |
|
87 | - return $this->plugin_basename; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function pluginPath() |
|
96 | - { |
|
97 | - return $this->plugin_path; |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @return string |
|
104 | - */ |
|
105 | - public function pluginUrl() |
|
106 | - { |
|
107 | - return $this->plugin_url; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public function version() |
|
116 | - { |
|
117 | - return (string) $this->version; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return Version |
|
124 | - */ |
|
125 | - public function versionValueObject() |
|
126 | - { |
|
127 | - return $this->version; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function distributionAssetsPath() |
|
135 | - { |
|
136 | - return $this->pluginPath() . 'assets/dist/'; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - public function distributionAssetsUrl() |
|
144 | - { |
|
145 | - return $this->pluginUrl() . 'assets/dist/'; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * @return string |
|
151 | - */ |
|
152 | - public function assetNamespace() |
|
153 | - { |
|
154 | - return $this->asset_namespace; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * @return void |
|
160 | - */ |
|
161 | - private function setAssetNamespace() |
|
162 | - { |
|
163 | - $this->asset_namespace = sanitize_key( |
|
164 | - // convert directory separators to dashes and remove file extension |
|
165 | - str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename) |
|
166 | - ); |
|
167 | - } |
|
19 | + /** |
|
20 | + * Equivalent to `__FILE__` for main plugin file. |
|
21 | + * |
|
22 | + * @var FilePath |
|
23 | + */ |
|
24 | + private $plugin_file; |
|
25 | + |
|
26 | + /** |
|
27 | + * String indicating version for plugin |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + private $version; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string $plugin_basename |
|
35 | + */ |
|
36 | + private $plugin_basename; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string $plugin_path |
|
40 | + */ |
|
41 | + private $plugin_path; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var string $plugin_url |
|
45 | + */ |
|
46 | + private $plugin_url; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var string $asset_namespace |
|
50 | + */ |
|
51 | + private $asset_namespace; |
|
52 | + |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Initializes internal properties. |
|
57 | + * |
|
58 | + * @param FilePath $plugin_file |
|
59 | + * @param Version $version |
|
60 | + */ |
|
61 | + public function __construct(FilePath $plugin_file, Version $version) |
|
62 | + { |
|
63 | + $this->plugin_file = $plugin_file; |
|
64 | + $this->version = $version; |
|
65 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
66 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
67 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
68 | + $this->setAssetNamespace(); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function pluginFile() |
|
76 | + { |
|
77 | + return (string) $this->plugin_file; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function pluginBasename() |
|
86 | + { |
|
87 | + return $this->plugin_basename; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function pluginPath() |
|
96 | + { |
|
97 | + return $this->plugin_path; |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @return string |
|
104 | + */ |
|
105 | + public function pluginUrl() |
|
106 | + { |
|
107 | + return $this->plugin_url; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public function version() |
|
116 | + { |
|
117 | + return (string) $this->version; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return Version |
|
124 | + */ |
|
125 | + public function versionValueObject() |
|
126 | + { |
|
127 | + return $this->version; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function distributionAssetsPath() |
|
135 | + { |
|
136 | + return $this->pluginPath() . 'assets/dist/'; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + public function distributionAssetsUrl() |
|
144 | + { |
|
145 | + return $this->pluginUrl() . 'assets/dist/'; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * @return string |
|
151 | + */ |
|
152 | + public function assetNamespace() |
|
153 | + { |
|
154 | + return $this->asset_namespace; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * @return void |
|
160 | + */ |
|
161 | + private function setAssetNamespace() |
|
162 | + { |
|
163 | + $this->asset_namespace = sanitize_key( |
|
164 | + // convert directory separators to dashes and remove file extension |
|
165 | + str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename) |
|
166 | + ); |
|
167 | + } |
|
168 | 168 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $script->version(), |
147 | 147 | $script->loadInFooter() |
148 | 148 | ); |
149 | - if (! $registered && $this->debug()) { |
|
149 | + if ( ! $registered && $this->debug()) { |
|
150 | 150 | throw new AssetRegistrationException($script->handle()); |
151 | 151 | } |
152 | 152 | $script->setRegistered($registered); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $this->removeAlreadyRegisteredDataForScriptHandles(); |
207 | 207 | wp_add_inline_script( |
208 | 208 | 'eejs-core', |
209 | - 'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)), |
|
209 | + 'var eejsdata='.wp_json_encode(array('data' => $this->jsdata)), |
|
210 | 210 | 'before' |
211 | 211 | ); |
212 | 212 | $scripts = $this->assets->getJavascriptAssetsWithData(); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | public function addData($key, $value) |
237 | 237 | { |
238 | 238 | if ($this->verifyDataNotExisting($key)) { |
239 | - $this->jsdata[ $key ] = $value; |
|
239 | + $this->jsdata[$key] = $value; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function pushData($key, $value) |
259 | 259 | { |
260 | - if (isset($this->jsdata[ $key ]) |
|
261 | - && ! is_array($this->jsdata[ $key ]) |
|
260 | + if (isset($this->jsdata[$key]) |
|
261 | + && ! is_array($this->jsdata[$key]) |
|
262 | 262 | ) { |
263 | - if (! $this->debug()) { |
|
263 | + if ( ! $this->debug()) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | throw new InvalidArgumentException( |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | ) |
276 | 276 | ); |
277 | 277 | } |
278 | - $this->jsdata[ $key ][] = $value; |
|
278 | + $this->jsdata[$key][] = $value; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | |
@@ -289,12 +289,12 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function addTemplate($template_reference, $template_content) |
291 | 291 | { |
292 | - if (! isset($this->jsdata['templates'])) { |
|
292 | + if ( ! isset($this->jsdata['templates'])) { |
|
293 | 293 | $this->jsdata['templates'] = array(); |
294 | 294 | } |
295 | 295 | //no overrides allowed. |
296 | - if (isset($this->jsdata['templates'][ $template_reference ])) { |
|
297 | - if (! $this->debug()) { |
|
296 | + if (isset($this->jsdata['templates'][$template_reference])) { |
|
297 | + if ( ! $this->debug()) { |
|
298 | 298 | return; |
299 | 299 | } |
300 | 300 | throw new InvalidArgumentException( |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | ) |
308 | 308 | ); |
309 | 309 | } |
310 | - $this->jsdata['templates'][ $template_reference ] = $template_content; |
|
310 | + $this->jsdata['templates'][$template_reference] = $template_content; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function getTemplate($template_reference) |
321 | 321 | { |
322 | - return isset($this->jsdata['templates'][ $template_reference ]) |
|
323 | - ? $this->jsdata['templates'][ $template_reference ] |
|
322 | + return isset($this->jsdata['templates'][$template_reference]) |
|
323 | + ? $this->jsdata['templates'][$template_reference] |
|
324 | 324 | : ''; |
325 | 325 | } |
326 | 326 | |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | */ |
334 | 334 | public function getData($key) |
335 | 335 | { |
336 | - return isset($this->jsdata[ $key ]) |
|
337 | - ? $this->jsdata[ $key ] |
|
336 | + return isset($this->jsdata[$key]) |
|
337 | + ? $this->jsdata[$key] |
|
338 | 338 | : false; |
339 | 339 | } |
340 | 340 | |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | */ |
350 | 350 | protected function verifyDataNotExisting($key) |
351 | 351 | { |
352 | - if (isset($this->jsdata[ $key ])) { |
|
353 | - if (! $this->debug()) { |
|
352 | + if (isset($this->jsdata[$key])) { |
|
353 | + if ( ! $this->debug()) { |
|
354 | 354 | return false; |
355 | 355 | } |
356 | - if (is_array($this->jsdata[ $key ])) { |
|
356 | + if (is_array($this->jsdata[$key])) { |
|
357 | 357 | throw new InvalidArgumentException( |
358 | 358 | sprintf( |
359 | 359 | __( |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | public function getAssetUrl($namespace, $chunk_name, $asset_type) |
397 | 397 | { |
398 | 398 | $url = isset( |
399 | - $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ], |
|
400 | - $this->manifest_data[ $namespace ]['url_base'] |
|
399 | + $this->manifest_data[$namespace][$chunk_name.'.'.$asset_type], |
|
400 | + $this->manifest_data[$namespace]['url_base'] |
|
401 | 401 | ) |
402 | - ? $this->manifest_data[ $namespace ]['url_base'] |
|
403 | - . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ] |
|
402 | + ? $this->manifest_data[$namespace]['url_base'] |
|
403 | + . $this->manifest_data[$namespace][$chunk_name.'.'.$asset_type] |
|
404 | 404 | : $chunk_name; |
405 | 405 | return apply_filters( |
406 | 406 | 'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl', |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $this->registerManifestFile( |
451 | 451 | $manifest_file->assetNamespace(), |
452 | 452 | $manifest_file->urlBase(), |
453 | - $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST |
|
453 | + $manifest_file->filepath().Registry::FILE_NAME_BUILD_MANIFEST |
|
454 | 454 | ); |
455 | 455 | } |
456 | 456 | } |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | */ |
469 | 469 | public function registerManifestFile($namespace, $url_base, $manifest_file) |
470 | 470 | { |
471 | - if (isset($this->manifest_data[ $namespace ])) { |
|
472 | - if (! $this->debug()) { |
|
471 | + if (isset($this->manifest_data[$namespace])) { |
|
472 | + if ( ! $this->debug()) { |
|
473 | 473 | return; |
474 | 474 | } |
475 | 475 | throw new InvalidArgumentException( |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | } |
503 | 503 | return; |
504 | 504 | } |
505 | - $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file); |
|
506 | - if (! isset($this->manifest_data[ $namespace ]['url_base'])) { |
|
507 | - $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base); |
|
505 | + $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file); |
|
506 | + if ( ! isset($this->manifest_data[$namespace]['url_base'])) { |
|
507 | + $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base); |
|
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | */ |
520 | 520 | private function decodeManifestFile($manifest_file) |
521 | 521 | { |
522 | - if (! file_exists($manifest_file)) { |
|
522 | + if ( ! file_exists($manifest_file)) { |
|
523 | 523 | throw new InvalidFilePathException($manifest_file); |
524 | 524 | } |
525 | 525 | return json_decode(file_get_contents($manifest_file), true); |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | */ |
534 | 534 | private function addRegisteredScriptHandlesWithData($script_handle) |
535 | 535 | { |
536 | - $this->script_handles_with_data[ $script_handle ] = $script_handle; |
|
536 | + $this->script_handles_with_data[$script_handle] = $script_handle; |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -559,23 +559,23 @@ discard block |
||
559 | 559 | */ |
560 | 560 | private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
561 | 561 | { |
562 | - if (isset($this->script_handles_with_data[ $script_handle ])) { |
|
562 | + if (isset($this->script_handles_with_data[$script_handle])) { |
|
563 | 563 | global $wp_scripts; |
564 | 564 | $unset_handle = false; |
565 | 565 | if ($wp_scripts->get_data($script_handle, 'data')) { |
566 | - unset($wp_scripts->registered[ $script_handle ]->extra['data']); |
|
566 | + unset($wp_scripts->registered[$script_handle]->extra['data']); |
|
567 | 567 | $unset_handle = true; |
568 | 568 | } |
569 | 569 | //deal with inline_scripts |
570 | 570 | if ($wp_scripts->get_data($script_handle, 'before')) { |
571 | - unset($wp_scripts->registered[ $script_handle ]->extra['before']); |
|
571 | + unset($wp_scripts->registered[$script_handle]->extra['before']); |
|
572 | 572 | $unset_handle = true; |
573 | 573 | } |
574 | 574 | if ($wp_scripts->get_data($script_handle, 'after')) { |
575 | - unset($wp_scripts->registered[ $script_handle ]->extra['after']); |
|
575 | + unset($wp_scripts->registered[$script_handle]->extra['after']); |
|
576 | 576 | } |
577 | 577 | if ($unset_handle) { |
578 | - unset($this->script_handles_with_data[ $script_handle ]); |
|
578 | + unset($this->script_handles_with_data[$script_handle]); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | } |
@@ -23,586 +23,586 @@ |
||
23 | 23 | class Registry |
24 | 24 | { |
25 | 25 | |
26 | - const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json'; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var AssetCollection $assets |
|
30 | - */ |
|
31 | - protected $assets; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var I18nRegistry |
|
35 | - */ |
|
36 | - private $i18n_registry; |
|
37 | - |
|
38 | - /** |
|
39 | - * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - protected $jsdata = array(); |
|
44 | - |
|
45 | - /** |
|
46 | - * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
47 | - * page source. |
|
48 | - * |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - private $script_handles_with_data = array(); |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Holds the manifest data obtained from registered manifest files. |
|
56 | - * Manifests are maps of asset chunk name to actual built asset file names. |
|
57 | - * Shape of this array is: |
|
58 | - * array( |
|
59 | - * 'some_namespace_slug' => array( |
|
60 | - * 'some_chunk_name' => array( |
|
61 | - * 'js' => 'filename.js' |
|
62 | - * 'css' => 'filename.js' |
|
63 | - * ), |
|
64 | - * 'url_base' => 'https://baseurl.com/to/assets |
|
65 | - * ) |
|
66 | - * ) |
|
67 | - * |
|
68 | - * @var array |
|
69 | - */ |
|
70 | - private $manifest_data = array(); |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * Registry constructor. |
|
75 | - * Hooking into WP actions for script registry. |
|
76 | - * |
|
77 | - * @param AssetCollection $assets |
|
78 | - * @param I18nRegistry $i18n_registry |
|
79 | - */ |
|
80 | - public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry) |
|
81 | - { |
|
82 | - $this->assets = $assets; |
|
83 | - $this->i18n_registry = $i18n_registry; |
|
84 | - add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1); |
|
85 | - add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1); |
|
86 | - add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3); |
|
87 | - add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3); |
|
88 | - add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4); |
|
89 | - add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4); |
|
90 | - add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
91 | - add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n |
|
97 | - * translation handling. |
|
98 | - * |
|
99 | - * @return I18nRegistry |
|
100 | - */ |
|
101 | - public function getI18nRegistry() |
|
102 | - { |
|
103 | - return $this->i18n_registry; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * Callback for the wp_enqueue_scripts actions used to register assets. |
|
109 | - * |
|
110 | - * @since 4.9.62.p |
|
111 | - * @throws Exception |
|
112 | - */ |
|
113 | - public function registerScriptsAndStyles() |
|
114 | - { |
|
115 | - try { |
|
116 | - $this->registerScripts($this->assets->getJavascriptAssets()); |
|
117 | - $this->registerStyles($this->assets->getStylesheetAssets()); |
|
118 | - } catch (Exception $exception) { |
|
119 | - new ExceptionStackTraceDisplay($exception); |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * Registers JS assets with WP core |
|
126 | - * |
|
127 | - * @since 4.9.62.p |
|
128 | - * @param JavascriptAsset[] $scripts |
|
129 | - * @throws AssetRegistrationException |
|
130 | - * @throws InvalidDataTypeException |
|
131 | - */ |
|
132 | - public function registerScripts(array $scripts) |
|
133 | - { |
|
134 | - foreach ($scripts as $script) { |
|
135 | - // skip to next script if this has already been done |
|
136 | - if ($script->isRegistered()) { |
|
137 | - continue; |
|
138 | - } |
|
139 | - do_action( |
|
140 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
141 | - $script |
|
142 | - ); |
|
143 | - $registered = wp_register_script( |
|
144 | - $script->handle(), |
|
145 | - $script->source(), |
|
146 | - $script->dependencies(), |
|
147 | - $script->version(), |
|
148 | - $script->loadInFooter() |
|
149 | - ); |
|
150 | - if (! $registered && $this->debug()) { |
|
151 | - throw new AssetRegistrationException($script->handle()); |
|
152 | - } |
|
153 | - $script->setRegistered($registered); |
|
154 | - if ($script->requiresTranslation()) { |
|
155 | - $this->registerTranslation($script->handle()); |
|
156 | - } |
|
157 | - do_action( |
|
158 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script', |
|
159 | - $script |
|
160 | - ); |
|
161 | - } |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * Registers CSS assets with WP core |
|
167 | - * |
|
168 | - * @since 4.9.62.p |
|
169 | - * @param StylesheetAsset[] $styles |
|
170 | - * @throws InvalidDataTypeException |
|
171 | - */ |
|
172 | - public function registerStyles(array $styles) |
|
173 | - { |
|
174 | - foreach ($styles as $style) { |
|
175 | - // skip to next style if this has already been done |
|
176 | - if ($style->isRegistered()) { |
|
177 | - continue; |
|
178 | - } |
|
179 | - do_action( |
|
180 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style', |
|
181 | - $style |
|
182 | - ); |
|
183 | - wp_register_style( |
|
184 | - $style->handle(), |
|
185 | - $style->source(), |
|
186 | - $style->dependencies(), |
|
187 | - $style->version(), |
|
188 | - $style->media() |
|
189 | - ); |
|
190 | - $style->setRegistered(); |
|
191 | - do_action( |
|
192 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style', |
|
193 | - $style |
|
194 | - ); |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * Call back for the script print in frontend and backend. |
|
201 | - * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
202 | - * |
|
203 | - * @since 4.9.31.rc.015 |
|
204 | - */ |
|
205 | - public function enqueueData() |
|
206 | - { |
|
207 | - $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
208 | - wp_add_inline_script( |
|
209 | - 'eejs-core', |
|
210 | - 'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)), |
|
211 | - 'before' |
|
212 | - ); |
|
213 | - $scripts = $this->assets->getJavascriptAssetsWithData(); |
|
214 | - foreach ($scripts as $script) { |
|
215 | - $this->addRegisteredScriptHandlesWithData($script->handle()); |
|
216 | - if ($script->hasInlineDataCallback()) { |
|
217 | - $localize = $script->inlineDataCallback(); |
|
218 | - $localize(); |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * Used to add data to eejs.data object. |
|
226 | - * Note: Overriding existing data is not allowed. |
|
227 | - * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
228 | - * If the data you add is something like this: |
|
229 | - * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
230 | - * It will be exposed in the page source as: |
|
231 | - * eejs.data.my_plugin_data.foo == gar |
|
232 | - * |
|
233 | - * @param string $key Key used to access your data |
|
234 | - * @param string|array $value Value to attach to key |
|
235 | - * @throws InvalidArgumentException |
|
236 | - */ |
|
237 | - public function addData($key, $value) |
|
238 | - { |
|
239 | - if ($this->verifyDataNotExisting($key)) { |
|
240 | - $this->jsdata[ $key ] = $value; |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
247 | - * elements in an array. |
|
248 | - * When you use this method, the value you include will be appended to the end of an array on $key. |
|
249 | - * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
250 | - * object like this, eejs.data.test = [ my_data, |
|
251 | - * ] |
|
252 | - * If there has already been a scalar value attached to the data object given key, then |
|
253 | - * this will throw an exception. |
|
254 | - * |
|
255 | - * @param string $key Key to attach data to. |
|
256 | - * @param string|array $value Value being registered. |
|
257 | - * @throws InvalidArgumentException |
|
258 | - */ |
|
259 | - public function pushData($key, $value) |
|
260 | - { |
|
261 | - if (isset($this->jsdata[ $key ]) |
|
262 | - && ! is_array($this->jsdata[ $key ]) |
|
263 | - ) { |
|
264 | - if (! $this->debug()) { |
|
265 | - return; |
|
266 | - } |
|
267 | - throw new InvalidArgumentException( |
|
268 | - sprintf( |
|
269 | - __( |
|
270 | - 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
26 | + const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json'; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var AssetCollection $assets |
|
30 | + */ |
|
31 | + protected $assets; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var I18nRegistry |
|
35 | + */ |
|
36 | + private $i18n_registry; |
|
37 | + |
|
38 | + /** |
|
39 | + * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + protected $jsdata = array(); |
|
44 | + |
|
45 | + /** |
|
46 | + * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
47 | + * page source. |
|
48 | + * |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + private $script_handles_with_data = array(); |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Holds the manifest data obtained from registered manifest files. |
|
56 | + * Manifests are maps of asset chunk name to actual built asset file names. |
|
57 | + * Shape of this array is: |
|
58 | + * array( |
|
59 | + * 'some_namespace_slug' => array( |
|
60 | + * 'some_chunk_name' => array( |
|
61 | + * 'js' => 'filename.js' |
|
62 | + * 'css' => 'filename.js' |
|
63 | + * ), |
|
64 | + * 'url_base' => 'https://baseurl.com/to/assets |
|
65 | + * ) |
|
66 | + * ) |
|
67 | + * |
|
68 | + * @var array |
|
69 | + */ |
|
70 | + private $manifest_data = array(); |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * Registry constructor. |
|
75 | + * Hooking into WP actions for script registry. |
|
76 | + * |
|
77 | + * @param AssetCollection $assets |
|
78 | + * @param I18nRegistry $i18n_registry |
|
79 | + */ |
|
80 | + public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry) |
|
81 | + { |
|
82 | + $this->assets = $assets; |
|
83 | + $this->i18n_registry = $i18n_registry; |
|
84 | + add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1); |
|
85 | + add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1); |
|
86 | + add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3); |
|
87 | + add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3); |
|
88 | + add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4); |
|
89 | + add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4); |
|
90 | + add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
91 | + add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n |
|
97 | + * translation handling. |
|
98 | + * |
|
99 | + * @return I18nRegistry |
|
100 | + */ |
|
101 | + public function getI18nRegistry() |
|
102 | + { |
|
103 | + return $this->i18n_registry; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * Callback for the wp_enqueue_scripts actions used to register assets. |
|
109 | + * |
|
110 | + * @since 4.9.62.p |
|
111 | + * @throws Exception |
|
112 | + */ |
|
113 | + public function registerScriptsAndStyles() |
|
114 | + { |
|
115 | + try { |
|
116 | + $this->registerScripts($this->assets->getJavascriptAssets()); |
|
117 | + $this->registerStyles($this->assets->getStylesheetAssets()); |
|
118 | + } catch (Exception $exception) { |
|
119 | + new ExceptionStackTraceDisplay($exception); |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * Registers JS assets with WP core |
|
126 | + * |
|
127 | + * @since 4.9.62.p |
|
128 | + * @param JavascriptAsset[] $scripts |
|
129 | + * @throws AssetRegistrationException |
|
130 | + * @throws InvalidDataTypeException |
|
131 | + */ |
|
132 | + public function registerScripts(array $scripts) |
|
133 | + { |
|
134 | + foreach ($scripts as $script) { |
|
135 | + // skip to next script if this has already been done |
|
136 | + if ($script->isRegistered()) { |
|
137 | + continue; |
|
138 | + } |
|
139 | + do_action( |
|
140 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
141 | + $script |
|
142 | + ); |
|
143 | + $registered = wp_register_script( |
|
144 | + $script->handle(), |
|
145 | + $script->source(), |
|
146 | + $script->dependencies(), |
|
147 | + $script->version(), |
|
148 | + $script->loadInFooter() |
|
149 | + ); |
|
150 | + if (! $registered && $this->debug()) { |
|
151 | + throw new AssetRegistrationException($script->handle()); |
|
152 | + } |
|
153 | + $script->setRegistered($registered); |
|
154 | + if ($script->requiresTranslation()) { |
|
155 | + $this->registerTranslation($script->handle()); |
|
156 | + } |
|
157 | + do_action( |
|
158 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script', |
|
159 | + $script |
|
160 | + ); |
|
161 | + } |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * Registers CSS assets with WP core |
|
167 | + * |
|
168 | + * @since 4.9.62.p |
|
169 | + * @param StylesheetAsset[] $styles |
|
170 | + * @throws InvalidDataTypeException |
|
171 | + */ |
|
172 | + public function registerStyles(array $styles) |
|
173 | + { |
|
174 | + foreach ($styles as $style) { |
|
175 | + // skip to next style if this has already been done |
|
176 | + if ($style->isRegistered()) { |
|
177 | + continue; |
|
178 | + } |
|
179 | + do_action( |
|
180 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style', |
|
181 | + $style |
|
182 | + ); |
|
183 | + wp_register_style( |
|
184 | + $style->handle(), |
|
185 | + $style->source(), |
|
186 | + $style->dependencies(), |
|
187 | + $style->version(), |
|
188 | + $style->media() |
|
189 | + ); |
|
190 | + $style->setRegistered(); |
|
191 | + do_action( |
|
192 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style', |
|
193 | + $style |
|
194 | + ); |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * Call back for the script print in frontend and backend. |
|
201 | + * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
202 | + * |
|
203 | + * @since 4.9.31.rc.015 |
|
204 | + */ |
|
205 | + public function enqueueData() |
|
206 | + { |
|
207 | + $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
208 | + wp_add_inline_script( |
|
209 | + 'eejs-core', |
|
210 | + 'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)), |
|
211 | + 'before' |
|
212 | + ); |
|
213 | + $scripts = $this->assets->getJavascriptAssetsWithData(); |
|
214 | + foreach ($scripts as $script) { |
|
215 | + $this->addRegisteredScriptHandlesWithData($script->handle()); |
|
216 | + if ($script->hasInlineDataCallback()) { |
|
217 | + $localize = $script->inlineDataCallback(); |
|
218 | + $localize(); |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * Used to add data to eejs.data object. |
|
226 | + * Note: Overriding existing data is not allowed. |
|
227 | + * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
228 | + * If the data you add is something like this: |
|
229 | + * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
230 | + * It will be exposed in the page source as: |
|
231 | + * eejs.data.my_plugin_data.foo == gar |
|
232 | + * |
|
233 | + * @param string $key Key used to access your data |
|
234 | + * @param string|array $value Value to attach to key |
|
235 | + * @throws InvalidArgumentException |
|
236 | + */ |
|
237 | + public function addData($key, $value) |
|
238 | + { |
|
239 | + if ($this->verifyDataNotExisting($key)) { |
|
240 | + $this->jsdata[ $key ] = $value; |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
247 | + * elements in an array. |
|
248 | + * When you use this method, the value you include will be appended to the end of an array on $key. |
|
249 | + * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
250 | + * object like this, eejs.data.test = [ my_data, |
|
251 | + * ] |
|
252 | + * If there has already been a scalar value attached to the data object given key, then |
|
253 | + * this will throw an exception. |
|
254 | + * |
|
255 | + * @param string $key Key to attach data to. |
|
256 | + * @param string|array $value Value being registered. |
|
257 | + * @throws InvalidArgumentException |
|
258 | + */ |
|
259 | + public function pushData($key, $value) |
|
260 | + { |
|
261 | + if (isset($this->jsdata[ $key ]) |
|
262 | + && ! is_array($this->jsdata[ $key ]) |
|
263 | + ) { |
|
264 | + if (! $this->debug()) { |
|
265 | + return; |
|
266 | + } |
|
267 | + throw new InvalidArgumentException( |
|
268 | + sprintf( |
|
269 | + __( |
|
270 | + 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
271 | 271 | push values to this data element when it is an array.', |
272 | - 'event_espresso' |
|
273 | - ), |
|
274 | - $key, |
|
275 | - __METHOD__ |
|
276 | - ) |
|
277 | - ); |
|
278 | - } |
|
279 | - $this->jsdata[ $key ][] = $value; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * Used to set content used by javascript for a template. |
|
285 | - * Note: Overrides of existing registered templates are not allowed. |
|
286 | - * |
|
287 | - * @param string $template_reference |
|
288 | - * @param string $template_content |
|
289 | - * @throws InvalidArgumentException |
|
290 | - */ |
|
291 | - public function addTemplate($template_reference, $template_content) |
|
292 | - { |
|
293 | - if (! isset($this->jsdata['templates'])) { |
|
294 | - $this->jsdata['templates'] = array(); |
|
295 | - } |
|
296 | - //no overrides allowed. |
|
297 | - if (isset($this->jsdata['templates'][ $template_reference ])) { |
|
298 | - if (! $this->debug()) { |
|
299 | - return; |
|
300 | - } |
|
301 | - throw new InvalidArgumentException( |
|
302 | - sprintf( |
|
303 | - __( |
|
304 | - 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
305 | - 'event_espresso' |
|
306 | - ), |
|
307 | - $template_reference |
|
308 | - ) |
|
309 | - ); |
|
310 | - } |
|
311 | - $this->jsdata['templates'][ $template_reference ] = $template_content; |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * Retrieve the template content already registered for the given reference. |
|
317 | - * |
|
318 | - * @param string $template_reference |
|
319 | - * @return string |
|
320 | - */ |
|
321 | - public function getTemplate($template_reference) |
|
322 | - { |
|
323 | - return isset($this->jsdata['templates'][ $template_reference ]) |
|
324 | - ? $this->jsdata['templates'][ $template_reference ] |
|
325 | - : ''; |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - /** |
|
330 | - * Retrieve registered data. |
|
331 | - * |
|
332 | - * @param string $key Name of key to attach data to. |
|
333 | - * @return mixed If there is no for the given key, then false is returned. |
|
334 | - */ |
|
335 | - public function getData($key) |
|
336 | - { |
|
337 | - return isset($this->jsdata[ $key ]) |
|
338 | - ? $this->jsdata[ $key ] |
|
339 | - : false; |
|
340 | - } |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * Verifies whether the given data exists already on the jsdata array. |
|
345 | - * Overriding data is not allowed. |
|
346 | - * |
|
347 | - * @param string $key Index for data. |
|
348 | - * @return bool If valid then return true. |
|
349 | - * @throws InvalidArgumentException if data already exists. |
|
350 | - */ |
|
351 | - protected function verifyDataNotExisting($key) |
|
352 | - { |
|
353 | - if (isset($this->jsdata[ $key ])) { |
|
354 | - if (! $this->debug()) { |
|
355 | - return false; |
|
356 | - } |
|
357 | - if (is_array($this->jsdata[ $key ])) { |
|
358 | - throw new InvalidArgumentException( |
|
359 | - sprintf( |
|
360 | - __( |
|
361 | - 'The value for %1$s already exists in the Registry::eejs object. |
|
272 | + 'event_espresso' |
|
273 | + ), |
|
274 | + $key, |
|
275 | + __METHOD__ |
|
276 | + ) |
|
277 | + ); |
|
278 | + } |
|
279 | + $this->jsdata[ $key ][] = $value; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * Used to set content used by javascript for a template. |
|
285 | + * Note: Overrides of existing registered templates are not allowed. |
|
286 | + * |
|
287 | + * @param string $template_reference |
|
288 | + * @param string $template_content |
|
289 | + * @throws InvalidArgumentException |
|
290 | + */ |
|
291 | + public function addTemplate($template_reference, $template_content) |
|
292 | + { |
|
293 | + if (! isset($this->jsdata['templates'])) { |
|
294 | + $this->jsdata['templates'] = array(); |
|
295 | + } |
|
296 | + //no overrides allowed. |
|
297 | + if (isset($this->jsdata['templates'][ $template_reference ])) { |
|
298 | + if (! $this->debug()) { |
|
299 | + return; |
|
300 | + } |
|
301 | + throw new InvalidArgumentException( |
|
302 | + sprintf( |
|
303 | + __( |
|
304 | + 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
305 | + 'event_espresso' |
|
306 | + ), |
|
307 | + $template_reference |
|
308 | + ) |
|
309 | + ); |
|
310 | + } |
|
311 | + $this->jsdata['templates'][ $template_reference ] = $template_content; |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * Retrieve the template content already registered for the given reference. |
|
317 | + * |
|
318 | + * @param string $template_reference |
|
319 | + * @return string |
|
320 | + */ |
|
321 | + public function getTemplate($template_reference) |
|
322 | + { |
|
323 | + return isset($this->jsdata['templates'][ $template_reference ]) |
|
324 | + ? $this->jsdata['templates'][ $template_reference ] |
|
325 | + : ''; |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + /** |
|
330 | + * Retrieve registered data. |
|
331 | + * |
|
332 | + * @param string $key Name of key to attach data to. |
|
333 | + * @return mixed If there is no for the given key, then false is returned. |
|
334 | + */ |
|
335 | + public function getData($key) |
|
336 | + { |
|
337 | + return isset($this->jsdata[ $key ]) |
|
338 | + ? $this->jsdata[ $key ] |
|
339 | + : false; |
|
340 | + } |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * Verifies whether the given data exists already on the jsdata array. |
|
345 | + * Overriding data is not allowed. |
|
346 | + * |
|
347 | + * @param string $key Index for data. |
|
348 | + * @return bool If valid then return true. |
|
349 | + * @throws InvalidArgumentException if data already exists. |
|
350 | + */ |
|
351 | + protected function verifyDataNotExisting($key) |
|
352 | + { |
|
353 | + if (isset($this->jsdata[ $key ])) { |
|
354 | + if (! $this->debug()) { |
|
355 | + return false; |
|
356 | + } |
|
357 | + if (is_array($this->jsdata[ $key ])) { |
|
358 | + throw new InvalidArgumentException( |
|
359 | + sprintf( |
|
360 | + __( |
|
361 | + 'The value for %1$s already exists in the Registry::eejs object. |
|
362 | 362 | Overrides are not allowed. Since the value of this data is an array, you may want to use the |
363 | 363 | %2$s method to push your value to the array.', |
364 | - 'event_espresso' |
|
365 | - ), |
|
366 | - $key, |
|
367 | - 'pushData()' |
|
368 | - ) |
|
369 | - ); |
|
370 | - } |
|
371 | - throw new InvalidArgumentException( |
|
372 | - sprintf( |
|
373 | - __( |
|
374 | - 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
364 | + 'event_espresso' |
|
365 | + ), |
|
366 | + $key, |
|
367 | + 'pushData()' |
|
368 | + ) |
|
369 | + ); |
|
370 | + } |
|
371 | + throw new InvalidArgumentException( |
|
372 | + sprintf( |
|
373 | + __( |
|
374 | + 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
375 | 375 | allowed. Consider attaching your value to a different key', |
376 | - 'event_espresso' |
|
377 | - ), |
|
378 | - $key |
|
379 | - ) |
|
380 | - ); |
|
381 | - } |
|
382 | - return true; |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * Get the actual asset path for asset manifests. |
|
388 | - * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned. |
|
389 | - * |
|
390 | - * @param string $namespace The namespace associated with the manifest file hosting the map of chunk_name to actual |
|
391 | - * asset file location. |
|
392 | - * @param string $chunk_name |
|
393 | - * @param string $asset_type |
|
394 | - * @return string |
|
395 | - * @since 4.9.59.p |
|
396 | - */ |
|
397 | - public function getAssetUrl($namespace, $chunk_name, $asset_type) |
|
398 | - { |
|
399 | - $url = isset( |
|
400 | - $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ], |
|
401 | - $this->manifest_data[ $namespace ]['url_base'] |
|
402 | - ) |
|
403 | - ? $this->manifest_data[ $namespace ]['url_base'] |
|
404 | - . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ] |
|
405 | - : $chunk_name; |
|
406 | - return apply_filters( |
|
407 | - 'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl', |
|
408 | - $url, |
|
409 | - $namespace, |
|
410 | - $chunk_name, |
|
411 | - $asset_type |
|
412 | - ); |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * Return the url to a js file for the given namespace and chunk name. |
|
419 | - * |
|
420 | - * @param string $namespace |
|
421 | - * @param string $chunk_name |
|
422 | - * @return string |
|
423 | - */ |
|
424 | - public function getJsUrl($namespace, $chunk_name) |
|
425 | - { |
|
426 | - return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS); |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * Return the url to a css file for the given namespace and chunk name. |
|
432 | - * |
|
433 | - * @param string $namespace |
|
434 | - * @param string $chunk_name |
|
435 | - * @return string |
|
436 | - */ |
|
437 | - public function getCssUrl($namespace, $chunk_name) |
|
438 | - { |
|
439 | - return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS); |
|
440 | - } |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * @since 4.9.62.p |
|
445 | - * @throws InvalidArgumentException |
|
446 | - * @throws InvalidFilePathException |
|
447 | - */ |
|
448 | - public function registerManifestFiles() |
|
449 | - { |
|
450 | - $manifest_files = $this->assets->getManifestFiles(); |
|
451 | - foreach ($manifest_files as $manifest_file) { |
|
452 | - $this->registerManifestFile( |
|
453 | - $manifest_file->assetNamespace(), |
|
454 | - $manifest_file->urlBase(), |
|
455 | - $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST |
|
456 | - ); |
|
457 | - } |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * Used to register a js/css manifest file with the registered_manifest_files property. |
|
463 | - * |
|
464 | - * @param string $namespace Provided to associate the manifest file with a specific namespace. |
|
465 | - * @param string $url_base The url base for the manifest file location. |
|
466 | - * @param string $manifest_file The absolute path to the manifest file. |
|
467 | - * @throws InvalidArgumentException |
|
468 | - * @throws InvalidFilePathException |
|
469 | - * @since 4.9.59.p |
|
470 | - */ |
|
471 | - public function registerManifestFile($namespace, $url_base, $manifest_file) |
|
472 | - { |
|
473 | - if (isset($this->manifest_data[ $namespace ])) { |
|
474 | - if (! $this->debug()) { |
|
475 | - return; |
|
476 | - } |
|
477 | - throw new InvalidArgumentException( |
|
478 | - sprintf( |
|
479 | - esc_html__( |
|
480 | - 'The namespace for this manifest file has already been registered, choose a namespace other than %s', |
|
481 | - 'event_espresso' |
|
482 | - ), |
|
483 | - $namespace |
|
484 | - ) |
|
485 | - ); |
|
486 | - } |
|
487 | - if (filter_var($url_base, FILTER_VALIDATE_URL) === false) { |
|
488 | - if (is_admin()) { |
|
489 | - EE_Error::add_error( |
|
490 | - sprintf( |
|
491 | - esc_html__( |
|
492 | - 'The url given for %1$s assets is invalid. The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant', |
|
493 | - 'event_espresso' |
|
494 | - ), |
|
495 | - 'Event Espresso', |
|
496 | - $url_base, |
|
497 | - 'plugins_url', |
|
498 | - 'WP_PLUGIN_URL' |
|
499 | - ), |
|
500 | - __FILE__, |
|
501 | - __FUNCTION__, |
|
502 | - __LINE__ |
|
503 | - ); |
|
504 | - } |
|
505 | - return; |
|
506 | - } |
|
507 | - $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file); |
|
508 | - if (! isset($this->manifest_data[ $namespace ]['url_base'])) { |
|
509 | - $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base); |
|
510 | - } |
|
511 | - } |
|
512 | - |
|
513 | - |
|
514 | - /** |
|
515 | - * Decodes json from the provided manifest file. |
|
516 | - * |
|
517 | - * @since 4.9.59.p |
|
518 | - * @param string $manifest_file Path to manifest file. |
|
519 | - * @return array |
|
520 | - * @throws InvalidFilePathException |
|
521 | - */ |
|
522 | - private function decodeManifestFile($manifest_file) |
|
523 | - { |
|
524 | - if (! file_exists($manifest_file)) { |
|
525 | - throw new InvalidFilePathException($manifest_file); |
|
526 | - } |
|
527 | - return json_decode(file_get_contents($manifest_file), true); |
|
528 | - } |
|
529 | - |
|
530 | - |
|
531 | - /** |
|
532 | - * This is used to set registered script handles that have data. |
|
533 | - * |
|
534 | - * @param string $script_handle |
|
535 | - */ |
|
536 | - private function addRegisteredScriptHandlesWithData($script_handle) |
|
537 | - { |
|
538 | - $this->script_handles_with_data[ $script_handle ] = $script_handle; |
|
539 | - } |
|
540 | - |
|
541 | - |
|
542 | - /**i |
|
376 | + 'event_espresso' |
|
377 | + ), |
|
378 | + $key |
|
379 | + ) |
|
380 | + ); |
|
381 | + } |
|
382 | + return true; |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * Get the actual asset path for asset manifests. |
|
388 | + * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned. |
|
389 | + * |
|
390 | + * @param string $namespace The namespace associated with the manifest file hosting the map of chunk_name to actual |
|
391 | + * asset file location. |
|
392 | + * @param string $chunk_name |
|
393 | + * @param string $asset_type |
|
394 | + * @return string |
|
395 | + * @since 4.9.59.p |
|
396 | + */ |
|
397 | + public function getAssetUrl($namespace, $chunk_name, $asset_type) |
|
398 | + { |
|
399 | + $url = isset( |
|
400 | + $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ], |
|
401 | + $this->manifest_data[ $namespace ]['url_base'] |
|
402 | + ) |
|
403 | + ? $this->manifest_data[ $namespace ]['url_base'] |
|
404 | + . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ] |
|
405 | + : $chunk_name; |
|
406 | + return apply_filters( |
|
407 | + 'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl', |
|
408 | + $url, |
|
409 | + $namespace, |
|
410 | + $chunk_name, |
|
411 | + $asset_type |
|
412 | + ); |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * Return the url to a js file for the given namespace and chunk name. |
|
419 | + * |
|
420 | + * @param string $namespace |
|
421 | + * @param string $chunk_name |
|
422 | + * @return string |
|
423 | + */ |
|
424 | + public function getJsUrl($namespace, $chunk_name) |
|
425 | + { |
|
426 | + return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS); |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * Return the url to a css file for the given namespace and chunk name. |
|
432 | + * |
|
433 | + * @param string $namespace |
|
434 | + * @param string $chunk_name |
|
435 | + * @return string |
|
436 | + */ |
|
437 | + public function getCssUrl($namespace, $chunk_name) |
|
438 | + { |
|
439 | + return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS); |
|
440 | + } |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * @since 4.9.62.p |
|
445 | + * @throws InvalidArgumentException |
|
446 | + * @throws InvalidFilePathException |
|
447 | + */ |
|
448 | + public function registerManifestFiles() |
|
449 | + { |
|
450 | + $manifest_files = $this->assets->getManifestFiles(); |
|
451 | + foreach ($manifest_files as $manifest_file) { |
|
452 | + $this->registerManifestFile( |
|
453 | + $manifest_file->assetNamespace(), |
|
454 | + $manifest_file->urlBase(), |
|
455 | + $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST |
|
456 | + ); |
|
457 | + } |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * Used to register a js/css manifest file with the registered_manifest_files property. |
|
463 | + * |
|
464 | + * @param string $namespace Provided to associate the manifest file with a specific namespace. |
|
465 | + * @param string $url_base The url base for the manifest file location. |
|
466 | + * @param string $manifest_file The absolute path to the manifest file. |
|
467 | + * @throws InvalidArgumentException |
|
468 | + * @throws InvalidFilePathException |
|
469 | + * @since 4.9.59.p |
|
470 | + */ |
|
471 | + public function registerManifestFile($namespace, $url_base, $manifest_file) |
|
472 | + { |
|
473 | + if (isset($this->manifest_data[ $namespace ])) { |
|
474 | + if (! $this->debug()) { |
|
475 | + return; |
|
476 | + } |
|
477 | + throw new InvalidArgumentException( |
|
478 | + sprintf( |
|
479 | + esc_html__( |
|
480 | + 'The namespace for this manifest file has already been registered, choose a namespace other than %s', |
|
481 | + 'event_espresso' |
|
482 | + ), |
|
483 | + $namespace |
|
484 | + ) |
|
485 | + ); |
|
486 | + } |
|
487 | + if (filter_var($url_base, FILTER_VALIDATE_URL) === false) { |
|
488 | + if (is_admin()) { |
|
489 | + EE_Error::add_error( |
|
490 | + sprintf( |
|
491 | + esc_html__( |
|
492 | + 'The url given for %1$s assets is invalid. The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant', |
|
493 | + 'event_espresso' |
|
494 | + ), |
|
495 | + 'Event Espresso', |
|
496 | + $url_base, |
|
497 | + 'plugins_url', |
|
498 | + 'WP_PLUGIN_URL' |
|
499 | + ), |
|
500 | + __FILE__, |
|
501 | + __FUNCTION__, |
|
502 | + __LINE__ |
|
503 | + ); |
|
504 | + } |
|
505 | + return; |
|
506 | + } |
|
507 | + $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file); |
|
508 | + if (! isset($this->manifest_data[ $namespace ]['url_base'])) { |
|
509 | + $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base); |
|
510 | + } |
|
511 | + } |
|
512 | + |
|
513 | + |
|
514 | + /** |
|
515 | + * Decodes json from the provided manifest file. |
|
516 | + * |
|
517 | + * @since 4.9.59.p |
|
518 | + * @param string $manifest_file Path to manifest file. |
|
519 | + * @return array |
|
520 | + * @throws InvalidFilePathException |
|
521 | + */ |
|
522 | + private function decodeManifestFile($manifest_file) |
|
523 | + { |
|
524 | + if (! file_exists($manifest_file)) { |
|
525 | + throw new InvalidFilePathException($manifest_file); |
|
526 | + } |
|
527 | + return json_decode(file_get_contents($manifest_file), true); |
|
528 | + } |
|
529 | + |
|
530 | + |
|
531 | + /** |
|
532 | + * This is used to set registered script handles that have data. |
|
533 | + * |
|
534 | + * @param string $script_handle |
|
535 | + */ |
|
536 | + private function addRegisteredScriptHandlesWithData($script_handle) |
|
537 | + { |
|
538 | + $this->script_handles_with_data[ $script_handle ] = $script_handle; |
|
539 | + } |
|
540 | + |
|
541 | + |
|
542 | + /**i |
|
543 | 543 | * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the |
544 | 544 | * Dependency stored in WP_Scripts if its set. |
545 | 545 | */ |
546 | - private function removeAlreadyRegisteredDataForScriptHandles() |
|
547 | - { |
|
548 | - if (empty($this->script_handles_with_data)) { |
|
549 | - return; |
|
550 | - } |
|
551 | - foreach ($this->script_handles_with_data as $script_handle) { |
|
552 | - $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
553 | - } |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * Removes any data dependency registered in WP_Scripts if its set. |
|
559 | - * |
|
560 | - * @param string $script_handle |
|
561 | - */ |
|
562 | - private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
563 | - { |
|
564 | - if (isset($this->script_handles_with_data[ $script_handle ])) { |
|
565 | - global $wp_scripts; |
|
566 | - $unset_handle = false; |
|
567 | - if ($wp_scripts->get_data($script_handle, 'data')) { |
|
568 | - unset($wp_scripts->registered[ $script_handle ]->extra['data']); |
|
569 | - $unset_handle = true; |
|
570 | - } |
|
571 | - //deal with inline_scripts |
|
572 | - if ($wp_scripts->get_data($script_handle, 'before')) { |
|
573 | - unset($wp_scripts->registered[ $script_handle ]->extra['before']); |
|
574 | - $unset_handle = true; |
|
575 | - } |
|
576 | - if ($wp_scripts->get_data($script_handle, 'after')) { |
|
577 | - unset($wp_scripts->registered[ $script_handle ]->extra['after']); |
|
578 | - } |
|
579 | - if ($unset_handle) { |
|
580 | - unset($this->script_handles_with_data[ $script_handle ]); |
|
581 | - } |
|
582 | - } |
|
583 | - } |
|
584 | - |
|
585 | - |
|
586 | - /** |
|
587 | - * register translations for a registered script |
|
588 | - * |
|
589 | - * @param string $handle |
|
590 | - */ |
|
591 | - public function registerTranslation($handle) |
|
592 | - { |
|
593 | - $this->i18n_registry->registerScriptI18n($handle); |
|
594 | - } |
|
595 | - |
|
596 | - |
|
597 | - /** |
|
598 | - * @since $VID:$ |
|
599 | - * @return bool |
|
600 | - */ |
|
601 | - private function debug() |
|
602 | - { |
|
603 | - return apply_filters( |
|
604 | - 'FHEE__EventEspresso_core_services_assets_Registry__debug', |
|
605 | - defined('EE_DEBUG') && EE_DEBUG |
|
606 | - ); |
|
607 | - } |
|
546 | + private function removeAlreadyRegisteredDataForScriptHandles() |
|
547 | + { |
|
548 | + if (empty($this->script_handles_with_data)) { |
|
549 | + return; |
|
550 | + } |
|
551 | + foreach ($this->script_handles_with_data as $script_handle) { |
|
552 | + $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
553 | + } |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * Removes any data dependency registered in WP_Scripts if its set. |
|
559 | + * |
|
560 | + * @param string $script_handle |
|
561 | + */ |
|
562 | + private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
563 | + { |
|
564 | + if (isset($this->script_handles_with_data[ $script_handle ])) { |
|
565 | + global $wp_scripts; |
|
566 | + $unset_handle = false; |
|
567 | + if ($wp_scripts->get_data($script_handle, 'data')) { |
|
568 | + unset($wp_scripts->registered[ $script_handle ]->extra['data']); |
|
569 | + $unset_handle = true; |
|
570 | + } |
|
571 | + //deal with inline_scripts |
|
572 | + if ($wp_scripts->get_data($script_handle, 'before')) { |
|
573 | + unset($wp_scripts->registered[ $script_handle ]->extra['before']); |
|
574 | + $unset_handle = true; |
|
575 | + } |
|
576 | + if ($wp_scripts->get_data($script_handle, 'after')) { |
|
577 | + unset($wp_scripts->registered[ $script_handle ]->extra['after']); |
|
578 | + } |
|
579 | + if ($unset_handle) { |
|
580 | + unset($this->script_handles_with_data[ $script_handle ]); |
|
581 | + } |
|
582 | + } |
|
583 | + } |
|
584 | + |
|
585 | + |
|
586 | + /** |
|
587 | + * register translations for a registered script |
|
588 | + * |
|
589 | + * @param string $handle |
|
590 | + */ |
|
591 | + public function registerTranslation($handle) |
|
592 | + { |
|
593 | + $this->i18n_registry->registerScriptI18n($handle); |
|
594 | + } |
|
595 | + |
|
596 | + |
|
597 | + /** |
|
598 | + * @since $VID:$ |
|
599 | + * @return bool |
|
600 | + */ |
|
601 | + private function debug() |
|
602 | + { |
|
603 | + return apply_filters( |
|
604 | + 'FHEE__EventEspresso_core_services_assets_Registry__debug', |
|
605 | + defined('EE_DEBUG') && EE_DEBUG |
|
606 | + ); |
|
607 | + } |
|
608 | 608 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.63.rc.025'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.63.rc.025'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |