本文整理汇总了PHP中WPCF_Roles::user_can_edit_custom_post_by_slug方法的典型用法代码示例。如果您正苦于以下问题:PHP WPCF_Roles::user_can_edit_custom_post_by_slug方法的具体用法?PHP WPCF_Roles::user_can_edit_custom_post_by_slug怎么用?PHP WPCF_Roles::user_can_edit_custom_post_by_slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPCF_Roles
的用法示例。
在下文中一共展示了WPCF_Roles::user_can_edit_custom_post_by_slug方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf_ajax
/**
* All AJAX calls go here.
*
* @global object $wpdb
*
*/
function wpcf_ajax()
{
/**
* check nounce
*/
if (!(isset($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['wpcf_action']))) {
die;
}
require_once WPCF_INC_ABSPATH . '/classes/class.wpcf.roles.php';
/**
* check permissions
*/
switch ($_REQUEST['wpcf_action']) {
case 'deactivate_post_type':
case 'activate_post_type':
case 'delete_post_type':
case 'duplicate_post_type':
$post_type = wpcf_ajax_helper_get_post_type();
if (empty($post_type)) {
wpcf_ajax_helper_print_error_and_die();
}
if (!WPCF_Roles::user_can_edit_custom_post_by_slug($post_type)) {
wpcf_ajax_helper_verification_failed_and_die();
}
break;
case 'taxonomy_duplicate':
case 'deactivate_taxonomy':
case 'activate_taxonomy':
case 'delete_taxonomy':
$custom_taxonomy = wpcf_ajax_helper_get_taxonomy();
if (empty($custom_taxonomy)) {
wpcf_ajax_helper_print_error_and_die();
}
if (!WPCF_Roles::user_can_edit_custom_taxonomy_by_slug($custom_taxonomy)) {
wpcf_ajax_helper_verification_failed_and_die();
}
break;
case 'deactivate_group':
case 'activate_group':
case 'delete_group':
if (!isset($_GET['group_id']) || empty($_GET['group_id'])) {
wpcf_ajax_helper_print_error_and_die();
}
if (!WPCF_Roles::user_can_edit_custom_field_group_by_id($_GET['group_id'])) {
wpcf_ajax_helper_verification_failed_and_die();
}
break;
case 'deactivate_user_group':
case 'activate_user_group':
case 'delete_usermeta_group':
if (!isset($_GET['group_id']) || empty($_GET['group_id'])) {
wpcf_ajax_helper_print_error_and_die();
}
if (!WPCF_Roles::user_can_edit_usermeta_field_group_by_id($_GET['group_id'])) {
wpcf_ajax_helper_verification_failed_and_die();
}
break;
case 'deactivate_term_group':
case 'activate_term_group':
case 'delete_term_group':
if (!isset($_GET['group_id']) || empty($_GET['group_id'])) {
wpcf_ajax_helper_print_error_and_die();
}
if (!WPCF_Roles::user_can_edit_term_field_group_by_id($_GET['group_id'])) {
wpcf_ajax_helper_verification_failed_and_die();
}
break;
case 'usermeta_delete':
case 'delete_usermeta':
case 'remove_from_history2':
case 'usermeta_insert_existing':
case 'fields_insert':
case 'fields_insert_existing':
case 'remove_field_from_group':
case 'add_radio_option':
case 'add_select_option':
case 'add_checkboxes_option':
case 'group_form_collapsed':
case 'form_fieldset_toggle':
case 'fields_delete':
case 'delete_field':
case 'remove_from_history':
case 'add_condition':
case 'pt_edit_fields':
case 'toggle':
case 'cb_save_empty_migrate':
if (!current_user_can('manage_options')) {
wpcf_ajax_helper_verification_failed_and_die();
}
/**
* do not check actions from other places
*/
break;
default:
//.........这里部分代码省略.........