How do I access vc_map() internal values to create custom markup for WPBakery interface?

A similar question has been asked here, without any viable responses: Visual Composer custom markup for custom shortcode (vc_map)

and here: Visual Composer custom shortcode template - custom_markup display user input

I am trying to create custom markup within the WPBakery interface.

I can add custom markup no problem by doing:

$markup = 'test'; 
vc_map( array(
   "name" => __("MyShortcode"),
   "base" => "myshortcode",
   "category" => __('Content'),
   "custom_markup" => $markup, // @TODO how do we access shortcode's attributes here to display in bakery grid
   "params" => $params
) );

This will output "test" in the WPBakery grid which is good, but how do I access vc_map() internal values to display?

For instance I have "post types" as a field for this shortcode. If someone selects "page" post type for example, I would like to display those posts within the WPBakery grid. What I cannot figure out is how to get the values that the user selected to display.

Any help would be greatly appreciated. I've searched endlessly on this one.

Solutions

I found a solution. By extending the class WPBakeryShortCode, you could change the contentAdmin output :

// Extend Class WPBakeryShortCodesContainer
if (class_exists('WPBakeryShortCode')) {
class WPBakeryShortCode_Custom_Element extends WPBakeryShortCode {
    /**
     * @param $atts
     * @param $content
     *
     * @return string
     * @throws \Exception
     */
    public function contentAdmin( $atts, $content = null ) {
        $output = $custom_markup = $width = $el_position = '';
        if ( null !== $content ) {
            $content = wpautop( stripslashes( $content ) );
        }

        $shortcode_attributes = array( 'width' => '1/1' );
        $atts = vc_map_get_attributes( $this->getShortcode(), $atts ) + $shortcode_attributes;
        $this->atts = $atts;
        $elem = $this->getElementHolder( $width );
        if ( isset( $this->settings['custom_markup'] ) && '' !== $this->settings['custom_markup'] ) {
            $markup = $this->settings['custom_markup'];
            $elem = str_ireplace( '%wpb_element_content%', $this->customMarkup( $markup, $content ), $elem );
            $output .= $elem;
        } else {
            $inner = $this->outputTitle( $this->settings['name'] );
            $inner .= $this->paramsHtmlHolders( $atts );
            $elem = str_ireplace( '%wpb_element_content%', $inner, $elem );
            $output .= $elem;
        }

        return $output;
    }
}
}

I follow this Git example to create my custom elements : https://gist.github.com/Webcreations907/ff0b068c5c364f63e45d

Similar questions

How to place markup.html from structured data markup in a Wordpress page
My Google analytics account suggested I add Structured Data markup to my web pages in the Head section. I tagged the content I wanted and created the HTML. However, when I go to place that code in the HTML on the page I tagged, I do not see a Head section. So, I just put it in the top of the page. When I add it to the top of the page it creates a s...
Wordpress | Is it possible to insert markup after the post title's markup using a hook?
I'm building a plugin that needs to insert some links after the main title on any given page/post. If I use the post_title filter, my markup is added inside the H1 for example... not after it. Is there a way to add custom markup after the title's markup?
Using WPBakery ( Visual Composer) and Advanced Custom fields, I want to create or use an object that displays custom images
I'm currently working on a Wordpress website using the Advanced custom fields and WPBakery aka visual composer plugins. While I manage to use these two plugins to post custom text, I have problems with images. What I have tried so far is: use acf in plain text, but as expected this only displays the link, not the image using an image building block...
WPBakery Page Builder - Checkboxes won't retain values from v6.xx
For the last few years I have been developing a custom theme and various plugins that add options to WPBakery Page Builder elements and create new custom elements, etc. Everything has worked perfectly up to Page Builder v5.7. But then when v6.0.x came out, suddenly every Checkbox option I have added to every element, be it a custom element or one o...
How to create vc_col-sm-5 and vc_col-sm-7 custom layout in WPBakery?
I am using the WPBackey plugin. I want to create custom layout vc_col-sm-5 and vc_col-sm-7. What number I have to use here 1/2 + 1/2 is for vc_col-sm-6 and vc_col-sm-6
After upgrading WordPress, can't access admin interface
After performing a WordPress upgrade to 3.3.1, I can no longer access the administration interface. The website works fine, but when I click on Dashboard, I receive the following error: Fatal error: Call to undefined function _wp_admin_html_begin() in /home/a7938356/public_html/wp-admin/admin-header.php on line 40 ... help! What can I do? I don't h...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .