wp_prototype_before_jquery() WordPress Function

The wp_prototype_before_jquery() function is used to load the Prototype JavaScript library before jQuery. This is necessary when using certain plugins that require Prototype.

wp_prototype_before_jquery( array $js_array ) #

Reorders JavaScript scripts array to place prototype before jQuery.


Parameters

$js_array

(array)(Required)JavaScript scripts array


Top ↑

Return

(array) Reordered array, if needed.


Top ↑

Source

File: wp-includes/script-loader.php

function wp_prototype_before_jquery( $js_array ) {
	$prototype = array_search( 'prototype', $js_array, true );

	if ( false === $prototype ) {
		return $js_array;
	}

	$jquery = array_search( 'jquery', $js_array, true );

	if ( false === $jquery ) {
		return $js_array;
	}

	if ( $prototype < $jquery ) {
		return $js_array;
	}

	unset( $js_array[ $prototype ] );

	array_splice( $js_array, $jquery, 0, 'prototype' );

	return $js_array;
}

Top ↑

Changelog

Changelog
VersionDescription
2.3.1Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More