wp_default_styles

Assign default styles to $styles object.

Description

wp_default_styles( (WP_Styles) &$styles ); 

Nothing is returned, because the $styles parameter is passed by reference. Meaning that whatever object is passed will be updated without having to reassign the variable that was passed back to the same value. This saves memory.

Adding default styles is not the only task, it also assigns the base_url property, the default version, and text direction for the object.

Parameters (1)

0. $styles (WP_Styles) => &$styles
The styles.

Usage

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

Defined (1)

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

/wp-includes/script-loader.php  
  1. function wp_default_styles( &$styles ) { 
  2. include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 
  3.  
  4. if ( ! defined( 'SCRIPT_DEBUG' ) ) 
  5. define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); 
  6.  
  7. if ( ! $guessurl = site_url() ) 
  8. $guessurl = wp_guess_url(); 
  9.  
  10. $styles->base_url = $guessurl; 
  11. $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : ''; 
  12. $styles->default_version = get_bloginfo( 'version' ); 
  13. $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr'; 
  14. $styles->default_dirs = array('/wp-admin/', '/wp-includes/css/'); 
  15.  
  16. // Open Sans is no longer used by core, but may be relied upon by themes and plugins. 
  17. $open_sans_font_url = ''; 
  18.  
  19. /** translators: If there are characters in your language that are not supported 
  20. * by Open Sans, translate this to 'off'. Do not translate into your own language. 
  21. */ 
  22. if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) { 
  23. $subsets = 'latin, latin-ext'; 
  24.  
  25. /** translators: To add an additional Open Sans character subset specific to your language,  
  26. * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. 
  27. */ 
  28. $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' ); 
  29.  
  30. if ( 'cyrillic' == $subset ) { 
  31. $subsets .= ', cyrillic, cyrillic-ext'; 
  32. } elseif ( 'greek' == $subset ) { 
  33. $subsets .= ', greek, greek-ext'; 
  34. } elseif ( 'vietnamese' == $subset ) { 
  35. $subsets .= ', vietnamese'; 
  36.  
  37. // Hotlink Open Sans, for now 
  38. $open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic, 400italic, 600italic, 300, 400, 600&subset=$subsets"; 
  39.  
  40. // Register a stylesheet for the selected admin color scheme. 
  41. $styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) ); 
  42.  
  43. $suffix = SCRIPT_DEBUG ? '' : '.min'; 
  44.  
  45. // Admin CSS 
  46. $styles->add( 'common', "/wp-admin/css/common$suffix.css" ); 
  47. $styles->add( 'forms', "/wp-admin/css/forms$suffix.css" ); 
  48. $styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" ); 
  49. $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css" ); 
  50. $styles->add( 'list-tables', "/wp-admin/css/list-tables$suffix.css" ); 
  51. $styles->add( 'edit', "/wp-admin/css/edit$suffix.css" ); 
  52. $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" ); 
  53. $styles->add( 'media', "/wp-admin/css/media$suffix.css" ); 
  54. $styles->add( 'themes', "/wp-admin/css/themes$suffix.css" ); 
  55. $styles->add( 'about', "/wp-admin/css/about$suffix.css" ); 
  56. $styles->add( 'nav-menus', "/wp-admin/css/nav-menus$suffix.css" ); 
  57. $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css" ); 
  58. $styles->add( 'site-icon', "/wp-admin/css/site-icon$suffix.css" ); 
  59. $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" ); 
  60.  
  61. $styles->add( 'wp-admin', false, array( 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n' ) ); 
  62.  
  63. $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) ); 
  64. $styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'buttons' ) ); 
  65. $styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" ); 
  66. $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) ); 
  67. $styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) ); 
  68. $styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) ); 
  69. $styles->add( 'press-this', "/wp-admin/css/press-this$suffix.css", array( 'buttons' ) ); 
  70.  
  71. $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" ); 
  72. $styles->add_data( 'ie', 'conditional', 'lte IE 7' ); 
  73.  
  74. // Common dependencies 
  75. $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); 
  76. $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" ); 
  77.  
  78. // Includes CSS 
  79. $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'dashicons' ) ); 
  80. $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) ); 
  81. $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) ); 
  82. $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) ); 
  83. $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) ); 
  84. $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) ); 
  85. $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" ); 
  86. $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' ); 
  87.  
  88. // External libraries and friends 
  89. $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); 
  90. $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) ); 
  91. $styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer.min.css", array(), '2.22.0' ); 
  92. $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) ); 
  93. $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) ); 
  94.  
  95. // Deprecated CSS 
  96. $styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" ); 
  97. $styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' ); 
  98. $styles->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.css", array(), '0.9.12' ); 
  99. $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle. 
  100. $styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6 
  101.  
  102. // RTL CSS 
  103. $rtl_styles = array( 
  104. // wp-admin 
  105. 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus',  
  106. 'widgets', 'site-icon', 'l10n', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', 'customize-preview',  
  107. 'ie', 'login', 'press-this',  
  108. // wp-includes 
  109. 'buttons', 'admin-bar', 'wp-auth-check', 'editor-buttons', 'media-views', 'wp-pointer',  
  110. 'wp-jquery-ui-dialog',  
  111. // deprecated 
  112. 'deprecated-media', 'farbtastic',  
  113. ); 
  114.  
  115. foreach ( $rtl_styles as $rtl_style ) { 
  116. $styles->add_data( $rtl_style, 'rtl', 'replace' ); 
  117. if ( $suffix ) { 
  118. $styles->add_data( $rtl_style, 'suffix', $suffix );