• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / e57e01309ec9fc3afc714e6ce0fd243e7b6d1f90

27 May 2025 12:40PM UTC coverage: 45.733%. First build
e57e01309ec9fc3afc714e6ce0fd243e7b6d1f90

Pull #22275

github

web-flow
Merge f0a8d33c9 into 5f64dc203
Pull Request #22275: Move and refactor ai generator rest endpoints

0 of 392 new or added lines in 26 files covered. (0.0%)

15548 of 33997 relevant lines covered (45.73%)

3.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/ai-generator/user-interface/bust-subscription-cache-route.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
namespace Yoast\WP\SEO\AI_Generator\User_Interface;
4

5
use WP_REST_Response;
6
use WPSEO_Addon_Manager;
7
use Yoast\WP\SEO\Conditionals\AI_Conditional;
8
use Yoast\WP\SEO\Main;
9
use Yoast\WP\SEO\Routes\Route_Interface;
10

11
/**
12
 * Registers a route to bust the subscription cache.
13
 *
14
 * @makePublic
15
 *
16
 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
17
 */
18
class Bust_Subscription_Cache_Route implements Route_Interface {
19

20
        use Route_Permission_Trait;
21

22
        /**
23
         *  The namespace for this route.
24
         *
25
         * @var string
26
         */
27
        public const ROUTE_NAMESPACE = Main::API_V1_NAMESPACE;
28

29
        /**
30
         *  The prefix for this route.
31
         *
32
         * @var string
33
         */
34
        public const ROUTE_PREFIX = '/ai_generator/bust_subscription_cache';
35

36
        /**
37
         * The addon manager instance.
38
         *
39
         * @var WPSEO_Addon_Manager
40
         */
41
        private $addon_manager;
42

43
        /**
44
         * Returns the conditionals based in which this loadable should be active.
45
         *
46
         * @return array<string> The conditionals.
47
         */
NEW
48
        public static function get_conditionals() {
×
NEW
49
                return [ AI_Conditional::class ];
×
50
        }
51

52
        /**
53
         * Class constructor.
54
         *
55
         * @param WPSEO_Addon_Manager $addon_manager The addon manager instance.
56
         */
NEW
57
        public function __construct( WPSEO_Addon_Manager $addon_manager ) {
×
NEW
58
                $this->addon_manager = $addon_manager;
×
59
        }
60

61
        /**
62
         * Registers routes with WordPress.
63
         *
64
         * @return void
65
         */
NEW
66
        public function register_routes() {
×
NEW
67
                \register_rest_route(
×
NEW
68
                        self::ROUTE_NAMESPACE,
×
NEW
69
                        self::ROUTE_PREFIX,
×
NEW
70
                        [
×
NEW
71
                                'methods'             => 'POST',
×
NEW
72
                                'args'                => [],
×
NEW
73
                                'callback'            => [ $this, 'bust_subscription_cache' ],
×
NEW
74
                                'permission_callback' => [ $this, 'check_permissions' ],
×
NEW
75
                        ]
×
NEW
76
                );
×
77
        }
78

79
        /**
80
         * Runs the callback that busts the subscription cache.
81
         *
82
         * @return WP_REST_Response The response of the callback action.
83
         */
NEW
84
        public function bust_subscription_cache(): WP_REST_Response {
×
NEW
85
                $this->addon_manager->remove_site_information_transients();
×
86

NEW
87
                return new WP_REST_Response( 'Subscription cache successfully busted.' );
×
88
        }
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc