wp_prototype_before_jquery

函式
wp_prototype_before_jquery ( $js_array )
引數
  • (string[]) $js_array JavaScript scripts array
    Required:
返回值
  • (string[]) Reordered array, if needed.
定義位置
相關方法
wp_reset_querywp_privacy_exports_urlwp_post_mime_type_wherewp_edit_posts_querysanitize_title_for_query
引入
2.3.1
棄用
-

wp_prototype_before_jquery: 這個函式用於在jQuery庫之前載入Prototype JavaScript庫。如果你使用的外掛或主題需要Prototype庫才能正常工作,這個功能就很有用。

重新排列JavaScript指令碼陣列,將原型放在jQuery之前。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >