-
+ D95199605A8ED528631AF9F91D17BB3A20DCDB9C9B8BAE0B0DF224DB9D8F4F400971E4F1E0E90D9E35D2B5673AB47122D3487463B31003C4AD826125873EB33Fmp-wp/wp-includes/class.wp-scripts.php(0 . 0)(1 . 110)
81745 <?php
81746 /**
81747 * BackPress Scripts enqueue.
81748 *
81749 * These classes were refactored from the WordPress WP_Scripts and WordPress
81750 * script enqueue API.
81751 *
81752 * @package BackPress
81753 * @since r16
81754 */
81755
81756 /**
81757 * BackPress Scripts enqueue class.
81758 *
81759 * @package BackPress
81760 * @uses WP_Dependencies
81761 * @since r16
81762 */
81763 class WP_Scripts extends WP_Dependencies {
81764 var $base_url; // Full URL with trailing slash
81765 var $default_version;
81766
81767 function __construct() {
81768 do_action_ref_array( 'wp_default_scripts', array(&$this) );
81769 }
81770
81771 /**
81772 * Prints scripts
81773 *
81774 * Prints the scripts passed to it or the print queue. Also prints all necessary dependencies.
81775 *
81776 * @param mixed handles (optional) Scripts to be printed. (void) prints queue, (string) prints that script, (array of strings) prints those scripts.
81777 * @return array Scripts that have been printed
81778 */
81779 function print_scripts( $handles = false ) {
81780 return $this->do_items( $handles );
81781 }
81782
81783 function print_scripts_l10n( $handle ) {
81784 if ( empty($this->registered[$handle]->extra['l10n']) || empty($this->registered[$handle]->extra['l10n'][0]) || !is_array($this->registered[$handle]->extra['l10n'][1]) )
81785 return false;
81786
81787 $object_name = $this->registered[$handle]->extra['l10n'][0];
81788
81789 echo "<script type='text/javascript'>\n";
81790 echo "/* <![CDATA[ */\n";
81791 echo "\t$object_name = {\n";
81792 $eol = '';
81793 foreach ( $this->registered[$handle]->extra['l10n'][1] as $var => $val ) {
81794 if ( 'l10n_print_after' == $var ) {
81795 $after = $val;
81796 continue;
81797 }
81798 echo "$eol\t\t$var: \"" . js_escape( $val ) . '"';
81799 $eol = ",\n";
81800 }
81801 echo "\n\t}\n";
81802 echo isset($after) ? "\t$after\n" : '';
81803 echo "/* ]]> */\n";
81804 echo "</script>\n";
81805
81806 return true;
81807 }
81808
81809 function do_item( $handle ) {
81810 if ( !parent::do_item($handle) )
81811 return false;
81812
81813 $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
81814 if ( isset($this->args[$handle]) )
81815 $ver .= '&' . $this->args[$handle];
81816
81817 $src = $this->registered[$handle]->src;
81818 if ( !preg_match('|^https?://|', $src) && !preg_match('|^' . preg_quote(WP_CONTENT_URL) . '|', $src) ) {
81819 $src = $this->base_url . $src;
81820 }
81821
81822 $src = add_query_arg('ver', $ver, $src);
81823 $src = clean_url(apply_filters( 'script_loader_src', $src, $handle ));
81824
81825 $this->print_scripts_l10n( $handle );
81826
81827 echo "<script type='text/javascript' src='$src'></script>\n";
81828
81829 return true;
81830 }
81831
81832 /**
81833 * Localizes a script
81834 *
81835 * Localizes only if script has already been added
81836 *
81837 * @param string handle Script name
81838 * @param string object_name Name of JS object to hold l10n info
81839 * @param array l10n Array of JS var name => localized string
81840 * @return bool Successful localization
81841 */
81842 function localize( $handle, $object_name, $l10n ) {
81843 if ( !$object_name || !$l10n )
81844 return false;
81845 return $this->add_data( $handle, 'l10n', array( $object_name, $l10n ) );
81846 }
81847
81848 function all_deps( $handles, $recursion = false ) {
81849 $r = parent::all_deps( $handles, $recursion );
81850 if ( !$recursion )
81851 $this->to_do = apply_filters( 'print_scripts_array', $this->to_do );
81852 return $r;
81853 }
81854 }