本文整理汇总了PHP中translate_user_role函数的典型用法代码示例。如果您正苦于以下问题:PHP translate_user_role函数的具体用法?PHP translate_user_role怎么用?PHP translate_user_role使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了translate_user_role函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 ";
}
}
}
示例2: wp_get_editable_roles
function wp_get_editable_roles()
{
global $wp_roles;
$all_roles = $wp_roles->roles;
$editable_roles = apply_filters('editable_roles', $all_roles);
$possible_values = array();
foreach ($all_roles as $role => $details) {
$name = translate_user_role($details['name']);
switch ($role) {
case 'administrator':
$keyrole = 'switch_themes';
break;
case 'editor':
$keyrole = 'moderate_comments';
break;
case 'author':
$keyrole = 'upload_files';
break;
case 'contributor':
$keyrole = 'edit_posts';
break;
case 'subscriber':
$keyrole = 'read';
break;
default:
$keyrole = $role;
}
$possible_values[$keyrole] = $name;
}
return $possible_values;
}
示例3: 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 .= ' ' . $name_translated;
$output .= '</label>';
$output .= '</li>';
echo $output;
}
return;
}
示例4: 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;
}
示例5: render_settings
protected function render_settings($form)
{
$roles = array('administrator' => translate_user_role('Administrator'), 'editor' => translate_user_role('Editor'), 'author' => translate_user_role('Author'), 'contributor' => translate_user_role('Contributor'), 'subscriber' => translate_user_role('Subscriber'));
?>
<table class="form-table itsec-settings-section">
<tr>
<th scope="row"><label for="itsec-strong-passwords-role"><?php
_e('Select Role for Strong Passwords', 'better-wp-security');
?>
</label></th>
<td>
<?php
$form->add_select('role', $roles);
?>
<br />
<label for="itsec-strong-passwords-role"><?php
_e('Minimum role at which a user must choose a strong password.', 'better-wp-security');
?>
</label>
<p class="description"><?php
printf(__('For more information on WordPress roles and capabilities please see <a href="%1$s" target="_blank">%1$s</a>.', 'better-wp-security'), 'http://codex.wordpress.org/Roles_and_Capabilities');
?>
</p>
<p class="warningtext description"><?php
_e('Warning: If your site invites public registrations setting the role too low may annoy your members.', 'better-wp-security');
?>
</p>
</td>
</tr>
</table>
<?php
}
示例6: 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
}
示例7: role_select_copy_prepare_html
private function role_select_copy_prepare_html($select_width = 200)
{
global $current_user;
$key_capability = $this->lib->get_key_capability();
$user_is_ure_admin = current_user_can($key_capability);
$role_to_skip = $user_is_ure_admin ? '' : $current_user->roles[0];
$caps_access_restrict_for_simple_admin = $this->lib->get_option('caps_access_restrict_for_simple_admin', 0);
$show_admin_role = $this->lib->show_admin_role_allowed();
$this->role_to_copy_html = '<select id="user_role_copy_from" name="user_role_copy_from" style="width: ' . $select_width . 'px">
<option value="none" selected="selected">' . esc_html__('None', 'user-role-editor') . '</option>';
$this->role_select_html = '<select id="user_role" name="user_role" onchange="ure_role_change(this.value);">';
$current_role = $this->lib->get('current_role');
$roles = $this->lib->get_editable_user_roles();
foreach ($roles as $key => $value) {
if ($key === $role_to_skip) {
// skip role of current user if he does not have full access to URE
continue;
}
$selected1 = $this->lib->option_selected($key, $current_role);
$disabled = $key === 'administrator' && $caps_access_restrict_for_simple_admin && !is_super_admin() ? 'disabled' : '';
if ($show_admin_role || $key != 'administrator') {
$translated_name = esc_html__($value['name'], 'user-role-editor');
// get translation from URE language file, if exists
if ($translated_name === $value['name']) {
// get WordPress internal translation
$translated_name = translate_user_role($translated_name);
}
$translated_name .= ' (' . $key . ')';
$this->role_select_html .= '<option value="' . $key . '" ' . $selected1 . ' ' . $disabled . '>' . $translated_name . '</option>';
$this->role_to_copy_html .= '<option value="' . $key . '" ' . $disabled . '>' . $translated_name . '</option>';
}
}
$this->role_select_html .= '</select>';
$this->role_to_copy_html .= '</select>';
}
示例8: get_user_role
/**
* Returns the translated role of the current user. If that user has
* no role for the current blog, it returns false.
*
* @return string The name of the current role
**/
public function get_user_role(WP_User $user)
{
global $wp_roles;
$roles = $user->roles;
$role = array_shift($roles);
return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role]) : '';
}
示例9: get_roles
public function get_roles()
{
$roles = array();
foreach (wp_roles()->roles as $k => $role) {
$roles[$k] = translate_user_role($role['name']);
}
return $roles;
}
示例10: callback_set_user_role
public static function callback_set_user_role($user_id, $new_role, $old_roles)
{
if (empty($old_roles)) {
return;
}
global $wp_roles;
self::log(_x('%1$s\'s role was changed from %2$s to %3$s', '1: User display name, 2: Old role, 3: New role', 'mainwp_child_reports'), array('display_name' => get_user_by('id', $user_id)->display_name, 'old_role' => translate_user_role($wp_roles->role_names[$old_roles[0]]), 'new_role' => translate_user_role($wp_roles->role_names[$new_role])), $user_id, array('profiles' => 'updated'));
}
示例11: get_user_role_by_id
function get_user_role_by_id($id)
{
global $wp_roles;
$curr_user = get_userdata($id);
$roles = $curr_user->roles;
$role = array_shift($roles);
return isset($wp_roles->role_names[$role]) ? strtolower(translate_user_role($wp_roles->role_names[$role])) : false;
}
示例12: wcv_get_user_role
function wcv_get_user_role($user_id)
{
global $wp_roles;
$user = new WP_User($user_id);
$roles = $user->roles;
$role = array_shift($roles);
return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role]) : false;
}
示例13: getPicklistOptions
/**
*
* @return array;
*/
public function getPicklistOptions()
{
$editable_roles = get_editable_roles();
foreach ($editable_roles as $role => $details) {
$name = translate_user_role($details['name']);
$options[esc_attr($role)] = $name;
}
return $options;
}
示例14: admin_menu
/**
* Adds "Redirection" tab to Theme My Login menu
*
* @since 6.0
* @access public
*/
public function admin_menu()
{
global $wp_roles;
add_submenu_page('theme_my_login', __('Theme My Login Custom Redirection Settings', 'theme-my-login'), __('Redirection', 'theme-my-login'), 'manage_options', $this->options_key, array(&$this, 'settings_page'));
foreach ($wp_roles->get_names() as $role => $role_name) {
if ('pending' != $role) {
add_meta_box($role, translate_user_role($role_name), array(&$this, 'redirection_meta_box'), 'tml_page_' . $this->options_key, 'normal');
}
}
}
示例15: choices
/**
* Setup color scheme choices for use by control
*/
public function choices()
{
$choices = array('' => __('— No role for this site —'));
$editable_roles = array_reverse(get_editable_roles());
foreach ($editable_roles as $role => $details) {
$name = translate_user_role($details['name']);
$choices[$role] = $name;
}
return $choices;
}