-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
46 lines (30 loc) · 1023 Bytes
/
init.php
File metadata and controls
46 lines (30 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
function headless_apidata_function() {
// API HTML output
$string .= '
<div class="hl-apidata-container">
</div>
';
// Code returned
return $string;
}
function headless_apidata_enqueue_scripts() {
/**
* Registers and enqueue styles and scripts
*/
wp_register_style( 'wp-headless-apidata', plugins_url ( 'css/styles.css', __FILE__ ));
wp_enqueue_style( 'wp-headless-apidata' );
wp_register_script( 'wp-headless-apidata-script' , plugins_url ('js/script.js', __FILE__ ));
wp_enqueue_script( 'wp-headless-apidata-script' );
//wp_localize_script( 'wp-headless-apidata-script', 'php_vars', $spcAtt );
}
function defer_headlessapi_scripts( $tag, $handle, $src ) {
$defer = array(
'wp-headless-apidata-script'
);
if ( in_array( $handle, $defer ) ) {
return '<script src="' . $src . '" defer="defer" type="text/javascript"></script>' . "\n";
}
return $tag;
}
add_filter( 'script_loader_tag', 'defer_headlessapi_scripts', 10, 3 );