added deferred youtuibe video block

This commit is contained in:
Marco Cavalli 2024-01-11 18:09:03 +01:00
parent f34cfd1bff
commit 6e8f0b0bb9
9 changed files with 63 additions and 33 deletions

View file

@ -6,6 +6,15 @@
require_once 'includes/custom-functions.php';
/**
* Registering Custom Blocks
*/
function congegni_block_init() {
register_block_type( __DIR__ . '/blocks/deferred-youtube-video' );
}
add_action( 'init', 'congegni_block_init' );
/**
* Add support for useful stuff
@ -69,8 +78,6 @@ add_filter('post_comments_feed_link', 'barebones_post_comments_feed_link');
*/
function barebones_enqueue_scripts() {
// wp_enqueue_style( 'fonts', '//fonts.googleapis.com/css?family=Font+Family' );
// wp_enqueue_style( 'icons', '//use.fontawesome.com/releases/v5.0.10/css/all.css' );
wp_deregister_script('jquery');
wp_enqueue_style( 'styles', get_stylesheet_directory_uri() . '/style.css?' . filemtime( get_stylesheet_directory() . '/style.css' ) );
wp_enqueue_script( 'scripts', get_stylesheet_directory_uri() . '/js/scripts.min.js?' . filemtime( get_stylesheet_directory() . '/js/scripts.min.js' ), [], null, true );
@ -106,37 +113,6 @@ function defer_scripts( $tag, $handle, $src ) {
add_filter( 'script_loader_tag', 'defer_scripts', 10, 3 );
/**
* Add custom scripts to head
*
* @return string
*/
function add_gtag_to_head() {
// Check is staging environment
if ( strpos( get_bloginfo( 'url' ), '.test' ) !== false ) return;
// Google Analytics
$tracking_code = 'UA-*********-1';
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $tracking_code; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo $tracking_code; ?>');
</script>
<?php
}
add_action( 'wp_head', 'add_gtag_to_head' );
/**
* Remove unnecessary scripts
*