locate_template

Definition:
function locate_template($template_names, $load = false, $require_once = true ) {}

Retrieve the name of the highest priority template file that exists.
Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which inherit from a parent theme can just overload one file.

Parameters

  • string|array $template_names: Template file(s) to search for, in order.
  • bool $load: If true the template file will be loaded if it is found.
  • bool $require_once: Whether to require_once or require. Default true. Has no effect if $load is false.

Return values

returns:The template filename if one is located.

Source code

function locate_template($template_names, $load = false, $require_once = true ) {

	$located = '';

	foreach ( (array) $template_names as $template_name ) {

		if ( !$template_name )

			continue;

		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {

			$located = STYLESHEETPATH . '/' . $template_name;

			break;

		} else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {

			$located = TEMPLATEPATH . '/' . $template_name;

			break;

		}

	}



	if ( $load && '' != $located )

		load_template( $located, $require_once );



	return $located;

}

2297

locale_stylesheet

Definition:
function locale_stylesheet() {}

Display localized stylesheet link element.

Source code

function locale_stylesheet() {

	$stylesheet = get_locale_stylesheet_uri();

	if ( empty($stylesheet) )

		return;

	echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';

}

2295

load_theme_textdomain

Definition:
function load_theme_textdomain( $domain, $path = false ) {}

Loads the theme’s translated strings.
If the current locale exists as a .mo file in the theme’s root directory, it will be included in the translated strings by the $domain.

Parameters

  • string $domain: Unique identifier for retrieving translated strings
  • $path

Defined filters

  • theme_locale
    apply_filters( 'theme_locale', get_locale()

Source code

function load_theme_textdomain( $domain, $path = false ) {

	$locale = apply_filters( 'theme_locale', get_locale(), $domain );



	$path = ( empty( $path ) ) ? get_template_directory() : $path;



	$mofile = "$path/$locale.mo";

	return load_textdomain($domain, $mofile);

}

2293

load_textdomain

Definition:
function load_textdomain( $domain, $mofile ) {}

Loads a MO file into the domain $domain.
If the domain already exists, the translations will be merged. If both sets have the same string, the translation from the original value will be taken.

Parameters

  • string $domain: Unique identifier for retrieving translated strings
  • string $mofile: Path to the .mo file

Return values

returns:True on success, false on failure

Defined filters

  • override_load_textdomain
    apply_filters( 'override_load_textdomain', false, $domain, $mofile )
  • load_textdomain_mofile
    apply_filters( 'load_textdomain_mofile', $mofile, $domain )

Defined actions

  • load_textdomain
    do_action( 'load_textdomain', $domain, $mofile );

Source code

function load_textdomain( $domain, $mofile ) {

	global $l10n;



	$plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );



	if ( true == $plugin_override ) {

		return true;

	}



	do_action( 'load_textdomain', $domain, $mofile );



	$mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );



	if ( !is_readable( $mofile ) ) return false;



	$mo = new MO();

	if ( !$mo->import_from_file( $mofile ) ) return false;



	if ( isset( $l10n[$domain] ) )

		$mo->merge_with( $l10n[$domain] );



	$l10n[$domain] = &$mo;



	return true;

}

2291