PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.4
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / myyoast-client / user-interface / connection-permission.php

connection-permission.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.4, at src/myyoast-client/user-interface/connection-permission.php

36 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4
5 namespace Yoast\WP\SEO\MyYoast_Client\User_Interface;
6
7 /**
8 * Single source of truth for the HTTP-boundary check that gates managing the
9 * site's MyYoast connection.
10 *
11 * Deliberately a user-interface concern, not an application one: the WP-CLI
12 * entry point (`wp yoast auth`) is trusted by virtue of shell access and runs
13 * with no logged-in user, so the capability check must live at the HTTP
14 * boundary and never leak into `MyYoast_Client` or the application layer.
15 * Pushing it down would break CLI usage or force a `--user=` flag on every
16 * command.
17 */
18 class Connection_Permission {
19
20 /**
21 * The capability required to manage the MyYoast connection over HTTP.
22 *
23 * @var string
24 */
25 private const MANAGE_CAPABILITY = 'wpseo_manage_options';
26
27 /**
28 * Whether the current HTTP user may manage the MyYoast connection.
29 *
30 * @return bool
31 */
32 public function can_manage(): bool {
33 return \current_user_can( self::MANAGE_CAPABILITY );
34 }
35 }
36