lundi 25 avril 2016

Not working checkbox shortcode for wordpress visual composer

I'am making my own and first shortcode for visual composer, and in my functions.php I have:

add_shortcode( 'firsttag', 'firsttag_func' );
function firsttag_func( $atts ) {
   extract( shortcode_atts( array(
      // not important code,
      'checkboxRight' => !empty($checkboxRight) ? '' : 'pull-right',
   ), $atts ) );

   return   "<div class='col-md-12'>".
                "<div class='container container-about'>".
                    "<div class='row'>".
                        "<div class='container'>".
                            "<div class='col-md-6 {$checkboxRight}'>".
                                "<p class='subtitle'>{$beforefoo}</p>".
                                "<p class='title' style='color:{$color};' data-foo='${foo}'>{$foo}</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>";}

add_action( 'vc_before_init', 'your_name_integrateWithVC' );
function your_name_integrateWithVC() {
   vc_map( array(
      "name" => __( "PlayFair Heading box", "my-text-domain" ),
      "base" => "firsttag",
      "class" => "",
      "category" => __( "Content", "my-text-domain"),
      'admin_enqueue_css' => array(get_template_directory_uri().'/style.css'),
      "params" => array(
         array(
            "type" => "textfield",
            "holder" => "",
            "class" => "",
            "heading" => __( "PreHeading", "my-text-domain" ),
            "param_name" => "beforefoo",
            "value" => __( "", "my-text-domain" ),
            "description" => __( "Example: Before Name of the text block", "my-text-domain" )
         ),
         // not important arrays,
         array(
            "type" => "checkbox",
            "holder" => "div",
            "class" => "",
            "heading" => __( "Right screen position", "my-text-domain" ),
            "param_name" => "checkboxRight",
            "admin_label" => '',
            "value" =>  array( 'Yes please' => '1'),
            "description" => __( "", "my-text-domain" )
         ).......

I have checked my function part

'checkboxRight' => !empty($checkboxRight) ? ' ' : 'pull-right',

and it's working, but seems that I don't get good value from checkbox array

"admin_label" => '',
"value" => array( 'Yes please' => '1'),

any ideas why ?




Aucun commentaire:

Enregistrer un commentaire