wp_get_theme_preview_path

函数
wp_get_theme_preview_path ( $current_stylesheet = null )
参数
  • (string) $current_stylesheet The current theme's stylesheet or template path.
    Required:
    Default: null
返回值
  • (string) The previewed theme's stylesheet or template path.
定义位置
相关方法
get_theme_file_path_wp_get_attachment_relative_pathwp_initialize_theme_preview_hookswp_attach_theme_preview_middlewareget_parent_theme_file_path
引入
6.3.0
弃用
-

过滤博客选项,返回预览主题的路径。

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;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 20:33:00

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: