How to modify/extend/override a core method?

There’s already a simliar answer by toscho here. Based on this one and from a look at WP_Styles, which extends WP_Dependencies and _WP_Dependency, I can’t see a reason why it should not work:

Whatever got added as extraconditional, gets thrown in:

// ~/wp-includes/class.wp-styles.php
if ( isset($obj->extra['conditional']) && $obj->extra['conditional'] ) {
    $tag .= "<!--[if {$obj->extra['conditional']}]>\n";
    $end_cond = "<![endif]-->\n";
}

_WP_Dependency defines add_data() the following way:

function add_data( $name, $data ) {
    if ( !is_scalar($name) )
        return false;
    $this->extra[$name] = $data;
    return true;
}

and WP_Dependencies defines add_data() like this:

function add_data( $handle, $key, $value ) {
    if ( !isset( $this->registered[$handle] ) )
        return false;

    return $this->registered[$handle]->add_data( $key, $value );
}

Leave a Comment