New Landing How can we help? Themeforest Theme Support Pinpoint Enqueing CSS files correctly in Pinpoint

Viewing 3 posts - 1 through 3 (of 3 total)
  • Posted in: Pinpoint
  • #27761
    henrycullen
    Member
    Post count: 19

    Using Pinpoint 1.55 WP 3.6.1 with a child theme.
    Quite heavily modified CSS and a custom style sheet.
    I am enqueing my custom by adding it to the list of scripts enqued in functions.php.
    I am enqueing all CSS from the child theme, as I have made a few changes to the themes CSS too.

    It works fine, but I would like to use my functions.php file in the child theme so as to be able to update the main theme without to edit anything manually afterwards.

    so far in my child theme functions.php file I have put this:

    
    		wp_register_style('ashford-css', get_stylesheet_directory_uri() . '/ashford-styles.css', array(), '1.0', 'screen');
    		wp_register_style('main-css', get_stylesheet_directory_uri() . '/style.css', array(), NULL, 'screen'); 
    		wp_register_style('custom-css', get_stylesheet_directory_uri() . '/css/custom-styles.css.php', array(), NULL, 'screen');
    		wp_register_style('base-css', get_stylesheet_directory_uri() . '/css/base.css', array(), NULL, 'screen');  
    		wp_register_style('skeleton-css', get_stylesheet_directory_uri() . '/css/skeleton.css', array(), NULL, 'screen');  
    		wp_register_style('fontawesome-css', get_stylesheet_directory_uri() . '/css/font-awesome.min.css', array(), NULL, 'screen');  
    		wp_register_style('layout-css', get_stylesheet_directory_uri() . '/css/layout.css', array(), NULL, 'screen');
    
    		wp_enqueue_style('base-css');  
    		if ($enable_responsive) {
    		wp_enqueue_style('skeleton-css');  
    		}
    		wp_enqueue_style('fontawesome-css'); 
    		wp_enqueue_style('main-css');  
    		if ($enable_responsive) {
    		wp_enqueue_style('layout-css');  
    		}
    		wp_enqueue_style('custom-css');
    		wp_enqueue_style('ashford-css');
    

    It works great in the frontend, but also works in the admin area, which makes the admin look nasty and weird. So i Put this in my main themes functions.php and all is good ….for now…until I update.

    So, how would I go about setting the functions.php in my child theme up to just load the css I want from my child theme, but not when I am in the admin area?

    I hope I am making myself clear, sorry if not.

    Many thanks for any help.

    #28085
    Cosmin – SUPPORT
    Member
    Post count: 3851

    You can wrap that whole thing in a function, say you call id hc_loadscripts(). Then, call it if not in the admin:

    function hc_loadscripts() {
    // what you are adding in your example above
    }
    
    if(!is_admin()) {
    	if (function_exists('hc_loadscripts')) {
    		add_action('wp_enqueue_scripts', 'hc_loadscripts');
    	}
    }

    Regards,

    ————————————————————————————————————

    Cosmin
    Support Assistant

    #28087
    Cosmin – SUPPORT
    Member
    Post count: 3851

    Of course, for styles, you need a separate one:

    function hc_loadstyles() {
    // what you are adding in your example above, but only for styles
    }
    
    if(!is_admin()) {
        if (function_exists('hc_loadstyles')) {
            add_action('wp_enqueue_scripts', 'hc_loadstyles');
        }
    }

    Regards,

    ————————————————————————————————————

    Cosmin
    Support Assistant

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register