Advertisement
verygoodplugins

Untitled

Oct 25th, 2022
1,781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.98 KB | None | 0 0
  1. /**
  2.  * Enqueue and clean up scripts and styles
  3.  */
  4. function fix_styles_and_scripts() {
  5.  
  6.     if ( is_singular( 'documentation' ) ) {
  7.         wp_enqueue_script( 'prism', get_stylesheet_directory_uri() . '/js/prism.js', array(), '2.8', true );
  8.     }
  9.  
  10.     wp_deregister_style( 'font-awesome' ); // This is now handled by the official Font Awesome plugin
  11.  
  12.     // Clean up uneeded styles
  13.  
  14.     if ( ! is_admin() && ! \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
  15.         wp_deregister_style( 'elementor-icons' );
  16.         wp_deregister_style( 'elementor-icons-shared-0' );
  17.         wp_deregister_style( 'elementor-icons-fa-regular' );
  18.     }
  19.  
  20.     wp_deregister_style( 'astra-theme-css' );
  21.     wp_deregister_style( 'astra-menu-animation' );
  22.     wp_deregister_style( 'wp-block-library' );
  23.     wp_deregister_style( 'wp-block-library-theme' );
  24.     wp_deregister_style( 'edd-changelog' );
  25.     wp_deregister_style( 'genericons' ); // Icons for EDD changelog
  26.     wp_deregister_style( 'edd-recurring' );
  27.  
  28.     // Scripts
  29.  
  30.     wp_dequeue_script( 'astra-flexibility' );
  31.     wp_dequeue_script( 'astra-customevent' );
  32.     wp_dequeue_script( 'astra-theme-js' );
  33.     wp_dequeue_script( 'wp-seopress-gutenberg-faq-block' );
  34.     wp_dequeue_script( 'edd-jilt-subscribe-form' );
  35.     wp_dequeue_script( 'jquery-block-ui' ); // Jilt
  36.     wp_dequeue_script( 'wp-embed' );
  37.     wp_dequeue_script( 'elementor-sticky' );
  38.     wp_dequeue_script( 'elementor-waypoints' );
  39.     wp_dequeue_script( 'jquery-migrate' );
  40.  
  41.     if ( ! is_page( 'affiliate-area' ) && ! is_page( 'affiliate-registration' ) ) {
  42.         wp_deregister_style( 'affwp-forms' );
  43.     }
  44.  
  45.     if ( false === strpos( $_SERVER['REQUEST_URI'], 'checkout' ) && false === strpos( $_SERVER['REQUEST_URI'], 'account' ) ) {
  46.         wp_deregister_style( 'astra-edd' );
  47.         wp_deregister_style( 'edd-styles' );
  48.         wp_dequeue_script( 'edd-stripe-js' );
  49.         wp_dequeue_script( 'edd-ajax' );
  50.         wp_dequeue_script( 'edd-jilt' );
  51.         wp_dequeue_script( 'edd-frontend-recurring' );
  52.     }
  53.  
  54.     if ( false === strpos( $_SERVER['REQUEST_URI'], 'feature-requests' ) && ! is_page( 'roadmap' ) ) {
  55.         wp_deregister_style( 'jck-sfr-main' );
  56.         wp_dequeue_script( 'jck-sfr-main' );
  57.     }
  58.  
  59.     if ( ! is_page( 'documentation' ) && ! is_search() ) {
  60.         wp_deregister_style( 'searchwp-live-search' );
  61.         wp_dequeue_script( 'swp-live-search-client' );
  62.     }
  63.  
  64.     if ( ! is_page( 'pricing' ) && ! is_single( 'crm-compatibility-table' ) ) {
  65.         wp_deregister_style( 'tablepress-default' );
  66.     }
  67.  
  68.     if ( ! is_singular( 'documentation' ) ) {
  69.         wp_deregister_style( 'helpful-theme-base' );
  70.         wp_dequeue_script( 'helpful' );
  71.     }
  72.  
  73.     if ( ! is_singular( 'post' ) && ! is_singular( 'cpt_feature_requests' ) ) {
  74.         wp_dequeue_script( 'comment-reply' );
  75.     }
  76.  
  77.     global $wp_styles;
  78.  
  79.     unset( $wp_styles->registered['elementor-frontend']->extra['after'] );
  80.  
  81.     // Move the Astra custom stuff to the child theme and save one request
  82.  
  83.     // $wp_styles->registered['astra-child-theme-css']->extra['after'] = $wp_styles->registered['astra-theme-css']->extra['after'];
  84. }
  85.  
  86. add_action( 'wp_enqueue_scripts', 'fix_styles_and_scripts', PHP_INT_MAX ); // has to be be PHP_INT_MAX because Helpful enqueues their styles at that priority
  87.  
  88. function child_enqueue_styles() {
  89.  
  90.     wp_enqueue_style( 'astra-child-theme-css', get_stylesheet_directory_uri() . '/style.css', array(), '1.0.65', 'all' );
  91.     wp_enqueue_style( 'prism', get_stylesheet_directory_uri() . '/prism.css', array(), '1.0.2', 'all' );
  92.  
  93.     // Load the font sizes and colors early to avoid the flash of styling.
  94.  
  95.     $data = '*{border:0;font-size:100%;font-style:inherit;font-weight:inherit;margin:0;outline:0;padding:0}html>body{font-family:Sans-serif;-webkit-font-smoothing:antialiased;overflow-x:hidden;line-height:1.8;font-size:18px;color:#737f90}:not( h1,h2,h3,h4,h5,h6,.blob-code,pre ){font-family:"Lota Grotesque",Sans-serif}h1,h1>span,h2,h3,h4,h5,h6{font-family:Geomanist,Sans-serif;color:#000;font-weight:600;line-height:1.15}.h1,h1{font-size:3rem}.h2,h2{margin:30px 0 10px;font-size:1.66rem}.h3,h3{margin:30px 0 10px;font-size:1.5rem}.h4,h4{margin:40px 0 10px;font-size:1.25rem}h1.elementor-heading-title{font-size:64px}.fa,.far,.fas{font-family:"Font Awesome 5 Free";font-weight:900}@media (max-width:767px){body{background-image:none!important}svg#blue-blob-bg{display:none}h1.elementor-heading-title,h2.elementor-heading-title{font-size:48px!important;line-height:1.15!important}}body.single-documentation h1.elementor-heading-title{font-size:48px}.entry-content p,p{margin-bottom:.89em}img{vertical-align:middle;height:auto;max-width:100%}a{color:#0b328e}table{border-spacing:0}body b,body strong{color:#333;font-weight:600}body a>b,body a>strong{color:#0b328e}@media (min-width:767px){.elementor-nav-menu li.menu-item-has-children{padding-right:22px!important}}.elementor-nav-menu .sub-arrow{position:absolute;right:0;display:none}ul.elementor-nav-menu li.menu-item.menu-item-has-children:after{font-family:"Font Awesome 5 Free";font-weight:900;display:inline-block;content:"\f0d7";position:absolute;right:20px;top:50%;margin-top:-8px;color:#000;border:none}.elementor-16596 ul.elementor-nav-menu li.menu-item.menu-item-has-children:after,.elementor-18192 ul.elementor-nav-menu li.menu-item.menu-item-has-children:after{color:#fff}';
  96.  
  97.     wp_add_inline_style( 'astra-child-theme-css', $data );
  98.  
  99.     // wp_enqueue_script( 'anchoring', get_stylesheet_directory_uri() . '/js/jquery.anchoring.js', array( 'jquery' ), '2.8', true );
  100.  
  101.     // The main .js file
  102.  
  103.     $ver = '2.8.7';
  104.  
  105.     if ( current_user_can( 'manage_options' ) ) {
  106.         $ver = time();
  107.     }
  108.  
  109.     wp_enqueue_script( 'wpfmain', get_stylesheet_directory_uri() . '/js/main.js', array( 'jquery' ), $ver, true );
  110.  
  111.     wp_localize_script( 'wpfmain', 'wpfmain', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
  112.  
  113. }
  114.  
  115. add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 5 ); // on 5 so there isn't a flash.
  116.  
  117. add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
  118.  
  119. // Set fonts to font-display: swap; to prevent flash
  120.  
  121. add_filter(
  122.     'elementor_pro/custom_fonts/font_display',
  123.     function( $current_value, $font_family, $data ) {
  124.         return 'swap';
  125.     },
  126.     10,
  127.     3
  128. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement