/** * Get rendered controls * * @param array $controls * * @return string */ public function getControls($controls) { if (!is_array($controls) || empty($controls)) { return ''; } $buttons = array(); $editAccess = vc_user_access_check_shortcode_edit($this->shortcode); $allAccess = vc_user_access_check_shortcode_all($this->shortcode); foreach ($controls as $control) { switch ($control) { case 'add': if ($allAccess) { $buttons[] = '<a class="vc_control-btn vc_control-btn-add" href="#" title="' . __('Add to this grid item', 'js_composer') . '" data-vc-control="add"><i class="vc_icon"></i></a>'; } break; case 'edit': if ($editAccess) { $buttons[] = '<a class="vc_control-btn vc_control-btn-edit" href="#" title="' . __('Edit this grid item', 'js_composer') . '" data-vc-control="edit"><i class="vc_icon"></i></a>'; } break; case 'delete': if ($allAccess) { $buttons[] = '<a class="vc_control-btn vc_control-btn-delete" href="#" title="' . __('Delete this grid item ', 'js_composer') . '" data-vc-control="delete"><i class="vc_icon"></i></a>'; } break; } } $html = '<div class="vc_controls vc_controls-dark vc_controls-visible">' . implode(' ', $buttons) . '</div>'; return $html; }
/** * Generates list of shortcodes only for Grid element. * * This method parses the list of mapped shortcodes and creates categories list for users. * Also it checks is 'is_grid_item_element' attribute true. * * @static * * @param bool $force - force data generation even data already generated. */ protected static function generateGitemUserData($force = false) { if (!$force && false !== self::$gitem_user_sc && false !== self::$gitem_user_categories) { return; } self::$gitem_user_sc = self::$gitem_user_categories = self::$gitem_user_sorted_sc = array(); $deprecated = 'deprecated'; $add_deprecated = false; if (is_array(self::$sc) && !empty(self::$sc)) { foreach (self::$sc as $name => $values) { if (isset($values['post_type']) && Vc_Grid_Item_Editor::postType() === $values['post_type'] && vc_user_access_check_shortcode_all($name)) { if (!isset($values['content_element']) || true === $values['content_element']) { $categories = isset($values['category']) ? $values['category'] : '_other_category_'; $values['_category_ids'] = array(); if (isset($values['deprecated']) && false !== $values['deprecated']) { $add_deprecated = true; $values['_category_ids'][] = $deprecated; } else { if (is_array($categories) && !empty($categories)) { foreach ($categories as $c) { if (false === array_search($c, self::$gitem_user_categories)) { self::$gitem_user_categories[] = $c; } $values['_category_ids'][] = md5($c); } } else { if (false === array_search($categories, self::$gitem_user_categories)) { self::$gitem_user_categories[] = $categories; } $values['_category_ids'][] = md5($categories); } } } self::$gitem_user_sc[$name] = $values; self::$gitem_user_sorted_sc[] = $values; } } } if ($add_deprecated) { self::$gitem_user_categories[] = $deprecated; } $sort = new Vc_Sort(self::$gitem_user_sorted_sc); self::$gitem_user_sorted_sc = $sort->sortByKey(); }
<?php if ($templates_total_count > 0 && vc_user_access()->part('templates')->can()->get()) { ?> <a id="vc_templates-more-layouts" class="vc_general vc_ui-button vc_ui-button-shape-rounded vc_ui-button-warning" href="#"> <i class="vc_ui-icon-pixel vc_ui-icon-pixel-control-template"></i> <?php echo __('Add template', 'js_composer'); ?> </a> <?php } ?> </div> <?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')) { ?> <div class="vc_welcome-visible-ne"> <a id="vc_not-empty-add-element" class="vc_add-element-not-empty-button" title="<?php _e('Add Element', 'js_composer'); ?> " data-vc-element="add-element-action"> </a> </div> <?php } ?> <p class="vc_ui-help-block vc_welcome-visible-e"> <?php $targetLink = '<a href="http://kb.wpbakery.com" target="_blank">' . __('knowledge base', 'js_composer') . '</a>';
public function contentAdmin($atts, $content = null) { $width = $el_class = $title = ''; extract(shortcode_atts($this->predefined_atts, $atts)); $output = ''; $column_controls = $this->getColumnControls($this->settings('controls')); $column_controls_bottom = $this->getColumnControls('add', 'bottom-controls'); if ('column_14' === $width || '1/4' === $width) { $width = array('vc_col-sm-3'); } elseif ('column_14-14-14-14' === $width) { $width = array('vc_col-sm-3', 'vc_col-sm-3', 'vc_col-sm-3', 'vc_col-sm-3'); } elseif ('column_13' === $width || '1/3' === $width) { $width = array('vc_col-sm-4'); } elseif ('column_13-23' === $width) { $width = array('vc_col-sm-4', 'vc_col-sm-8'); } elseif ('column_13-13-13' === $width) { $width = array('vc_col-sm-4', 'vc_col-sm-4', 'vc_col-sm-4'); } elseif ('column_12' === $width || '1/2' === $width) { $width = array('vc_col-sm-6'); } elseif ('column_12-12' === $width) { $width = array('vc_col-sm-6', 'vc_col-sm-6'); } elseif ('column_23' === $width || '2/3' === $width) { $width = array('vc_col-sm-8'); } elseif ('column_34' === $width || '3/4' === $width) { $width = array('vc_col-sm-9'); } elseif ('column_16' === $width || '1/6' === $width) { $width = array('vc_col-sm-2'); } else { $width = array(''); } $sortable = vc_user_access_check_shortcode_all($this->shortcode) ? 'wpb_sortable' : $this->nonDraggableClass; for ($i = 0; $i < count($width); $i++) { $output .= '<div class="group ' . $sortable . '">'; $output .= '<h3><span class="tab-label"><%= params.title %></span></h3>'; $output .= '<div ' . $this->mainHtmlBlockParams($width, $i) . '>'; $output .= str_replace('%column_size%', wpb_translateColumnWidthToFractional($width[$i]), $column_controls); $output .= '<div class="wpb_element_wrapper">'; $output .= '<div ' . $this->containerHtmlBlockParams($width, $i) . '>'; $output .= do_shortcode(shortcode_unautop($content)); $output .= '</div>'; if (isset($this->settings['params'])) { $inner = ''; foreach ($this->settings['params'] as $param) { $param_value = isset(${$param}['param_name']) ? ${$param}['param_name'] : ''; if (is_array($param_value)) { // Get first element from the array reset($param_value); $first_key = key($param_value); $param_value = $param_value[$first_key]; } $inner .= $this->singleParamHtmlHolder($param, $param_value); } $output .= $inner; } $output .= '</div>'; $output .= str_replace('%column_size%', wpb_translateColumnWidthToFractional($width[$i]), $column_controls_bottom); $output .= '</div>'; $output .= '</div>'; } return $output; }
public function mainHtmlBlockParams($width, $i) { $sortable = vc_user_access_check_shortcode_all($this->shortcode) ? 'wpb_sortable' : $this->nonDraggableClass; return 'data-element_type="' . $this->settings['base'] . '" class="wpb_' . $this->settings['base'] . ' ' . $sortable . ' wpb_content_holder"' . $this->customAdminBlockParams(); }
/** * @param $width * @param $i * * @return string */ public function mainHtmlBlockParams($width, $i) { $sortable = vc_user_access_check_shortcode_all($this->shortcode) ? 'wpb_sortable' : $this->nonDraggableClass; return 'data-element_type="' . $this->settings['base'] . '" data-vc-column-width="' . wpb_vc_get_column_width_indent($width[$i]) . '" class="wpb_' . $this->settings['base'] . ' ' . $sortable . ' ' . $this->templateWidth() . ' wpb_content_holder"' . $this->customAdminBlockParams(); }
/** * @param $controls * @param string $extended_css * * @return string */ public function getColumnControls($controls = 'full', $extended_css = '') { $controls_start = '<div class="vc_controls vc_controls-visible controls controls_column' . (!empty($extended_css) ? " {$extended_css}" : '') . '">'; $controls_end = '</div>'; if ('bottom-controls' === $extended_css) { $control_title = sprintf(__('Append to this %s', 'js_composer'), strtolower($this->settings('name'))); } else { $control_title = sprintf(__('Prepend to this %s', 'js_composer'), strtolower($this->settings('name'))); } $controls_move = '<a class="vc_control column_move" data-vc-control="move" href="#" title="' . sprintf(__('Move this %s', 'js_composer'), strtolower($this->settings('name'))) . '"><span class="vc_icon"></span></a>'; $controls_add = '<a class="vc_control column_add" data-vc-control="add" href="#" title="' . $control_title . '"><span class="vc_icon"></span></a>'; $controls_edit = '<a class="vc_control column_edit" data-vc-control="edit" href="#" title="' . sprintf(__('Edit this %s', 'js_composer'), strtolower($this->settings('name'))) . '"><span class="vc_icon"></span></a>'; $controls_clone = '<a class="vc_control column_clone" data-vc-control="clone" href="#" title="' . sprintf(__('Clone this %s', 'js_composer'), strtolower($this->settings('name'))) . '"><span class="vc_icon"></span></a>'; $controls_delete = '<a class="vc_control column_delete" data-vc-control="delete" href="#" title="' . sprintf(__('Delete this %s', 'js_composer'), strtolower($this->settings('name'))) . '"><span class="vc_icon"></span></a>'; $controls_full = $controls_move . $controls_add . $controls_edit . $controls_clone . $controls_delete; $editAccess = vc_user_access_check_shortcode_edit($this->shortcode); $allAccess = vc_user_access_check_shortcode_all($this->shortcode); if (!empty($controls)) { if (is_string($controls)) { $controls = array($controls); } $controls_string = $controls_start; foreach ($controls as $control) { $control_var = 'controls_' . $control; if ($editAccess && 'edit' == $control || $allAccess) { if (isset(${$control_var})) { $controls_string .= ${$control_var}; } } } return $controls_string . $controls_end; } if ($allAccess) { return $controls_start . $controls_full . $controls_end; } elseif ($editAccess) { return $controls_start . $controls_edit . $controls_end; } return $controls_start . $controls_end; }
/** * @return string */ public function getControlAddElement() { 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')) { return '<li class="vc_show-mobile">' . ' <a href="javascript:;" class="vc_icon-btn vc_element-button" data-model-id="vc_element" id="vc_add-new-element" title="' . '' . __('Add new element', 'js_composer') . '">' . ' </a>' . '</li>'; } return ''; }
public function cssAdminClass() { $sortable = vc_user_access_check_shortcode_all($this->shortcode) ? ' wpb_sortable' : ' ' . $this->nonDraggableClass; return 'wpb_' . $this->settings['base'] . $sortable; }
/** * Check is allowed to add another element inside current element. * * @since 4.8 * * @return bool */ public function getAddAllowed() { return vc_user_access_check_shortcode_all('vc_tta_section'); }
<?php $editAccess = vc_user_access_check_shortcode_edit($shortcode); $allAccess = vc_user_access_check_shortcode_all($shortcode); ?> <div class="vc_controls<?php echo !empty($extended_css) ? ' ' . $extended_css : ''; ?> "> <div class="vc_controls-<?php echo $position; ?> "> <a class="vc_element-name"> <span class="vc_btn-content"><?php echo $name; ?> </span> </a> <?php foreach ($controls as $control) { ?> <?php if ('add' === $control && vc_user_access()->part('shortcodes')->checkStateAny(true, 'custom', null)->get()) { ?> <a class="vc_control-btn vc_control-btn-prepend vc_edit" href="#" title="<?php printf(__('Prepend to %s', 'js_composer'), $name); ?> "><span class="vc_btn-content"><span class="icon"></span></span></a>
/** * Generates list of shortcodes taking into account the access rules for shortcodes from VC Settings page. * * This method parses the list of mapped shortcodes and creates categories list for users. * * @static * * @param bool $force - force data generation even data already generated. */ protected static function generateUserData($force = false) { if (!$force && false !== self::$user_sc && false !== self::$user_categories) { return; } //$settings = self::getSettings(); self::$user_sc = self::$user_categories = self::$user_sorted_sc = array(); $deprecated = 'deprecated'; $add_deprecated = false; if (is_array(self::$sc) && !empty(self::$sc)) { foreach (array_keys(self::$sc) as $name) { self::setElementSettings($name); if (!isset(self::$sc[$name])) { continue; } $values = self::$sc[$name]; if (vc_user_access_check_shortcode_all($name)) { if (!isset($values['content_element']) || true === $values['content_element']) { $categories = isset($values['category']) ? $values['category'] : '_other_category_'; $values['_category_ids'] = array(); if (isset($values['deprecated']) && false !== $values['deprecated']) { $add_deprecated = true; $values['_category_ids'][] = 'deprecated'; } else { if (is_array($categories) && !empty($categories)) { foreach ($categories as $c) { if (false === array_search($c, self::$user_categories)) { self::$user_categories[] = $c; } $values['_category_ids'][] = md5($c); } } else { if (false === array_search($categories, self::$user_categories)) { self::$user_categories[] = $categories; } $values['_category_ids'][] = md5($categories); } } } self::$user_sc[$name] = $values; self::$user_sorted_sc[] = $values; } } } if ($add_deprecated) { self::$user_categories[] = $deprecated; } $sort = new Vc_Sort(self::$user_sorted_sc); self::$user_sorted_sc = $sort->sortByKey(); }