我在wordpress博客中使用了2个插件-WP-Members 和Dropbox Folder Share. 我想这样做:
[dropbox-foldershare-hyno link="[wp-members field="some_link"]" ver_como=\'lista\']
这可能吗?我在wordpress博客中使用了2个插件-WP-Members 和Dropbox Folder Share. 我想这样做:
[dropbox-foldershare-hyno link="[wp-members field="some_link"]" ver_como=\'lista\']
这可能吗?不能使用这样的短代码。解析器不会像您希望的那样读取它。
但有一个解决方法:劫持短代码dropbox-foldershare-hyno
, 运行的回调函数wp-members
在链接上,并将结果传递给原始dropbox-foldershare-hyno
回调。
未测试的示例代码:
// wait until the other plugins are loaded
add_action( \'wp_loaded\', \'wpse_100100_shortcode_magic\' );
function wpse_100100_shortcode_magic()
{
add_shortcode(
\'dropbox-foldershare-hyno\',
\'wpse_100100_shortcode_replacement\'
);
}
function wpse_100100_shortcode_replacement( $atts )
{
global $bvwidget;
if ( isset ( $atts[\'link\'] ) )
$atts[\'link\'] = wpmem_shortcode( array( \'field\' => $atts[\'link\'] ) );
return $bvwidget->replace_shortcode( $atts );
}
现在您可以使用快捷码[dropbox-foldershare-hyno]
并传递link
属性,该属性应在Dropbox文件夹共享获得之前从WP成员转换而来。dropbox-foldershare-hyno
插件变成WordPress3.6
准备好了,我们可以这样做:add_filter(\'shortcode_atts_dfh\',\'overwrite_dfh_atts\',10,3);
function overwrite_dfh_atts($out, $pairs, $atts){
if($atts[\'link\'])
$out[\'link\'] = do_shortcode( sprintf( \'[wp-members field="%s"]\', esc_attr( $atts[\'link\'] ) ) );
return $out;
}
要覆盖快捷码的链接属性,请执行以下操作:[dropbox-foldershare-hyno link="some value for the wp-member field attribute"]
如果对应的shortcode_atts_{$shortcode}
筛选器为shortcode_atts_dfh
.你可以了解更多here.
嵌套短代码仅在某些特定情况下有效:
只能嵌套封闭的短代码。换言之,[短代码]内容的样式[[短代码]。不能嵌套像[shortcode attribute=“foo”]这样的自封闭短代码do_shortcodes() 返回的内容。(参考号:Shortcodes API: Nested Shortcodes)
我安装了插件“mobble”,它提供了更多的条件标记。由于我想为移动设备隐藏一些内容,我尝试构建一个短代码[is\\u mobile]。但我尝试了很多不同的方法return do_shortcode($content); 和return $content;或return apply_filters(\'the_content\', $content);但这根本不是我想做的;(add_shortcode( \'is_mobile\', \'is_mobile_shortcode\' ); &#x