0

ユーザーがカスタムテキスト、リンク、および(カスタム)フォントアイコンを含むボタンを追加できるように、VC内にカスタム要素をセットアップしました。

タイトルとリンクを正常にエコーアウトできますが、フォントアイコンは空白です。print_r($atts) すると、次のようになります。

Array
(
    [reach_vc_button_text] => More Information
    [reach_vc_button_link] => url:http%3A%2F%2Flocalhost%2FWordPress%2FJammyCustard%2Freach%2Ffunding%2Fthriving-rural-communities-scheme-trc%2F|||
    [reach_vc_button_icon] => 
);

    <?php
function reach_vc_button_html( $atts ) {

    $atts = shortcode_atts(
        array(
            'reach_vc_button_text' => '',
            'reach_vc_button_link' => '',
            'reach_vc_button_icon' => '',
        ), $atts, 'reach_vc_button'
    );

    ob_start();
    ?>

        <?php
            $href = $atts['reach_vc_button_link'];
            $button_link = vc_build_link( $href );

            //echo '<pre>'; print_r($atts); echo '</pre>';

        ?>  

    <a href="<?php echo $button_link['url']; ?>" class="read-more excerpt-read-more project-read-more"><?php echo $atts['reach_vc_button_text']; ?><i class="<?php echo $atts['reach_vc_button_icon']; ?>"></i></a>

    <?php
    $html = ob_get_clean(); 
    return $html;

}

add_shortcode( 'reach_vc_button', 'reach_vc_button_html' );

編集:パラメータコードを追加:

array(
                "type"        => "iconpicker",
                "heading"     => __( "Button Icon", "reach-rdp" ),
                "param_name"  => "reach_vc_button_icon",
                "value"       => "icon-more-information",
                "description" => __( "Select the icon to display for this button", "reach-rdp" ),
                "settings"   => array(
                    "emptyIcon"    => false,
                    "type"         => "reach",
                    "iconsPerPage" => "50",
                ),
                "dependency" => array(
                    "element" => "icon_type",
                    "value"   => "reach",
                ),
            ),
4

1 に答える 1

0

問題は、param 宣言コードにある可能性があります。次のコードを試してください

array(
      'type' => 'iconpicker',
      'heading' => __( 'Button Icon', 'reach-rdp' ),
      'param_name' => 'reach_vc_button_icon',
      'settings' => array(
        'emptyIcon' => false, // default true, display an "EMPTY" icon?
        'type' => 'openiconic',
        'iconsPerPage' => 200, // default 100, how many icons per/page to display
      ),
      'dependency' => array(
        'element' => 'icon_type',
        'value' => 'openiconic',
      ),
      'description' => __( 'Select icon from library.', 'reach-rdp' ),
    ),

次のステップは、ショートコード出力ファイルで Openiconic スタイルをエンキューするか、Visual Composer の指定された関数を使用することです。このコードに従ってください

vc_icon_element_fonts_enqueue( $i_type );

詳細については、このリンクを確認してくださいhttps://wpbakery.atlassian.net/wiki/display/VC/Adding+Icons+to+vc_icon

于 2017-01-26T10:44:43.480 に答える