本文整理汇总了PHP中vc_user_access函数的典型用法代码示例。如果您正苦于以下问题:PHP vc_user_access函数的具体用法?PHP vc_user_access怎么用?PHP vc_user_access使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vc_user_access函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* 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);
}
示例2: wpb_templatera_add_submenu_page
/**
* 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()), '');
}
}
示例3: vc_check_for_custom_css_build
/**
* 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');
}
}
示例4: vc_get_autocomplete_suggestion
/**
* @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);
}
示例5: getColumnControls
/**
* @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;
}
示例6: vc_welcome_menu_hooks
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 */
}
示例7: vc_network_menu_page_build
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');
}
示例8: 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;
}
示例9: vc_pointer_reset
/**
* 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));
}
示例10: vc_page_settings_build
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');
}
示例11: save
/**
* 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);
}
}
示例12: isActive
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;
}
示例13: vc_user_access_check_shortcode_all
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;
}
}
示例14: getPartState
public function getPartState()
{
return vc_user_access()->part('shortcodes')->getState();
}
示例15: render
/**
* 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');
}