/home/u523506497/domains/mymelon.in/public_html/career/wp-includes UP
<?php
/**
* User API: WP_Roles class
*
* @package WordPress
* @subpackage Users
* @since 4.4.0
*/
/**
* Core class used to implement a user roles API.
*
* The role option is simple, the structure is organized by role name that store
* the name in value of the 'name' key. The capabilities are stored as an array
* in the value of the 'capability' key.
*
* array (
* 'rolename' => array (
* 'name' => 'rolename',
* 'capabilities' => array()
* )
* )
*
* @since 2.0.0
*/
#[AllowDynamicProperties]
class WP_Roles {
/**
* List of roles and capabilities.
*
* @since 2.0.0
* @var array[]
*/
public $roles;
/**
* List of the role objects.
*
* @since 2.0.0
* @var WP_Role[]
*/
public $role_objects = array();
/**
* List of role names.
*
* @since 2.0.0
* @var string[]
*/
public $role_names = array();
/**
* Option name for storing role list.
*
* @since 2.0.0
* @var string
*/
public $role_key;
/**
* Whether to use the database for retrieval and storage.
*
* @since 2.1.0
* @var bool
*/
public $use_db = true;
/**
* The site ID the roles are initialized for.
*
* @since 4.9.0
* @var int
*/
protected $site_id = 0;
/**
* Constructor.
*
* @since 2.0.0
* @since 4.9.0 The `$site_id` argument was added.
*
* @global array $wp_user_roles Used to set the 'roles' property value.
*
* @param int $site_id Site ID to initialize roles for. Default is the current site.
*/
public function __construct( $site_id = null ) {
global $wp_user_roles;
$this->use_db = empty( $wp_user_roles );
$this->for_site( $site_id );
}
/**
* Makes private/protected methods readable for backward compatibility.
*
* @since 4.0.0
*
* @param string $name Method to call.
* @param array $arguments Arguments to pass when calling.
* @return mixed|false Return value of the callback, false otherwise.
*/
public function __call( $name, $arguments ) {
if ( '_init' === $name ) {
return $this->_init( ...$arguments );
}
return false;
}
/**
* Sets up the object properties.
*
* The role key is set to the current prefix for the $wpdb object with
* 'user_roles' appended. If the $wp_user_roles global is set, then it will
* be used and the role option will not be updated or used.
*
* @since 2.1.0
* @deprecated 4.9.0 Use WP_Roles::for_site()
*/
protected function _init() {
_deprecated_function( __METHOD__, '4.9.0', 'WP_Roles::for_site()' );
$this->for_site();
}
/**
* Reinitializes the object.
*
* Recreates the role objects. This is typically called only by switch_to_blog()
* after switching wpdb to a new site ID.
*
* @since 3.5.0
* @deprecated 4.7.0 Use WP_Roles::for_site()
*/
public function reinit() {
_deprecated_function( __METHOD__, '4.7.0', 'WP_Roles::for_site()' );
$this->for_site();
}
/**
* Adds a role name with capabilities to the list.
*
* Updates the list of roles, if the role doesn't already exist.
*
* The capabilities are defined in the following format: `array( 'read' => true )`.
* To explicitly deny the role a capability, set the value for that capability to false.
*
* @since 2.0.0
*
* @param string $role Role name.
* @param string $display_name Role display name.
* @param bool[] $capabilities Optional. List of capabilities keyed by the capability name,
* e.g. `array( 'edit_posts' => true, 'delete_posts' => false )`.
* Default empty array.
* @return WP_Role|void WP_Role object, if the role is added.
*/
public function add_role( $role, $display_name, $capabilities = array() ) {
if ( empty( $role ) || isset( $this->roles[ $role ] ) ) {
return;
}
$this->roles[ $role ] = array(
'name' => $display_name,
'capabilities' => $capabilities,
);
if ( $this->use_db ) {
update_option( $this->role_key, $this->roles, true );
}
$this->role_objects[ $role ] = new WP_Role( $role, $capabilities );
$this->role_names[ $role ] = $display_name;
return $this->role_objects[ $role ];
}
/**
* Removes a role by name.
*
* @since 2.0.0
*
* @param string $role Role name.
*/
public function remove_role( $role ) {
if ( ! isset( $this->role_objects[ $role ] ) ) {
return;
}
unset( $this->role_objects[ $role ] );
unset( $this->role_names[ $role ] );
unset( $this->roles[ $role ] );
if ( $this->use_db ) {
update_option( $this->role_key, $this->roles );
}
if ( get_option( 'default_role' ) === $role ) {
update_option( 'default_role', 'subscriber' );
}
}
/**
* Adds a capability to role.
*
* @since 2.0.0
*
* @param string $role Role name.
* @param string $cap Capability name.
* @param bool $grant Optional. Whether role is capable of performing capability.
* Default true.
*/
public function add_cap( $role, $cap, $grant = true ) {
if ( ! isset( $this->roles[ $role ] ) ) {
return;
}
$this->roles[ $role ]['capabilities'][ $cap ] = $grant;
if ( $this->use_db ) {
update_option( $this->role_key, $this->roles );
}
}
/**
* Removes a capability from role.
*
* @since 2.0.0
*
* @param string $role Role name.
* @param string $cap Capability name.
*/
public function remove_cap( $role, $cap ) {
if ( ! isset( $this->roles[ $role ] ) ) {
return;
}
unset( $this->roles[ $role ]['capabilities'][ $cap ] );
if ( $this->use_db ) {
update_option( $this->role_key, $this->roles );
}
}
/**
* Retrieves a role object by name.
*
* @since 2.0.0
*
* @param string $role Role name.
* @return WP_Role|null WP_Role object if found, null if the role does not exist.
*/
public function get_role( $role ) {
if ( isset( $this->role_objects[ $role ] ) ) {
return $this->role_objects[ $role ];
} else {
return null;
}
}
/**
* Retrieves a list of role names.
*
* @since 2.0.0
*
* @return string[] List of role names.
*/
public function get_names() {
return $this->role_names;
}
/**
* Determines whether a role name is currently in the list of available roles.
*
* @since 2.0.0
*
* @param string $role Role name to look up.
* @return bool
*/
public function is_role( $role ) {
return isset( $this->role_names[ $role ] );
}
/**
* Initializes all of the available roles.
*
* @since 4.9.0
*/
public function init_roles() {
if ( empty( $this->roles ) ) {
return;
}
$this->role_objects = array();
$this->role_names = array();
foreach ( array_keys( $this->roles ) as $role ) {
$this->role_objects[ $role ] = new WP_Role( $role, $this->roles[ $role ]['capabilities'] );
$this->role_names[ $role ] = $this->roles[ $role ]['name'];
}
/**
* Fires after the roles have been initialized, allowing plugins to add their own roles.
*
* @since 4.7.0
*
* @param WP_Roles $wp_roles A reference to the WP_Roles object.
*/
do_action( 'wp_roles_init', $this );
}
/**
* Sets the site to operate on. Defaults to the current site.
*
* @since 4.9.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $site_id Site ID to initialize roles for. Default is the current site.
*/
public function for_site( $site_id = null ) {
global $wpdb;
if ( ! empty( $site_id ) ) {
$this->site_id = absint( $site_id );
} else {
$this->site_id = get_current_blog_id();
}
$this->role_key = $wpdb->get_blog_prefix( $this->site_id ) . 'user_roles';
if ( ! empty( $this->roles ) && ! $this->use_db ) {
return;
}
$this->roles = $this->get_roles_data();
$this->init_roles();
}
/**
* Gets the ID of the site for which roles are currently initialized.
*
* @since 4.9.0
*
* @return int Site ID.
*/
public function get_site_id() {
return $this->site_id;
}
/**
* Gets the available roles data.
*
* @since 4.9.0
*
* @global array $wp_user_roles Used to set the 'roles' property value.
*
* @return array Roles array.
*/
protected function get_roles_data() {
global $wp_user_roles;
if ( ! empty( $wp_user_roles ) ) {
return $wp_user_roles;
}
if ( is_multisite() && get_current_blog_id() !== $this->site_id ) {
remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 );
$roles = get_blog_option( $this->site_id, $this->role_key, array() );
add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 );
return $roles;
}
return get_option( $this->role_key, array() );
}
}
| ID3 | - | |
| IXR | - | |
| PHPMailer | - | |
| Requests | - | |
| SimplePie | - | |
| Text | - | |
| admin-bar.php | 37100 | V |
| assets | - | |
| atomlib.php | 12078 | V |
| author-template.php | 18951 | V |
| block-bindings | - | |
| block-bindings.php | 5594 | V |
| block-editor.php | 28340 | V |
| block-i18n.json | 316 | V |
| block-patterns | - | |
| block-patterns.php | 13119 | V |
| block-supports | - | |
| block-template-utils.php | 60145 | V |
| block-template.php | 14142 | V |
| blocks | - | |
| blocks.php | 104889 | V |
| bookmark-template.php | 12948 | V |
| bookmark.php | 15427 | V |
| cache-compat.php | 5969 | V |
| cache.php | 13474 | V |
| canonical.php | 34523 | V |
| capabilities.php | 42718 | V |
| category-template.php | 57003 | V |
| category.php | 12709 | V |
| certificates | - | |
| class-IXR.php | 2543 | V |
| class-avif-info.php | 29615 | V |
| class-feed.php | 539 | V |
| class-http.php | 367 | V |
| class-json.php | 43684 | V |
| class-oembed.php | 401 | V |
| class-phpass.php | 6771 | V |
| class-phpmailer.php | 664 | V |
| class-pop3.php | 21174 | V |
| class-requests.php | 2237 | V |
| class-simplepie.php | 453 | V |
| class-smtp.php | 457 | V |
| class-snoopy.php | 37715 | V |
| class-walker-category-dropdown.php | 2469 | V |
| class-walker-category.php | 8477 | V |
| class-walker-comment.php | 14221 | V |
| class-walker-nav-menu.php | 11784 | V |
| class-walker-page-dropdown.php | 2710 | V |
| class-walker-page.php | 7612 | V |
| class-wp-admin-bar.php | 17874 | V |
| class-wp-ajax-response.php | 5266 | V |
| class-wp-application-passwords.php | 15617 | V |
| class-wp-block-bindings-registry.php | 8463 | V |
| class-wp-block-bindings-source.php | 2992 | V |
| class-wp-block-editor-context.php | 1350 | V |
| class-wp-block-list.php | 4757 | V |
| class-wp-block-metadata-registry.php | 10227 | V |
| class-wp-block-parser-block.php | 2555 | V |
| class-wp-block-parser-frame.php | 2017 | V |
| class-wp-block-parser.php | 11532 | V |
| class-wp-block-pattern-categories-registry.php | 5371 | V |
| class-wp-block-patterns-registry.php | 10783 | V |
| class-wp-block-styles-registry.php | 6262 | V |
| class-wp-block-supports.php | 5612 | V |
| class-wp-block-template.php | 2033 | V |
| class-wp-block-templates-registry.php | 7231 | V |
| class-wp-block-type-registry.php | 5013 | V |
| class-wp-block-type.php | 17265 | V |
| class-wp-block.php | 20438 | V |
| class-wp-classic-to-block-menu-converter.php | 4088 | V |
| class-wp-comment-query.php | 48395 | V |
| class-wp-comment.php | 9372 | V |
| class-wp-customize-control.php | 25730 | V |
| class-wp-customize-manager.php | 202539 | V |
| class-wp-customize-nav-menus.php | 57185 | V |
| class-wp-customize-panel.php | 10637 | V |
| class-wp-customize-section.php | 11209 | V |
| class-wp-customize-setting.php | 29889 | V |
| class-wp-customize-widgets.php | 72157 | V |
| class-wp-date-query.php | 35726 | V |
| class-wp-dependencies.php | 15139 | V |
| class-wp-dependency.php | 2627 | V |
| class-wp-duotone.php | 40783 | V |
| class-wp-editor.php | 72335 | V |
| class-wp-embed.php | 15994 | V |
| class-wp-error.php | 7502 | V |
| class-wp-exception.php | 253 | V |
| class-wp-fatal-error-handler.php | 8150 | V |
| class-wp-feed-cache-transient.php | 3176 | V |
| class-wp-feed-cache.php | 969 | V |
| class-wp-hook.php | 16000 | V |
| class-wp-http-cookie.php | 7389 | V |
| class-wp-http-curl.php | 12541 | V |
| class-wp-http-encoding.php | 6689 | V |
| class-wp-http-ixr-client.php | 3501 | V |
| class-wp-http-proxy.php | 5980 | V |
| class-wp-http-requests-hooks.php | 2022 | V |
| class-wp-http-requests-response.php | 4400 | V |
| class-wp-http-response.php | 2977 | V |
| class-wp-http-streams.php | 16859 | V |
| class-wp-http.php | 41506 | V |
| class-wp-image-editor-gd.php | 19886 | V |
| class-wp-image-editor-imagick.php | 32668 | V |
| class-wp-image-editor.php | 16938 | V |
| class-wp-list-util.php | 7443 | V |
| class-wp-locale-switcher.php | 6630 | V |
| class-wp-locale.php | 16111 | V |
| class-wp-matchesmapregex.php | 1828 | V |
| class-wp-meta-query.php | 30531 | V |
| class-wp-metadata-lazyloader.php | 6833 | V |
| class-wp-navigation-fallback.php | 9211 | V |
| class-wp-network-query.php | 19857 | V |
| class-wp-network.php | 12296 | V |
| class-wp-object-cache.php | 17524 | V |
| class-wp-oembed-controller.php | 6905 | V |
| class-wp-oembed.php | 31475 | V |
| class-wp-paused-extensions-storage.php | 5111 | V |
| class-wp-plugin-dependencies.php | 25319 | V |
| class-wp-post-type.php | 30340 | V |
| class-wp-post.php | 6484 | V |
| class-wp-query.php | 154081 | V |
| class-wp-recovery-mode-cookie-service.php | 6877 | V |
| class-wp-recovery-mode-email-service.php | 11183 | V |
| class-wp-recovery-mode-key-service.php | 4608 | V |
| class-wp-recovery-mode-link-service.php | 3463 | V |
| class-wp-recovery-mode.php | 11435 | V |
| class-wp-rewrite.php | 63688 | V |
| class-wp-role.php | 2523 | V |
| class-wp-roles.php | 8586 | V |
| class-wp-script-modules.php | 19366 | V |
| class-wp-scripts.php | 28344 | V |
| class-wp-session-tokens.php | 7451 | V |
| class-wp-simplepie-file.php | 3408 | V |
| class-wp-simplepie-sanitize-kses.php | 1837 | V |
| class-wp-site-query.php | 31625 | V |
| class-wp-site.php | 7454 | V |
| class-wp-styles.php | 11010 | V |
| class-wp-tax-query.php | 19555 | V |
| class-wp-taxonomy.php | 18567 | V |
| class-wp-term-query.php | 40869 | V |
| class-wp-term.php | 5298 | V |
| class-wp-text-diff-renderer-inline.php | 979 | V |
| class-wp-text-diff-renderer-table.php | 18807 | V |
| class-wp-textdomain-registry.php | 10481 | V |
| class-wp-theme-json-data.php | 1809 | V |
| class-wp-theme-json-resolver.php | 35805 | V |
| class-wp-theme-json-schema.php | 7367 | V |
| class-wp-theme-json.php | 160780 | V |
| class-wp-theme.php | 65413 | V |
| class-wp-token-map.php | 28618 | V |
| class-wp-user-meta-session-tokens.php | 2990 | V |
| class-wp-user-query.php | 43654 | V |
| class-wp-user-request.php | 2222 | V |
| class-wp-user.php | 22827 | V |
| class-wp-walker.php | 13322 | V |
| class-wp-widget-factory.php | 3347 | V |
| class-wp-widget.php | 18424 | V |
| class-wp-xmlrpc-server.php | 214948 | V |
| class-wp.php | 26119 | V |
| class-wpdb.php | 118389 | V |
| class.wp-dependencies.php | 373 | V |
| class.wp-scripts.php | 343 | V |
| class.wp-styles.php | 338 | V |
| comment-template.php | 102773 | V |
| comment.php | 130275 | V |
| compat.php | 16974 | V |
| cron.php | 41594 | V |
| css | - | |
| customize | - | |
| date.php | 400 | V |
| default-constants.php | 11365 | V |
| default-filters.php | 35685 | V |
| default-widgets.php | 2222 | V |
| deprecated.php | 190130 | V |
| embed-template.php | 338 | V |
| embed.php | 37908 | V |
| error-protection.php | 4121 | V |
| feed-atom-comments.php | 5504 | V |
| feed-atom.php | 3048 | V |
| feed-rdf.php | 2668 | V |
| feed-rss.php | 1189 | V |
| feed-rss2-comments.php | 4136 | V |
| feed-rss2.php | 3799 | V |
| feed.php | 23411 | V |
| fonts | - | |
| fonts.php | 9751 | V |
| formatting.php | 335229 | V |
| functions.php | 283163 | V |
| functions.wp-scripts.php | 14558 | V |
| functions.wp-styles.php | 8583 | V |
| general-template.php | 169492 | V |
| global-styles-and-settings.php | 21205 | V |
| html-api | - | |
| http.php | 25312 | V |
| https-detection.php | 5661 | V |
| https-migration.php | 4741 | V |
| images | - | |
| interactivity-api | - | |
| js | - | |
| kses.php | 74403 | V |
| l10n | - | |
| l10n.php | 68415 | V |
| link-template.php | 157710 | V |
| load.php | 55658 | V |
| locale.php | 162 | V |
| media-template.php | 63043 | V |
| media.php | 218424 | V |
| meta.php | 64409 | V |
| ms-blogs.php | 25772 | V |
| ms-default-constants.php | 4921 | V |
| ms-default-filters.php | 6636 | V |
| ms-deprecated.php | 21759 | V |
| ms-files.php | 2711 | V |
| ms-functions.php | 91249 | V |
| ms-load.php | 19883 | V |
| ms-network.php | 3782 | V |
| ms-settings.php | 4124 | V |
| ms-site.php | 40490 | V |
| nav-menu-template.php | 25917 | V |
| nav-menu.php | 44373 | V |
| option.php | 101759 | V |
| php-compat | - | |
| pluggable-deprecated.php | 6263 | V |
| pluggable.php | 115970 | V |
| plugin.php | 35465 | V |
| pomo | - | |
| post-formats.php | 7102 | V |
| post-template.php | 66880 | V |
| post-thumbnail-template.php | 10826 | V |
| post.php | 289894 | V |
| query.php | 37035 | V |
| registration-functions.php | 200 | V |
| registration.php | 200 | V |
| rest-api | - | |
| rest-api.php | 99593 | V |
| revision.php | 30890 | V |
| rewrite.php | 19541 | V |
| robots-template.php | 5185 | V |
| rss-functions.php | 255 | V |
| rss.php | 23113 | V |
| script-loader.php | 130735 | V |
| script-modules.php | 7712 | V |
| session.php | 258 | V |
| shortcodes.php | 24051 | V |
| sitemaps | - | |
| sitemaps.php | 3238 | V |
| sodium_compat | - | |
| spl-autoload-compat.php | 441 | V |
| style-engine | - | |
| style-engine.php | 7563 | V |
| taxonomy.php | 175438 | V |
| template-canvas.php | 544 | V |
| template-loader.php | 3012 | V |
| template.php | 24154 | V |
| theme-compat | - | |
| theme-i18n.json | 1292 | V |
| theme-previews.php | 2832 | V |
| theme-templates.php | 6223 | V |
| theme.json | 8704 | V |
| theme.php | 133985 | V |
| update.php | 36788 | V |
| user.php | 174410 | V |
| vars.php | 6489 | V |
| version.php | 931 | V |
| widgets | - | |
| widgets.php | 70682 | V |
| wp-db.php | 445 | V |
| wp-diff.php | 726 | V |