感谢大家的回复。作为WordPress和OOP的新手,创建自己的类似乎相当令人畏惧。我已经拼凑出另一个解决方案来完成这项工作。
首先,我重新启用了自定义标题主题支持,然后修改了我的函数。php文件。
首先,我想阻止用户从wp主菜单访问“Header”链接。通过标题链接,他们可以上传图像,因此通过添加以下代码段,我可以从管理菜单中删除此内容:
add_action( \'admin_menu\', \'adjust_the_wp_menu\', 999 );
function adjust_the_wp_menu() {
$page = remove_submenu_page( \'themes.php\', \'custom-header\' );
}
然后,我使用register\\u default\\u headers()函数将默认图像加载到现有的custom\\u头中。我不知道怎么做,但这也提供了从自定义窗口停止上传所需的功能。在自定义主题视图中,在标题图像下的“上载”旁边创建了一个名为“默认”的选项卡。
add_action( \'after_setup_theme\', \'add_default_banner_images\' );
if ( ! function_exists(\'add_default_banner_images\') ):
define( \'HEADER_IMAGE\', \'%s/banners/5.jpg\' );
register_default_headers(
array (
\'head\' => array (
\'url\' => \'%s/banners/1.jpg\',
\'thumbnail_url\' => \'%s/banners/1.jpg\',
\'description\' => __( \'Image 01\', \'twentytwelve_mod\' )
),
\'vision\' => array (
\'url\' => \'%s/banners/2.jpg\',
\'thumbnail_url\' => \'%s/banners/2.jpg\',
\'description\' => __( \'Image 02\', \'twentytwelve_mod\' )
),
\'gallery\' => array (
\'url\' => \'%s/banners/3.jpg\',
\'thumbnail_url\' => \'%s/banners/3.jpg\',
\'description\' => __( \'Image 03\', \'twentytwelve_mod\' )
),
\'sea\' => array (
\'url\' => \'%s/banners/4.jpg\',
\'thumbnail_url\' => \'%s/banners/4.jpg\',
\'description\' => __( \'Image 04\', \'twentytwelve_mod\' )
),
\'orangeworld\' => array (
\'url\' => \'%s/banners/5.jpg\',
\'thumbnail_url\' => \'%s/banners/5.jpg\',
\'description\' => __( \'Image 05\', \'twentytwelve_mod\' )
)
)
);
}
endif;
最后,我利用“cusomize\\u register”挂钩删除了标题图像下不需要的“Upload”选项卡:
add_action( \'customize_register\', \'customize_register_mytheme\' );
function customize_register_mytheme( $wp_customize ) {
//Remove \'uploaded\' tab from control \'header_image\'
$controlHeaderImage = $wp_customize->get_control( \'header_image\' );
$controlHeaderImage->remove_tab( \'uploaded\' );
}