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

Yoast / wordpress-seo / 8b43089c625103ac862fa11105ec20207cf5705a

13 Aug 2024 11:22AM UTC coverage: 51.228% (+0.2%) from 51.025%
8b43089c625103ac862fa11105ec20207cf5705a

Pull #21314

github

web-flow
Merge c66634528 into 82a18954b
Pull Request #21314: Don't overwrite user settings when the respective features are disabled

152 of 164 new or added lines in 10 files covered. (92.68%)

197 existing lines in 6 files now uncovered.

16378 of 31971 relevant lines covered (51.23%)

3.92 hits per line

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

0.0
/src/conditionals/primary-category-conditional.php
1
<?php
2

3
namespace Yoast\WP\SEO\Conditionals;
4

5
use Yoast\WP\SEO\Helpers\Current_Page_Helper;
6

7
/**
8
 * Conditional that is only met when in frontend or page is a post overview or post add/edit form.
9
 */
10
class Primary_Category_Conditional implements Conditional {
11

12
        /**
13
         * The current page helper.
14
         *
15
         * @var Current_Page_Helper
16
         */
17
        private $current_page;
18

19
        /**
20
         * Primary_Category_Conditional constructor.
21
         *
22
         * @param Current_Page_Helper $current_page The current page helper.
23
         */
24
        public function __construct( Current_Page_Helper $current_page ) {
×
25
                $this->current_page = $current_page;
×
26
        }
27

28
        /**
29
         * Returns `true` when on the frontend,
30
         * or when on the post overview, post edit or new post admin page,
31
         * or when on additional admin pages, allowed by filter.
32
         *
33
         * @return bool `true` when on the frontend, or when on the post overview,
34
         *          post edit, new post admin page or additional admin pages, allowed by filter.
35
         */
36
        public function is_met() {
×
37

38
                if ( ! \is_admin() ) {
×
UNCOV
39
                        return true;
×
40
                }
41

UNCOV
42
                $current_page = $this->current_page->get_current_admin_page();
×
43
                // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: We are not processing form information.
UNCOV
44
                if ( $current_page === 'admin-ajax.php' && isset( $_POST['action'] ) && $_POST['action'] === 'wp-link-ajax' ) {
×
UNCOV
45
                        return true;
×
46
                }
47

48
                /**
49
                 * Filter: Adds the possibility to use primary category at additional admin pages.
50
                 *
51
                 * @param array $admin_pages List of additional admin pages.
52
                 */
UNCOV
53
                $additional_pages = \apply_filters( 'wpseo_primary_category_admin_pages', [] );
×
UNCOV
54
                return \in_array( $current_page, \array_merge( [ 'edit.php', 'post.php', 'post-new.php' ], $additional_pages ), true );
×
55
        }
56
}
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