PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.7.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.7.0
2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
thinkrank / includes / abilities / links / class-external-links-ability-base.php

class-external-links-ability-base.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 2.7.0, at includes/abilities/links/class-external-links-ability-base.php

86 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shared base for the external link abilities.
4 *
5 * @package ThinkRank\Abilities\Links
6 */
7
8 declare(strict_types=1);
9
10 namespace ThinkRank\Abilities\Links;
11
12 use ThinkRank\Abilities\Ability_Base;
13 use ThinkRank\SEO\External_Links_Manager;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Common manager access and schema fragments for the external link abilities.
21 *
22 * Mirrors {@see \ThinkRank\API\External_Links_Endpoint}, which owns the
23 * site-wide `nofollow_external`, `open_external_in_new_tab` and
24 * `external_link_exceptions` settings.
25 */
26 abstract class External_Links_Ability_Base extends Ability_Base {
27
28 /**
29 * Settings manager.
30 *
31 * @var External_Links_Manager|null
32 */
33 private ?External_Links_Manager $manager = null;
34
35 /**
36 * The settings manager, built once per ability instance.
37 *
38 * @return External_Links_Manager
39 */
40 protected function manager(): External_Links_Manager {
41 if ( null === $this->manager ) {
42 $this->manager = new External_Links_Manager();
43 }
44
45 return $this->manager;
46 }
47
48 /**
49 * The stored settings, with the exception list re-indexed.
50 *
51 * @return array<string, mixed>
52 */
53 protected function stored(): array {
54 $settings = $this->manager()->get_settings( 'site' );
55
56 $settings['external_link_exceptions'] = array_values(
57 (array) ( $settings['external_link_exceptions'] ?? [] )
58 );
59
60 return $settings;
61 }
62
63 /**
64 * Schema for the three settings.
65 *
66 * @return array<string, mixed>
67 */
68 protected function settings_properties(): array {
69 return [
70 'nofollow_external' => [
71 'type' => 'boolean',
72 'description' => __( 'Add rel="nofollow" to every link pointing at another domain.', 'thinkrank' ),
73 ],
74 'open_external_in_new_tab' => [
75 'type' => 'boolean',
76 'description' => __( 'Add target="_blank" to external links, along with the rel="noopener" it requires.', 'thinkrank' ),
77 ],
78 'external_link_exceptions' => [
79 'type' => 'array',
80 'items' => [ 'type' => 'string' ],
81 'description' => __( 'Hosts neither switch touches. A full URL or a "www." prefix is accepted and reduced to the host it matches on, so read the value back rather than assuming what was stored. Subdomains of a listed host are included.', 'thinkrank' ),
82 ],
83 ];
84 }
85 }
86