/** * Save generated shortcodes, html and visual composer status in posts meta. * * @access public * @since 4.4 * * @param $post_id - current post id * * @return void */ public function save($post_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // @todo fix_roles maybe check also for is vc_enabled if (!vc_user_access()->wpAny(array('edit_post', $post_id))->get()) { return; } $this->setJsStatus($post_id); if (!(isset($_POST['wp-preview']) && 'dopreview' === $_POST['wp-preview'])) { $this->setSettings($post_id); } /** * vc_filter: vc_base_save_post_custom_css * @since 4.4 */ $post_custom_css = apply_filters('vc_base_save_post_custom_css', vc_post_param('vc_post_custom_css')); if (null !== $post_custom_css && empty($post_custom_css)) { delete_post_meta($post_id, '_wpb_post_custom_css'); } elseif (null !== $post_custom_css) { $post_custom_css = strip_tags($post_custom_css); update_post_meta($post_id, '_wpb_post_custom_css', $post_custom_css); } visual_composer()->buildShortcodesCustomCss($post_id); }
public function jsComposerEditPage() { $vc = visual_composer(); $pt_array = $vc->getPostTypes(); foreach ($pt_array as $pt) { add_meta_box('vc_teaser', __('VC Teaser', "js_composer"), array(&$this, 'outputTeaser'), $pt, 'side'); } }
public function jsComposerEditPage() { $vc = visual_composer(); $pt_array = $vc->getPostTypes(); foreach ($pt_array as $pt) { add_meta_box('vc_teaser', __('VC: Custom Teaser', LANGUAGE_ZONE), array(&$this, 'outputTeaser'), $pt, 'side'); } add_action('save_post', array(&$this, 'saveTeaserMetaBox')); }
public function build() { $element = vc_post_param('element'); $shortCode = stripslashes(vc_post_param('shortcode')); visual_composer()->removeShortCode($element); $settings = WPBMap::getShortCode($element); new WPBakeryShortCode_Settings($settings); echo do_shortcode($shortCode); die; }
public function getHeading($atts) { if (isset($atts['use_custom_heading']) && 'true' === $atts['use_custom_heading']) { $custom_heading = visual_composer()->getShortCode('vc_custom_heading'); $data = vc_map_integrate_parse_atts($this->shortcode, 'vc_custom_heading', $atts, 'custom_'); $data['text'] = $atts['title']; return $custom_heading->render(array_filter($data)); } else { return '<h4>' . esc_html($atts['title']) . '</h4>'; } }
function render() { $output = '<div class="vc-css-editor row vc-row" data-css-editor="true">'; $output .= $this->onionLayout(); $output .= '<div class="col-xs-5 vc_span5 vc-settings">' . ' <label>' . __('Border', 'js_composer') . '</label> ' . ' <div class="color-group"><input type="text" name="border_color" value="" class="vc-color-control"></div>' . ' <div class="vc-border-style"><select name="border_style" class="vc-border-style">' . $this->getBorderStyleOptions() . '</select></div>' . ' <label>' . __('Background', 'js_composer') . '</label>' . ' <div class="color-group"><input type="text" name="background_color" value="" class="vc-color-control"></div>' . ' <div class="vc-background-image">' . $this->getBackgroundImageControl() . '<div class="clearfix"></div></div>' . ' <div class="vc-background-style"><select name="background_style" class="vc-background-style">' . $this->getBackgroundStyleOptions() . '</select></div>' . ' <label>' . __('Box controls', 'js_composer') . '</label>' . ' <label class="vc-checkbox"><input type="checkbox" name="simply" class="vc-simplify" value=""> ' . __('Simplify controls', 'js_composer') . '</label>' . '</div>'; $output .= '<input name="' . $this->setting('param_name') . '" class="wpb_vc_param_value ' . $this->setting('param_name') . ' ' . $this->setting('type') . '_field" type="hidden" value="' . esc_attr($this->value()) . '"/>'; $output .= '</div><div class="clearfix"></div>'; $output .= '<script type="text/html" id="vc-css-editor-image-block">' . '<li class="added">' . ' <div class="inner" style="width: 75px; height: 75px; overflow: hidden;text-align: center;">' . ' <img src="{{ img.url }}?id={{ img.id }}" data-image-id="{{ img.id }}" class="vc-ce-image<# if(!_.isUndefined(img.css_class)) {#> {{ img.css_class }}<# }#>">' . ' </div>' . ' <a href="#" class="icon-remove"></a>' . '</li>' . '</script>'; $output .= '<script type="text/javascript" src="' . visual_composer()->assetUrl('js/params/css_editor.js') . '"></script>'; return apply_filters('vc_css_editor', $output); }
public function setGlobalTtaInfo() { $sectionClass = visual_composer()->getShortCode('vc_tta_section')->shortcodeClass(); $this->sectionClass = $sectionClass; /** @var $sectionClass WPBakeryShortCode_VC_Tta_Section */ if (is_object($sectionClass)) { WPBakeryShortCode_VC_Tta_Section::$tta_base_shortcode = $this; WPBakeryShortCode_VC_Tta_Section::$self_count = 0; WPBakeryShortCode_VC_Tta_Section::$section_info = array(); return true; } return false; }
public function enqueue() { visual_composer()->frontCss(); visual_composer()->frontJsRegister(); wp_enqueue_script('prettyphoto'); wp_enqueue_style('prettyphoto'); wp_enqueue_style('js_composer_front'); wp_enqueue_script('wpb_composer_front_js'); wp_enqueue_style('js_composer_custom_css'); VcShortcodeAutoloader::getInstance()->includeClass('WPBakeryShortCode_VC_Basic_Grid'); $grid = new WPBakeryShortCode_VC_Basic_Grid(array('base' => 'vc_basic_grid')); $grid->shortcodeScripts(); $grid->enqueueScripts(); }
public function enqueue() { visual_composer()->frontCss(); visual_composer()->frontJsRegister(); wp_enqueue_script('prettyphoto'); wp_enqueue_style('prettyphoto'); wp_enqueue_style('js_composer_front'); wp_enqueue_script('wpb_composer_front_js'); wp_enqueue_style('js_composer_custom_css'); require_once vc_path_dir('SHORTCODES_DIR', 'vc-basic-grid.php'); $grid = new WPBakeryShortCode_VC_Basic_Grid(array('base' => 'vc_basic_grid')); $grid->shortcodeScripts(); $grid->enqueueScripts(); }
public function getVcIcon($atts) { if (empty($atts['i_type'])) { $atts['i_type'] = 'fontawesome'; } $data = vc_map_integrate_parse_atts($this->shortcode, 'vc_icon', $atts, 'i_'); if ($data) { $icon = visual_composer()->getShortCode('vc_icon'); if (is_object($icon)) { return $icon->render(array_filter($data)); } } return ''; }
/** * This method is called by Vc_Manager to register required action hooks for VC backend editor. * * @since 4.2 * @access public */ public function addHooksSettings() { add_action('edit_post', array(&$this, 'save')); add_action('wp_ajax_wpb_get_element_backend_html', array(&$this, 'elementBackendHtml')); // load backend editor if (function_exists('add_theme_support')) { add_theme_support('post-thumbnails'); } add_post_type_support('page', 'excerpt'); add_action('admin_init', array(&$this, 'render'), 5); add_action('admin_print_scripts-post.php', array(&$this, 'printScriptsMessages')); add_action('admin_print_scripts-post-new.php', array(&$this, 'printScriptsMessages')); // Load required vendors classes; visual_composer()->vendorsManager()->load(); }
/** * Helper function to add new third-party adaptation class. * * @since 4.3 * @param Vc_Vendor_Interface $vendor - instance of class. */ function vc_add_vendor(Vc_Vendor_Interface $vendor) { visual_composer()->vendorsManager()->add($vendor); }
$nav_bar->render(); // [/vc_navbar frontend] ?> <div id="vc_inline-frame-wrapper"></div> <?php // [add element popup/box] require_once vc_path_dir('EDITORS_DIR', 'popups/class-vc-add-element-box.php'); $add_element_box = new Vc_Add_Element_Box($editor); $add_element_box->render(); // [/add element popup/box] // [shortcodes edit form panel render] visual_composer()->editForm()->render(); // [/shortcodes edit form panel render] // [templates panel editor render] if (vc_user_access()->part('templates')->can()->get()) { visual_composer()->templatesPanelEditor()->renderUITemplate(); } // [/templates panel editor render] // [post settings panel render] if (vc_user_access()->part('post_settings')->can()->get()) { require_once vc_path_dir('EDITORS_DIR', 'popups/class-vc-post-settings.php'); $post_settings = new Vc_Post_Settings($editor); $post_settings->renderUITemplate(); } // [/post settings panel render] // [panel edit layout render] require_once vc_path_dir('EDITORS_DIR', 'popups/class-vc-edit-layout.php'); $edit_layout = new Vc_Edit_Layout(); $edit_layout->renderUITemplate(); // [/panel edit layout render] // fe controls
/** * Used to save new template from ajax request in new panel window * @since 4.4 * */ public function saveTemplate() { if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) { die; } $title = vc_post_param('template_name'); $content = vc_post_param('template'); $template_id = $this->create($title, $content); $template_title = get_the_title($template_id); if ($this->isNewVcVersion(self::$vcWithTemplatePreview)) { echo visual_composer()->templatesPanelEditor()->renderTemplateListItem(array('name' => $template_title, 'unique_id' => $template_id, 'type' => self::$template_type)); } else { echo $this->renderTemplateWindowTemplateraTemplates($template_title, array('unique_id' => $template_id)); } die; }
/** * @since 4.4 * * @output/@return string - grid data for ajax request. */ public function getGridDataForAjax() { $tag = vc_request_param('tag'); if (vc_verify_public_nonce() && $tag) { $shorcode_fishbone = visual_composer()->getShortCode($tag); if (is_object($shorcode_fishbone)) { /** @var $vc_grid WPBakeryShortcode_Vc_Basic_Grid */ $vc_grid = $shorcode_fishbone->shortcodeClass(); if (method_exists($vc_grid, 'isObjectPageable') && $vc_grid->isObjectPageable() && method_exists($vc_grid, 'renderAjax')) { die($vc_grid->renderAjax(vc_request_param('data'))); } } } }
<?php if (!defined('ABSPATH')) { die('-1'); } $total_templates = visual_composer()->templatesPanelEditor()->loadDefaultTemplates(); $templates_total_count = count($total_templates); if (vc_user_access()->part('shortcodes')->checkStateAny(true, 'custom', null)->get() && vc_user_access_check_shortcode_all('vc_row') && vc_user_access_check_shortcode_all('vc_column')) { ?> <div id="vc_no-content-helper" class="vc_welcome vc_ui-font-open-sans"> <div class="vc_welcome-brand vc_welcome-visible-e"> <img src="<?php echo vc_asset_url('vc/logo/64x64.png'); ?> " alt=""> </div> <div class="vc_welcome-header vc_welcome-visible-e"> <?php _e('You have blank page <br> Start adding content or templates', 'js_composer'); ?> </div> <div class="vc_ui-btn-group vc_welcome-visible-e"> <?php if (vc_user_access()->part('shortcodes')->checkStateAny(true, 'custom', null)->get() && vc_user_access_check_shortcode_all('vc_row') && vc_user_access_check_shortcode_all('vc_column')) { ?> <a id="vc_no-content-add-element" class="vc_general vc_ui-button vc_ui-button-shape-rounded vc_ui-button-info vc_welcome-visible-e" title="<?php _e('Add Element', 'js_composer'); ?> "
<span class="vc_description"><?php _e('Append previosly saved template to the current layout', 'js_composer'); ?> </span> <ul class="wpb_templates_list" id="vc-templatera-list"> <?php echo $this->getList(); ?> </ul> </div> </div> <div id="tabs-templatera-tabs-2"> <div class="vc_col-md-12 vc_column inside"> <?php $templates = visual_composer()->templatesEditor()->loadDefaultTemplates(); ?> <div class="wpb_element_label"><?php _e('Load Template', 'js_composer'); ?> </div> <span class="description"><?php _e('Append default template to the current layout', 'js_composer'); ?> </span> <ul id="vc_default-template-list" class="wpb_templates_list"> <?php foreach ($templates as $template) { ?> <li class="wpb_template_li"><a href="#" data-template_name="<?php echo str_replace('.json', '', basename($template['filename']));
/** * Helper function to add new third-party adaptation class. * @deprecated 4.4 * @since 4.3 * * @param Vc_Vendor_Interface $vendor - instance of class. */ function vc_add_vendor(Vc_Vendor_Interface $vendor) { // _deprecated_function( 'vc_add_vendor', '4.4 (will be removed in 4.10)', 'autoload logic' ); visual_composer()->vendorsManager()->add($vendor); }
<?php vc_grid_item_map_shortcodes(); do_action('vc-render-templates-preview-template'); /** @var $vc_grid_item_editor Vc_Grid_Item_Editor */ global $vc_grid_item_editor; if ($vc_grid_item_editor) { add_filter('admin_body_class', array($vc_grid_item_editor->templatesEditor(), 'addBodyClassTemplatePreview')); add_action('admin_enqueue_scripts', array(&$vc_grid_item_editor, 'enqueueEditorScripts')); add_action('admin_footer', array(&$vc_grid_item_editor, 'renderEditorFooter')); add_filter('vc_wpbakery_shortcode_get_controls_list', array($vc_grid_item_editor, 'shortcodesControls')); } add_action('admin_enqueue_scripts', array(visual_composer()->templatesPanelEditor(), 'enqueuePreviewScripts')); global $menu, $submenu, $parent_file, $post_ID, $post, $post_type; $post_ID = $editorPost->ID; $post_type = $editorPost->post_type; $post_title = trim($editorPost->post_title); $nonce_action = $nonce_action = 'update-post_' . $post_ID; $user_ID = isset($current_user) && isset($current_user->ID) ? (int) $current_user->ID : 0; $form_action = 'editpost'; $menu = array(); remove_action('wp_head', 'print_emoji_detection_script'); remove_action('wp_print_styles', 'print_emoji_styles'); remove_action('admin_print_scripts', 'print_emoji_detection_script'); remove_action('admin_print_styles', 'print_emoji_styles'); add_thickbox(); wp_enqueue_media(array('post' => $post_ID)); require_once ABSPATH . 'wp-admin/admin-header.php'; ?> <style type="text/css"> #screen-meta, #adminmenumain, .notice {
/** * Save method for edit_post action. * * @since 4.2 * @access public * * @param null $post_id */ public function save($post_id = null) { // @todo fix_roles maybe we also need to check if vc_enabled? if (!vc_user_access()->wpAny(array('edit_post', $post_id))->get()) { return; } /** * vc_filter: vc_base_save_post_custom_css * @since 4.4 */ $post_custom_css = apply_filters('vc_base_save_post_custom_css', vc_post_param('vc_post_custom_css')); if (null !== $post_custom_css && empty($post_custom_css)) { delete_post_meta($post_id, '_wpb_post_custom_css'); } elseif (null !== $post_custom_css) { update_post_meta($post_id, '_wpb_post_custom_css', $post_custom_css); } visual_composer()->buildShortcodesCustomCss($post_id); }
/** * Add custom css from shortcodes that were mapped for vc grid item. * @return string */ public function addShortcodesCustomCss() { $output = $shortcodes_custom_css = ''; $id = $this->template_id; if (preg_match('/^\\d+$/', $id)) { $shortcodes_custom_css = get_post_meta($id, '_wpb_shortcodes_custom_css', true); } elseif (false !== ($predefined_template = $this->predefinedTemplate($id))) { $shortcodes_custom_css = visual_composer()->parseShortcodesCustomCss($predefined_template['template']); } if (!empty($shortcodes_custom_css)) { $output .= '<style type="text/css" data-type="vc_shortcodes-custom-css">'; $output .= $shortcodes_custom_css; $output .= '</style>'; } return $output; }
/** * Save method for edit_post action. * * @since 4.2 * @access public * * @param null $post_id */ public function save($post_id = null) { /** * vc_filter: vc_base_save_post_custom_css * @since 4.4 */ $post_custom_css = apply_filters('vc_base_save_post_custom_css', vc_post_param('vc_post_custom_css')); if ($post_custom_css !== null && empty($post_custom_css)) { delete_post_meta($post_id, '_wpb_post_custom_css'); } elseif ($post_custom_css !== null) { update_post_meta($post_id, '_wpb_post_custom_css', $post_custom_css); } visual_composer()->buildShortcodesCustomCss($post_id); }
function enqueueRequired() { global $wpVC_setup; do_action( 'wp_enqueue_scripts' ); visual_composer()->frontCss(); visual_composer()->frontJsRegister(); }
function vc_enabled_frontend() { return visual_composer()->inlineEditor()->inlineEnabled(); }
/** * Add custom css from shortcodes from template for template editor. * * Used by action 'wp_print_scripts'. * * @todo move to autoload or else some where. * @since 4.4.3 * * @return string */ public function addFrontendTemplatesShortcodesCustomCss() { $output = $shortcodes_custom_css = ''; $shortcodes_custom_css = visual_composer()->parseShortcodesCustomCss(vc_frontend_editor()->getTemplateContent()); if (!empty($shortcodes_custom_css)) { $output .= '<style type="text/css" data-type="vc_shortcodes-custom-css">'; $output .= $shortcodes_custom_css; $output .= '</style>'; } echo $output; }
/** * @param $shortcode * @param $content * * @since 4.2 * @return string */ function toString($shortcode, $content) { $shortcode_obj = visual_composer()->getShortCode($shortcode['tag']); $is_container = $shortcode_obj->settings('is_container') || $shortcode_obj->settings('as_parent') != null && $shortcode_obj->settings('as_parent') !== false; $shortcode = apply_filters('vc_frontend_editor_to_string', $shortcode, $shortcode_obj); $output = '<div class="vc_element" data-tag="' . $shortcode['tag'] . '" data-shortcode-controls="' . esc_attr(json_encode($shortcode_obj->shortcodeClass()->getControlsList())) . '" data-model-id="' . $shortcode['id'] . '"' . self::cleanStyle() . '>' . $this->wrapperStart() . '[' . $shortcode['tag'] . ' ' . $shortcode['attrs_query'] . ']' . ($is_container ? '[vc_container_anchor]' . $this->parseShortcodesString($content, $is_container, $shortcode['id']) : do_shortcode($content)) . '[/' . $shortcode['tag'] . ']' . $this->wrapperEnd() . '</div>'; return $output; }
public function registerBackendJavascript() { // editor can be disabled but fe can be enabled. so we currently need this file. @todo maybe make backend-disabled.min.js wp_register_script('vc-backend-actions-js', vc_asset_url('js/dist/backend-actions.min.js'), array('jquery', 'backbone', 'underscore'), WPB_VC_VERSION, true); wp_register_script('vc-backend-min-js', vc_asset_url('js/dist/backend.min.js'), array('vc-backend-actions-js'), WPB_VC_VERSION, true); // used in tta shortcodes, and panels. wp_register_script('vc_accordion_script', vc_asset_url('lib/vc_accordion/vc-accordion.min.js'), array('jquery'), WPB_VC_VERSION, true); wp_register_script('wpb_php_js', vc_asset_url('lib/php.default/php.default.min.js'), array('jquery'), WPB_VC_VERSION, true); // used as polyfill for JSON.stringify and etc wp_register_script('wpb_json-js', vc_asset_url('lib/bower/json-js/json2.min.js'), array(), WPB_VC_VERSION, true); // used in post settings editor wp_register_script('ace-editor', vc_asset_url('lib/bower/ace-builds/src-min-noconflict/ace.js'), array('jquery'), WPB_VC_VERSION, true); wp_register_script('webfont', '//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js'); // Google Web Font CDN wp_localize_script('vc-backend-actions-js', 'i18nLocale', visual_composer()->getEditorsLocale()); }
</div> <a href="#" class="icon-remove"></a> </li> </script> <?php foreach (WPBMap::getShortCodes() as $sc_base => $el) { ?> <script type="text/html" id="vc_shortcode-template-<?php echo $sc_base; ?> "> <?php echo visual_composer()->getShortCode($sc_base)->template(); ?> </script> <?php } ?> <script type="text/html" id="vc_row-inner-element-template"> <?php echo visual_composer()->getShortCode('vc_row_inner')->template(); ?> </script> <script type="text/html" id="vc_settings-page-param-block"> <div class="row-fluid wpb_el_type_<%= type %>"> <div class="wpb_element_label"><%= heading %></div> <div class="edit_form_line"> <%= form_element %> </div> </div> </script>
/** * Add new param to shortcode params list after specified parameter. * * @static * * @param $name * @param array $attribute * * @return bool - true if added, false if scheduled/rejected */ public static function addParamAfter($name, $attribute = array(), $after = false) { if (!$after) { return self::addParam($name, $attribute); } if (!self::$is_init) { vc_mapper()->addActivity('mapper', 'add_param', array('name' => $name, 'attribute' => $attribute)); return false; } if (!isset(self::$sc[$name])) { trigger_error(sprintf(__("Wrong name for shortcode:%s. Name required", "js_composer"), $name)); } elseif (!isset($attribute['param_name'])) { trigger_error(sprintf(__("Wrong attribute for '%s' shortcode. Attribute 'param_name' required", "js_composer"), $name)); } else { $replaced = false; foreach (self::$sc[$name]['params'] as $index => $param) { if ($param['param_name'] == $attribute['param_name']) { $replaced = true; self::$sc[$name]['params'][$index] = $attribute; } } if ($replaced === false) { $after_index = false; foreach (self::$sc[$name]['params'] as $index => $param) { if ($param['param_name'] == $after) { $after_index = $index; break; } } if ($after_index) { array_splice(self::$sc[$name]['params'], $after_index + 1, 0, array($attribute)); } else { self::$sc[$name]['params'][] = $attribute; } } $sort = new Vc_Sort(self::$sc[$name]['params']); self::$sc[$name]['params'] = $sort->sortByKey(); visual_composer()->addShortCode(self::$sc[$name]); return true; } return false; }
/** * Modify shortcode's mapped settings. * You can modify only one option of the group options. * Call this method with $settings_name param as associated array to mass modifications. * * @static * * @param $name - shortcode' name. * @param $setting_name - option key name or the array of options. * @param $value - value of settings if $setting_name is option key. * * @return array|bool */ public static function modify($name, $setting_name, $value = '') { if (!self::$is_init) { vc_mapper()->addActivity('mapper', 'modify', array('name' => $name, 'setting_name' => $setting_name, 'value' => $value)); return false; } if (!isset(self::$sc[$name])) { return trigger_error(sprintf(__("Wrong name for shortcode:%s. Name required", "js_composer"), $name)); } elseif ($setting_name === 'base') { return trigger_error(sprintf(__("Wrong setting_name for shortcode:%s. Base can't be modified.", "js_composer"), $name)); } if (is_array($setting_name)) { foreach ($setting_name as $key => $value) { self::modify($name, $key, $value); } } else { self::$sc[$name][$setting_name] = $value; visual_composer()->updateShortcodeSetting($name, $setting_name, $value); } return self::$sc; }