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

Yoast / wordpress-seo / 7004843404

27 Nov 2023 11:48AM UTC coverage: 49.206% (-0.03%) from 49.232%
7004843404

push

github

web-flow
Merge pull request #20858 from Yoast/improve-copy-in-the-ftc-57

15305 of 31104 relevant lines covered (49.21%)

4.03 hits per line

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

0.0
/src/integrations/admin/fix-news-dependencies-integration.php
1
<?php
2

3
namespace Yoast\WP\SEO\Integrations\Admin;
4

5
use WP_Screen;
6
use WPSEO_Admin_Asset_Manager;
7
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
8
use Yoast\WP\SEO\Conditionals\News_Conditional;
9
use Yoast\WP\SEO\Integrations\Integration_Interface;
10

11
/**
12
 * Fix_News_Dependencies_Integration class.
13
 */
14
class Fix_News_Dependencies_Integration implements Integration_Interface {
15

16
        /**
17
         * Returns the conditionals based in which this loadable should be active.
18
         *
19
         * In this case: when on an admin page.
20
         *
21
         * @return array The conditionals.
22
         */
23
        public static function get_conditionals() {
×
24
                return [ Admin_Conditional::class, News_Conditional::class ];
×
25
        }
26

27
        /**
28
         * Registers an action to disable script concatenation.
29
         */
30
        public function register_hooks() {
×
31
                global $pagenow;
×
32

33
                // Load the editor script when on an edit post or new post page.
34
                $is_post_edit_page = $pagenow === 'post.php' || $pagenow === 'post-new.php';
×
35
                if ( $is_post_edit_page ) {
×
36
                        \add_action( 'admin_enqueue_scripts', [ $this, 'add_news_script_dependency' ], 11 );
×
37
                }
38
        }
39

40
        /**
41
         * Fixes the news script dependency.
42
         *
43
         * @return void
44
         */
45
        public function add_news_script_dependency() {
×
46
                $scripts = \wp_scripts();
×
47

48
                if ( ! isset( $scripts->registered['wpseo-news-editor'] ) ) {
×
49
                        return;
×
50
                }
51

52
                $is_block_editor  = WP_Screen::get()->is_block_editor();
×
53
                $post_edit_handle = 'post-edit';
×
54
                if ( ! $is_block_editor ) {
×
55
                        $post_edit_handle = 'post-edit-classic';
×
56
                }
57

58
                $scripts->registered['wpseo-news-editor']->deps[] = WPSEO_Admin_Asset_Manager::PREFIX . $post_edit_handle;
×
59
        }
60
}
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

© 2026 Coveralls, Inc