【问题标题】:Visual composer Converting Double quote ("some text") into back quote ( ``some text`` )视觉作曲家将双引号(“某些文本”)转换为反引号(“某些文本”)
【发布时间】:2019-08-06 06:54:58
【问题描述】:

如何将带有双引号的可视作曲家短代码转义为文本字段中的双引号 每次在字符串中添加双引号时,VC 都会用反引号将其转换。 Lorem ipsum dolor sit amet, "consectetur" 转为Lorem ipsum dolor sit amet,``consectetur``

下面是我为带有自定义标题、自定义文本、背景图像和右侧图像的自定义标题创建的代码。

我几乎使用了所有数据清理/转义方法和正则表达式,但没有运气

class vcCustomHeader extends WPBakeryShortCode {

    // Element Init
    function __construct() {
        add_action( 'init', array( $this, 'vc_customheader_mapping' ) );
        add_shortcode( 'vc_customheader', array( $this, 'vc_customheader_html' ) );
    }

    // Element Mapping
    public function vc_customheader_mapping() {

        // Stop all if VC is not enabled
        if ( !defined( 'WPB_VC_VERSION' ) ) {
            return;
        }

        // Map the block with vc_map()
        vc_map(
            array(
                'name' => __('VC Custom Header', 'text-domain'),
                'base' => 'vc_customheader',
                'description' => __('VC Custom Header addon', 'text-domain'),
                'category' => __('Stevetrautman theme', 'text-domain'),
                'icon' => get_template_directory_uri().'/assets/images/demo.png',
                'params' => array(

                    array(
                        "type" => "textfield",
                        "holder" => "h3",
                        "class" => "title-class",
                        "heading" => __( "Title", "text-domain" ),
                        "param_name" => "title",
                        "value" => __( "", "text-domain" ),
                        "description" => __( "Add Header Title", "text-domain" ),
                        "admin_label" => false,
                        "weight" => 0,
                        "group" => "Text",
                    ),

                    array(
                        "type" => "textarea",
                        "holder" => "div",
                        "class" => "text-class",
                        "heading" => __( "Text", "text-domain" ),
                        "param_name" => "text",
                        "value" => __( "", "text-domain" ),
                        "description" => __( "Add Header Text", "text-domain" ),
                        "admin_label" => false,
                        "weight" => 0,
                        "group" => "Text",
                    ),

                    array(
                        "type" => "attach_image",
                        "holder" => "img",
                        "class" => "head-bg-img",
                        "heading" => __( "BackGround Image", "text-domain" ),
                        "param_name" => "imagebg",
                        "value" => __( "", "text-domain" ),
                        "description" => __( "Add Header Background Image", "text-domain" ),
                        "admin_label" => false,
                        "weight" => 0,
                        "group" => "Image",
                    ),
                    array(
                        "type" => "attach_image",
                        "holder" => "img",
                        "class" => "head-right-img",
                        "heading" => __( "Header Right Image", "text-domain" ),
                        "param_name" => "imageright",
                        "value" => __( "", "text-domain" ),
                        "description" => __( "Add Header Right Image", "text-domain" ),
                        "admin_label" => false,
                        "weight" => 0,
                        "group" => "Image",
                    )
                )
            )
        );

    }


    // Element HTML
    public function vc_customheader_html( $atts ) {
        $html='';
        // Params extraction
        extract(
            shortcode_atts(
                array(
                    'title'     => '',
                    'text'      => '',
                    'imagebg'   => '',
                    'imageright'=> '',
                ),
                $atts
            )
        );

        // Fill $html var with data
        $imageBG = wp_get_attachment_image_src($imagebg, 'full');
        $headerRight = wp_get_attachment_image_src($imageright, 'full');
$html = '
        <div class="lp-hero-main full-section" style="background-color: #f4f4f4; background-image: url('.$imageBG[0].'); background-position: bottom right; background-repeat: no-repeat; background-size: 37% auto; padding: 134px 0 47px;">
    <div class="inner-hero-lp full-section">
        <div class="lp-left">
            <h1>' . $title . '</h1>
            <p>' . $text . '</p>
        </div>';
        if($headerRight){
            $html.='
                <div class="lp-right text-center">
                    <img src="'.$headerRight[0].'">
                </div>';
        }
        $html.='</div>
    </div>';
        return $html;

    }

} // End Element Class


// Element Class Init
new vcCustomHeader();

【问题讨论】:

    标签: wordpress shortcode visual-composer


    【解决方案1】:

    试过&lt;h1&gt;' . str_replace('``', '"', $title) . '&lt;/h1&gt; 及其工作,我知道它不是正确的方法,但解决了我的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-08
      • 1970-01-01
      • 2010-12-17
      • 2020-02-28
      • 2021-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多