PHP 8.2.31
Preview: capability-helper.php Size: 2.07 KB
/home/nshryvcy/blissfulnepal.com/wp-content/plugins/wordpress-seo/src/helpers/capability-helper.php

<?php

namespace Yoast\WP\SEO\Helpers;

/**
 * A helper object for user capabilities.
 */
class Capability_Helper {

	/**
	 * Checks if the user has at least one of the proper capabilities.
	 *
	 * @param string $capability Capability to check.
	 *
	 * @return bool True if the user has at least one of the proper rights.
	 */
	public function current_user_can( $capability ) {
		if ( $capability === 'wpseo_manage_options' ) {
			return \current_user_can( $capability );
		}

		return $this->has_any( [ 'wpseo_manage_options', $capability ] );
	}

	/**
	 * Retrieves the users that have the specified capability.
	 *
	 * @param string $capability The name of the capability.
	 *
	 * @return array The users that have the capability.
	 */
	public function get_applicable_users( $capability ) {
		$applicable_roles = $this->get_applicable_roles( $capability );

		if ( $applicable_roles === [] ) {
			return [];
		}

		return \get_users( [ 'role__in' => $applicable_roles ] );
	}

	/**
	 * Retrieves the roles that have the specified capability.
	 *
	 * @param string $capability The name of the capability.
	 *
	 * @return array The names of the roles that have the capability.
	 */
	public function get_applicable_roles( $capability ) {
		$roles      = \wp_roles();
		$role_names = $roles->get_names();

		$applicable_roles = [];
		foreach ( \array_keys( $role_names ) as $role_name ) {
			$role = $roles->get_role( $role_name );

			if ( ! $role ) {
				continue;
			}

			// Add role if it has the capability.
			if ( \array_key_exists( $capability, $role->capabilities ) && $role->capabilities[ $capability ] === true ) {
				$applicable_roles[] = $role_name;
			}
		}

		return $applicable_roles;
	}

	/**
	 * Checks if the current user has at least one of the supplied capabilities.
	 *
	 * @param array $capabilities Capabilities to check against.
	 *
	 * @return bool True if the user has at least one capability.
	 */
	private function has_any( array $capabilities ) {
		foreach ( $capabilities as $capability ) {
			if ( \current_user_can( $capability ) ) {
				return true;
			}
		}

		return false;
	}
}

Directory Contents

Dirs: 3 × Files: 48

Name Size Perms Modified Actions
- drwxr-xr-x 2026-06-03 14:57:42
Edit Download
schema DIR
- drwxr-xr-x 2026-06-03 14:57:42
Edit Download
twitter DIR
- drwxr-xr-x 2026-06-03 14:57:42
Edit Download
1.24 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.51 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.24 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
5.25 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.32 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.07 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
8.10 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
655 B lrw-r--r-- 2026-06-03 14:57:42
Edit Download
15.63 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
3.13 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
793 B lrw-r--r-- 2026-06-03 14:57:42
Edit Download
5.36 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
681 B lrw-r--r-- 2026-06-03 14:57:42
Edit Download
11.69 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
1.36 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
716 B lrw-r--r-- 2026-06-03 14:57:42
Edit Download
9.24 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
6.75 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
12.69 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.65 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.84 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.91 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.01 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
4.65 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
5.68 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
1.60 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
5.42 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
7.18 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
1.37 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
1.08 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
1.73 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
326 B lrw-r--r-- 2026-06-03 14:57:42
Edit Download
1.74 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
3.40 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
694 B lrw-r--r-- 2026-06-03 14:57:42
Edit Download
1.03 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.78 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
3.52 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
566 B lrw-r--r-- 2026-06-03 14:57:42
Edit Download
10.73 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
1.19 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
4.98 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
8.13 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
3.93 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
2.51 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
1.27 KB lrw-r--r-- 2026-06-03 14:57:42
Edit Download
512 B lrw-r--r-- 2026-06-03 14:57:42
Edit Download
937 B lrw-r--r-- 2026-06-03 14:57:42
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).