我正在我的函数中添加对编辑器字体大小的主题支持。php,但它不起作用。知道为什么吗?
我已经添加了一个没有问题的自定义调色板,但有以下问题:
add_theme_support( \'editor-font-sizes\', array(
array(
\'name\' => __( \'extra small\', \'platetheme\' ),
\'shortName\' => __( \'XS\', \'platetheme\' ),
\'size\' => 11,
\'slug\' => \'small\'
),
array(
\'name\' => __( \'regular\', \'platetheme\' ),
\'shortName\' => __( \'M\', \'platetheme\' ),
\'size\' => 16,
\'slug\' => \'regular\'
),
array(
\'name\' => __( \'large\', \'platetheme\' ),
\'shortName\' => __( \'L\', \'platetheme\' ),
\'size\' => 36,
\'slug\' => \'large\'
),
array(
\'name\' => __( \'larger\', \'platetheme\' ),
\'shortName\' => __( \'XL\', \'platetheme\' ),
\'size\' => 50,
\'slug\' => \'larger\'
)
) );
我曾尝试禁用自定义字体大小,以查看这是否是一项要求(代码正常工作对上述内容没有帮助)
add_theme_support(\'disable-custom-font-sizes\');
知道它为什么不能在后端编辑器上工作吗?
最合适的回答,由SO网友:thetwopct 整理而成
我相信要让它工作起来,我没有在正确的时间调用它,我将它包装在一个函数中after_setup_theme
, 像这样:
add_action( \'after_setup_theme\', \'ttp_custom_font_sizes\' );
function ttp_custom_font_sizes() {
// removes custom font sizes
add_theme_support(\'disable-custom-font-sizes\');
// add my own custom sizes
add_theme_support( \'editor-font-sizes\', array(
array(
\'name\' => __( \'Small\'),
\'size\' => 12,
\'slug\' => \'small\'
),
array(
\'name\' => __( \'Normal\'),
\'size\' => 16,
\'slug\' => \'normal\'
),
array(
\'name\' => __( \'Large\'),
\'size\' => 36,
\'slug\' => \'large\'
),
array(
\'name\' => __( \'Huge\'),
\'size\' => 50,
\'slug\' => \'huge\'
)
) );
}