@@ -19,182 +19,182 @@ |
||
19 | 19 | class RecommendedVersions extends Middleware |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * converts a Request to a Response |
|
24 | - * |
|
25 | - * @param RequestInterface $request |
|
26 | - * @param ResponseInterface $response |
|
27 | - * @return ResponseInterface |
|
28 | - * @throws InvalidDataTypeException |
|
29 | - */ |
|
30 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
31 | - { |
|
32 | - $this->request = $request; |
|
33 | - $this->response = $response; |
|
34 | - // check required WP version |
|
35 | - if (! $this->minimumWordPressVersionRequired()) { |
|
36 | - $this->request->unSetRequestParam('activate', true); |
|
37 | - add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
|
38 | - $this->response->terminateRequest(); |
|
39 | - $this->response->deactivatePlugin(); |
|
40 | - } |
|
41 | - // check recommended PHP version |
|
42 | - if (! $this->minimumPhpVersionRecommended()) { |
|
43 | - $this->displayMinimumRecommendedPhpVersionNotice(); |
|
44 | - } |
|
45 | - // upcoming required version |
|
46 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
47 | - $this->displayUpcomingRequiredVersion(); |
|
48 | - } |
|
49 | - $this->response = $this->processRequestStack($this->request, $this->response); |
|
50 | - return $this->response; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Helper method to assess installed wp version against given values. |
|
56 | - * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
57 | - * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
58 | - * against) so consider that when sending in your values. |
|
59 | - * |
|
60 | - * @param string $version_to_check |
|
61 | - * @param string $operator |
|
62 | - * @return bool |
|
63 | - */ |
|
64 | - public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
65 | - { |
|
66 | - global $wp_version; |
|
67 | - return version_compare( |
|
68 | - // first account for wp_version being pre-release |
|
69 | - // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
70 | - strpos($wp_version, '-') > 0 |
|
71 | - ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
72 | - : $wp_version, |
|
73 | - $version_to_check, |
|
74 | - $operator |
|
75 | - ); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @return boolean |
|
81 | - */ |
|
82 | - private function minimumWordPressVersionRequired() |
|
83 | - { |
|
84 | - return RecommendedVersions::compareWordPressVersion(); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @param string $min_version |
|
90 | - * @return boolean |
|
91 | - */ |
|
92 | - private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
93 | - { |
|
94 | - return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @return boolean |
|
100 | - */ |
|
101 | - private function minimumPhpVersionRecommended() |
|
102 | - { |
|
103 | - return $this->checkPhpVersion(); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return void |
|
109 | - */ |
|
110 | - public function minimumWpVersionError() |
|
111 | - { |
|
112 | - global $wp_version; |
|
113 | - ?> |
|
22 | + /** |
|
23 | + * converts a Request to a Response |
|
24 | + * |
|
25 | + * @param RequestInterface $request |
|
26 | + * @param ResponseInterface $response |
|
27 | + * @return ResponseInterface |
|
28 | + * @throws InvalidDataTypeException |
|
29 | + */ |
|
30 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
31 | + { |
|
32 | + $this->request = $request; |
|
33 | + $this->response = $response; |
|
34 | + // check required WP version |
|
35 | + if (! $this->minimumWordPressVersionRequired()) { |
|
36 | + $this->request->unSetRequestParam('activate', true); |
|
37 | + add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
|
38 | + $this->response->terminateRequest(); |
|
39 | + $this->response->deactivatePlugin(); |
|
40 | + } |
|
41 | + // check recommended PHP version |
|
42 | + if (! $this->minimumPhpVersionRecommended()) { |
|
43 | + $this->displayMinimumRecommendedPhpVersionNotice(); |
|
44 | + } |
|
45 | + // upcoming required version |
|
46 | + if (! $this->upcomingRequiredPhpVersion()) { |
|
47 | + $this->displayUpcomingRequiredVersion(); |
|
48 | + } |
|
49 | + $this->response = $this->processRequestStack($this->request, $this->response); |
|
50 | + return $this->response; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Helper method to assess installed wp version against given values. |
|
56 | + * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
57 | + * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
58 | + * against) so consider that when sending in your values. |
|
59 | + * |
|
60 | + * @param string $version_to_check |
|
61 | + * @param string $operator |
|
62 | + * @return bool |
|
63 | + */ |
|
64 | + public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
65 | + { |
|
66 | + global $wp_version; |
|
67 | + return version_compare( |
|
68 | + // first account for wp_version being pre-release |
|
69 | + // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
70 | + strpos($wp_version, '-') > 0 |
|
71 | + ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
72 | + : $wp_version, |
|
73 | + $version_to_check, |
|
74 | + $operator |
|
75 | + ); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @return boolean |
|
81 | + */ |
|
82 | + private function minimumWordPressVersionRequired() |
|
83 | + { |
|
84 | + return RecommendedVersions::compareWordPressVersion(); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @param string $min_version |
|
90 | + * @return boolean |
|
91 | + */ |
|
92 | + private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
93 | + { |
|
94 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @return boolean |
|
100 | + */ |
|
101 | + private function minimumPhpVersionRecommended() |
|
102 | + { |
|
103 | + return $this->checkPhpVersion(); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return void |
|
109 | + */ |
|
110 | + public function minimumWpVersionError() |
|
111 | + { |
|
112 | + global $wp_version; |
|
113 | + ?> |
|
114 | 114 | <div class="error"> |
115 | 115 | <p> |
116 | 116 | <?php |
117 | - printf( |
|
118 | - __( |
|
119 | - 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
120 | - 'event_espresso' |
|
121 | - ), |
|
122 | - EE_MIN_WP_VER_REQUIRED, |
|
123 | - $wp_version, |
|
124 | - '<br/>', |
|
125 | - '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
126 | - ); |
|
127 | - ?> |
|
117 | + printf( |
|
118 | + __( |
|
119 | + 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
120 | + 'event_espresso' |
|
121 | + ), |
|
122 | + EE_MIN_WP_VER_REQUIRED, |
|
123 | + $wp_version, |
|
124 | + '<br/>', |
|
125 | + '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
126 | + ); |
|
127 | + ?> |
|
128 | 128 | </p> |
129 | 129 | </div> |
130 | 130 | <?php |
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * _display_minimum_recommended_php_version_notice |
|
136 | - * |
|
137 | - * @access private |
|
138 | - * @return void |
|
139 | - * @throws InvalidDataTypeException |
|
140 | - */ |
|
141 | - private function displayMinimumRecommendedPhpVersionNotice() |
|
142 | - { |
|
143 | - if ($this->request->isAdmin()) { |
|
144 | - new PersistentAdminNotice( |
|
145 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
146 | - sprintf( |
|
147 | - esc_html__( |
|
148 | - 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
|
149 | - 'event_espresso' |
|
150 | - ), |
|
151 | - EE_MIN_PHP_VER_RECOMMENDED, |
|
152 | - PHP_VERSION, |
|
153 | - '<br/>', |
|
154 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
155 | - ) |
|
156 | - ); |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Returns whether the provided php version number is less than the current version of php installed on the server. |
|
163 | - * |
|
164 | - * @param string $version_required |
|
165 | - * @return bool |
|
166 | - */ |
|
167 | - private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
168 | - { |
|
169 | - return true; |
|
170 | - // return $this->checkPhpVersion($version_required); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
176 | - */ |
|
177 | - private function displayUpcomingRequiredVersion() |
|
178 | - { |
|
179 | - if ($this->request->isAdmin() |
|
180 | - && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
|
181 | - && current_user_can('update_plugins') |
|
182 | - ) { |
|
183 | - add_action('admin_notices', function () { |
|
184 | - echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
185 | - . sprintf( |
|
186 | - esc_html__( |
|
187 | - 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
188 | - 'event_espresso' |
|
189 | - ), |
|
190 | - '<strong>', |
|
191 | - '</strong>', |
|
192 | - PHP_VERSION, |
|
193 | - '<a href="https://wordpress.org/support/upgrade-php/">', |
|
194 | - '</a>' |
|
195 | - ) |
|
196 | - . '</p></div>'; |
|
197 | - }); |
|
198 | - } |
|
199 | - } |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * _display_minimum_recommended_php_version_notice |
|
136 | + * |
|
137 | + * @access private |
|
138 | + * @return void |
|
139 | + * @throws InvalidDataTypeException |
|
140 | + */ |
|
141 | + private function displayMinimumRecommendedPhpVersionNotice() |
|
142 | + { |
|
143 | + if ($this->request->isAdmin()) { |
|
144 | + new PersistentAdminNotice( |
|
145 | + 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
146 | + sprintf( |
|
147 | + esc_html__( |
|
148 | + 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
|
149 | + 'event_espresso' |
|
150 | + ), |
|
151 | + EE_MIN_PHP_VER_RECOMMENDED, |
|
152 | + PHP_VERSION, |
|
153 | + '<br/>', |
|
154 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
155 | + ) |
|
156 | + ); |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Returns whether the provided php version number is less than the current version of php installed on the server. |
|
163 | + * |
|
164 | + * @param string $version_required |
|
165 | + * @return bool |
|
166 | + */ |
|
167 | + private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
168 | + { |
|
169 | + return true; |
|
170 | + // return $this->checkPhpVersion($version_required); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
176 | + */ |
|
177 | + private function displayUpcomingRequiredVersion() |
|
178 | + { |
|
179 | + if ($this->request->isAdmin() |
|
180 | + && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
|
181 | + && current_user_can('update_plugins') |
|
182 | + ) { |
|
183 | + add_action('admin_notices', function () { |
|
184 | + echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
185 | + . sprintf( |
|
186 | + esc_html__( |
|
187 | + 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
188 | + 'event_espresso' |
|
189 | + ), |
|
190 | + '<strong>', |
|
191 | + '</strong>', |
|
192 | + PHP_VERSION, |
|
193 | + '<a href="https://wordpress.org/support/upgrade-php/">', |
|
194 | + '</a>' |
|
195 | + ) |
|
196 | + . '</p></div>'; |
|
197 | + }); |
|
198 | + } |
|
199 | + } |
|
200 | 200 | } |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | $this->request = $request; |
33 | 33 | $this->response = $response; |
34 | 34 | // check required WP version |
35 | - if (! $this->minimumWordPressVersionRequired()) { |
|
35 | + if ( ! $this->minimumWordPressVersionRequired()) { |
|
36 | 36 | $this->request->unSetRequestParam('activate', true); |
37 | 37 | add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
38 | 38 | $this->response->terminateRequest(); |
39 | 39 | $this->response->deactivatePlugin(); |
40 | 40 | } |
41 | 41 | // check recommended PHP version |
42 | - if (! $this->minimumPhpVersionRecommended()) { |
|
42 | + if ( ! $this->minimumPhpVersionRecommended()) { |
|
43 | 43 | $this->displayMinimumRecommendedPhpVersionNotice(); |
44 | 44 | } |
45 | 45 | // upcoming required version |
46 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
46 | + if ( ! $this->upcomingRequiredPhpVersion()) { |
|
47 | 47 | $this->displayUpcomingRequiredVersion(); |
48 | 48 | } |
49 | 49 | $this->response = $this->processRequestStack($this->request, $this->response); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | if ($this->request->isAdmin()) { |
144 | 144 | new PersistentAdminNotice( |
145 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
145 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
146 | 146 | sprintf( |
147 | 147 | esc_html__( |
148 | 148 | 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
181 | 181 | && current_user_can('update_plugins') |
182 | 182 | ) { |
183 | - add_action('admin_notices', function () { |
|
183 | + add_action('admin_notices', function() { |
|
184 | 184 | echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
185 | 185 | . sprintf( |
186 | 186 | esc_html__( |
@@ -21,201 +21,201 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * AssetCollection constructor |
|
26 | - * |
|
27 | - * @throws InvalidInterfaceException |
|
28 | - */ |
|
29 | - public function __construct() |
|
30 | - { |
|
31 | - parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * @return StylesheetAsset[] |
|
37 | - * @since 4.9.62.p |
|
38 | - */ |
|
39 | - public function getStylesheetAssets() |
|
40 | - { |
|
41 | - return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @return JavascriptAsset[] |
|
47 | - * @since 4.9.62.p |
|
48 | - */ |
|
49 | - public function getJavascriptAssets() |
|
50 | - { |
|
51 | - return $this->getAssetsOfType(Asset::TYPE_JS); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @return ManifestFile[] |
|
57 | - * @since 4.9.62.p |
|
58 | - */ |
|
59 | - public function getManifestFiles() |
|
60 | - { |
|
61 | - return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @param $type |
|
67 | - * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[] |
|
68 | - * @since 4.9.62.p |
|
69 | - */ |
|
70 | - protected function getAssetsOfType($type) |
|
71 | - { |
|
72 | - $files = array(); |
|
73 | - $this->rewind(); |
|
74 | - while ($this->valid()) { |
|
75 | - /** @var Asset $asset */ |
|
76 | - $asset = $this->current(); |
|
77 | - if ($asset->type() === $type) { |
|
78 | - $files[ $asset->handle() ] = $asset; |
|
79 | - } |
|
80 | - $this->next(); |
|
81 | - } |
|
82 | - $this->rewind(); |
|
83 | - return $files; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @return JavascriptAsset[] |
|
89 | - * @since 4.9.62.p |
|
90 | - */ |
|
91 | - public function getJavascriptAssetsWithData() |
|
92 | - { |
|
93 | - $files = array(); |
|
94 | - $this->rewind(); |
|
95 | - while ($this->valid()) { |
|
96 | - /** @var JavascriptAsset $asset */ |
|
97 | - $asset = $this->current(); |
|
98 | - if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
|
99 | - $files[ $asset->handle() ] = $asset; |
|
100 | - } |
|
101 | - $this->next(); |
|
102 | - } |
|
103 | - $this->rewind(); |
|
104 | - return $files; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * has |
|
110 | - * returns TRUE or FALSE |
|
111 | - * depending on whether the object is within the Collection |
|
112 | - * based on the supplied $identifier and type |
|
113 | - * |
|
114 | - * @param mixed $identifier |
|
115 | - * @param string $type |
|
116 | - * @return bool |
|
117 | - * @since $VID:$ |
|
118 | - */ |
|
119 | - public function hasAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
120 | - { |
|
121 | - $this->rewind(); |
|
122 | - while ($this->valid()) { |
|
123 | - if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
124 | - $this->rewind(); |
|
125 | - return true; |
|
126 | - } |
|
127 | - $this->next(); |
|
128 | - } |
|
129 | - return false; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * has |
|
135 | - * returns TRUE or FALSE |
|
136 | - * depending on whether the Stylesheet Asset is within the Collection |
|
137 | - * based on the supplied $identifier |
|
138 | - * |
|
139 | - * @param mixed $identifier |
|
140 | - * @return bool |
|
141 | - * @since $VID:$ |
|
142 | - */ |
|
143 | - public function hasStylesheetAsset($identifier) |
|
144 | - { |
|
145 | - return $this->hasAssetOfType($identifier, Asset::TYPE_CSS); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * has |
|
151 | - * returns TRUE or FALSE |
|
152 | - * depending on whether the Javascript Asset is within the Collection |
|
153 | - * based on the supplied $identifier |
|
154 | - * |
|
155 | - * @param mixed $identifier |
|
156 | - * @return bool |
|
157 | - * @since $VID:$ |
|
158 | - */ |
|
159 | - public function hasJavascriptAsset($identifier) |
|
160 | - { |
|
161 | - return $this->hasAssetOfType($identifier, Asset::TYPE_JS); |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * has |
|
166 | - * returns TRUE or FALSE |
|
167 | - * depending on whether the object is within the Collection |
|
168 | - * based on the supplied $identifier and type |
|
169 | - * |
|
170 | - * @param mixed $identifier |
|
171 | - * @param string $type |
|
172 | - * @return JavascriptAsset|StylesheetAsset |
|
173 | - * @since $VID:$ |
|
174 | - */ |
|
175 | - public function getAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
176 | - { |
|
177 | - $this->rewind(); |
|
178 | - while ($this->valid()) { |
|
179 | - if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
180 | - /** @var JavascriptAsset|StylesheetAsset $object */ |
|
181 | - $object = $this->current(); |
|
182 | - $this->rewind(); |
|
183 | - return $object; |
|
184 | - } |
|
185 | - $this->next(); |
|
186 | - } |
|
187 | - return null; |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * has |
|
193 | - * returns TRUE or FALSE |
|
194 | - * depending on whether the Stylesheet Asset is within the Collection |
|
195 | - * based on the supplied $identifier |
|
196 | - * |
|
197 | - * @param mixed $identifier |
|
198 | - * @return StylesheetAsset |
|
199 | - * @since $VID:$ |
|
200 | - */ |
|
201 | - public function getStylesheetAsset($identifier) |
|
202 | - { |
|
203 | - return $this->getAssetOfType($identifier, Asset::TYPE_CSS); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * has |
|
209 | - * returns TRUE or FALSE |
|
210 | - * depending on whether the Javascript Asset is within the Collection |
|
211 | - * based on the supplied $identifier |
|
212 | - * |
|
213 | - * @param mixed $identifier |
|
214 | - * @return JavascriptAsset |
|
215 | - * @since $VID:$ |
|
216 | - */ |
|
217 | - public function getJavascriptAsset($identifier) |
|
218 | - { |
|
219 | - return $this->getAssetOfType($identifier, Asset::TYPE_JS); |
|
220 | - } |
|
24 | + /** |
|
25 | + * AssetCollection constructor |
|
26 | + * |
|
27 | + * @throws InvalidInterfaceException |
|
28 | + */ |
|
29 | + public function __construct() |
|
30 | + { |
|
31 | + parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * @return StylesheetAsset[] |
|
37 | + * @since 4.9.62.p |
|
38 | + */ |
|
39 | + public function getStylesheetAssets() |
|
40 | + { |
|
41 | + return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @return JavascriptAsset[] |
|
47 | + * @since 4.9.62.p |
|
48 | + */ |
|
49 | + public function getJavascriptAssets() |
|
50 | + { |
|
51 | + return $this->getAssetsOfType(Asset::TYPE_JS); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @return ManifestFile[] |
|
57 | + * @since 4.9.62.p |
|
58 | + */ |
|
59 | + public function getManifestFiles() |
|
60 | + { |
|
61 | + return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @param $type |
|
67 | + * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[] |
|
68 | + * @since 4.9.62.p |
|
69 | + */ |
|
70 | + protected function getAssetsOfType($type) |
|
71 | + { |
|
72 | + $files = array(); |
|
73 | + $this->rewind(); |
|
74 | + while ($this->valid()) { |
|
75 | + /** @var Asset $asset */ |
|
76 | + $asset = $this->current(); |
|
77 | + if ($asset->type() === $type) { |
|
78 | + $files[ $asset->handle() ] = $asset; |
|
79 | + } |
|
80 | + $this->next(); |
|
81 | + } |
|
82 | + $this->rewind(); |
|
83 | + return $files; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @return JavascriptAsset[] |
|
89 | + * @since 4.9.62.p |
|
90 | + */ |
|
91 | + public function getJavascriptAssetsWithData() |
|
92 | + { |
|
93 | + $files = array(); |
|
94 | + $this->rewind(); |
|
95 | + while ($this->valid()) { |
|
96 | + /** @var JavascriptAsset $asset */ |
|
97 | + $asset = $this->current(); |
|
98 | + if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
|
99 | + $files[ $asset->handle() ] = $asset; |
|
100 | + } |
|
101 | + $this->next(); |
|
102 | + } |
|
103 | + $this->rewind(); |
|
104 | + return $files; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * has |
|
110 | + * returns TRUE or FALSE |
|
111 | + * depending on whether the object is within the Collection |
|
112 | + * based on the supplied $identifier and type |
|
113 | + * |
|
114 | + * @param mixed $identifier |
|
115 | + * @param string $type |
|
116 | + * @return bool |
|
117 | + * @since $VID:$ |
|
118 | + */ |
|
119 | + public function hasAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
120 | + { |
|
121 | + $this->rewind(); |
|
122 | + while ($this->valid()) { |
|
123 | + if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
124 | + $this->rewind(); |
|
125 | + return true; |
|
126 | + } |
|
127 | + $this->next(); |
|
128 | + } |
|
129 | + return false; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * has |
|
135 | + * returns TRUE or FALSE |
|
136 | + * depending on whether the Stylesheet Asset is within the Collection |
|
137 | + * based on the supplied $identifier |
|
138 | + * |
|
139 | + * @param mixed $identifier |
|
140 | + * @return bool |
|
141 | + * @since $VID:$ |
|
142 | + */ |
|
143 | + public function hasStylesheetAsset($identifier) |
|
144 | + { |
|
145 | + return $this->hasAssetOfType($identifier, Asset::TYPE_CSS); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * has |
|
151 | + * returns TRUE or FALSE |
|
152 | + * depending on whether the Javascript Asset is within the Collection |
|
153 | + * based on the supplied $identifier |
|
154 | + * |
|
155 | + * @param mixed $identifier |
|
156 | + * @return bool |
|
157 | + * @since $VID:$ |
|
158 | + */ |
|
159 | + public function hasJavascriptAsset($identifier) |
|
160 | + { |
|
161 | + return $this->hasAssetOfType($identifier, Asset::TYPE_JS); |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * has |
|
166 | + * returns TRUE or FALSE |
|
167 | + * depending on whether the object is within the Collection |
|
168 | + * based on the supplied $identifier and type |
|
169 | + * |
|
170 | + * @param mixed $identifier |
|
171 | + * @param string $type |
|
172 | + * @return JavascriptAsset|StylesheetAsset |
|
173 | + * @since $VID:$ |
|
174 | + */ |
|
175 | + public function getAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
176 | + { |
|
177 | + $this->rewind(); |
|
178 | + while ($this->valid()) { |
|
179 | + if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
180 | + /** @var JavascriptAsset|StylesheetAsset $object */ |
|
181 | + $object = $this->current(); |
|
182 | + $this->rewind(); |
|
183 | + return $object; |
|
184 | + } |
|
185 | + $this->next(); |
|
186 | + } |
|
187 | + return null; |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * has |
|
193 | + * returns TRUE or FALSE |
|
194 | + * depending on whether the Stylesheet Asset is within the Collection |
|
195 | + * based on the supplied $identifier |
|
196 | + * |
|
197 | + * @param mixed $identifier |
|
198 | + * @return StylesheetAsset |
|
199 | + * @since $VID:$ |
|
200 | + */ |
|
201 | + public function getStylesheetAsset($identifier) |
|
202 | + { |
|
203 | + return $this->getAssetOfType($identifier, Asset::TYPE_CSS); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * has |
|
209 | + * returns TRUE or FALSE |
|
210 | + * depending on whether the Javascript Asset is within the Collection |
|
211 | + * based on the supplied $identifier |
|
212 | + * |
|
213 | + * @param mixed $identifier |
|
214 | + * @return JavascriptAsset |
|
215 | + * @since $VID:$ |
|
216 | + */ |
|
217 | + public function getJavascriptAsset($identifier) |
|
218 | + { |
|
219 | + return $this->getAssetOfType($identifier, Asset::TYPE_JS); |
|
220 | + } |
|
221 | 221 | } |
@@ -14,238 +14,238 @@ |
||
14 | 14 | */ |
15 | 15 | class I18nRegistry |
16 | 16 | { |
17 | - /** |
|
18 | - * @var DomainInterface |
|
19 | - */ |
|
20 | - private $domain; |
|
21 | - |
|
22 | - /** |
|
23 | - * Will hold all registered i18n scripts. Prevents script handles from being registered more than once. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - private $registered_i18n = array(); |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * Used to hold queued translations for the chunks loading in a view. |
|
32 | - * |
|
33 | - * @var array |
|
34 | - */ |
|
35 | - private $queued_handle_translations = array(); |
|
36 | - |
|
37 | - /** |
|
38 | - * Used to track script handles queued for adding translation strings as inline data in the dom. |
|
39 | - * |
|
40 | - * @var array |
|
41 | - */ |
|
42 | - private $queued_scripts = array(); |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to |
|
47 | - * translation strings. |
|
48 | - * |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - private $i18n_map; |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * I18nRegistry constructor. |
|
56 | - * |
|
57 | - * @param array() $i18n_map An array of script handle names and the strings translated for those handles. If not |
|
58 | - * provided, the class will look for map in root of plugin with filename of |
|
59 | - * 'translation-map.json'. |
|
60 | - * @param DomainInterface $domain |
|
61 | - */ |
|
62 | - public function __construct(array $i18n_map = array(), DomainInterface $domain) |
|
63 | - { |
|
64 | - $this->domain = $domain; |
|
65 | - $this->setI18nMap($i18n_map); |
|
66 | - add_filter('print_scripts_array', array($this, 'queueI18n')); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Used to register a script that has i18n strings for its $handle |
|
72 | - * |
|
73 | - * @param string $handle The script handle reference. |
|
74 | - * @param string $domain The i18n domain for the strings. |
|
75 | - */ |
|
76 | - public function registerScriptI18n($handle, $domain = 'event_espresso') |
|
77 | - { |
|
78 | - if(! isset($this->registered_i18n[$handle])) { |
|
79 | - $this->registered_i18n[ $handle ] = 1; |
|
80 | - $this->queued_scripts[ $handle ] = $domain; |
|
81 | - } |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data. |
|
88 | - * |
|
89 | - * @param array $handles Array of registered script handles. |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public function queueI18n(array $handles) |
|
93 | - { |
|
94 | - if (empty($this->queued_scripts)) { |
|
95 | - return $handles; |
|
96 | - } |
|
97 | - foreach ($handles as $handle) { |
|
98 | - $this->queueI18nTranslationsForHandle($handle); |
|
99 | - } |
|
100 | - if ($this->queued_handle_translations) { |
|
101 | - foreach ($this->queued_handle_translations as $handle => $translations_for_domain) { |
|
102 | - $this->registerInlineScript( |
|
103 | - $handle, |
|
104 | - $translations_for_domain['translations'], |
|
105 | - $translations_for_domain['domain'] |
|
106 | - ); |
|
107 | - } |
|
108 | - } |
|
109 | - return $handles; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * Registers inline script with translations for given handle and domain. |
|
115 | - * |
|
116 | - * @param string $handle Handle used to register javascript file containing translations. |
|
117 | - * @param array $translations Array of string translations. |
|
118 | - * @param string $domain Domain for translations. If left empty then strings are registered with the default |
|
119 | - * domain for the javascript. |
|
120 | - */ |
|
121 | - protected function registerInlineScript($handle, array $translations, $domain) |
|
122 | - { |
|
123 | - $script = $domain ? |
|
124 | - 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
125 | - 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
126 | - wp_add_inline_script($handle, $script, 'before'); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Queues up the translation strings for the given handle. |
|
132 | - * |
|
133 | - * @param string $handle The script handle being queued up. |
|
134 | - */ |
|
135 | - private function queueI18nTranslationsForHandle($handle) |
|
136 | - { |
|
137 | - if (isset($this->queued_scripts[$handle])) { |
|
138 | - $domain = $this->queued_scripts[$handle]; |
|
139 | - $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain); |
|
140 | - if (count($translations) > 0) { |
|
141 | - $this->queued_handle_translations[$handle] = array( |
|
142 | - 'domain' => $domain, |
|
143 | - 'translations' => $translations, |
|
144 | - ); |
|
145 | - } |
|
146 | - unset($this->queued_scripts[$handle]); |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * Sets the internal i18n_map property. |
|
153 | - * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map. |
|
154 | - * |
|
155 | - * @param array $i18n_map If provided, an array of translation strings indexed by script handle names they |
|
156 | - * correspond to. |
|
157 | - */ |
|
158 | - private function setI18nMap(array $i18n_map) |
|
159 | - { |
|
160 | - if (empty($i18n_map)) { |
|
161 | - $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
162 | - ? json_decode( |
|
163 | - file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
164 | - true |
|
165 | - ) |
|
166 | - : array(); |
|
167 | - } |
|
168 | - $this->i18n_map = $i18n_map; |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * Get the jed locale data for a given $handle and domain |
|
174 | - * |
|
175 | - * @param string $handle The name for the script handle we want strings returned for. |
|
176 | - * @param string $domain The i18n domain. |
|
177 | - * @return array |
|
178 | - */ |
|
179 | - protected function getJedLocaleDataForDomainAndChunk($handle, $domain) |
|
180 | - { |
|
181 | - $translations = $this->getJedLocaleData($domain); |
|
182 | - // get index for adding back after extracting strings for this $chunk. |
|
183 | - $index = $translations['']; |
|
184 | - $translations = $this->getLocaleDataMatchingMap( |
|
185 | - $this->getOriginalStringsForHandleFromMap($handle), |
|
186 | - $translations |
|
187 | - ); |
|
188 | - $translations[''] = $index; |
|
189 | - return $translations; |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * Get locale data for given strings from given translations |
|
195 | - * |
|
196 | - * @param array $string_set This is the subset of strings (msgIds) we want to extract from the translations array. |
|
197 | - * @param array $translations Translation data to extra strings from. |
|
198 | - * @return array |
|
199 | - */ |
|
200 | - protected function getLocaleDataMatchingMap(array $string_set, array $translations) |
|
201 | - { |
|
202 | - if (empty($string_set)) { |
|
203 | - return array(); |
|
204 | - } |
|
205 | - // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are |
|
206 | - // slashed also filter falsey values. |
|
207 | - $string_set = array_unique(array_filter(wp_slash($string_set))); |
|
208 | - return array_intersect_key($translations, array_flip($string_set)); |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * Get original strings to translate for the given chunk from the map |
|
214 | - * |
|
215 | - * @param string $handle The script handle name to get strings from the map for. |
|
216 | - * @return array |
|
217 | - */ |
|
218 | - protected function getOriginalStringsForHandleFromMap($handle) |
|
219 | - { |
|
220 | - return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array(); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * Returns Jed-formatted localization data. |
|
226 | - * |
|
227 | - * @param string $domain Translation domain. |
|
228 | - * @return array |
|
229 | - */ |
|
230 | - private function getJedLocaleData($domain) |
|
231 | - { |
|
232 | - $translations = get_translations_for_domain($domain); |
|
233 | - |
|
234 | - $locale = array( |
|
235 | - '' => array( |
|
236 | - 'domain' => $domain, |
|
237 | - 'lang' => is_admin() ? get_user_locale() : get_locale(), |
|
238 | - ), |
|
239 | - ); |
|
240 | - |
|
241 | - if (! empty($translations->headers['Plural-Forms'])) { |
|
242 | - $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
243 | - } |
|
244 | - |
|
245 | - foreach ($translations->entries as $msgid => $entry) { |
|
246 | - $locale[$msgid] = $entry->translations; |
|
247 | - } |
|
248 | - |
|
249 | - return $locale; |
|
250 | - } |
|
17 | + /** |
|
18 | + * @var DomainInterface |
|
19 | + */ |
|
20 | + private $domain; |
|
21 | + |
|
22 | + /** |
|
23 | + * Will hold all registered i18n scripts. Prevents script handles from being registered more than once. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + private $registered_i18n = array(); |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * Used to hold queued translations for the chunks loading in a view. |
|
32 | + * |
|
33 | + * @var array |
|
34 | + */ |
|
35 | + private $queued_handle_translations = array(); |
|
36 | + |
|
37 | + /** |
|
38 | + * Used to track script handles queued for adding translation strings as inline data in the dom. |
|
39 | + * |
|
40 | + * @var array |
|
41 | + */ |
|
42 | + private $queued_scripts = array(); |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to |
|
47 | + * translation strings. |
|
48 | + * |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + private $i18n_map; |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * I18nRegistry constructor. |
|
56 | + * |
|
57 | + * @param array() $i18n_map An array of script handle names and the strings translated for those handles. If not |
|
58 | + * provided, the class will look for map in root of plugin with filename of |
|
59 | + * 'translation-map.json'. |
|
60 | + * @param DomainInterface $domain |
|
61 | + */ |
|
62 | + public function __construct(array $i18n_map = array(), DomainInterface $domain) |
|
63 | + { |
|
64 | + $this->domain = $domain; |
|
65 | + $this->setI18nMap($i18n_map); |
|
66 | + add_filter('print_scripts_array', array($this, 'queueI18n')); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Used to register a script that has i18n strings for its $handle |
|
72 | + * |
|
73 | + * @param string $handle The script handle reference. |
|
74 | + * @param string $domain The i18n domain for the strings. |
|
75 | + */ |
|
76 | + public function registerScriptI18n($handle, $domain = 'event_espresso') |
|
77 | + { |
|
78 | + if(! isset($this->registered_i18n[$handle])) { |
|
79 | + $this->registered_i18n[ $handle ] = 1; |
|
80 | + $this->queued_scripts[ $handle ] = $domain; |
|
81 | + } |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data. |
|
88 | + * |
|
89 | + * @param array $handles Array of registered script handles. |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public function queueI18n(array $handles) |
|
93 | + { |
|
94 | + if (empty($this->queued_scripts)) { |
|
95 | + return $handles; |
|
96 | + } |
|
97 | + foreach ($handles as $handle) { |
|
98 | + $this->queueI18nTranslationsForHandle($handle); |
|
99 | + } |
|
100 | + if ($this->queued_handle_translations) { |
|
101 | + foreach ($this->queued_handle_translations as $handle => $translations_for_domain) { |
|
102 | + $this->registerInlineScript( |
|
103 | + $handle, |
|
104 | + $translations_for_domain['translations'], |
|
105 | + $translations_for_domain['domain'] |
|
106 | + ); |
|
107 | + } |
|
108 | + } |
|
109 | + return $handles; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * Registers inline script with translations for given handle and domain. |
|
115 | + * |
|
116 | + * @param string $handle Handle used to register javascript file containing translations. |
|
117 | + * @param array $translations Array of string translations. |
|
118 | + * @param string $domain Domain for translations. If left empty then strings are registered with the default |
|
119 | + * domain for the javascript. |
|
120 | + */ |
|
121 | + protected function registerInlineScript($handle, array $translations, $domain) |
|
122 | + { |
|
123 | + $script = $domain ? |
|
124 | + 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
125 | + 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
126 | + wp_add_inline_script($handle, $script, 'before'); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Queues up the translation strings for the given handle. |
|
132 | + * |
|
133 | + * @param string $handle The script handle being queued up. |
|
134 | + */ |
|
135 | + private function queueI18nTranslationsForHandle($handle) |
|
136 | + { |
|
137 | + if (isset($this->queued_scripts[$handle])) { |
|
138 | + $domain = $this->queued_scripts[$handle]; |
|
139 | + $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain); |
|
140 | + if (count($translations) > 0) { |
|
141 | + $this->queued_handle_translations[$handle] = array( |
|
142 | + 'domain' => $domain, |
|
143 | + 'translations' => $translations, |
|
144 | + ); |
|
145 | + } |
|
146 | + unset($this->queued_scripts[$handle]); |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * Sets the internal i18n_map property. |
|
153 | + * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map. |
|
154 | + * |
|
155 | + * @param array $i18n_map If provided, an array of translation strings indexed by script handle names they |
|
156 | + * correspond to. |
|
157 | + */ |
|
158 | + private function setI18nMap(array $i18n_map) |
|
159 | + { |
|
160 | + if (empty($i18n_map)) { |
|
161 | + $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
162 | + ? json_decode( |
|
163 | + file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
164 | + true |
|
165 | + ) |
|
166 | + : array(); |
|
167 | + } |
|
168 | + $this->i18n_map = $i18n_map; |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * Get the jed locale data for a given $handle and domain |
|
174 | + * |
|
175 | + * @param string $handle The name for the script handle we want strings returned for. |
|
176 | + * @param string $domain The i18n domain. |
|
177 | + * @return array |
|
178 | + */ |
|
179 | + protected function getJedLocaleDataForDomainAndChunk($handle, $domain) |
|
180 | + { |
|
181 | + $translations = $this->getJedLocaleData($domain); |
|
182 | + // get index for adding back after extracting strings for this $chunk. |
|
183 | + $index = $translations['']; |
|
184 | + $translations = $this->getLocaleDataMatchingMap( |
|
185 | + $this->getOriginalStringsForHandleFromMap($handle), |
|
186 | + $translations |
|
187 | + ); |
|
188 | + $translations[''] = $index; |
|
189 | + return $translations; |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * Get locale data for given strings from given translations |
|
195 | + * |
|
196 | + * @param array $string_set This is the subset of strings (msgIds) we want to extract from the translations array. |
|
197 | + * @param array $translations Translation data to extra strings from. |
|
198 | + * @return array |
|
199 | + */ |
|
200 | + protected function getLocaleDataMatchingMap(array $string_set, array $translations) |
|
201 | + { |
|
202 | + if (empty($string_set)) { |
|
203 | + return array(); |
|
204 | + } |
|
205 | + // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are |
|
206 | + // slashed also filter falsey values. |
|
207 | + $string_set = array_unique(array_filter(wp_slash($string_set))); |
|
208 | + return array_intersect_key($translations, array_flip($string_set)); |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * Get original strings to translate for the given chunk from the map |
|
214 | + * |
|
215 | + * @param string $handle The script handle name to get strings from the map for. |
|
216 | + * @return array |
|
217 | + */ |
|
218 | + protected function getOriginalStringsForHandleFromMap($handle) |
|
219 | + { |
|
220 | + return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array(); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * Returns Jed-formatted localization data. |
|
226 | + * |
|
227 | + * @param string $domain Translation domain. |
|
228 | + * @return array |
|
229 | + */ |
|
230 | + private function getJedLocaleData($domain) |
|
231 | + { |
|
232 | + $translations = get_translations_for_domain($domain); |
|
233 | + |
|
234 | + $locale = array( |
|
235 | + '' => array( |
|
236 | + 'domain' => $domain, |
|
237 | + 'lang' => is_admin() ? get_user_locale() : get_locale(), |
|
238 | + ), |
|
239 | + ); |
|
240 | + |
|
241 | + if (! empty($translations->headers['Plural-Forms'])) { |
|
242 | + $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
243 | + } |
|
244 | + |
|
245 | + foreach ($translations->entries as $msgid => $entry) { |
|
246 | + $locale[$msgid] = $entry->translations; |
|
247 | + } |
|
248 | + |
|
249 | + return $locale; |
|
250 | + } |
|
251 | 251 | } |
252 | 252 | \ No newline at end of file |
@@ -21,142 +21,142 @@ |
||
21 | 21 | abstract class AssetManager implements AssetManagerInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var AssetCollection $assets |
|
26 | - */ |
|
27 | - protected $assets; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var DomainInterface |
|
31 | - */ |
|
32 | - protected $domain; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var Registry $registry |
|
36 | - */ |
|
37 | - protected $registry; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * AssetRegister constructor. |
|
42 | - * |
|
43 | - * @param DomainInterface $domain |
|
44 | - * @param AssetCollection $assets |
|
45 | - * @param Registry $registry |
|
46 | - */ |
|
47 | - public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
48 | - { |
|
49 | - $this->domain = $domain; |
|
50 | - $this->assets = $assets; |
|
51 | - $this->registry = $registry; |
|
52 | - add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
53 | - add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
54 | - add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
55 | - add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @return void |
|
61 | - * @throws DuplicateCollectionIdentifierException |
|
62 | - * @throws InvalidDataTypeException |
|
63 | - * @throws InvalidEntityException |
|
64 | - * @since 4.9.62.p |
|
65 | - */ |
|
66 | - public function addManifestFile() |
|
67 | - { |
|
68 | - // if a manifest file has already been added for this domain, then just return that one |
|
69 | - if ($this->assets->has($this->domain->assetNamespace())) { |
|
70 | - return; |
|
71 | - } |
|
72 | - $asset = new ManifestFile($this->domain); |
|
73 | - $this->assets->add($asset, $this->domain->assetNamespace()); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * @return ManifestFile[] |
|
79 | - * @since 4.9.62.p |
|
80 | - */ |
|
81 | - public function getManifestFile() |
|
82 | - { |
|
83 | - return $this->assets->getManifestFiles(); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @param string $handle |
|
89 | - * @param string $source |
|
90 | - * @param array $dependencies |
|
91 | - * @param bool $load_in_footer |
|
92 | - * @return JavascriptAsset |
|
93 | - * @throws DuplicateCollectionIdentifierException |
|
94 | - * @throws InvalidDataTypeException |
|
95 | - * @throws InvalidEntityException |
|
96 | - * @since 4.9.62.p |
|
97 | - */ |
|
98 | - public function addJavascript( |
|
99 | - $handle, |
|
100 | - $source, |
|
101 | - array $dependencies = array(), |
|
102 | - $load_in_footer = true |
|
103 | - ) { |
|
104 | - $asset = new JavascriptAsset( |
|
105 | - $handle, |
|
106 | - $source, |
|
107 | - $dependencies, |
|
108 | - $load_in_footer, |
|
109 | - $this->domain |
|
110 | - ); |
|
111 | - $this->assets->add($asset, $handle); |
|
112 | - return $asset; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @param string $handle |
|
119 | - * @param string $source |
|
120 | - * @param array $dependencies |
|
121 | - * @param string $media |
|
122 | - * @return StylesheetAsset |
|
123 | - * @throws DuplicateCollectionIdentifierException |
|
124 | - * @throws InvalidDataTypeException |
|
125 | - * @throws InvalidEntityException |
|
126 | - * @since 4.9.62.p |
|
127 | - */ |
|
128 | - public function addStylesheet( |
|
129 | - $handle, |
|
130 | - $source, |
|
131 | - array $dependencies = array(), |
|
132 | - $media = 'all' |
|
133 | - ) { |
|
134 | - $asset = new StylesheetAsset( |
|
135 | - $handle, |
|
136 | - $source, |
|
137 | - $dependencies, |
|
138 | - $this->domain, |
|
139 | - $media |
|
140 | - ); |
|
141 | - $this->assets->add($asset, $handle); |
|
142 | - return $asset; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @param string $handle |
|
148 | - * @return bool |
|
149 | - * @since 4.9.62.p |
|
150 | - */ |
|
151 | - public function enqueueAsset($handle) |
|
152 | - { |
|
153 | - if ($this->assets->has($handle)) { |
|
154 | - $asset = $this->assets->get($handle); |
|
155 | - if ($asset->isRegistered()) { |
|
156 | - $asset->enqueueAsset(); |
|
157 | - return true; |
|
158 | - } |
|
159 | - } |
|
160 | - return false; |
|
161 | - } |
|
24 | + /** |
|
25 | + * @var AssetCollection $assets |
|
26 | + */ |
|
27 | + protected $assets; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var DomainInterface |
|
31 | + */ |
|
32 | + protected $domain; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var Registry $registry |
|
36 | + */ |
|
37 | + protected $registry; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * AssetRegister constructor. |
|
42 | + * |
|
43 | + * @param DomainInterface $domain |
|
44 | + * @param AssetCollection $assets |
|
45 | + * @param Registry $registry |
|
46 | + */ |
|
47 | + public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
48 | + { |
|
49 | + $this->domain = $domain; |
|
50 | + $this->assets = $assets; |
|
51 | + $this->registry = $registry; |
|
52 | + add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
53 | + add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
54 | + add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
55 | + add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @return void |
|
61 | + * @throws DuplicateCollectionIdentifierException |
|
62 | + * @throws InvalidDataTypeException |
|
63 | + * @throws InvalidEntityException |
|
64 | + * @since 4.9.62.p |
|
65 | + */ |
|
66 | + public function addManifestFile() |
|
67 | + { |
|
68 | + // if a manifest file has already been added for this domain, then just return that one |
|
69 | + if ($this->assets->has($this->domain->assetNamespace())) { |
|
70 | + return; |
|
71 | + } |
|
72 | + $asset = new ManifestFile($this->domain); |
|
73 | + $this->assets->add($asset, $this->domain->assetNamespace()); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * @return ManifestFile[] |
|
79 | + * @since 4.9.62.p |
|
80 | + */ |
|
81 | + public function getManifestFile() |
|
82 | + { |
|
83 | + return $this->assets->getManifestFiles(); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @param string $handle |
|
89 | + * @param string $source |
|
90 | + * @param array $dependencies |
|
91 | + * @param bool $load_in_footer |
|
92 | + * @return JavascriptAsset |
|
93 | + * @throws DuplicateCollectionIdentifierException |
|
94 | + * @throws InvalidDataTypeException |
|
95 | + * @throws InvalidEntityException |
|
96 | + * @since 4.9.62.p |
|
97 | + */ |
|
98 | + public function addJavascript( |
|
99 | + $handle, |
|
100 | + $source, |
|
101 | + array $dependencies = array(), |
|
102 | + $load_in_footer = true |
|
103 | + ) { |
|
104 | + $asset = new JavascriptAsset( |
|
105 | + $handle, |
|
106 | + $source, |
|
107 | + $dependencies, |
|
108 | + $load_in_footer, |
|
109 | + $this->domain |
|
110 | + ); |
|
111 | + $this->assets->add($asset, $handle); |
|
112 | + return $asset; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @param string $handle |
|
119 | + * @param string $source |
|
120 | + * @param array $dependencies |
|
121 | + * @param string $media |
|
122 | + * @return StylesheetAsset |
|
123 | + * @throws DuplicateCollectionIdentifierException |
|
124 | + * @throws InvalidDataTypeException |
|
125 | + * @throws InvalidEntityException |
|
126 | + * @since 4.9.62.p |
|
127 | + */ |
|
128 | + public function addStylesheet( |
|
129 | + $handle, |
|
130 | + $source, |
|
131 | + array $dependencies = array(), |
|
132 | + $media = 'all' |
|
133 | + ) { |
|
134 | + $asset = new StylesheetAsset( |
|
135 | + $handle, |
|
136 | + $source, |
|
137 | + $dependencies, |
|
138 | + $this->domain, |
|
139 | + $media |
|
140 | + ); |
|
141 | + $this->assets->add($asset, $handle); |
|
142 | + return $asset; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @param string $handle |
|
148 | + * @return bool |
|
149 | + * @since 4.9.62.p |
|
150 | + */ |
|
151 | + public function enqueueAsset($handle) |
|
152 | + { |
|
153 | + if ($this->assets->has($handle)) { |
|
154 | + $asset = $this->assets->get($handle); |
|
155 | + if ($asset->isRegistered()) { |
|
156 | + $asset->enqueueAsset(); |
|
157 | + return true; |
|
158 | + } |
|
159 | + } |
|
160 | + return false; |
|
161 | + } |
|
162 | 162 | } |
@@ -20,72 +20,72 @@ |
||
20 | 20 | interface AssetManagerInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @since 4.9.62.p |
|
25 | - */ |
|
26 | - public function addAssets(); |
|
23 | + /** |
|
24 | + * @since 4.9.62.p |
|
25 | + */ |
|
26 | + public function addAssets(); |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @return ManifestFile |
|
31 | - * @throws DuplicateCollectionIdentifierException |
|
32 | - * @throws InvalidDataTypeException |
|
33 | - * @throws InvalidEntityException |
|
34 | - * @since 4.9.62.p |
|
35 | - */ |
|
36 | - public function addManifestFile(); |
|
29 | + /** |
|
30 | + * @return ManifestFile |
|
31 | + * @throws DuplicateCollectionIdentifierException |
|
32 | + * @throws InvalidDataTypeException |
|
33 | + * @throws InvalidEntityException |
|
34 | + * @since 4.9.62.p |
|
35 | + */ |
|
36 | + public function addManifestFile(); |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return ManifestFile[] |
|
41 | - * @since 4.9.62.p |
|
42 | - */ |
|
43 | - public function getManifestFile(); |
|
39 | + /** |
|
40 | + * @return ManifestFile[] |
|
41 | + * @since 4.9.62.p |
|
42 | + */ |
|
43 | + public function getManifestFile(); |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @param string $handle |
|
48 | - * @param string $source |
|
49 | - * @param array $dependencies |
|
50 | - * @param bool $load_in_footer |
|
51 | - * @return JavascriptAsset |
|
52 | - * @throws DuplicateCollectionIdentifierException |
|
53 | - * @throws InvalidDataTypeException |
|
54 | - * @throws InvalidEntityException |
|
55 | - * @since 4.9.62.p |
|
56 | - */ |
|
57 | - public function addJavascript( |
|
58 | - $handle, |
|
59 | - $source, |
|
60 | - array $dependencies = array(), |
|
61 | - $load_in_footer = true |
|
62 | - ); |
|
46 | + /** |
|
47 | + * @param string $handle |
|
48 | + * @param string $source |
|
49 | + * @param array $dependencies |
|
50 | + * @param bool $load_in_footer |
|
51 | + * @return JavascriptAsset |
|
52 | + * @throws DuplicateCollectionIdentifierException |
|
53 | + * @throws InvalidDataTypeException |
|
54 | + * @throws InvalidEntityException |
|
55 | + * @since 4.9.62.p |
|
56 | + */ |
|
57 | + public function addJavascript( |
|
58 | + $handle, |
|
59 | + $source, |
|
60 | + array $dependencies = array(), |
|
61 | + $load_in_footer = true |
|
62 | + ); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @param string $handle |
|
68 | - * @param string $source |
|
69 | - * @param array $dependencies |
|
70 | - * @param string $media |
|
71 | - * @return StylesheetAsset |
|
72 | - * @throws DuplicateCollectionIdentifierException |
|
73 | - * @throws InvalidDataTypeException |
|
74 | - * @throws InvalidEntityException |
|
75 | - * @since 4.9.62.p |
|
76 | - */ |
|
77 | - public function addStylesheet( |
|
78 | - $handle, |
|
79 | - $source, |
|
80 | - array $dependencies = array(), |
|
81 | - $media = 'all' |
|
82 | - ); |
|
66 | + /** |
|
67 | + * @param string $handle |
|
68 | + * @param string $source |
|
69 | + * @param array $dependencies |
|
70 | + * @param string $media |
|
71 | + * @return StylesheetAsset |
|
72 | + * @throws DuplicateCollectionIdentifierException |
|
73 | + * @throws InvalidDataTypeException |
|
74 | + * @throws InvalidEntityException |
|
75 | + * @since 4.9.62.p |
|
76 | + */ |
|
77 | + public function addStylesheet( |
|
78 | + $handle, |
|
79 | + $source, |
|
80 | + array $dependencies = array(), |
|
81 | + $media = 'all' |
|
82 | + ); |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @param string $handle |
|
87 | - * @return bool |
|
88 | - * @since 4.9.62.p |
|
89 | - */ |
|
90 | - public function enqueueAsset($handle); |
|
85 | + /** |
|
86 | + * @param string $handle |
|
87 | + * @return bool |
|
88 | + * @since 4.9.62.p |
|
89 | + */ |
|
90 | + public function enqueueAsset($handle); |
|
91 | 91 | } |
@@ -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.015'); |
|
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.015'); |
|
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 | } |