resume_theme
函数
resume_theme ( $theme, $redirect = '' )
- 参数
-
-
(string)
$theme
Single theme to resume.- Required: 是
-
(string)
$redirect
Optional. URL to redirect to. Default empty string.- Required: 否
- Default: (empty)
-
(string)
- 返回值
-
- (bool|WP_Error) True on success, false if `$theme` was not paused, `WP_Error` on failure.
- 定义位置
-
-
wp-admin/includes/theme.php
, line 1137
-
wp-admin/includes/theme.php
- 引入
- 5.2.0
- 弃用
- –
试图恢复一个单一的主题。
如果提供了重定向,并且找到了function.php文件,我们首先确保function.php文件不再抛出致命的错误。
它的工作方式是在尝试包含该文件之前将重定向设置为错误。如果主题失败了,那么重定向将不会被成功信息覆盖,主题也不会被恢复。
function resume_theme( $theme, $redirect = '' ) {
list( $extension ) = explode( '/', $theme );
/*
* We'll override this later if the theme could be resumed without
* creating a fatal error.
*/
if ( ! empty( $redirect ) ) {
$functions_path = '';
if ( strpos( STYLESHEETPATH, $extension ) ) {
$functions_path = STYLESHEETPATH . '/functions.php';
} elseif ( strpos( TEMPLATEPATH, $extension ) ) {
$functions_path = TEMPLATEPATH . '/functions.php';
}
if ( ! empty( $functions_path ) ) {
wp_redirect(
add_query_arg(
'_error_nonce',
wp_create_nonce( 'theme-resume-error_' . $theme ),
$redirect
)
);
// Load the theme's functions.php to test whether it throws a fatal error.
ob_start();
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
define( 'WP_SANDBOX_SCRAPING', true );
}
include $functions_path;
ob_clean();
}
}
$result = wp_paused_themes()->delete( $extension );
if ( ! $result ) {
return new WP_Error(
'could_not_resume_theme',
__( 'Could not resume the theme.' )
);
}
return true;
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。