- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
shortcodes (ultimate) doen't works within homemade wordpress spoiler
(附言:以上是我问题的初始标题。我已将其改写为更笼统)
我根据 this tutorial 创建了一个自制剧透.它很好用。然而,shortcodes-ultimate 的简码在剧透中不起作用:它只是将其源代码显示为纯文本。
我的问题是如何在剧透中“启用”那些短代码?
[su_button url="http://www.my-url.com/wp-content/uploads/2015/01/fileName.txt" download = "FileName.txt" background="#FF6B53" size="2" icon="icon: download" rel="download = 'fileName'"]download[/su_button]
[dag_spoiler title="My spoiler"]
[su_button url="http://www.my-url.com/wp-content/uploads/2015/01/fileName.txt" download = "FileName.txt" background="#FF6B53" size="2" icon="icon: download" rel="download = 'fileName'"]download[/su_button]
[/dag_spoiler]
(两个按钮完全相同)
<?php
/**
* @package dag_spoiler
* @version 0.1
*/
/*
Plugin Name: ebo Spoiler
Plugin URI: http://designerandgeek.com/dag-spoiler
Description: Spoilers!
Author: ebo ft. Designer and Geek
Version: 0.1
Author URI: http://designerandgeek.com/
*/
/**
* Adds a spoiler shortcode to WordPress.
*
* @return none outputs HTML
*/
function dag_spoiler_func( $atts, $content = null ) {
$default_title = __('Spoiler alert!');
$helptext_show = __('fa-plus');
$helptext_hide = __('fa-minus');
extract( shortcode_atts( array(
'title' => 'Click to show spoiler',
), $atts ) );
$spoiler =
'<div class="dag_spoiler">' .
'<p class="dag_spoiler_header" ' .
'data-dag-spoiler-show="' . $helptext_show .'" '.
'data-dag-spoiler-hide="' . $helptext_hide . '">' . $title . '</p>' .
'<div class="dag_spoiler_content">' .
$content .
'</div>' .
'</div>';
return $spoiler;
}
add_shortcode( 'dag_spoiler', 'dag_spoiler_func' );
/*EOF*/
/**
* Enqueue plugin css and javascript
*/
add_action( 'wp_enqueue_scripts', 'dag_enqueue' );
function dag_enqueue() {
wp_register_style( 'dag-spoiler-style', plugins_url('/ebo-spoiler.css', __FILE__) );
wp_enqueue_style( 'dag-spoiler-style' );
wp_register_script( 'dag-spoiler-js', plugins_url('/ebo-spoiler.js', __FILE__) );
wp_enqueue_script( 'dag-spoiler-js' );
}
add_action( 'wp_enqueue_scripts', 'dag_enqueue' );
?>
jQuery(document).ready( jQuery(function( $ ) {
$(".dag_spoiler_header").each(function(){
$(this).click( function() {
var help_text_span = $(this).children('span.dag_spoiler_help_text');
$(this).siblings('.dag_spoiler_content').slideToggle( "slow", function() {
help_text_span.html(
help_text_span.html() == '<i class="fa '+hide_text+'"></i>' ? '<i class="fa '+show_text+'"></i>' : '<i class="fa '+hide_text+'"></i>'
);
});
});
var show_text = $(this).attr('data-dag-spoiler-show');
var hide_text = $(this).attr('data-dag-spoiler-hide');
$(this).prepend(' <span class="dag_spoiler_help_text" style="margin-right: 15px; margin-left: 5px; font-size: 14px;"> <i class="fa '+show_text+'"></i></span>');
});
}));
.dag_spoiler {
margin: .5em 0 .5em 0;
}
.dag_spoiler .dag_spoiler_header {
cursor: pointer;
font-size: 13px;
font-weight: bold;
line-height: 20px;
min-height: 20px;
padding-bottom: 7px;
padding-left: 0;
padding-right: 7px;
padding-top: 7px;
position: relative;
font-weight: bold;
}
.dag_spoiler .dag_spoiler_header::before {
font-family: FontAwesome;
font-weight: normal;
margin-left: 5px;
margin-right: 15px;
}
.dag_spoiler div.dag_spoiler_content {
padding-left: 7%;
padding-right: 7%;
display: none;
}
最佳答案
尝试添加
do_shortcode($content)
在你的剧透短代码中。像这样:
<?php
/**
* @package dag_spoiler
* @version 0.1
*/
/*
Plugin Name: ebo Spoiler
Plugin URI: http://designerandgeek.com/dag-spoiler
Description: Spoilers!
Author: ebo ft. Designer and Geek
Version: 0.1
Author URI: http://designerandgeek.com/
*/
/**
* Adds a spoiler shortcode to WordPress.
*
* @return none outputs HTML
*/
function dag_spoiler_func( $atts, $content = null ) {
$default_title = __('Spoiler alert!');
$helptext_show = __('fa-plus');
$helptext_hide = __('fa-minus');
extract( shortcode_atts( array(
'title' => 'Click to show spoiler',
), $atts ) );
$spoiler =
/*'<style>'.
'.dag_spoiler .dag_spoiler_header::before {'.
'data-dag-spoiler-show="'. $helptext_show .'" '.
'data-dag-spoiler-hide="'. $helptext_hide.'" '.
'}'.
'</style>'.*/
'<div class="dag_spoiler">' .
'<p class="dag_spoiler_header" ' .
'data-dag-spoiler-show="' . $helptext_show .'" '.
'data-dag-spoiler-hide="' . $helptext_hide . '">' . $title . '</p>' .
'<div class="dag_spoiler_content">' .
/*'<p class="dag_spoiler_header">'. $title . '</p>' .
'<div class="dag_spoiler_content">' .*/
do_shortcode($content) .
'</div>' .
'</div>';
return $spoiler;
}
add_shortcode( 'dag_spoiler', 'dag_spoiler_func' );
/*EOF*/
/**
* Enqueue plugin css and javascript
*/
add_action( 'wp_enqueue_scripts', 'dag_enqueue' );
function dag_enqueue() {
wp_register_style( 'dag-spoiler-style', plugins_url('/ebo-spoiler.css', __FILE__) );
wp_enqueue_style( 'dag-spoiler-style' );
/*wp_enqueue_script( 'jquery' );*/
wp_register_script( 'dag-spoiler-js', plugins_url('/ebo-spoiler.js', __FILE__) );
wp_enqueue_script( 'dag-spoiler-js' );
}
add_action( 'wp_enqueue_scripts', 'dag_enqueue' );
?>
关于php - 在自制的 wordpress 剧透插件中启用/激活简码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33474600/
如何在 Grav CMS 中剧透(隐藏文本或 block ) Markdown 或插件?官方不剧透markdown和 Markdown Extra (由 Grav 支持)。 我尝试像 this 这样的
我一直在研究 Python Challenge 中提出的问题.其中一个问题要求从一堆字符中筛选出最稀有的字符。 我的方法是从文本文件中读取字符,将字符/出现作为键/值对存储在字典中。按值对字典进行排序
我有一个很大的矩阵 A,它有 1GB 的 double 值,当我将它重新整形为不同的维度时,它的速度快得令人难以置信。 A=rand(128,1024,1024); tic;B=reshape(A,1
好吧,让我解释一下我的意思是哪种“剧透标签”: 在我所在的 phpBB 论坛中,有一个 [剧透] BBCode 隐藏了里面的文本,有一个显示/隐藏的按钮,应该看起来像发布页面中的 prosilver
我在很多记录中都有这个字符串 [spoiler:abcdefgh]。 abcdefgh 是可变字符。我希望它成为 [剧透]。所以我想删除 :abcdefgh。 我知道查询是: UPDATE post
所以我正在尝试参加 Stripe CTF 竞赛,但我对安全性一无所知,所以当我遇到问题时,我查看了问题 3。我仍然不明白它是如何工作的。 黑客攻击的目标是通过使用设置了 SUID 位的应用程序访问不同
我之前曾尝试暴力破解它,但没有成功。这是我的递归尝试#2(第一次使用递归方法)。请帮忙! 发生的情况是这样的:代码运行良好,数字较小,但是当我们达到一百万时,代码就会运行,并且什么也不会发生。在 Ec
我是一名优秀的程序员,十分优秀!