wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_get_theme_preview_path › WordPress Function

Seit6.3.0
Veraltetn/v
wp_get_theme_preview_path ( $current_stylesheet = null )
Parameter:
  • (string) $current_stylesheet The current theme's stylesheet or template path.
    Erforderlich: Nein
    Standard: null
Gibt zurück:
  • (string) The previewed theme's stylesheet or template path.
Definiert in:
Codex:

Filters the blog option to return the path for the previewed theme.



Quellcode

function wp_get_theme_preview_path( $current_stylesheet = null ) {
	if ( ! current_user_can( 'switch_themes' ) ) {
		return $current_stylesheet;
	}

	$preview_stylesheet = ! empty( $_GET['wp_theme_preview'] ) ? sanitize_text_field( wp_unslash( $_GET['wp_theme_preview'] ) ) : null;
	$wp_theme           = wp_get_theme( $preview_stylesheet );
	if ( ! is_wp_error( $wp_theme->errors() ) ) {
		if ( current_filter() === 'template' ) {
			$theme_path = $wp_theme->get_template();
		} else {
			$theme_path = $wp_theme->get_stylesheet();
		}

		return sanitize_text_field( $theme_path );
	}

	return $current_stylesheet;
}