wp_prototype_before_jquery

Reorder JavaScript scripts array to place prototype before jQuery.

Description

(array) wp_prototype_before_jquery( (array) $js_array ); 

Returns (array)

Reordered array, if needed.

Parameters (1)

0. $js_array (array)
JavaScript scripts array

Usage

  1. if ( !function_exists( 'wp_prototype_before_jquery' ) ) { 
  2. require_once ABSPATH . WPINC . '/script-loader.php'; 
  3.  
  4. // JavaScript scripts array 
  5. $js_array = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_prototype_before_jquery($js_array); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/script-loader.php  
  1. function wp_prototype_before_jquery( $js_array ) { 
  2. if ( false === $prototype = array_search( 'prototype', $js_array, true ) ) 
  3. return $js_array; 
  4.  
  5. if ( false === $jquery = array_search( 'jquery', $js_array, true ) ) 
  6. return $js_array; 
  7.  
  8. if ( $prototype < $jquery ) 
  9. return $js_array; 
  10.  
  11. unset($js_array[$prototype]); 
  12.  
  13. array_splice( $js_array, $jquery, 0, 'prototype' ); 
  14.  
  15. return $js_array;