Как поместить HTML-код в PHP для разработки визуальных дополнений композитора? - PullRequest
0 голосов
/ 19 июня 2019

Я пытался исправить код как можно лучше, но я новичок, любая помощь будет оценена.

При запуске моего кода я получаю фатальную ошибку.

Этот вывод работает

public function renderMyBartag( $atts, $content = null ) {
  extract( shortcode_atts( array(
    'foo' => 'something',
    'color' => '#FF0000'
  ), $atts ) );
  $content = wpb_js_remove_wpautop($content, true); // fix unclosed/unwanted paragraph tags in $content

  $output = "<div style='color:{$color};' data-foo='${foo}'>{$content}</div>";
  return $output;
}

Это не

public function renderMyBartag( $atts, $content = null ) {
  extract( shortcode_atts( array(
    'foo' => 'something',
    'color' => '#FF0000'
  ), $atts ) );
  $content = wpb_js_remove_wpautop($content, true); // fix unclosed/unwanted paragraph tags in $content

  $output = "<div class="container">
    < class="learn-more">
        <div class="circle">
            <span class="icon arrow"></span>
            </div>
    <p class="button-text">{$foo}</p>
     </button>
    </div>"
;
  return $output;
}

При запуске моего кода я получаю фатальную ошибку.

Я просто хочу встроить HTML-код в шорткод, который я создаю

1 Ответ

0 голосов
/ 19 июня 2019

В выводе $ замените внутренние двойные кавычки одинарными или избегайте двойных кавычек.

<?php
    $o = " 'single quoute' ";
    $o_esc = " \"escaped_doublequotes\" ";
...