thematic_create_stylesheet Not working in 1.0.1?

Home Forums Using Thematic Child Themes Build Your Own Custom Child Themes thematic_create_stylesheet Not working in 1.0.1?

This topic is: resolved

This topic contains 17 replies, has 4 voices, and was last updated by  helgatheviking 5 years, 6 months ago.

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #311

    PhillyDesign
    Participant

    This used to work for me, but after upgrading, it no longer does:

    //CALL ALL STYLESHEETS AT ONCE INSTEAD OF USING @import

    function childtheme_create_stylesheet() {
    $templatedir = get_bloginfo('template_directory');
    $stylesheetdir = get_bloginfo('stylesheet_directory');
    ?>
    <link rel="stylesheet" type="text/css" href="/library/styles/reset.css" />
    <link rel="stylesheet" type="text/css" href="/library/styles/typography.css" />
    <link rel="stylesheet" type="text/css" href="/library/styles/images.css" />
    <link rel="stylesheet" type="text/css" href="/library/layouts/2c-r-fixed.css" />
    <link rel="stylesheet" type="text/css" href="/library/styles/18px.css" />
    <link rel="stylesheet" type="text/css" href="/ls.css" />
    <link rel="stylesheet" type="text/css" href="/local.css" />
    <link rel="stylesheet" type="text/css" href="/dropdown1.css" />
    <link rel="stylesheet" type="text/css" href="/dropdown2.css" />

    <link rel="stylesheet" type="text/css" href="/ie.css" />

    <?php
    }
    add_filter('thematic_create_stylesheet', 'childtheme_create_stylesheet');

    Any insight you can offer? Thanks in advance.

    #320

    helgatheviking
    Moderator

    from the readme.txt (and yes i know the changelog is super long since alot changed in 1.0)

    * Changed: Function <code>thematic_create_stylesheet</code> to <code>wp_enqueue_style</code>.

    thematic 1.0 changed to support using wp_enqueue_stylesheet() to properly load stylesheets according to WP best practices and theme review guidelines.  so, this filter is no longer there for you to use as you are using above.

    i would actually suggest just pasting all of those stylesheets into your child’s style.css.  it is typically better to serve 1 larger stylesheet as it means fewer items to load.  however, it can be nice for you mentally to keep them all separate.

    drop that function.. and replace it with something along the lines of the following, depending on where the stylesheets are located:


    function kia_enqueue_stylesheets(){
    wp_enqueue_style( 'reset', get_template_directory_uri() . '/library/styles/reset.css' );
    wp_enqueue_style( 'typography', get_stylesheet_directory_uri() . '/mytypography.css' );
    }
    add_action('wp_enqueue_scripts','kia_enqueue_stylesheets');

    here is the Codex reference to wp_enqueue_stylesheet().

    #323

    PhillyDesign
    Participant

    Thanks, Helga. Your knowledge of WP continues to astound. 🙂

    #324

    PhillyDesign
    Participant

    Helga (or whomever), one more related question:

    Because I was simply echoing all of the stylesheet links via thematic_create_stylesheet, I was able to include this conditional call:

    <!–[if lt IE 9]>
    <link rel=”stylesheet” type=”text/css” href=”<?php echo $stylesheetdir ?>/ie.css” />
    <![endif]–>

    How, if at all, would you recommend I do that now that I can’t use the previous method?

    #325

    PhillyDesign
    Participant

    Hmmm. Also, FWIW: I replaced the previous thematic_create_stylesheet function in my child theme’s functions.php file with this:

    function child_enqueue_stylesheets() {
    wp_enqueue_style( 'reset', get_template_uri() . '/library/styles/reset.css' );
    wp_enqueue_style( 'reset', get_template_uri() . '/library/styles/typography.css' );
    wp_enqueue_style( 'reset', get_template_uri() . '/library/styles/images.css' );
    wp_enqueue_style( 'reset', get_template_uri() . '/library/styles/18px.css' );
    wp_enqueue_style( 'reset', get_template_uri() . '/library/layouts/2c-r-fixed.css' );
    wp_enqueue_style( 'reset', get_stylesheet_uri() . '/ls.css' );
    wp_enqueue_style( 'reset', get_stylesheet_uri() . '/dropdown1.css' );
    wp_enqueue_style( 'reset', get_stylesheet_uri() . '/dropdown2.css' );
    }
    add_action('wp_enqueue_scripts', 'child_enqueue_stylesheets');

    … and now I’m getting a blank, white page. This is all that shows in “View Source”:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Laurel Springs | Accredited Online Private School</title>
    <link rel="pingback" href="http://10.1.1.53/laurelsprings/xmlrpc.php" />

    So I’m assuming it’s dying right at the wp_enqueue_scripts action.
    Still confused.

    #326

    helgatheviking
    Moderator

    shouldn’t be the cause of the problem, but you need to give each stylesheet a different id/name.  i’d fix my post but so far i can’t figure out how. the brilliance of wp_enqueue system is that it won’t load the same thing 2x.

    edited: first code block has been edited to be correct

     

    WSOD is usually a syntax error.  double check all your other code. (edit: or my code! i don’t always test before typing!)

    #329

    PhillyDesign
    Participant

    Oops. My bad on the IDs. Thanks for pointing it out.

    As for the larger issue: I pruned the stylesheet call for testing purposes to just this:

    function child_enqueue_stylesheets() {
    wp_enqueue_style( 'ls', get_stylesheet_uri() . '/ls.css' );
    }
    add_action('wp_enqueue_scripts', 'child_enqueue_stylesheets');

    When I view the source, I see that this is what it’s spitting out:

    <link rel='stylesheet' id='ls-css'  href='http://10.1.1.53/laurelsprings/wp-content/themes/theme-name/style.css/ls.css?ver=3.3.2' type='text/css' media='all' />

    So I’m assuming that means that “get_stylesheet_uri()” returns wp-content/themes/theme-name/style.css … the style.css being the problem. I’m searching for the solution, but posting here in case you know it off the top of your head.

    #331

    PhillyDesign
    Participant

    Figured it out:

    Instead of get_stylesheet_uri(), use get_stylesheet_directory_uri()

    Likewise for get_template_directory_uri() instead of get_template_uri().

    Thanks again for your help! 🙂

    #333

    helgatheviking
    Moderator

    ummm…. ooops!?  sorry.  i don’t always test before typing and sometimes mistakes get made.  to answer your other question you can’t enqueue an IE-specific conditional comment, so you should just add it to wp_head

    `
    function kia_add_ie_style(){ ?>

    <!–[if lt IE 9]>
    <link rel=”stylesheet” type=”text/css” href=”<?php echo $stylesheetdir ?>/ie.css” />
    <![endif]–>

    <?php }
    add_action(‘wp_head’,’kia_add_ie_style’);

    `

    #337

    PhillyDesign
    Participant

    Awesome. Thanks.

    Did I mention “Thanks”? Thanks!

    #339

    greyhavns
    Participant

    where did 2c-r-fixed.css go?

    #342

    PhillyDesign
    Participant

    This is what the final version looks like in my child theme’s functions.php file:

    function child_enqueue_stylesheets() {
    wp_enqueue_style( 'reset', get_template_directory_uri() . '/library/styles/reset.css' );
    wp_enqueue_style( 'typography', get_template_directory_uri() . '/library/styles/typography.css' );
    wp_enqueue_style( 'images', get_template_directory_uri() . '/library/styles/images.css' );
    wp_enqueue_style( '18px', get_template_directory_uri() . '/library/styles/18px.css' );
    wp_enqueue_style( '2c-r-fixed', get_template_directory_uri() . '/library/layouts/2c-r-fixed.css' );
    wp_enqueue_style( 'ls', get_stylesheet_directory_uri() . '/ls.css' );
    wp_enqueue_style( 'dropdown1', get_stylesheet_directory_uri() . '/dropdown1.css' );
    wp_enqueue_style( 'dropdown2', get_stylesheet_directory_uri() . '/dropdown2.css' );
    }
    add_action('wp_enqueue_scripts', 'child_enqueue_stylesheets');

    #343

    greyhavns
    Participant

    thanks philly.  didn’t realize they just moved it to layouts folder.  what’s this 18px css file?

    #355

    helgatheviking
    Moderator

    @greyhavns it has to do with enforcing an 18px line height and vertical rhythm.

    #362

    middlesister
    Keymaster

    As a sidenote, you can enqueue a stylesheet with conditional comments. See http://kuttler.eu/post/wordpress-style-version-conditional-comments/


    if ( !is_admin() ) {
    $theme = get_theme( get_current_theme() );
    wp_register_style( 'your-style', get_bloginfo( 'stylesheet_directory' ) . '/css/ie.css', false, $theme['Version'] );
    global $wp_styles;
    $wp_styles->add_data( 'your-style', 'conditional', 'lte IE 8' );
    wp_enqueue_style( 'your-style' );
    }

    This only works with styles and not scripts, but I’ve seen trac discussions about adding the same functionality for scripts to core.

Viewing 15 posts - 1 through 15 (of 18 total)

The topic ‘thematic_create_stylesheet Not working in 1.0.1?’ is closed to new replies.