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 / integrations / admin / brand-insights-page.php

brand-insights-page.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/integrations/admin/brand-insights-page.php

97 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Integrations\Admin;
4
5 use Yoast\WP\SEO\Conditionals\Admin_Conditional;
6 use Yoast\WP\SEO\Helpers\Product_Helper;
7 use Yoast\WP\SEO\Integrations\Integration_Interface;
8
9 /**
10 * Brand_Insights_Page class
11 */
12 class Brand_Insights_Page implements Integration_Interface {
13
14 /**
15 * External link icon.
16 */
17 public const EXTERNAL_LINK_ICON = '<span class="yst-external-link-icon"></span>';
18
19 /**
20 * The product helper.
21 *
22 * @var Product_Helper
23 */
24 private $product_helper;
25
26 /**
27 * Constructor.
28 *
29 * @param Product_Helper $product_helper The product helper.
30 */
31 public function __construct(
32 Product_Helper $product_helper
33 ) {
34 $this->product_helper = $product_helper;
35 }
36
37 /**
38 * Returns the conditionals based in which this loadable should be active.
39 *
40 * @return array<string>
41 */
42 public static function get_conditionals() {
43 return [
44 Admin_Conditional::class,
45 ];
46 }
47
48 /**
49 * Registers all hooks to WordPress.
50 *
51 * @return void
52 */
53 public function register_hooks() {
54 // Add page with PHP_INT_MAX so it's always the last item. This is the AI Brand Insights button in the sidebar menu.
55 \add_filter( 'wpseo_submenu_pages', [ $this, 'add_submenu_page' ], \PHP_INT_MAX );
56 }
57
58 /**
59 * Adds the Brand Insights submenu page.
60 *
61 * @param string[] $submenu_pages The Yoast SEO submenu pages.
62 *
63 * @return string[] The filtered submenu pages.
64 */
65 public function add_submenu_page( $submenu_pages ) {
66 $page = $this->product_helper->is_premium() ? 'wpseo_brand_insights_premium' : 'wpseo_brand_insights';
67
68 $button_content = 'AI Brand Insights';
69
70 $menu_title = '<span class="yoast-brand-insights-gradient-border">'
71 . '<span class="yoast-brand-insights-content">'
72 . $button_content
73 . self::EXTERNAL_LINK_ICON
74 . '</span></span>';
75
76 $submenu_pages[] = [
77 'wpseo_dashboard',
78 '',
79 $menu_title,
80 'edit_posts',
81 $page,
82 [ $this, 'show_brand_insights_page' ],
83 ];
84
85 return $submenu_pages;
86 }
87
88 /**
89 * The Brand Insights page render function, noop.
90 *
91 * @return void
92 */
93 public function show_brand_insights_page() {
94 // Do nothing and let the redirect happen from the redirect integration.
95 }
96 }
97