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

Yoast / wordpress-seo / 7293537a0cd29d7f14d45611091af1f6c6956336

07 Jun 2024 11:54AM UTC coverage: 48.416% (-4.3%) from 52.695%
7293537a0cd29d7f14d45611091af1f6c6956336

push

github

web-flow
Merge pull request #21415 from Yoast/update-styling-of-sparkle-buttons-ai-assessment-fixes

Update styling of sparkle buttons ai assessment fixes

7449 of 13517 branches covered (55.11%)

Branch coverage included in aggregate %.

20 of 20 new or added lines in 2 files covered. (100.0%)

3710 existing lines in 106 files now uncovered.

25081 of 53672 relevant lines covered (46.73%)

42041.36 hits per line

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

0.0
/admin/class-option-tabs.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin\Options\Tabs
6
 */
7

8
/**
9
 * Class WPSEO_Option_Tabs.
10
 */
11
class WPSEO_Option_Tabs {
12

13
        /**
14
         * Tabs base.
15
         *
16
         * @var string
17
         */
18
        private $base;
19

20
        /**
21
         * The tabs in this group.
22
         *
23
         * @var array
24
         */
25
        private $tabs = [];
26

27
        /**
28
         * Name of the active tab.
29
         *
30
         * @var string
31
         */
32
        private $active_tab = '';
33

34
        /**
35
         * WPSEO_Option_Tabs constructor.
36
         *
37
         * @codeCoverageIgnore
38
         *
39
         * @param string $base       Base of the tabs.
40
         * @param string $active_tab Currently active tab.
41
         */
42
        public function __construct( $base, $active_tab = '' ) {
43
                $this->base = sanitize_title( $base );
44

45
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
46
                $tab              = isset( $_GET['tab'] ) && is_string( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : '';
47
                $this->active_tab = empty( $tab ) ? $active_tab : $tab;
48
        }
49

50
        /**
51
         * Get the base.
52
         *
53
         * @return string
54
         */
UNCOV
55
        public function get_base() {
×
UNCOV
56
                return $this->base;
×
57
        }
58

59
        /**
60
         * Add a tab.
61
         *
62
         * @param WPSEO_Option_Tab $tab Tab to add.
63
         *
64
         * @return $this
65
         */
UNCOV
66
        public function add_tab( WPSEO_Option_Tab $tab ) {
×
UNCOV
67
                $this->tabs[] = $tab;
×
68

UNCOV
69
                return $this;
×
70
        }
71

72
        /**
73
         * Get active tab.
74
         *
75
         * @return WPSEO_Option_Tab|null Get the active tab.
76
         */
UNCOV
77
        public function get_active_tab() {
×
UNCOV
78
                if ( empty( $this->active_tab ) ) {
×
UNCOV
79
                        return null;
×
80
                }
81

UNCOV
82
                $active_tabs = array_filter( $this->tabs, [ $this, 'is_active_tab' ] );
×
UNCOV
83
                if ( ! empty( $active_tabs ) ) {
×
UNCOV
84
                        $active_tabs = array_values( $active_tabs );
×
UNCOV
85
                        if ( count( $active_tabs ) === 1 ) {
×
UNCOV
86
                                return $active_tabs[0];
×
87
                        }
88
                }
89

UNCOV
90
                return null;
×
91
        }
92

93
        /**
94
         * Is the tab the active tab.
95
         *
96
         * @param WPSEO_Option_Tab $tab Tab to check for active tab.
97
         *
98
         * @return bool
99
         */
UNCOV
100
        public function is_active_tab( WPSEO_Option_Tab $tab ) {
×
UNCOV
101
                return ( $tab->get_name() === $this->active_tab );
×
102
        }
103

104
        /**
105
         * Get all tabs.
106
         *
107
         * @return WPSEO_Option_Tab[]
108
         */
UNCOV
109
        public function get_tabs() {
×
UNCOV
110
                return $this->tabs;
×
111
        }
112

113
        /**
114
         * Display the tabs.
115
         *
116
         * @param Yoast_Form $yform Yoast Form needed in the views.
117
         *
118
         * @return void
119
         */
UNCOV
120
        public function display( Yoast_Form $yform ) {
×
UNCOV
121
                $formatter = new WPSEO_Option_Tabs_Formatter();
×
UNCOV
122
                $formatter->run( $this, $yform );
×
123
        }
124
}
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