PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.14.0
GiveWP – Donation Plugin and Fundraising Platform v4.14.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
← All changes | src/Framework/EnqueueScript.php +53 -0 2.31.04.14.0 View file →
@@ -128,8 +128,9 @@
128 128 return $this;
129 129 }
130 130
131 131 /**
132 + * @since 4.0.0 added registration of style sheets generated by wordpress/scripts
132 133 * @since 2.19.6
133 134 * @return $this
134 135 */
135 136 public function register()
@@ -136,8 +137,32 @@
136 137 {
137 138 $scriptUrl = $this->pluginDirUrl . $this->relativeScriptPath;
138 139 $scriptAsset = $this->getAssetFileData();
139 140
141 + $stylePath = $this->getStylePath();
142 + $styleUrl = $this->getStyleUrl();
143 +
144 + if (file_exists($stylePath)) {
145 + wp_register_style(
146 + $this->scriptId,
147 + $styleUrl,
148 + [],
149 + $scriptAsset['version']
150 + );
151 + }
152 +
153 + $stylePathIndex = $this->getStylePath('style-');
154 + $styleUrlIndex = $this->getStyleUrl('style-');
155 +
156 + if (file_exists($stylePathIndex)) {
157 + wp_register_style(
158 + 'style-' . $this->scriptId,
159 + $styleUrlIndex,
160 + [],
161 + $scriptAsset['version']
162 + );
163 + }
164 +
140 165 wp_register_script(
141 166 $this->scriptId,
142 167 $scriptUrl,
143 168 $scriptAsset['dependencies'],
@@ -201,10 +226,19 @@
201 226 {
202 227 if (!wp_script_is($this->scriptId, 'registered')) {
203 228 $this->register();
204 229 }
230 +
205 231 wp_enqueue_script($this->scriptId);
206 232
233 + if (wp_style_is($this->scriptId, 'registered')) {
234 + wp_enqueue_style($this->scriptId);
235 + }
236 +
237 + if (wp_style_is('style-' . $this->scriptId, 'registered')) {
238 + wp_enqueue_style('style-' . $this->scriptId);
239 + }
240 +
207 241 return $this;
208 242 }
209 243
210 244 /**
@@ -234,7 +268,26 @@
234 268 $scriptAsset['dependencies'] = array_merge($this->scriptDependencies, $scriptAsset['dependencies']);
235 269 }
236 270
237 271 return $scriptAsset;
272 + }
273 +
274 + /**
275 + * @since 4.0.0
276 + */
277 + public function getStylePath($prefix = ''): string
278 + {
279 + return trailingslashit(dirname($this->absoluteScriptPath))
280 + . trim($prefix . basename($this->relativeScriptPath, '.js')) . '.css';
281 + }
282 +
283 + /**
284 + * @since 4.0.0
285 + */
286 + public function getStyleUrl($prefix = ''): string
287 + {
288 + $cssFileName = trim($prefix . basename($this->relativeScriptPath, '.js')) . '.css';
289 +
290 + return $this->pluginDirUrl . str_replace(basename($this->relativeScriptPath), $cssFileName, $this->relativeScriptPath);
238 291 }
239 292 }
240 293