Skip to content

Commit 47636e5

Browse files
committed
adds conditional
1 parent 8aaea65 commit 47636e5

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

src/general/user-interface/opt-in-route.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use WP_REST_Request;
66
use WP_REST_Response;
7-
use Yoast\WP\SEO\Conditionals\No_Conditionals;
7+
use Yoast\WP\SEO\Conditionals\Yoast_Admin_And_Dashboard_Conditional;
88
use Yoast\WP\SEO\Helpers\Capability_Helper;
99
use Yoast\WP\SEO\Helpers\User_Helper;
1010
use Yoast\WP\SEO\Main;
@@ -15,8 +15,6 @@
1515
*/
1616
class Opt_In_Route implements Route_Interface {
1717

18-
use No_Conditionals;
19-
2018
/**
2119
* The namespace for this route.
2220
*
@@ -45,6 +43,17 @@ class Opt_In_Route implements Route_Interface {
4543
*/
4644
private $capability_helper;
4745

46+
/**
47+
* Returns the conditionals based on which this integration should be active.
48+
*
49+
* @return array<Yoast_Admin_And_Dashboard_Conditional> The array of conditionals.
50+
*/
51+
public static function get_conditionals() {
52+
return [
53+
Yoast_Admin_And_Dashboard_Conditional::class,
54+
];
55+
}
56+
4857
/**
4958
* Constructs Opt_In_Route.
5059
*
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3+
// phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded
4+
namespace Yoast\WP\SEO\Tests\Unit\General\User_Interface\Opt_In_Route;
5+
6+
use Yoast\WP\SEO\Conditionals\Yoast_Admin_And_Dashboard_Conditional;
7+
8+
/**
9+
* Tests the Opt_In_Route get_conditionals method.
10+
*
11+
* @group opt-in-route
12+
*
13+
* @covers \Yoast\WP\SEO\General\User_Interface\Opt_In_Route::get_conditionals
14+
*/
15+
final class Get_Conditional_Test extends Abstract_Opt_In_Route_Test {
16+
17+
/**
18+
* Tests the get_conditionals method.
19+
*
20+
* @return void
21+
*/
22+
public function test_get_conditionals() {
23+
$this->assertEquals(
24+
[ Yoast_Admin_And_Dashboard_Conditional::class ],
25+
$this->instance::get_conditionals()
26+
);
27+
}
28+
}

0 commit comments

Comments
 (0)