public function save($params = array()) { $data = array('message' => ''); $roles = $this->getWpRoles(); $editable_roles = get_editable_roles(); foreach ($params as $role => $parts) { if (is_string($parts)) { $parts = json_decode(stripslashes($parts), true); } if (isset($editable_roles[$role])) { foreach ($parts as $part => $settings) { $part_key = vc_role_access()->who($role)->part($part)->getStateKey(); $stateValue = '0'; $roles->use_db = false; // Disable saving in DB on every cap change foreach ($settings as $key => $value) { if ('_state' === $key) { $stateValue = in_array($value, array('0', '1')) ? (bool) $value : $value; } else { if (empty($value)) { $roles->remove_cap($role, $part_key . '/' . $key); } else { $roles->add_cap($role, $part_key . '/' . $key, true); } } } $roles->use_db = true; // Enable for the lat change in cap of role to store data in DB $roles->add_cap($role, $part_key, $stateValue); } } } $data['message'] = __('Roles settings successfully saved.', 'js_composer'); return $data; }
/** * Set post types where VC editors are enabled. * * @since 4.4 * @access public * * @param array $post_types */ public function setEditorPostTypes(array $post_types) { $this->editor_post_types = !empty($post_types) ? $post_types : $this->editorDefaultPostTypes(); require_once ABSPATH . 'wp-admin/includes/user.php'; $editable_roles = get_editable_roles(); foreach ($editable_roles as $role => $settings) { $part = vc_role_access()->who($role)->part('post_types'); $all_post_types = $part->getAllCaps(); foreach ($all_post_types as $post_type => $value) { $part->getRole()->remove_cap($part->getStateKey() . '/' . $post_type); } $part->setState('custom'); foreach ($this->editor_post_types as $post_type) { $part->setCapRule($post_type); } } }
<?php if (vc_frontend_editor()->inlineEnabled()) { vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'custom_value' => 'custom', 'options' => array(array(true, __('Enabled', 'js_composer')), array(false, __('Disabled', 'js_composer'))), 'main_label' => __('Frontend editor', 'js_composer'), 'custom_label' => __('Frontend editor', 'js_composer'))); }
<?php if (!defined('ABSPATH')) { die('-1'); } vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'custom_value' => 'custom', 'capabilities' => WPBMap::getSortedAllShortCodes(), 'ignore_capabilities' => array('vc_gitem', 'vc_gitem_animated_block', 'vc_gitem_zone', 'vc_gitem_zone_a', 'vc_gitem_zone_b', 'vc_gitem_zone_c', 'vc_column', 'vc_row_inner', 'vc_column_inner', 'vc_posts_grid'), 'categories' => WPBMap::getCategories(), 'cap_types' => array(array('all', __('All', 'js_composer')), array('edit', __('Edit', 'js_composer'))), 'item_header_name' => __('Element', 'js_composer'), 'options' => array(array(true, __('All', 'js_composer')), array('edit', __('Edit only', 'js_composer')), array('custom', __('Custom', 'js_composer'))), 'main_label' => __('Elements', 'js_composer'), 'custom_label' => __('Elements', 'js_composer'), 'description' => __('Control user access to content elements.', 'js_composer'), 'use_table' => true));
<?php $tabs = array(); foreach (vc_settings()->getTabs() as $tab => $title) { $tabs[] = array($tab . '-tab', $title); } vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'custom_value' => 'custom', 'capabilities' => $tabs, 'options' => array(array(true, __('All', 'js_composer')), array('custom', __('Custom', 'js_composer')), array(false, __('Disabled', 'js_composer'))), 'main_label' => __('Settings options', 'js_composer'), 'custom_label' => __('Settings options', 'js_composer'), 'description' => __('Control access rights to Visual Composer admin settings tabs (e.g. General Settings, Shortcode Mapper, ...)', 'js_composer')));
<?php vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'options' => array(array(true, __('All', 'js_composer')), array('add', __('Apply presets only', 'js_composer')), array(false, __('Disabled', 'js_composer'))), 'main_label' => __('Element Presets', 'js_composer'), 'description' => __('Control access rights to element presets in element edit form. Note: "Apply presets only" restricts users from saving new presets, deleting existing and setting defaults.', 'js_composer')));
<?php vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'options' => array(array(true, __('Enabled', 'js_composer')), array(false, __('Disabled', 'js_composer'))), 'main_label' => __('Grid Builder', 'js_composer'), 'custom_label' => __('Grid Builder', 'js_composer'), 'description' => __('Control user access to Grid Builder and Grid Builder Elements.', 'js_composer')));
function vc_bc_access_rule_48_backend_editor_add_cap_disabled_ce_editor($role) { if (!$role) { return $role; } $part = vc_role_access()->who($role->name)->part('backend_editor'); if (!isset($part->getRole()->capabilities[$part->getStateKey()])) { $group_access_settings = vc_settings()->get('groups_access_rules'); if (isset($group_access_settings[$role->name]['show']) && 'only' === $group_access_settings[$role->name]['show']) { $role->capabilities[$part->getStateKey() . '/disabled_ce_editor'] = true; } } return $role; }
<?php if (!defined('ABSPATH')) { die('-1'); } vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'options' => array(array(true, __('Enabled', 'js_composer')), array(false, __('Disabled', 'js_composer'))), 'main_label' => __('Page settings', 'js_composer'), 'description' => __('Control access to Visual Composer page settings. Note: Disable page settings to restrict editing of Custom CSS through page.', 'js_composer')));
<?php vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'custom_value' => 'custom', 'capabilities' => $vc_role->getPostTypes(), 'options' => array(array(true, __('Pages only', 'js_composer')), array('custom', __('Custom', 'js_composer')), array(false, __('Disabled', 'js_composer'))), 'main_label' => __('Post types', 'js_composer'), 'custom_label' => __('Post types', 'js_composer'), 'description' => __('Enable Visual Composer for pages, posts and custom post types. Note: By default Visual Composer is available for pages only.', 'js_composer')));
<?php vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'capabilities' => array(array('disabled_ce_editor', __('Disable Classic editor', 'js_composer'))), 'options' => array(array(true, __('Enabled', 'js_composer')), array('default', __('Enabled and default', 'js_composer')), array(false, __('Disabled', 'js_composer'))), 'main_label' => __('Backend editor', 'js_composer'), 'custom_label' => __('Backend editor', 'js_composer')));
<?php vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'options' => array(array(true, __('All', 'js_composer')), array('add', __('Apply templates only', 'js_composer')), array(false, __('Disabled', 'js_composer'))), 'main_label' => __('Templates', 'js_composer'), 'description' => __('Control access rights to templates and predefined templates. Note: "Apply templates only" restricts users from saving new templates and deleting existing.', 'js_composer')));