/** * 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); }
/** * Add sub page to Visual Composer pages * * @since 1.2 */ function wpb_templatera_add_submenu_page() { if (!WPB_VC_NEW_USER_ACCESS_VERSION || WPB_VC_NEW_USER_ACCESS_VERSION && vc_user_access()->part('templates')->checkStateAny(true, null)->get()) { $labels = VcTemplateManager::getPostTypesLabels(); add_submenu_page(VC_PAGE_MAIN_SLUG, $labels['name'], $labels['name'], 'manage_options', 'edit.php?post_type=' . rawurlencode(VcTemplateManager::postType()), ''); } }
/** * Function check is system has custom build of css * and check it version in comparison with current VC version * * @since 4.5 */ function vc_check_for_custom_css_build() { $version = vc_settings()->getCustomCssVersion(); if (vc_user_access()->wpAny('manage_options')->part('settings')->can('vc-color-tab')->get() && vc_settings()->useCustomCss() && (!$version || version_compare(WPB_VC_VERSION, $version, '<>'))) { add_action('admin_notices', 'vc_custom_css_admin_notice'); } }
/** * @since 4.4 */ function vc_get_autocomplete_suggestion() { vc_user_access()->checkAdminNonce()->validateDie()->wpAny('edit_posts', 'edit_pages')->validateDie(); $query = vc_post_param('query'); $tag = strip_tags(vc_post_param('shortcode')); $param_name = vc_post_param('param'); vc_render_suggestion($query, $tag, $param_name); }
/** * @param $controls * @param string $extended_css * * @return string */ public function getColumnControls($controls, $extended_css = '') { $output = '<div class="vc_controls vc_control-column vc_controls-visible controls' . (!empty($extended_css) ? " {$extended_css}" : '') . '">'; $controls_end = '</div>'; if (' bottom-controls' === $extended_css) { $control_title = __('Append to this column', 'js_composer'); } else { $control_title = __('Prepend to this column', 'js_composer'); } if (vc_user_access()->part('shortcodes')->checkStateAny(true, 'custom', null)->get()) { $controls_add = '<a class="vc_control column_add vc_column-add" data-vc-control="add" href="#" title="' . $control_title . '"><i class="vc_icon"></i></a>'; } else { $controls_add = ''; } $controls_edit = '<a class="vc_control column_edit vc_column-edit" data-vc-control="edit" href="#" title="' . __('Edit this column', 'js_composer') . '"><i class="vc_icon"></i></a>'; $controls_delete = '<a class="vc_control column_delete vc_column-delete" data-vc-control="delete" href="#" title="' . __('Delete this column', 'js_composer') . '"><i class="vc_icon"></i></a>'; $editAccess = vc_user_access_check_shortcode_edit($this->shortcode); $allAccess = vc_user_access_check_shortcode_all($this->shortcode); if (is_array($controls) && !empty($controls)) { foreach ($controls as $control) { if ('add' === $control || $editAccess && 'edit' === $control || $allAccess) { $method_name = vc_camel_case('output-editor-control-' . $control); if (method_exists($this, $method_name)) { $output .= $this->{$method_name}(); } else { $control_var = 'controls_' . $control; if (isset(${$control_var})) { $output .= ${$control_var}; } } } } return $output . $controls_end; } elseif (is_string($controls) && 'full' === $controls) { if ($allAccess) { return $output . $controls_add . $controls_edit . $controls_delete . $controls_end; } elseif ($editAccess) { return $output . $controls_add . $controls_edit . $controls_end; } else { return $output . $controls_add . $controls_end; } return $output . $controls_end; } elseif (is_string($controls)) { $control_var = 'controls_' . $controls; if ('add' === $controls || ($editAccess && 'edit' == $controls || $allAccess) && isset(${$control_var})) { return $output . ${$control_var} . $controls_end; } return $output . $controls_end; } if ($allAccess) { return $output . $controls_add . $controls_edit . $controls_delete . $controls_end; } elseif ($editAccess) { return $output . $controls_add . $controls_edit . $controls_end; } else { return $output . $controls_add . $controls_end; } return $output . $controls_end; }
function vc_welcome_menu_hooks() { $settings_tab_enabled = vc_user_access()->wpAny('manage_options')->part('settings')->can('vc-general-tab')->get(); /* nectar addition */ /*add_action( 'vc_menu_page_build', 'vc_page_welcome_add_sub_page', $settings_tab_enabled ? 11 : 1 ); add_action( 'vc_network_menu_page_build', 'vc_page_welcome_add_sub_page', $settings_tab_enabled && ! is_main_site() ? 11 : 1 );*/ /* nectar addition end */ }
function vc_network_menu_page_build() { if (vc_user_access()->wpAny('manage_options')->part('settings')->can('vc-general-tab')->get()) { define('VC_PAGE_MAIN_SLUG', 'vc-general'); } else { define('VC_PAGE_MAIN_SLUG', 'vc-welcome'); } add_menu_page(__('Visual Composer', 'js_composer'), __('Visual Composer', 'js_composer'), 'exist', VC_PAGE_MAIN_SLUG, null, vc_asset_url('vc/visual_composer.png'), 76); do_action('vc_network_menu_page_build'); }
/** * Build edit form fields * * @deprecated 4.4 * @use Vc_Shortcode_Edit_Form::renderFields */ public function build() { // _deprecated_function( 'Vc_Shortcode_Edit_Form::build', '4.4 (will be removed in 4.10)', 'Vc_Shortcode_Edit_Form::renderFields' ); $tag = vc_post_param('element'); vc_user_access()->checkAdminNonce()->validateDie(__('Access denied', 'js_composer'))->wpAny('edit_posts', 'edit_pages')->validateDie(__('Access denied', 'js_composer'))->check('vc_user_access_check_shortcode_edit', $tag)->validateDie(__('Access denied', 'js_composer')); $shortcode = stripslashes(vc_post_param('shortcode')); require_once vc_path_dir('EDITORS_DIR', 'class-vc-edit-form-fields.php'); $fields = new Vc_Edit_Form_Fields($tag, shortcode_parse_atts($shortcode)); $fields->render(); die; }
/** * Remove Vc pointers keys to show Tour markers again. * @sine 4.5 */ function vc_pointer_reset() { global $vc_default_pointers; vc_user_access()->checkAdminNonce()->validateDie()->wpAny('manage_options')->validateDie()->part('settings')->can('vc-general-tab')->validateDie(); $pointers = (array) apply_filters('vc_pointers_list', $vc_default_pointers); $prev_meta_value = get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true); $dismissed = explode(',', (string) $prev_meta_value); if (count($dismissed) > 0 && count($pointers)) { $meta_value = implode(',', array_diff($dismissed, $pointers)); update_user_meta(get_current_user_id(), 'dismissed_wp_pointers', $meta_value, $prev_meta_value); } wp_send_json(array('success' => true)); }
function vc_page_settings_build() { if (!vc_user_access()->wpAny('manage_options')->get()) { return; } $tabs = vc_settings()->getTabs(); foreach ($tabs as $slug => $title) { if (vc_user_access()->part('settings')->can($slug . '-tab')->get()) { $page = add_submenu_page(VC_PAGE_MAIN_SLUG, $title, $title, 'manage_options', $slug, 'vc_page_settings_render'); add_action('load-' . $page, array(vc_settings(), 'adminLoad')); } } do_action('vc_page_settings_build'); }
/** * 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); } }
public function isActive() { if (!$this->setMediumAsPost()) { return false; } // check for functions used if (!function_exists('vc_user_access') || !class_exists('Vc_Shortcodes_Manager') || !method_exists('Vc_Manager', 'backendEditor')) { return false; } // don't show VC if user role is not allowed to use the backend editor if (!vc_user_access()->part('backend_editor')->can()->get()) { return false; } $this->action(); return true; }
function vc_user_access_check_shortcode_all($shortcode) { $do_check = apply_filters('vc_user_access_check-shortcode_all', null, $shortcode); if (is_null($do_check)) { return vc_user_access()->part('shortcodes')->checkStateAny(true, 'custom', null)->can($shortcode . '_all')->get(); } else { return $do_check; } }
public function getPartState() { return vc_user_access()->part('shortcodes')->getState(); }
/** * Render fields html and output it. * @since 4.4 * vc_filter: vc_edit_form_class - filter to override editor_css_classes array */ public function render() { $this->loadDefaultParams(); $output = $el_position = ''; $groups_content = $groups = array(); $params = $this->setting('params'); $editor_css_classes = apply_filters('vc_edit_form_class', array('wpb_edit_form_elements', 'vc_edit_form_elements'), $this->atts, $params); $deprecated = $this->setting('deprecated'); require_once vc_path_dir('AUTOLOAD_DIR', 'class-vc-settings-presets.php'); $list_vendor_presets = Vc_Settings_Preset::listVendorSettingsPresets($this->tag); $list_presets = Vc_Settings_Preset::listSettingsPresets($this->tag); if (vc_user_access()->part('presets')->checkStateAny(true, null)->get() || !empty($list_presets) || !empty($list_vendor_presets)) { $output .= '<script type="text/javascript">window.vc_presets_show=true;</script>'; } else { $output .= '<script type="text/javascript">window.vc_presets_show=false;</script>'; } if (!empty($deprecated)) { $output .= '<div class="vc_row vc_ui-flex-row vc_shortcode-edit-form-deprecated-message"><div class="vc_col-sm-12 wpb_element_wrapper">' . vc_message_warning(sprintf(__('You are using outdated element, it is deprecated since version %s.', 'js_composer'), $this->setting('deprecated'))) . '</div></div>'; } $output .= '<div class="' . implode(' ', $editor_css_classes) . '" data-title="' . htmlspecialchars(__('Edit', 'js_composer') . ' ' . __($this->setting('name'), 'js_composer')) . '">'; if (is_array($params)) { foreach ($params as $param) { $name = isset($param['param_name']) ? $param['param_name'] : null; if (!is_null($name)) { $value = isset($this->atts[$name]) ? $this->atts[$name] : null; $value = $this->parseShortcodeAttributeValue($param, $value); $group = isset($param['group']) && '' !== $param['group'] ? $param['group'] : '_general'; if (!isset($groups_content[$group])) { $groups[] = $group; $groups_content[$group] = ''; } $groups_content[$group] .= $this->renderField($param, $value); } } } $output .= $this->renderGroupedFields($groups, $groups_content); $output .= '</div>'; $output .= $this->enqueueScripts(); echo $output; do_action('vc_edit_form_fields_after_render'); }
<div class="vc_ui-font-open-sans vc_ui-panel-window vc_media-xs vc_ui-panel" data-vc-panel=".vc_ui-panel-header-header" data-vc-ui-element="panel-edit-element" id="vc_ui-panel-edit-element"> <div class="vc_ui-panel-window-inner"> <?php $controls = array('minimize', 'close'); if (vc_user_access()->part('presets')->can()->get()) { $controls = array(array('template' => 'editors/partials/vc_ui-presets-dropdown.tpl.php'), 'minimize', 'close'); } vc_include_template('editors/popups/vc_ui-header.tpl.php', array('title' => __('Page settings', 'js_composer'), 'controls' => $controls, 'header_css_class' => 'vc_ui-post-settings-header-container', 'content_template' => '')); ?> <!-- param window footer--> <div class="vc_ui-panel-content-container"> <div class="vc_ui-panel-content vc_properties-list vc_edit_form_elements"> <!--/ temp content --> </div> </div> <!-- param window footer--> <?php vc_include_template('editors/popups/vc_ui-footer.tpl.php', array('controls' => array(array('name' => 'close', 'label' => __('Close', 'js_composer'), 'css_classes' => 'vc_ui-button-fw'), array('name' => 'save', 'label' => __('Save changes', 'js_composer'), 'css_classes' => 'vc_ui-button-fw', 'style' => 'action')))); ?> </div> </div>
/** * Create templates button on navigation bar of the Front/Backend editor. * * @param $buttons * * @return array */ public function createButtonFrontBack($buttons) { if ($this->isUserRoleAccessVcVersion() && !vc_user_access()->part('templates')->can()->get()) { return $buttons; } if ($this->getPostType() == "vc_grid_item") { return $buttons; } $new_buttons = array(); foreach ($buttons as $button) { if ($button[0] != 'templates') { // disable custom css as well but only in templatera page if (!$this->isSamePostType() || $this->isSamePostType() && $button[0] != 'custom_css') { $new_buttons[] = $button; } } else { if ($this->isPanelVcVersion()) { // @since 4.4 button is available but "Save" Functionality in form is disabled in templatera post. $new_buttons[] = array('custom_templates', '<li class="vc_navbar-border-right"><a href="#" class="vc_icon-btn vc_templatera_button" id="vc-templatera-editor-button" title="' . __('Templates', 'js_composer') . '"></a></li>'); } else { if ($this->isSamePostType()) { // in older version we doesn't need to display templates window in templatera post } else { $new_buttons[] = array('custom_templates', '<li class="vc_navbar-border-right"><a href="#" class="vc_icon-btn vc_templatera_button" id="vc-templatera-editor-button" title="' . __('Templates', 'js_composer') . '"></a></li>'); } } } } return $new_buttons; }
function vc_gitem_set_mapper_check_access() { if (vc_user_access()->checkAdminNonce()->wpAny('edit_posts', 'edit_pages')->part('grid_builder')->can()->get() && 'true' === vc_post_param('vc_grid_item_editor')) { vc_mapper()->setCheckForAccess(false); } }
?> </h1> <div class="about-text"> <?php _e('Congratulations! You are about to use most powerful time saver for WordPress ever - page builder plugin with Frontend and Backend editors by WPBakery.', 'js_composer'); ?> </div> <div class="wp-badge vc-page-logo"> <?php echo sprintf(__('Version %s', 'js_composer'), WPB_VC_VERSION); ?> </div> <p class="vc-page-actions"> <?php if (vc_user_access()->wpAny('manage_options')->part('settings')->can('vc-general-tab')->get() && (!is_multisite() || !is_main_site())) { ?> <a href="<?php echo esc_attr(admin_url('admin.php?page=vc-general')); ?> " class="button button-primary"><?php _e('Settings', 'js_composer'); ?> </a><?php } ?> <a href="https://twitter.com/share" class="twitter-share-button" data-text="Take full control over your WordPress site with Visual Composer page builder by @WPBakery" data-url="http://vc.wpbakery.com" data-size="large">Tweet</a> <script>! function ( d, s, id ) {
<?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>';
/** * Return rendered title prompt * * @since 4.7 * * @return string */ function vc_action_render_settings_preset_title_prompt() { vc_user_access()->checkAdminNonce()->validateDie()->wpAny('edit_posts', 'edit_pages')->validateDie()->part('presets')->can()->validateDie(); ob_start(); vc_include_template(apply_filters('vc_render_settings_preset_title_prompt', 'editors/partials/prompt.tpl.php')); $html = ob_get_clean(); $response = array('success' => true, 'html' => $html); wp_send_json($response); }
/** * */ public function goAction() { vc_user_access()->checkAdminNonce()->validateDie()->wpAny('manage_options')->validateDie()->part('settings')->can('vc-automapper-tab')->validateDie(); $action = vc_post_param('vc_action'); $this->result($this->{$action}()); }
/** * @return string */ public function getControlTemplates() { if (!vc_user_access()->part('templates')->can()->get()) { return ''; } return '<li><a href="javascript:;" class="vc_icon-btn vc_templates-button vc_navbar-border-right" id="vc_templates-editor-button" title="' . __('Templates', 'js_composer') . '"></a></li>'; }
/** * @since 4.4 */ function vc_param_group_clone() { vc_user_access()->checkAdminNonce()->validateDie()->wpAny('edit_posts', 'edit_pages')->validateDie(); $param = vc_post_param('param'); $value = vc_post_param('value'); $tag = vc_post_param('shortcode'); die(vc_param_group_clone_by_data($tag, json_decode(urldecode($param), true), json_decode(urldecode($value), true))); }
/** * @return bool */ public function editorEnabled() { return vc_user_access()->part('backend_editor')->can()->get(); }
/** * Setter for disable updater variable. * @since 4.2 * @see * * @param bool $value */ public function disableUpdater($value = true) { if ('administrator' !== vc_user_access()->part('settings')->getRoleName()) { $this->disable_updater = $value; } }
/** * Init settings page && menu item * vc_filter: vc_settings_tabs - hook to override settings tabs */ public function initAdmin() { $this->setTabs(); self::$color_settings = array(array('vc_color' => array('title' => __('Main accent color', 'js_composer'))), array('vc_color_hover' => array('title' => __('Hover color', 'js_composer'))), array('vc_color_call_to_action_bg' => array('title' => __('Call to action background color', 'js_composer'))), array('vc_color_google_maps_bg' => array('title' => __('Google maps background color', 'js_composer'))), array('vc_color_post_slider_caption_bg' => array('title' => __('Post slider caption background color', 'js_composer'))), array('vc_color_progress_bar_bg' => array('title' => __('Progress bar background color', 'js_composer'))), array('vc_color_separator_border' => array('title' => __('Separator border color', 'js_composer'))), array('vc_color_tab_bg' => array('title' => __('Tabs navigation background color', 'js_composer'))), array('vc_color_tab_bg_active' => array('title' => __('Active tab background color', 'js_composer')))); self::$defaults = array('vc_color' => '#f7f7f7', 'vc_color_hover' => '#F0F0F0', 'margin' => '35px', 'gutter' => '15', 'responsive_max' => '768', 'compiled_js_composer_less' => ''); if ('restore_color' === vc_post_param('vc_action') && vc_user_access()->check('wp_verify_nonce', vc_post_param('_wpnonce'), vc_settings()->getOptionGroup() . '_color' . '-options')->validateDie()->wpAny('manage_options')->validateDie()->part('settings')->can('vc-color-tab')->validateDie()->get()) { $this->restoreColor(); } /** * @since 4.5 used to call update file once option is changed */ add_action('update_option_wpb_js_compiled_js_composer_less', array(&$this, 'buildCustomColorCss')); /** * @since 4.5 used to call update file once option is changed */ add_action('update_option_wpb_js_custom_css', array(&$this, 'buildCustomCss')); /** * @since 4.5 used to call update file once option is changed */ add_action('add_option_wpb_js_compiled_js_composer_less', array(&$this, 'buildCustomColorCss')); /** * @since 4.5 used to call update file once option is changed */ add_action('add_option_wpb_js_custom_css', array(&$this, 'buildCustomCss')); /** * Tab: General Settings */ $tab = 'general'; $this->addSection($tab); $this->addField($tab, __('Disable responsive content elements', 'js_composer'), 'not_responsive_css', array(&$this, 'sanitize_not_responsive_css_callback'), array(&$this, 'not_responsive_css_field_callback')); $this->addField($tab, __('Google fonts subsets', 'js_composer'), 'google_fonts_subsets', array(&$this, 'sanitize_google_fonts_subsets_callback'), array(&$this, 'google_fonts_subsets_callback')); /** * Tab: Design Options */ $tab = 'color'; $this->addSection($tab); // Use custom checkbox $this->addField($tab, __('Use custom design options', 'js_composer'), 'use_custom', array(&$this, 'sanitize_use_custom_callback'), array(&$this, 'use_custom_callback')); foreach (self::$color_settings as $color_set) { foreach ($color_set as $key => $data) { $this->addField($tab, $data['title'], $key, array(&$this, 'sanitize_color_callback'), array(&$this, 'color_callback'), array('id' => $key)); } } // Margin $this->addField($tab, __('Elements bottom margin', 'js_composer'), 'margin', array(&$this, 'sanitize_margin_callback'), array(&$this, 'margin_callback')); // Gutter $this->addField($tab, __('Grid gutter width', 'js_composer'), 'gutter', array(&$this, 'sanitize_gutter_callback'), array(&$this, 'gutter_callback')); // Responsive max width $this->addField($tab, __('Mobile screen width', 'js_composer'), 'responsive_max', array(&$this, 'sanitize_responsive_max_callback'), array(&$this, 'responsive_max_callback')); $this->addField($tab, false, 'compiled_js_composer_less', array(&$this, 'sanitize_compiled_js_composer_less_callback'), array(&$this, 'compiled_js_composer_less_callback')); /** * Tab: Custom CSS */ $tab = 'custom_css'; $this->addSection($tab); $this->addField($tab, __('Paste your CSS code', 'js_composer'), 'custom_css', array(&$this, 'sanitize_custom_css_callback'), array(&$this, 'custom_css_field_callback')); /** * Custom Tabs */ foreach ($this->getTabs() as $tab => $title) { do_action('vc_settings_tab-' . preg_replace('/^vc\\-/', '', $tab), $this); } /** * Tab: Updater */ $tab = 'updater'; $this->addSection($tab); }
/** * Get settings page link * @since 4.2 * @return string url to settings page */ public function getSettingsPageLink() { $page = 'vc-general'; if (!vc_user_access()->part('settings')->can('vc-general-tab')->get()) { $page = 'vc-welcome'; } return add_query_arg(array('page' => $page), admin_url('admin.php')); }
/** * Get post types where VC editors are enabled. * * @since 4.2 * @access public * * @return array */ public function editorPostTypes() { if (is_null($this->editor_post_types)) { $post_types = array_keys(vc_user_access()->part('post_types')->getAllCaps()); $this->editor_post_types = $post_types ? $post_types : $this->editorDefaultPostTypes(); } return $this->editor_post_types; }
public function getPartState() { return vc_user_access()->part('grid_builder')->getState(); }