Last active
April 6, 2022 10:37
-
-
Save cristacheda/e8973a204c35d161363ff0b1a4c9d5dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//elementor pro fontawesome fix | |
if ( ! is_plugin_active('elementor-pro/elementor-pro.php') ) return; | |
function replace_font_awesome_pro( $settings ) { | |
$json_url = ELEMENTOR_PRO_ASSETS_URL . 'lib/font-awesome-pro/%s.js'; | |
$icons['fa-regular'] = [ | |
'name' => 'fa-regular', | |
'label' => __( 'Font Awesome - Regular Pro', 'elementor-pro' ), | |
'url' => false, | |
'enqueue' => false, | |
'prefix' => 'fa-', | |
'displayPrefix' => 'far', | |
'labelIcon' => 'fab fa-font-awesome-alt', | |
'ver' => '5.12.0-pro', | |
'fetchJson' => sprintf( $json_url, 'regular' ), | |
'native' => true, | |
]; | |
$icons['fa-solid'] = [ | |
'name' => 'fa-solid', | |
'label' => __( 'Font Awesome - Solid Pro', 'elementor-pro' ), | |
'url' => false, | |
'enqueue' => false, | |
'prefix' => 'fa-', | |
'displayPrefix' => 'fas', | |
'labelIcon' => 'fab fa-font-awesome', | |
'ver' => '5.12.0-pro', | |
'fetchJson' => sprintf( $json_url, 'solid' ), | |
'native' => true, | |
]; | |
$icons['fa-brands'] = [ | |
'name' => 'fa-brands', | |
'label' => __( 'Font Awesome - Brands Pro', 'elementor-pro' ), | |
'url' => false, | |
'enqueue' => false, | |
'prefix' => 'fa-', | |
'displayPrefix' => 'fab', | |
'labelIcon' => 'fab fa-font-awesome-flag', | |
'ver' => '5.12.0-pro', | |
'fetchJson' => sprintf( $json_url, 'brands' ), | |
'native' => true, | |
]; | |
$icons['fa-light'] = [ | |
'name' => 'fa-light', | |
'label' => __( 'Font Awesome - Light Pro', 'elementor-pro' ), | |
'url' => false, | |
'enqueue' => false, | |
'prefix' => 'fa-', | |
'displayPrefix' => 'fal', | |
'labelIcon' => 'fal fa-flag', | |
'ver' => '5.12.0-pro', | |
'fetchJson' => sprintf( $json_url, 'light' ), | |
'native' => true, | |
]; | |
$icons['fa-duotone'] = [ | |
'name' => 'fa-duotone', | |
'label' => __( 'Font Awesome - Duotone Pro', 'elementor-pro' ), | |
'url' => false, | |
'enqueue' => false, | |
'prefix' => 'fa-', | |
'displayPrefix' => 'fad', | |
'labelIcon' => 'fad fa-flag', | |
'ver' => '5.12.0-pro', | |
'fetchJson' => sprintf( $json_url, 'duotone' ), | |
'native' => true, | |
]; | |
// remove Free | |
unset( | |
$settings['fa-solid'], | |
$settings['fa-regular'], | |
$settings['fa-brands'] | |
); | |
return array_merge( $icons, $settings ); | |
} | |
function enqueue_kit_js() { | |
wp_enqueue_script( 'font-awesome-pro', 'https://fa.leadgap.ro/latest/js/all.min.js' ); | |
} | |
add_filter( 'elementor/icons_manager/native', 'replace_font_awesome_pro' ); | |
add_action( 'elementor/editor/after_enqueue_scripts', 'enqueue_kit_js' ); | |
// add_action( 'elementor/frontend/after_enqueue_scripts', 'enqueue_kit_js' ); | |
// Enqueue scripts and styles. | |
function scripts() { | |
wp_enqueue_style( 'replace-with-file-id', get_template_directory_uri() . '/style.css', array(), _S_VERSION ); | |
} | |
add_filter( 'wp_enqueue_scripts', 'scripts' ); | |
// Defer CSS | |
function _changeme_defer_css( $html, $handle ) { | |
$deferred_stylesheets = apply_filters( 'changeme_deferred_stylesheets', array() ); | |
if ( in_array( $handle, $deferred_stylesheets, true ) ) { | |
return str_replace( 'media=\'all\'', 'media="print" onload="this.media=\'all\'"', $html ); | |
} else { | |
return $html; | |
} | |
} | |
add_filter( 'style_loader_tag', '_changeme_defer_css', 10, 2 ); | |
add_filter( 'changeme_deferred_stylesheets', function( $handles ) { | |
$handles[] = 'replace-with-file-id'; | |
return $handles; | |
}, 10, 1 ); | |
// WP garbage cleanup | |
remove_action ('wp_head', 'rsd_link'); | |
remove_action( 'wp_head', 'wlwmanifest_link'); | |
remove_action( 'wp_head', 'wp_shortlink_wp_head'); | |
remove_action('wp_head', 'wp_generator'); | |
add_filter( 'xmlrpc_enabled', '__return_false' );remove_action( 'wp_head', 'feed_links_extra', 3 ); | |
remove_action( 'wp_head', 'feed_links', 2 ); | |
remove_action('wp_head', 'print_emoji_detection_script', 7); | |
remove_action('wp_print_styles', 'print_emoji_styles'); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
// Disable RSS | |
function itsme_disable_feed() { | |
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) ); | |
} | |
add_action('do_feed', 'itsme_disable_feed', 1); | |
add_action('do_feed_rdf', 'itsme_disable_feed', 1); | |
add_action('do_feed_rss', 'itsme_disable_feed', 1); | |
add_action('do_feed_rss2', 'itsme_disable_feed', 1); | |
add_action('do_feed_atom', 'itsme_disable_feed', 1); | |
add_action('do_feed_rss2_comments', 'itsme_disable_feed', 1); | |
add_action('do_feed_atom_comments', 'itsme_disable_feed', 1); | |
// Dequeue unused CSS | |
function remove_unusedcss(){ | |
wp_dequeue_style( 'wp-block-library' ); | |
wp_dequeue_style( 'wp-block-library-theme' ); | |
wp_dequeue_style( 'wc-block-style' ); // WooCommerce only | |
wp_dequeue_style( 'wc-blocks-style' ); // WooCommerce only | |
wp_dequeue_style( 'wc-blocks-vendors-style' ); // WooCommerce only | |
} | |
add_action( 'wp_enqueue_scripts', 'remove_unusedcss', 100 ); | |
// Dequeue WooCommerce assets on non-WooCommerce pages | |
/** | |
* Manage WooCommerce styles and scripts. | |
*/ | |
function grd_woocommerce_script_cleaner() { | |
if ( ! is_front_page() && ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { | |
wp_dequeue_style( 'woocommerce_frontend_styles' ); | |
wp_dequeue_style( 'woocommerce-general'); | |
wp_dequeue_style( 'woocommerce-layout' ); | |
wp_dequeue_style( 'woocommerce-smallscreen' ); | |
wp_dequeue_style( 'woocommerce_fancybox_styles' ); | |
wp_dequeue_style( 'woocommerce_chosen_styles' ); | |
wp_dequeue_style( 'woocommerce_prettyPhoto_css' ); | |
wp_dequeue_script( 'selectWoo' ); | |
wp_deregister_script( 'selectWoo' ); | |
wp_dequeue_script( 'wc-add-payment-method' ); | |
wp_dequeue_script( 'wc-lost-password' ); | |
wp_dequeue_script( 'wc_price_slider' ); | |
wp_dequeue_script( 'wc-single-product' ); | |
wp_dequeue_script( 'wc-add-to-cart' ); | |
wp_dequeue_script( 'wc-cart-fragments' ); | |
wp_dequeue_script( 'wc-credit-card-form' ); | |
wp_dequeue_script( 'wc-checkout' ); | |
wp_dequeue_script( 'wc-add-to-cart-variation' ); | |
wp_dequeue_script( 'wc-single-product' ); | |
wp_dequeue_script( 'wc-cart' ); | |
wp_dequeue_script( 'wc-chosen' ); | |
wp_dequeue_script( 'woocommerce' ); | |
wp_dequeue_script( 'prettyPhoto' ); | |
wp_dequeue_script( 'prettyPhoto-init' ); | |
wp_dequeue_script( 'jquery-blockui' ); | |
wp_dequeue_script( 'jquery-placeholder' ); | |
wp_dequeue_script( 'jquery-payment' ); | |
wp_dequeue_script( 'fancybox' ); | |
wp_dequeue_script( 'jqueryui' ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'grd_woocommerce_script_cleaner', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment