Advertisement
fahimmurshed

Astra Child functions.php

Aug 6th, 2020 (edited)
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Astra Child Theme functions and definitions
  4.  *
  5.  * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6.  *
  7.  * @package Astra Child
  8.  * @since 1.0.0
  9.  */
  10.  
  11. /**
  12.  * Define Constants
  13.  */
  14. define( 'CHILD_THEME_ASTRA_CHILD_VERSION', '1.0.0' );
  15.  
  16. /**
  17.  * Enqueue styles
  18.  */
  19. function child_enqueue_styles() {
  20.  
  21.     wp_enqueue_style( 'astra-child-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_ASTRA_CHILD_VERSION, 'all' );
  22.  
  23. }
  24.  
  25. add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 15 );
  26.  
  27. // Using the following code in the functions.php of your child theme
  28. // More info on https://fahimm.com
  29. add_filter( 'astra_enable_default_fonts', 'temp_disable_astra_fonts' );
  30. function temp_disable_astra_fonts( $load ) {
  31.   $load = false;
  32.   return $load;
  33. }
  34. add_action( 'wp_head', 'add_astra_fonts_preload', 1 );
  35. function add_astra_fonts_preload() {
  36.   ?>
  37.   <link rel="preload" href="<?php echo get_site_url(); ?>/wp-content/themes/astra/assets/fonts/astra.woff" as="font" crossorigin />
  38.   <link rel="preload" href="<?php echo get_site_url(); ?>/wp-content/themes/astra/assets/fonts/astra.ttf" as="font" crossorigin />
  39.   <link rel="preload" href="<?php echo get_site_url(); ?>/wp-content/themes/astra/assets/fonts/astra.svg#astra" as="font" crossorigin />
  40.   <style type='text/css'>
  41.   <?php
  42.   echo '@font-face {font-family: "Astra";src: url( ' . get_site_url() . '/wp-content/themes/astra/assets/fonts/astra.woff) format("woff"),url( ' . get_site_url() . '/wp-content/themes/astra/assets/fonts/astra.ttf) format("truetype"),url( ' . get_site_url() . '/wp-content/themes/astra/assets/fonts/astra.svg#astra) format("svg");font-weight: normal;font-style: normal;font-display: fallback;}';
  43.   ?>
  44.   </style>
  45.   <?php
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement