Changeset 10357 for trunk/wp-includes/class.wp-dependencies.php
- Timestamp:
- 01/14/2009 02:18:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class.wp-dependencies.php
r9002 r10357 23 23 var $done = array(); 24 24 var $args = array(); 25 var $groups = array(); 26 var $group = 0; 25 27 26 28 function WP_Dependencies() { … … 39 41 * @return array Items that have been processed 40 42 */ 41 function do_items( $handles = false ) {43 function do_items( $handles = false, $group = false ) { 42 44 // Print the queue if nothing is passed. If a string is passed, print that script. If an array is passed, print those scripts. 43 45 $handles = false === $handles ? $this->queue : (array) $handles; 44 46 $this->all_deps( $handles ); 45 47 46 foreach( $this->to_do as $ handle ) {48 foreach( $this->to_do as $key => $handle ) { 47 49 if ( !in_array($handle, $this->done) && isset($this->registered[$handle]) ) { 48 if ( $this->registered[$handle]->src ) { // Else it defines a group. 49 $this->do_item( $handle ); 50 51 if ( ! $this->registered[$handle]->src ) { // Defines a group. 52 $this->done[] = $handle; 53 continue; 50 54 } 51 $this->done[] = $handle; 55 56 if ( $this->do_item( $handle, $group ) ) 57 $this->done[] = $handle; 58 59 unset( $this->to_do[$key] ); 52 60 } 53 61 } 54 62 55 $this->to_do = array();56 63 return $this->done; 57 64 } … … 70 77 * @param bool recursion Used internally when function calls itself 71 78 */ 72 function all_deps( $handles, $recursion = false ) {79 function all_deps( $handles, $recursion = false, $group = false ) { 73 80 if ( !$handles = (array) $handles ) 74 81 return false; 75 82 76 83 foreach ( $handles as $handle ) { 77 $handle = explode('?', $handle); 78 if ( isset($handle[1]) ) 79 $this->args[$handle[0]] = $handle[1]; 80 $handle = $handle[0]; 81 82 if ( isset($this->to_do[$handle]) ) // Already grobbed it and its deps 84 $handle_parts = explode('?', $handle); 85 $handle = $handle_parts[0]; 86 87 if ( in_array($handle, $this->done, true) ) // Already done 83 88 continue; 89 90 $this->set_group( $handle, $recursion, $group ); 91 92 if ( in_array($handle, $this->to_do, true) ) // Already grobbed it and its deps 93 continue; 94 95 if ( isset($handle_parts[1]) ) 96 $this->args[$handle] = $handle_parts[1]; 84 97 85 98 $keep_going = true; … … 88 101 elseif ( $this->registered[$handle]->deps && array_diff($this->registered[$handle]->deps, array_keys($this->registered)) ) 89 102 $keep_going = false; // Script requires deps which don't exist (not a necessary check. efficiency?) 90 elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true ) )103 elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true, $group ) ) 91 104 $keep_going = false; // Script requires deps which don't exist 92 105 … … 98 111 } 99 112 100 $this->to_do[ $handle] = true;113 $this->to_do[] = $handle; 101 114 } 102 115 103 if ( !$recursion ) // at the end104 $this->to_do = array_keys( $this->to_do );105 116 return true; 106 117 } … … 182 193 } 183 194 195 function set_group( $handle, $recursion, $group ) { 196 $group = (int) $group; 197 198 if ( $recursion ) 199 $group = min($this->group, $group); 200 else 201 $this->group = $group; 202 203 if ( isset($this->groups[$handle]) && $this->groups[$handle] <= $group ) 204 return false; 205 206 $this->groups[$handle] = $group; 207 return true; 208 } 209 184 210 } 185 211
Note: See TracChangeset
for help on using the changeset viewer.