@bighoc
php/javascript developer

ShortCode выводит " ковычки из параметров атрибута. В чем проблема?

Проблема следующая.
Если я пишу вот такой шоткод [banner text="banner_text"]
То при вызове шоткода
function banner_shortcode($atts, $content = null) {

extract(shortcode_atts(
	        array('text' => ''), $atts));
print $text; // выводит ”banner_text”, хотя должно то ведь без ковычек - просто banner_text

Если пишу [banner text=banner_text] то выведет отлично, без ковычек.
То есть кавычки почему цепляются в значение атрибута шоткода.
уже в $atts приходит следующее значение:
’banner_text’

Я цеплялся на хук the_content , там та же ситация, уже везде проставленны эти ковычки.
Залазил в базу. Там всё хранится так как и я пишу то есть [banner text="banner_text"]

Буду благодарен за любые идеи.
  • Вопрос задан
  • 2250 просмотров
Пригласить эксперта
Ответы на вопрос 1
@bighoc Автор вопроса
php/javascript developer
Вот и решение .

Unregistered Names

Some plugin authors have chosen a strategy of not registering shortcode names, for example to disable a nested shortcode until the parent shortcode's handler function is called. This may have unintended consequences, such as failure to parse shortcode attribute values. For example:

[tag-a unit="north"]
[tag-b size="24"]
[tag-c color="red"]
[/tag-b]
[/tag-a]
Starting with version 4.0.1, if a plugin fails to register tag-b and tag-c as valid shortcodes, the wptexturize() processor will output the following text prior to any shortcode being parsed:

[tag-a unit="north"]
[tag-b size=”24”]
[tag-c color=”red”]
[/tag-b]
[/tag-a]
Unregistered shortcodes should be considered normal plain text that have no special meaning, and the practice of using unregistered shortcodes is discouraged. If you must enclose raw code between shortcode tags, at least consider using the no_texturize_shortcodes filter to prevent texturization of the contents of tag-a:

add_shortcode( 'tag-a', 'my_tag_a_handler' );
add_filter( 'no_texturize_shortcodes', 'ignore_tag_a' );

function ignore_tag_a( $list ) {
$list[] = 'tag-a';
return $list;
}
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы