当前位置: 首页>>代码示例>>PHP>>正文


PHP get_editable_roles函数代码示例

本文整理汇总了PHP中get_editable_roles函数的典型用法代码示例。如果您正苦于以下问题:PHP get_editable_roles函数的具体用法?PHP get_editable_roles怎么用?PHP get_editable_roles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_editable_roles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: settings_updated

 public function settings_updated()
 {
     global $pagenow, $usp_advanced;
     if (is_admin() && $pagenow == 'options-general.php') {
         if (isset($_GET['page']) && $_GET['page'] == 'usp_options') {
             if (isset($_GET['settings-updated']) && $_GET['settings-updated']) {
                 if (isset($usp_advanced['post_type_role'])) {
                     $roles = $usp_advanced['post_type_role'];
                     $matches = array();
                     $misses = array();
                     foreach (get_editable_roles() as $role_name => $role_info) {
                         if (in_array($role_name, $roles)) {
                             $matches[] = $role_name;
                         } else {
                             $misses[] = $role_name;
                         }
                     }
                     foreach ($matches as $match) {
                         $this->add_capability($match);
                     }
                     foreach ($misses as $miss) {
                         $this->remove_capability($miss);
                     }
                 }
             }
         }
     }
 }
开发者ID:alvarpoon,项目名称:aeg,代码行数:28,代码来源:usp-posts.php

示例2: get_all_privilege

function get_all_privilege()
{
    global $wpdb;
    $query = "SELECT option_name, option_value FROM {$wpdb->prefix}options WHERE option_name LIKE 'sm_%_dashboard';";
    $results = $wpdb->get_results($query);
    $rows_roles = $wpdb->num_rows;
    $roles = array();
    foreach ($results as $obj) {
        $roles_detail = unserialize($obj->option_value);
        $roles[$obj->option_name] = $roles_detail;
    }
    $all_roles = get_editable_roles();
    if (isset($all_roles['administrator'])) {
        unset($all_roles['administrator']);
    }
    foreach ($all_roles as $role => $details) {
        $name = translate_user_role($details['name']);
        $checked = array();
        if ($rows_roles > 0) {
            for ($i = 0; $i < count($roles['sm_' . $role . '_dashboard']); $i++) {
                $checked[$roles['sm_' . $role . '_dashboard'][$i]] = 'checked';
            }
        }
        $products_checked = isset($checked['Products']) && $checked['Products'] === 'checked' ? 'checked' : 'unchecked';
        $customers_orders_checked = isset($checked['Customers_Orders']) && $checked['Customers_Orders'] === 'checked' ? 'checked' : 'unchecked';
        if ($name != 'Administrator') {
            echo "\n                                <tr>\n                                        <th scope='row'>{$name}</th>\n                                        <td align='center'><input name='sm_" . $role . "_dashboard[]' type='checkbox' id='Products' value='Products' " . $products_checked . "></td>\n                                        <td align='center'><input name='sm_" . $role . "_dashboard[]' type='checkbox' id='Customers_Orders' value='Customers_Orders' " . $customers_orders_checked . "></td>\n                                </tr>\n                        ";
        }
    }
}
开发者ID:bulats,项目名称:chef,代码行数:30,代码来源:sm-privilege.php

示例3: save

 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;
 }
开发者ID:severnrescue,项目名称:web,代码行数:35,代码来源:class-vc-roles.php

示例4: aviators_settings_render_field

function aviators_settings_render_field($args)
{
    $option = $args['option'];
    if (isset($option->default)) {
        $value = get_option($args['id'], $option->default);
    } else {
        $value = get_option($args['id']);
    }
    $args = array('args' => $args, 'value' => $value, 'option' => $option);
    if ($option->type == 'select_user_role') {
        $args['user_roles'] = get_editable_roles();
    }
    if ($option->type == 'select_post_type') {
        $args['post_types'] = get_post_types(array('public' => true, '_builtin' => false), 'objects');
    }
    if ($option->type == 'select_post_type_for_submission') {
        $types = array();
        $post_types = get_post_types(array('public' => true, '_builtin' => false), 'objects');
        if (is_array($post_types)) {
            foreach ($post_types as $key => $post_type) {
                if (function_exists('aviators_' . $key . '_form')) {
                    $types[] = $post_type;
                }
            }
        }
        $args['post_types'] = $types;
    }
    echo View::render('settings/fields/' . $option->type . '.twig', $args);
}
开发者ID:dongchpp,项目名称:BIPHP,代码行数:29,代码来源:renderers.php

示例5: bbconnect_dropdown_roles

function bbconnect_dropdown_roles($selected = false)
{
    $p = '';
    $r = '';
    $editable_roles = get_editable_roles();
    foreach ($editable_roles as $role => $details) {
        $name = translate_user_role($details['name']);
        if (is_array($selected)) {
            if (in_array($role, $selected)) {
                // preselect specified role
                $p .= "\n\t<option selected='selected' value='" . esc_attr($role) . "'>{$name}</option>";
            } else {
                $r .= "\n\t<option value='" . esc_attr($role) . "'>{$name}</option>";
            }
        } else {
            if ($selected == $role) {
                // preselect specified role
                $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>{$name}</option>";
            } else {
                $r .= "\n\t<option value='" . esc_attr($role) . "'>{$name}</option>";
            }
        }
    }
    echo $p . $r;
}
开发者ID:whatthefork,项目名称:bbconnect,代码行数:25,代码来源:bbconnect-field-helpers.php

示例6: vtmin_fill_roles_checklist

 public function vtmin_fill_roles_checklist($tax_class, $checked_list = NULL)
 {
     $roles = get_editable_roles();
     $roles['notLoggedIn'] = array('name' => 'Not logged in (just visiting)');
     foreach ($roles as $role => $info) {
         $name_translated = translate_user_role($info['name']);
         $output = '<li id=' . $role . '>';
         $output .= '<label class="selectit">';
         $output .= '<input id="' . $role . '_' . $tax_class . ' " ';
         $output .= 'type="checkbox" name="tax-input-' . $tax_class . '[]" ';
         $output .= 'value="' . $role . '" ';
         if ($checked_list) {
             if (in_array($role, $checked_list)) {
                 //if cat_id is in previously checked_list
                 $output .= 'checked="checked"';
             }
         }
         $output .= '>';
         //end input statement
         $output .= '&nbsp;' . $name_translated;
         $output .= '</label>';
         $output .= '</li>';
         echo $output;
     }
     return;
 }
开发者ID:kevinotsuka,项目名称:coffeecircle,代码行数:26,代码来源:vtmin-checkbox-classes.php

示例7: role

 public function role($role = null)
 {
     if (is_null($role)) {
         $role = array_keys(get_editable_roles());
     }
     return $this->generator->randomElement($role);
 }
开发者ID:luancuba,项目名称:fakerpress,代码行数:7,代码来源:wp-user.php

示例8: get_roles_with_guest

 /**
  * Bypass the hide_guest_role() filter
  *
  * @return array $roles List of roles.
  */
 public static function get_roles_with_guest()
 {
     remove_filter('editable_roles', array(self::class, 'hide_guest_role'), 11);
     $roles = get_editable_roles();
     add_filter('editable_roles', array(self::class, 'hide_guest_role'), 11, 1);
     return $roles;
 }
开发者ID:WileESpaghetti,项目名称:dropbox-upload-widget,代码行数:12,代码来源:class-duw-permissions.php

示例9: prepare_data

 protected function prepare_data($delete_roles)
 {
     $this->roles = array();
     $editable_roles = get_editable_roles();
     global $wp_roles;
     $override = $this->main->override_edit_permissions();
     if ($override) {
         $editable_roles = $wp_roles->get_names();
     }
     foreach ($delete_roles as $value) {
         if (array_key_exists($value, $wp_roles->role_names)) {
             $status_message = '';
             $is_deletable = TRUE;
             if (!array_key_exists($value, $editable_roles)) {
                 $status_message = 'This role cannot be deleted: Permission denied.';
                 $is_deletable = FALSE;
             } else {
                 if ($value == self::ADMINISTRATOR_ROLE_KEY) {
                     $status_message = '\'administrator\' role cannot be deleted.';
                     $is_deletable = FALSE;
                 } else {
                     global $user_ID;
                     $user = new WP_User($user_ID);
                     if (!$override && in_array($value, $user->roles)) {
                         $status_message = 'Current user\'s role cannot be deleted.';
                         $is_deletable = FALSE;
                     }
                 }
             }
             $this->roles[$value] = (object) array('name' => $value, 'display_name' => $wp_roles->role_names[$value], 'is_deletable' => $is_deletable, 'status_message' => $status_message);
         }
     }
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:33,代码来源:class-wpfront-user-role-editor-delete.php

示例10: ninja_forms_register_feditor_sub_settings_metabox

function ninja_forms_register_feditor_sub_settings_metabox()
{
    $all_roles = get_editable_roles();
    $tmp_array = array();
    if (is_array($all_roles) and !empty($all_roles)) {
        foreach ($all_roles as $key => $role) {
            $tmp_array[] = array('name' => $role['name'], 'value' => $key);
        }
    }
    $all_roles = $tmp_array;
    $edit_table_cols = array();
    if (isset($_REQUEST['form_id'])) {
        $form_id = $_REQUEST['form_id'];
        $fields = ninja_forms_get_fields_by_form_id($form_id);
        foreach ($fields as $field) {
            if (isset($field['data']['label'])) {
                $edit_table_cols[] = array('name' => $field['data']['label'], 'value' => $field['id']);
            } else {
                $edit_table_cols[] = array('name' => 'Field ID: ' . $field['id'], 'value' => $field['id']);
            }
        }
    } else {
    }
    $args = array('page' => 'ninja-forms', 'tab' => 'form_settings', 'slug' => 'sub_settings', 'title' => __('Submission management settings', 'ninja-forms-feditor'), 'display_function' => '', 'state' => 'closed', 'settings' => array(array('name' => 'manage_sub', 'type' => 'checkbox', 'label' => __('Enable front-end submission management', 'ninja-forms-feditor'), 'default_value' => 1), array('name' => 'manage_sub_table', 'type' => 'checkbox', 'label' => __('Show submission management table above this form?', 'ninja-forms-feditor'), 'default_value' => 1), array('name' => 'manage_sub_table_cols', 'type' => 'multi_select', 'label' => __('Use these fields as table columns', 'ninja-forms-feditor'), 'options' => $edit_table_cols, 'size' => 10, 'desc' => __('Use CTRL + click to select multiple fields (COMMAND + click for Mac users). The number of field columns you want will depend upon the size of your field labels and values. Three is a good, standard value.', 'ninja-forms-feditor')), array('name' => 'manage_sub_hide_form', 'type' => 'checkbox', 'label' => __('Hide this form when a user has submissions to manage', 'ninja-forms-feditor')), array('name' => 'override_sub_rules', 'type' => 'checkbox', 'label' => __('Override rules settings', 'ninja-forms-feditor')), array('name' => '', 'type' => '', 'label' => '', 'display_function' => 'ninja_forms_feditor_sub_settings_user_list'), array('name' => 'manage_sub_roles', 'type' => 'checkbox_list', 'select_all' => false, 'options' => $all_roles, 'label' => __('Allow these roles', 'ninja-forms')), array('name' => 'edit_sub', 'type' => 'checkbox', 'label' => __('To Edit Submissions', 'ninja-forms-feditor')), array('name' => 'delete_sub', 'type' => 'checkbox', 'label' => __('To Delete Submissions', 'ninja-forms-feditor'))));
    if (function_exists('ninja_forms_register_tab_metabox')) {
        ninja_forms_register_tab_metabox($args);
    }
}
开发者ID:emtv,项目名称:hackmsi,代码行数:28,代码来源:sub-settings-metabox.php

示例11: ninja_forms_register_feditor_post_settings_metabox

function ninja_forms_register_feditor_post_settings_metabox()
{
    //Get an array of post types for our post type option.
    $post_types = get_post_types();
    //Remove the built-in post types that we aren't using.
    unset($post_types['nav_menu_item']);
    unset($post_types['mediapage']);
    unset($post_types['attachment']);
    unset($post_types['revision']);
    //Loop through the remaining post types and put the array in ['name'] and ['value'] format.
    $tmp_array = array();
    $x = 0;
    foreach ($post_types as $type) {
        $type_obj = get_post_type_object($type);
        $tmp_array[$x]['name'] = $type_obj->labels->singular_name;
        $tmp_array[$x]['value'] = $type_obj->name;
        $x++;
    }
    $post_types = $tmp_array;
    //Get a list of user roles
    $all_roles = get_editable_roles();
    //Reset the tmp_array variable to store our user roles array
    $tmp_array = array();
    $tmp_array[] = array('name' => __('Non-logged in user', 'ninja-forms-feditor'), 'value' => '_none');
    foreach ($all_roles as $key => $role) {
        $tmp_array[] = array('name' => $role['name'], 'value' => $key);
    }
    $all_roles = $tmp_array;
    $args = array('page' => 'ninja-forms', 'tab' => 'form_settings', 'slug' => 'create_post', 'title' => __('Post creation settings', 'ninja-forms-feditor'), 'display_function' => '', 'state' => 'closed', 'settings' => array(array('name' => 'create_post', 'type' => 'checkbox', 'desc' => '', 'label' => __('Create Post From Input?', 'ninja-forms-feditor'), 'display_function' => '', 'help' => __('If this box is checked, Ninja Forms will create a post from user input.', 'ninja-forms-feditor'), 'default' => 0), array('name' => 'post_as', 'type' => '', 'desc' => '', 'label' => __('Users must be logged in to create post?', 'ninja-forms-feditor'), 'display_function' => 'ninja_forms_metabox_post_as', 'help' => ''), array('name' => 'post_status', 'type' => 'select', 'options' => array(array('name' => 'Draft', 'value' => 'draft'), array('name' => 'Pending', 'value' => 'pending'), array('name' => 'Publish', 'value' => 'publish')), 'desc' => '', 'label' => __('Select a post status', 'ninja-forms-feditor'), 'display_function' => '', 'help' => ''), array('name' => 'post_type', 'type' => 'select', 'desc' => '', 'options' => $post_types, 'label' => __('Select a post type', 'ninja-forms-feditor'), 'display_function' => '', 'help' => '', 'class' => 'ninja-forms-post-type'), array('name' => 'comment_status', 'type' => 'checkbox', 'label' => __('Allow Comments', 'ninja-forms-feditor')), array('name' => 'before_post_terms', 'type' => '', 'label' => '', 'display_function' => 'ninja_forms_metabox_before_post_terms'), array('name' => 'post_terms', 'type' => '', 'desc' => '', 'label' => __('Default post terms', 'ninja-forms-feditor'), 'display_function' => 'ninja_forms_metabox_post_terms', 'help' => ''), array('name' => 'post_tags', 'type' => 'text', 'label' => __('Default post tags', 'ninja-forms-feditor'), 'display_function' => '', 'help' => '', 'desc' => __('Comma separated list', 'ninja-forms-feditor')), array('name' => 'post_title', 'type' => 'text', 'label' => __('Default post title', 'ninja-forms-feditor')), array('name' => 'post_content', 'type' => 'rte', 'label' => __('Default Post Content', 'ninja-forms-feditor'), 'display_function' => ''), array('name' => 'post_content_location', 'type' => 'radio', 'label' => __('Where should the default content be placed?', 'ninja-forms-feditor'), 'options' => array(array('name' => 'Before user submitted content', 'value' => 'prepend'), array('name' => 'After user submitted content', 'value' => 'append')), 'desc' => __('If you do not have a "Post Content" field in your form, the default content will be used instead of the main content.', 'ninja-forms-feditor')), array('name' => 'post_excerpt', 'type' => 'rte', 'label' => __('Default Post Excerpt', 'ninja-forms-feditor'), 'display_function' => ''), array('name' => '', 'type' => '', 'display_function' => 'ninja_forms_feditor_metabox_hr'), array('name' => 'enable_post_edit', 'type' => 'checkbox', 'label' => __('Enable Front-End Post Editing', 'ninja-forms-feditor'), 'desc' => __('If this box is unchecked, users will NOT be able to edit this post, regardless of rules settings.', 'ninja-forms-feditor'), 'default_value' => 1), array('name' => 'override_post_edit', 'type' => 'checkbox', 'label' => __('Override Editing Rules Settings', 'ninja-forms-feditor'), 'desc' => __('If this box is checked, the settings below will override any rules settings that may apply.', 'ninja-forms-feditor')), array('name' => 'enable_post_delete', 'type' => 'checkbox', 'label' => __('Allow Users To Delete This Post', 'ninja-forms-feditor'), 'desc' => __('This setting will only be used if the "Override" option above is set.', 'ninja-forms-feditor')), array('name' => 'post_edit_author', 'type' => 'checkbox', 'label' => __('Allow the author to edit this post', 'ninja-forms-feditor'), 'desc' => __('This setting will only be used if the "Override" option above is set.', 'ninja-forms-feditor')), array('name' => '', 'type' => '', 'label' => '', 'display_function' => 'ninja_forms_feditor_metabox_post_edit_users', 'desc' => __('This setting will only be used if the "Override" option above is set.', 'ninja-forms-feditor')), array('name' => 'post_edit_roles', 'type' => 'checkbox_list', 'label' => __('Allow these roles to edit', 'ninja-forms-feditor'), 'options' => $all_roles, 'desc' => __('This setting will only be used if the "Override" option above is set.', 'ninja-forms-feditor'))));
    if (function_exists('ninja_forms_register_tab_metabox')) {
        ninja_forms_register_tab_metabox($args);
    }
}
开发者ID:emtv,项目名称:hackmsi,代码行数:33,代码来源:post-settings-metabox.php

示例12: wp_roles_dropdown

    function wp_roles_dropdown($field_name, $capability)
    {
        $field_value = FrmAppHelper::get_param($field_name);
        $editable_roles = get_editable_roles();
        ?>
        <select name="<?php 
        echo $field_name;
        ?>
" id="<?php 
        echo $field_name;
        ?>
" class="frm-dropdown frm-pages-dropdown">
            <?php 
        foreach ($editable_roles as $role => $details) {
            $name = translate_user_role($details['name']);
            ?>
                <option value="<?php 
            echo esc_attr($role);
            ?>
" <?php 
            echo (isset($_POST[$field_name]) and $_POST[$field_name] == $role or !isset($_POST[$field_name]) and $capability == $role) ? ' selected="selected"' : '';
            ?>
><?php 
            echo $name;
            ?>
 </option>
            <?php 
        }
        ?>
        </select>
    <?php 
    }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:32,代码来源:FrmAppHelper.php

示例13: parse_request

 public function parse_request($qty, $request = array())
 {
     if (is_null($qty)) {
         $qty = Variable::super(INPUT_POST, array(Plugin::$slug, 'qty'), FILTER_UNSAFE_RAW);
         $min = absint($qty['min']);
         $max = max(absint(isset($qty['max']) ? $qty['max'] : 0), $min);
         $qty = $this->faker->numberBetween($min, $max);
     }
     if (0 === $qty) {
         return esc_attr__('Zero is not a good number of users to fake...', 'fakerpress');
     }
     $meta_module = Meta::instance();
     $description_use_html = Variable::super($request, array('use_html'), FILTER_SANITIZE_STRING, 'off') === 'on';
     $description_html_tags = array_map('trim', explode(',', Variable::super($request, array('html_tags'), FILTER_SANITIZE_STRING)));
     $roles = array_intersect(array_keys(get_editable_roles()), array_map('trim', explode(',', Variable::super($request, array('roles'), FILTER_SANITIZE_STRING))));
     $metas = Variable::super($request, array('meta'), FILTER_UNSAFE_RAW);
     $results = array();
     for ($i = 0; $i < $qty; $i++) {
         $this->param('role', $roles);
         $this->param('description', $description_use_html, array('elements' => $description_html_tags));
         $this->generate();
         $user_id = $this->save();
         if ($user_id && is_numeric($user_id)) {
             foreach ($metas as $meta_index => $meta) {
                 $meta_module->object($user_id, 'user')->build($meta['type'], $meta['name'], $meta)->save();
             }
         }
         $results[] = $user_id;
     }
     $results = array_filter($results, 'absint');
     return $results;
 }
开发者ID:juanfra,项目名称:fakerpress,代码行数:32,代码来源:user.php

示例14: get_roles

 public function get_roles()
 {
     $roles = array();
     foreach (get_editable_roles() as $role_name => $role) {
         $roles[$role_name] = $role['name'];
     }
     return $roles;
 }
开发者ID:kcdipesh,项目名称:tabulate,代码行数:8,代码来源:Grants.php

示例15: get_roles

 public function get_roles()
 {
     $roles = array(self::ANON_ROLE => 'Anonymous User');
     foreach (get_editable_roles() as $role_name => $role) {
         $roles[$role_name] = $role['name'];
     }
     return $roles;
 }
开发者ID:gitter-badger,项目名称:tabulate-1,代码行数:8,代码来源:Grants.php


注:本文中的get_editable_roles函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。