PluginProbe
Lawwwing | Textos legales web y Banner de cookies / trunk
Lawwwing | Textos legales web y Banner de cookies vtrunk
1.5.3 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.26 1.0.27 1.0.28 1.0.29 1.0.3 All 59 releases
ibamu / installation / install.php

install.php in Lawwwing | Textos legales web y Banner de cookies trunk, at installation/install.php

43 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Enqueue and customize Lawwwing cookie widget script
4 */
5
6 // Hook to enqueue the Lawwwing script
7 add_action('wp_enqueue_scripts', 'lawwwing_enqueue_script', 1);
8 function lawwwing_enqueue_script() {
9 $plugin_id = lawwwing_get_plugin_id();
10 if (!$plugin_id) return;
11
12 $script_url = sprintf(
13 'https://cdn.lawwwing.com/widgets/current/%s/cookie-widget.min.js', esc_attr($plugin_id)
14 );
15
16 wp_enqueue_script('lawwwing-plugin', $script_url, [], LW_PLUGIN_VERSION, false);
17 }
18
19 // Hook to add data-lwid attribute to the script tag
20 add_filter('script_loader_tag', 'lawwwing_add_data_attribute', 10, 2);
21 function lawwwing_add_data_attribute($tag, $handle) {
22 if ($handle !== 'lawwwing-plugin') {
23 return $tag;
24 }
25
26 $plugin_id = lawwwing_get_plugin_id();
27 if (!$plugin_id) return $tag;
28
29 return str_replace(
30 ' src',
31 sprintf(' data-lwid="%s" src', esc_attr($plugin_id)),
32 $tag
33 );
34 }
35
36 /**
37 * Helper: Get Lawwwing plugin ID
38 */
39 function lawwwing_get_plugin_id() {
40 return get_lawwwing_option('ibamu_widget_uuid') ?: null;
41 }
42 ?>
43