【发布时间】:2016-05-27 03:32:06
【问题描述】:
我有一个带有所见即所得编辑器的主题设置页面。我想使用带有属性的简码。
这是具有属性的简码之一,用作示例:
function row( $atts, $content = null ) {
extract(shortcode_atts(
array(
'paddingtop' => 'PADDINGTOP',
), $atts )
);
return '<div class="row" style="padding-top:'.$paddingtop.';"></div>';
}
add_shortcode( 'fila', 'row');
在这里,我将所见即所得编辑器添加到我的主题设置页面:
array(
'name' => '',
'id' => 'editor_top_shop',
'type' => 'editor',
'note' => '',
),
这是我在编辑器中检查和打印内容的方式:
<?php if ( get_option( 'editor_top_shop' ) == true ) {
$top_shop = get_option( 'editor_top_shop' );
echo stripslashes(apply_filters("the_content", $top_shop));
<?php } ?>
编辑器中的短代码:
[fila paddingtop="40px"]
最后,这是 HTML 输出:
<div class="row" style="padding-top:PADDINGTOP;"></div>
我会很感激一些反馈,我对此很生气:(
非常感谢! 弗雷德
【问题讨论】:
-
$atts 和 $content 变量中有什么?