Last active
December 24, 2015 16:19
-
-
Save ejntaylor/6827483 to your computer and use it in GitHub Desktop.
WP - Register CSS and JS for Woo Canvas
This file contains 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
// CSS | |
if ( WP_DEBUG ) { | |
define( 'RO_VERSION', time() ); | |
} else { | |
define( 'RO_VERSION', '1.0.1' ); | |
} | |
// wp_enqueue stylesheet for Woo Shortcodes | |
if ( ! function_exists( 'woo_shortcode_stylesheet' ) && get_option( 'framework_woo_disable_shortcodes' ) != 'true' ) { | |
function woo_shortcode_stylesheet() { | |
wp_register_style( 'woo-shortcode-css', get_template_directory_uri() . '/functions/css/shortcodes.css', array(), RO_VERSION, 'all' ); | |
wp_enqueue_style( 'woo-shortcode-css' ); | |
} // End woo_shortcode_stylesheet() | |
} | |
add_action( 'wp_enqueue_scripts', 'woo_shortcode_stylesheet', 25 ); | |
// wp_enqueue stylesheet for custom css | |
if ( ! function_exists( 'woo_output_custom_css' ) ) { | |
function woo_output_custom_css() { | |
$theme_dir = get_template_directory_uri(); | |
if ( is_child_theme() && file_exists( get_stylesheet_directory() . '/custom.css' ) ) | |
$theme_dir = get_stylesheet_directory_uri(); | |
wp_register_style( 'woo-custom-css', esc_url( $theme_dir . '/custom.css' ), array(), RO_VERSION, 'all' ); | |
wp_enqueue_style( 'woo-custom-css' ); | |
} // End woo_output_custom_css() | |
} | |
add_action( 'wp_enqueue_scripts', 'woo_output_custom_css', 26 ); | |
// wp_enqueue raison custom css | |
function raison_custom_css() { | |
if ( ! is_admin() ) { | |
wp_register_style( 'woo-styling', get_stylesheet_directory_uri() . '/assets/css/woo-styling.css', array(), RO_VERSION, 'all' ); | |
wp_enqueue_style( 'woo-styling' ); | |
wp_register_style( 'custom-style', get_stylesheet_directory_uri() . '/assets/css/custom-main.css', array(), RO_VERSION, 'all' ); | |
wp_enqueue_style( 'custom-style' ); | |
wp_register_style( 'custom-style-two', get_stylesheet_directory_uri() . '/assets/css/custom-two.css', array(), RO_VERSION, 'all' ); | |
wp_enqueue_style( 'custom-style-two' ); | |
wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Rye|Montserrat:400,700'); | |
wp_enqueue_style( 'googleFonts'); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'raison_custom_css', 30 ); | |
// js | |
function register_my_script() { | |
wp_register_script('modernizr', get_stylesheet_directory_uri().'/assets/js/modernizr.js', array('jquery'), RO_VERSION, true); | |
wp_register_script('general-js', get_stylesheet_directory_uri().'/assets/js/general-js.js', array('jquery'), RO_VERSION, true); | |
} | |
function print_my_scripts_head() { | |
wp_print_scripts('general-js'); | |
} | |
function print_my_scripts_foot() { | |
wp_print_scripts('modernizr'); | |
} | |
add_action('init', 'register_my_script'); | |
add_action('wp_head', 'print_my_scripts_head'); | |
add_action('wp_footer', 'print_my_scripts_foot'); | |
// enqueue woocommerce prettyphoto lightbox | |
add_action( 'wp_enqueue_scripts', 'frontend_scripts_include_lightbox' ); | |
function frontend_scripts_include_lightbox() { | |
global $woocommerce; | |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
$lightbox_en = get_option( 'woocommerce_enable_lightbox' ) == 'yes' ? true : false; | |
if ( $lightbox_en ) { | |
wp_enqueue_script( 'prettyPhoto', $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), '3.1.5', true ); | |
wp_enqueue_script( 'prettyPhoto-init', $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true ); | |
wp_enqueue_style( 'woocommerce_prettyPhoto_css', $woocommerce->plugin_url() . '/assets/css/prettyPhoto.css' ); | |
} | |
} | |
// admin | |
remove_action( 'admin_notices', 'woothemes_updater_notice' ); | |
// image upload limit | |
@ini_set( 'upload_max_size' , '64M' ); | |
@ini_set( 'post_max_size', '64M'); | |
@ini_set( 'max_execution_time', '300' ); | |
// Change Archive Template H1 | |
add_filter( 'woo_archive_title', 'new_woo_archive_title' ); | |
function new_woo_archive_title () { | |
$category = single_cat_title("", false); | |
$new_title = '<h1>'. $category .'</h1>' . '<div>' . strip_tags(category_description($category_id)) . '</div>'; | |
return $new_title; | |
} // End filter | |
// image sizes | |
function custom_image_sizes() { | |
add_theme_support('post-thumbnails'); | |
add_image_size('slide-full', 1008, 665, true); | |
} | |
add_action('after_setup_theme', 'custom_image_sizes'); | |
// remove canvas actions | |
function remove_canvas_actions() { | |
// remove woo inline styling | |
remove_action( 'woothemes_wp_head_before', 'woo_enqueue_custom_styling', 9 ); | |
// remove woo nav | |
// remove_action( 'woo_header_after','woo_nav', 10 ); | |
} | |
add_action('init','remove_canvas_actions'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to also wp_enqueue woo_shortcodes and woo_custom stylesheets