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

Yoast / wordpress-seo / dd6e866a9e6d253114633104d9e3858d807178ba

19 Jun 2024 10:03AM UTC coverage: 48.628% (-4.3%) from 52.936%
dd6e866a9e6d253114633104d9e3858d807178ba

push

github

web-flow
Merge pull request #21431 from Yoast/21429-update-copy-in-the-introduction-and-consent-modals

Updates the copy for the introduction and consent modals

7441 of 13454 branches covered (55.31%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 2 files covered. (0.0%)

3718 existing lines in 107 files now uncovered.

25100 of 53464 relevant lines covered (46.95%)

62392.47 hits per line

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

0.0
/admin/views/class-yoast-input-select.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin
6
 */
7

8
/**
9
 * Class for generating a html select.
10
 */
11
class Yoast_Input_Select {
12

13
        /**
14
         * The id attribute value.
15
         *
16
         * @var string
17
         */
18
        private $select_id;
19

20
        /**
21
         * The name attribute value.
22
         *
23
         * @var string
24
         */
25
        private $select_name;
26

27
        /**
28
         * Additional select attributes.
29
         *
30
         * @var array
31
         */
32
        private $select_attributes = [];
33

34
        /**
35
         * Array with the options to parse.
36
         *
37
         * @var array
38
         */
39
        private $select_options;
40

41
        /**
42
         * The current selected option.
43
         *
44
         * @var string
45
         */
46
        private $selected_option;
47

48
        /**
49
         * Constructor.
50
         *
51
         * @param string $select_id       ID for the select.
52
         * @param string $select_name     Name for the select.
53
         * @param array  $select_options  Array with the options to parse.
54
         * @param string $selected_option The current selected option.
55
         */
UNCOV
56
        public function __construct( $select_id, $select_name, array $select_options, $selected_option ) {
×
UNCOV
57
                $this->select_id       = $select_id;
×
UNCOV
58
                $this->select_name     = $select_name;
×
UNCOV
59
                $this->select_options  = $select_options;
×
UNCOV
60
                $this->selected_option = $selected_option;
×
61
        }
62

63
        /**
64
         * Print the rendered view.
65
         *
66
         * @return void
67
         */
UNCOV
68
        public function output_html() {
×
69
                // Extract it, because we want each value accessible via a variable instead of accessing it as an array.
UNCOV
70
                extract( $this->get_select_values() );
×
71

UNCOV
72
                require WPSEO_PATH . 'admin/views/form/select.php';
×
73
        }
74

75
        /**
76
         * Return the rendered view.
77
         *
78
         * @return string
79
         */
UNCOV
80
        public function get_html() {
×
UNCOV
81
                ob_start();
×
82

UNCOV
83
                $this->output_html();
×
84

UNCOV
85
                $rendered_output = ob_get_contents();
×
UNCOV
86
                ob_end_clean();
×
87

UNCOV
88
                return $rendered_output;
×
89
        }
90

91
        /**
92
         * Add an attribute to the attributes property.
93
         *
94
         * @param string $attribute The name of the attribute to add.
95
         * @param string $value     The value of the attribute.
96
         *
97
         * @return void
98
         */
UNCOV
99
        public function add_attribute( $attribute, $value ) {
×
UNCOV
100
                $this->select_attributes[ $attribute ] = $value;
×
101
        }
102

103
        /**
104
         * Return the set fields for the select.
105
         *
106
         * @return array
107
         */
UNCOV
108
        private function get_select_values() {
×
UNCOV
109
                return [
×
UNCOV
110
                        'id'         => $this->select_id,
×
UNCOV
111
                        'name'       => $this->select_name,
×
UNCOV
112
                        'attributes' => $this->get_attributes(),
×
UNCOV
113
                        'options'    => $this->select_options,
×
UNCOV
114
                        'selected'   => $this->selected_option,
×
UNCOV
115
                ];
×
116
        }
117

118
        /**
119
         * Return the attribute string, when there are attributes set.
120
         *
121
         * @return string
122
         */
UNCOV
123
        private function get_attributes() {
×
UNCOV
124
                $attributes = $this->select_attributes;
×
125

UNCOV
126
                if ( ! empty( $attributes ) ) {
×
UNCOV
127
                        array_walk( $attributes, [ $this, 'parse_attribute' ] );
×
128

UNCOV
129
                        return implode( ' ', $attributes ) . ' ';
×
130
                }
131

UNCOV
132
                return '';
×
133
        }
134

135
        /**
136
         * Get an attribute from the attributes.
137
         *
138
         * @param string $value     The value of the attribute.
139
         * @param string $attribute The attribute to look for.
140
         *
141
         * @return void
142
         */
UNCOV
143
        private function parse_attribute( &$value, $attribute ) {
×
UNCOV
144
                $value = sprintf( '%s="%s"', sanitize_key( $attribute ), esc_attr( $value ) );
×
145
        }
146
}
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

© 2025 Coveralls, Inc