guillermorangel
5/20/2015 - 4:20 PM

Enqueue Script or Style

Enqueue Script or Style

<?php 

function enqueue_custom_grid_gallery_js() {

    if ( is_page('work') ) {
        wp_dequeue_script( 'fl-gallery-grid' );
        wp_deregister_script( 'fl-gallery-grid' ); 

        $file_path = '/js/fl-gallery-grid-bss.js';
        $handle = 'fl-gallery-grid-bss';
        $src = get_stylesheet_directory_uri().$file_path;
        $deps = array('jquery');
        $ver = filemtime(get_stylesheet_directory().$file_path);
        $in_footer = true;
        wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
    }
    
} add_action('wp_enqueue_scripts', 'enqueue_custom_grid_gallery_js');

function enqueue_custom_custom_style() {

    $file_path = '/css/custom.css';
    $handle = 'custom-style';
    $src = get_stylesheet_directory_uri().$file_path;
    $deps = array();
    $ver = filemtime(get_stylesheet_directory().$file_path);
    $media = 'all';
    wp_enqueue_style( $handle, $src, $deps, $ver, $media );

} add_action('wp_enqueue_scripts', 'enqueue_custom_custom_style');


function remove_add_style_css() {
    $css_dequeue_handle = 'avada-stylesheet';
    $css_enqueue_handle = 'wsm-style';
    
    wp_dequeue_style( $css_dequeue_handle );
    wp_deregister_style( $css_dequeue_handle );

    wp_register_style( $css_enqueue_handle, get_stylesheet_directory_uri() . '/style.css', false, filemtime( get_stylesheet_directory().'/style.css' ) ); 
    wp_enqueue_style( $css_enqueue_handle );
} add_action( 'wp_enqueue_scripts', 'remove_add_style_css', 20 );


function enqueue_custom_custom_style() {

    $css_dequeue_handle = 'storefront-style';
    wp_dequeue_style( $css_dequeue_handle );
    wp_deregister_style( $css_dequeue_handle );

    $css_enqueue_handle = 'custom';
    $file_path = '/custom.css';
    $handle = $css_enqueue_handle;
    $src = get_stylesheet_directory_uri().$file_path;
    $deps = array();
    $ver = filemtime(get_stylesheet_directory().$file_path);
    $media = 'all';
    wp_enqueue_style( $handle, $src, $deps, $ver, $media );

} add_action('wp_enqueue_scripts', 'enqueue_custom_custom_style');


// remove unqueue default style.css and replace with custom css file
function replace_default_css_file() {

    $css_dequeue_handle = 'pellawm-style';
    wp_dequeue_style( $css_dequeue_handle );
    wp_deregister_style( $css_dequeue_handle );

    $css_enqueue_handle = 'pella';
    $file_path = '/pella.css';
    $src = get_stylesheet_directory_uri().$file_path;
 	  $deps = array();
    $ver = filemtime(get_stylesheet_directory().$file_path);
    $media = 'all';
    wp_register_style( $css_enqueue_handle, $src, $deps, $ver, $media ); 
    wp_enqueue_style( $css_enqueue_handle );

} add_action( 'wp_enqueue_scripts', 'replace_default_css_file', 20 );


?>