Make WordPress Core


Ignore:
Timestamp:
01/15/2009 07:50:23 PM (16 years ago)
Author:
azaozz
Message:

Let plugins register footer scripts easier and add filters to the concatenating functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/script-loader.php

    r10366 r10367  
    537537function wp_print_head_scripts() {
    538538    do_action( 'wp_print_scripts' );
    539     global $wp_scripts, $concatenate_scripts, $compress_scripts;
     539    global $wp_scripts, $concatenate_scripts;
    540540
    541541    if ( !is_a($wp_scripts, 'WP_Scripts') )
     
    548548    $wp_scripts->do_head_items();
    549549
    550     _pring_scripts();
     550    if ( apply_filters('print_head_scripts', true) )
     551        _pring_scripts();
    551552
    552553    $wp_scripts->do_concat = false;
     554    $wp_scripts->print_code = $wp_scripts->concat = $wp_scripts->concat_version = $wp_scripts->print_html = $wp_scripts->src = '';
    553555    return $wp_scripts->done;
    554556}
     
    571573    $wp_scripts->do_footer_items();
    572574
    573     _pring_scripts();
     575    if ( apply_filters('print_footer_scripts', true) )
     576        _pring_scripts();
    574577
    575578    $wp_scripts->do_concat = false;
     579    $wp_scripts->concat = $wp_scripts->concat_version = $wp_scripts->print_code = $wp_scripts->print_html = $wp_scripts->src = '';
    576580    return $wp_scripts->done;
    577581}
     
    590594            echo "/* ]]> */\n";
    591595            echo "</script>\n";
    592             $wp_scripts->print_code = '';
    593596        }
    594597
    595         $ver = md5($wp_scripts->concat_version);
    596         $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . rtrim($wp_scripts->concat, ',') . "&ver=$ver";
     598        $ver = md5("$wp_scripts->concat" . "$wp_scripts->concat_version");
     599        $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&amp;load=" . rtrim($wp_scripts->concat, ',') . "&amp;ver=$ver";
    597600        echo "<script type='text/javascript' src='$src'></script>\n";
    598         $wp_scripts->concat = $wp_scripts->concat_version = '';
    599601    }
    600602
    601     if ( !empty($wp_scripts->print_html) ) {
     603    if ( !empty($wp_scripts->print_html) )
    602604        echo $wp_scripts->print_html;
    603         $wp_scripts->print_html = '';
    604     }
     605
    605606}
    606607
     
    619620    $wp_styles->do_items(false);
    620621
    621     if ( !empty($wp_styles->concat) ) {
    622         $ver = md5($wp_styles->concat_version);
    623         $rtl = 'rtl' === $wp_styles->text_direction ? 1 : 0;
    624         $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&rtl={$rtl}&load=" . rtrim($wp_styles->concat, ',') . "&ver=$ver";
    625         echo "<link rel='stylesheet' href='$href' type='text/css' media='all' />\n";
    626         $wp_styles->concat = $wp_styles->concat_version = '';
     622    if ( apply_filters('print_admin_styles', true) ) {
     623        if ( !empty($wp_styles->concat) ) {
     624            $ver = md5("$wp_styles->concat" . "$wp_styles->concat_version");
     625            $rtl = 'rtl' === $wp_styles->text_direction ? 1 : 0;
     626            $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&amp;rtl={$rtl}&amp;load=" . rtrim($wp_styles->concat, ',') . "&amp;ver=$ver";
     627            echo "<link rel='stylesheet' href='$href' type='text/css' media='all' />\n";
     628        }
     629
     630        if ( !empty($wp_styles->print_html) )
     631            echo $wp_styles->print_html;
    627632    }
    628633
    629     if ( !empty($wp_styles->print_html) ) {
    630         echo $wp_styles->print_html;
    631         $wp_styles->print_html = '';
    632     }
    633 
    634634    $wp_styles->do_concat = false;
     635    $wp_styles->concat = $wp_styles->concat_version = $wp_styles->print_html = '';
    635636    return $wp_styles->done;
    636637}
Note: See TracChangeset for help on using the changeset viewer.