Php 未设置图像时包括默认的获取主题模式
因此,我正在构建我的主题,我正在WordPress上学习Php 未设置图像时包括默认的获取主题模式,php,wordpress,themes,Php,Wordpress,Themes,因此,我正在构建我的主题,我正在WordPress上学习get\u theme\u mod(),但我想再次检查主题开发人员在没有任何设置的情况下如何处理get\u theme\u mod() 所以我在Customizer中创建了我的部分来上传我的徽标 这是默认的WordPress。登录h1a: background-image: url(../images/w-logo-blue.png?ver=20131202); background-image: none,url(../image
get\u theme\u mod()
,但我想再次检查主题开发人员在没有任何设置的情况下如何处理get\u theme\u mod()
所以我在Customizer中创建了我的部分来上传我的徽标
这是默认的WordPress。登录h1a
:
background-image: url(../images/w-logo-blue.png?ver=20131202);
background-image: none,url(../images/wordpress-logo.svg?ver=20131107);
background-size: 84px;
background-position: center top;
background-repeat: no-repeat;
因此,我有一个自定义函数,它接受该徽标并覆盖/wp admin login徽标:
if (!function_exists('sillyemu_login_logo')) {
function sillyemu_login_logo()
{
// @todo: Fix bug that doesn't show the default WordPress logo when there is no theme mod.
$logo_url = wp_get_attachment_url(get_theme_mod('login_panel_logo'));
?>
<style type="text/css">
.login h1 a {
background-image: url(<?php echo $logo_url ?>)!important;
background-size: cover;
margin: 0 0 15px auto;
width: auto;
height: 100px;
}
</style>
<?php
}
}
add_action('login_head', 'sillyemu_login_logo');
在未设置任何设置的情况下,将默认值恢复到正常值的最佳方法是什么?我得到的回报是背景图像:url()
.login h1 a {
background-image: url()!important;
background-size: cover;
margin: 0 0 15px auto;
width: auto;
height: 100px;