PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 / abilities / user-interface / abilities-integration.php

abilities-integration.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/abilities/user-interface/abilities-integration.php

106 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4 namespace Yoast\WP\SEO\Abilities\User_Interface;
5
6 use Yoast\WP\SEO\Abilities\Domain\Ability_Interface;
7 use Yoast\WP\SEO\Conditionals\Abilities_API_Conditional;
8 use Yoast\WP\SEO\Integrations\Integration_Interface;
9
10 /**
11 * Integration that registers Yoast SEO abilities with the WordPress Abilities API.
12 */
13 class Abilities_Integration implements Integration_Interface {
14
15 /**
16 * The abilities to register.
17 *
18 * @var Ability_Interface[]
19 */
20 private $abilities;
21
22 /**
23 * Returns the conditionals based on which this loadable should be active.
24 *
25 * @return array<string> The conditionals.
26 */
27 public static function get_conditionals() {
28 return [ Abilities_API_Conditional::class ];
29 }
30
31 /**
32 * Constructor.
33 *
34 * @param Ability_Interface ...$abilities The abilities to register.
35 */
36 public function __construct( Ability_Interface ...$abilities ) {
37 $this->abilities = $abilities;
38 }
39
40 /**
41 * Registers hooks with WordPress.
42 *
43 * @return void
44 */
45 public function register_hooks() {
46 \add_action( 'wp_abilities_api_init', [ $this, 'register_abilities' ] );
47 }
48
49 /**
50 * Registers the available Yoast SEO abilities.
51 *
52 * @return void
53 */
54 public function register_abilities() {
55 foreach ( $this->abilities as $ability ) {
56 if ( ! $ability->is_available() ) {
57 continue;
58 }
59
60 \wp_register_ability( $ability->get_name(), $ability->get_args() );
61 }
62 }
63
64 /**
65 * Checks whether the current user can manage Yoast SEO.
66 *
67 * @deprecated 28.6
68 * @codeCoverageIgnore
69 *
70 * @return bool Whether the current user can manage Yoast SEO.
71 */
72 public function can_manage_seo(): bool {
73 \_deprecated_function( __METHOD__, 'Yoast SEO 28.6', 'Abstract_Score_Ability::can_manage_seo' );
74
75 return \YoastSEO()->helpers->capability->current_user_can( 'wpseo_manage_options' );
76 }
77
78 /**
79 * Checks whether the current user can edit advanced SEO metadata.
80 *
81 * @deprecated 28.6
82 * @codeCoverageIgnore
83 *
84 * @return bool Whether the current user can edit advanced SEO metadata.
85 */
86 public function can_edit_advanced_metadata(): bool {
87 \_deprecated_function( __METHOD__, 'Yoast SEO 28.6', 'Abstract_Post_SEO_Data_Ability::can_edit_advanced_metadata' );
88
89 return \YoastSEO()->helpers->capability->current_user_can( 'wpseo_edit_advanced_metadata' );
90 }
91
92 /**
93 * Checks whether the current user can read scores.
94 *
95 * @deprecated 28.2
96 * @codeCoverageIgnore Because of deprecation.
97 *
98 * @return bool Whether the current user can read scores.
99 */
100 public function can_read_scores(): bool {
101 \_deprecated_function( __METHOD__, 'Yoast SEO 28.2', 'Abstract_Score_Ability::can_manage_seo' );
102
103 return \YoastSEO()->helpers->capability->current_user_can( 'wpseo_manage_options' );
104 }
105 }
106