wp_default_scripts() – Registers all WordPress scripts.

You appear to be a bot. Output may be restricted

Description

Registers all WordPress scripts.

Localizes some of them. args order: $scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 ); when last arg === 1 queues the script for the footer

Usage

wp_default_scripts( $scripts );

Parameters

$scripts
( WP_Scripts ) required – WP_Scripts object.

Returns

void

Source

File name: wordpress/wp-includes/script-loader.php


Lines:

1 to 100 of 776
function wp_default_scripts( $scripts ) {
  $suffix     = wp_scripts_get_suffix();
  $dev_suffix = wp_scripts_get_suffix( 'dev' );
  $guessurl   = site_url();

  if ( ! $guessurl ) {
    $guessed_url = true;
    $guessurl    = wp_guess_url();
  }

  $scripts->base_url        = $guessurl;
  $scripts->content_url     = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : '';
  $scripts->default_version = get_bloginfo( 'version' );
  $scripts->default_dirs    = array( '/wp-admin/js/', '/wp-includes/js/' );

  $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" );
  did_action( 'init' ) && $scripts->localize(
    'utils',
    'userSettings',
    array(
      'url'    => (string) SITECOOKIEPATH,
      'uid'    => (string) get_current_user_id(),
      'time'   => (string) time(),
      'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ),
    )
  );

  $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils' ), false, 1 );
  $scripts->set_translations( 'common' );

  $scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 );

  $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );

  $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 );
  did_action( 'init' ) && $scripts->localize(
    'quicktags',
    'quicktagsL10n',
    array(
      'closeAllOpenTags'      => __( 'Close all open tags' ),
      'closeTags'             => __( 'close tags' ),
      'enterURL'              => __( 'Enter the URL' ),
      'enterImageURL'         => __( 'Enter the URL of the image' ),
      'enterImageDescription' => __( 'Enter a description of the image' ),
      'textdirection'         => __( 'text direction' ),
      'toggleTextdirection'   => __( 'Toggle Editor Text Direction' ),
      'dfw'                   => __( 'Distraction-free writing mode' ),
      'strong'                => __( 'Bold' ),
      'strongClose'           => __( 'Close bold tag' ),
      'em'                    => __( 'Italic' ),
      'emClose'               => __( 'Close italic tag' ),
      'link'                  => __( 'Insert link' ),
      'blockquote'            => __( 'Blockquote' ),
      'blockquoteClose'       => __( 'Close blockquote tag' ),
      'del'                   => __( 'Deleted text (strikethrough)' ),
      'delClose'              => __( 'Close deleted text tag' ),
      'ins'                   => __( 'Inserted text' ),
      'insClose'              => __( 'Close inserted text tag' ),
      'image'                 => __( 'Insert image' ),
      'ul'                    => __( 'Bulleted list' ),
      'ulClose'               => __( 'Close bulleted list tag' ),
      'ol'                    => __( 'Numbered list' ),
      'olClose'               => __( 'Close numbered list tag' ),
      'li'                    => __( 'List item' ),
      'liClose'               => __( 'Close list item tag' ),
      'code'                  => __( 'Code' ),
      'codeClose'             => __( 'Close code tag' ),
      'more'                  => __( 'Insert Read More tag' ),
    )
  );

  $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array( 'prototype' ), '3517m' );

  $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 );

  $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), '2.0.11', 1 );

  $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
  did_action( 'init' ) && $scripts->localize(
    'wp-ajax-response',
    'wpAjax',
    array(
      'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
      'broken' => __( 'Something went wrong.' ),
    )
  );

  $scripts->add( 'wp-api-request', "/wp-includes/js/api-request$suffix.js", array( 'jquery' ), false, 1 );
  // `wpApiSettings` is also used by `wp-api`, which depends on this script.
  did_action( 'init' ) && $scripts->localize(
    'wp-api-request',
    'wpApiSettings',
    array(
      'root'          => sanitize_url( get_rest_url() ),
      'nonce'         => wp_installing() ? '' : wp_create_nonce( 'wp_rest' ),
      'versionString' => 'wp/v2/',
    )

 View on GitHub View on Trac