[フレーム]
WordPress.org
Get WordPress
WordPress.org

WordPress Developer Resources

get_stylesheet_directory_uri()

Home Reference Functions get_stylesheet_directory_uri()

get_stylesheet_directory_uri(): string

Retrieves stylesheet directory URI for the active theme.

Return

string URI to active theme’s stylesheet directory.

More Information

  • The returned URI does not contain a trailing slash.
  • This function returns a properly-formed URI; in other words, it will be a web-address (starting with http:// or https:// for SSL). As such, it is most appropriately used for links, referencing additional stylesheets, or probably most commonly, images.
  • In the event a child theme is being used, this function will return the child’s theme directory URI. Use get_template_directory_uri() to avoid being overridden by a child theme.
  • If you want to include a local file in PHP, use get_stylesheet_directory() instead.

Source

function get_stylesheet_directory_uri() {
	$stylesheet = str_replace( '%2F', '/', rawurlencode( get_stylesheet() ) );
	$theme_root_uri = get_theme_root_uri( $stylesheet );
	$stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
	/**
	 * Filters the stylesheet directory URI.
	 *
	 * @since 1.5.0
	 *
	 * @param string $stylesheet_dir_uri Stylesheet directory URI.
	 * @param string $stylesheet Name of the activated theme's directory.
	 * @param string $theme_root_uri Themes root URI.
	 */
	return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri );
}

View all references View on Trac View on GitHub

Hooks

apply_filters( ‘stylesheet_directory_uri’, string $stylesheet_dir_uri, string $stylesheet, string $theme_root_uri )

Filters the stylesheet directory URI.

UsesDescription
get_theme_root_uri() wp-includes/theme.php

Retrieves URI for themes directory.

get_stylesheet() wp-includes/theme.php

Retrieves name of the current stylesheet.

apply_filters() wp-includes/plugin.php

Calls the callback functions that have been added to a filter hook.

Show 1 more Show less
Used byDescription
WP_URL_Pattern_Prefixer::get_default_contexts() wp-includes/class-wp-url-pattern-prefixer.php

Returns the default contexts used by the class.

WP_REST_Themes_Controller::prepare_item_for_response() wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php

Prepares a single theme output for response.

get_theme_file_uri() wp-includes/link-template.php

Retrieves the URL of a file in the theme.

get_editor_stylesheets() wp-includes/theme.php

Retrieves any registered editor stylesheet URLs.

Custom_Image_Header::get_default_header_images() wp-admin/includes/class-custom-image-header.php

Gets the details of default header images if defined.

Custom_Image_Header::step_1() wp-admin/includes/class-custom-image-header.php

Displays first step of custom header image page.

Custom_Image_Header::reset_header_image() wp-admin/includes/class-custom-image-header.php

Resets a header image to the default image for the theme.

Custom_Image_Header::process_default_headers() wp-admin/includes/class-custom-image-header.php

Processes the default headers.

WP_Customize_Manager::register_controls() wp-includes/class-wp-customize-manager.php

Registers some default controls.

_get_random_header_data() wp-includes/theme.php

Gets random header image data from registered images in theme.

get_custom_header() wp-includes/theme.php

Gets the header image data.

get_theme_mod() wp-includes/theme.php

Retrieves theme modification value for the active theme.

get_stylesheet_uri() wp-includes/theme.php

Retrieves stylesheet URI for the active theme.

get_locale_stylesheet_uri() wp-includes/theme.php

Retrieves the localized stylesheet URI.

get_bloginfo() wp-includes/general-template.php

Retrieves information about the current site.

Show 10 more Show less

Changelog

VersionDescription
1.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.

AltStyle によって変換されたページ (->オリジナル) /