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

Yoast / wordpress-seo / d06ecddd1a2dfd570966e4466fc1ee34449e48a4

28 May 2024 08:44AM UTC coverage: 52.735% (+0.1%) from 52.604%
d06ecddd1a2dfd570966e4466fc1ee34449e48a4

Pull #21412

github

web-flow
Merge dff4c17b2 into 1cf35a642
Pull Request #21412: Feature/decouple hidden fields

7359 of 13368 branches covered (55.05%)

Branch coverage included in aggregate %.

63 of 297 new or added lines in 44 files covered. (21.21%)

22 existing lines in 16 files now uncovered.

28302 of 54255 relevant lines covered (52.16%)

41401.53 hits per line

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

0.0
/src/presenters/admin/meta-fields-presenter.php
1
<?php
2

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

5
use WP_Post;
6
use WPSEO_Meta;
7
use Yoast\WP\SEO\Presenters\Abstract_Presenter;
8

9
/**
10
 * Presenter class for meta fields in the post editor.
11
 *
12
 * Outputs the hidden fields for a particular field group and post.
13
 */
14
class Meta_Fields_Presenter extends Abstract_Presenter {
15

16
        /**
17
         * The meta fields for which we are going to output hidden input.
18
         *
19
         * @var array
20
         */
21
        private $meta_fields;
22

23
        /**
24
         * The metabox post.
25
         *
26
         * @var WP_Post The metabox post.
27
         */
28
        private $post;
29

30
        /**
31
         * Meta_Fields_Presenter constructor.
32
         *
33
         * @param WP_Post $post        The metabox post.
34
         * @param string  $field_group The key under which a group of fields is grouped.
35
         * @param string  $post_type   The post type.
36
         */
37
        public function __construct( $post, $field_group, $post_type = 'post' ) {
×
38
                $this->post        = $post;
×
39
                $this->meta_fields = WPSEO_Meta::get_meta_field_defs( $field_group, $post_type );
×
40
        }
41

42
        /**
43
         * Presents the Meta Fields.
44
         *
45
         * @return string The styled Alert.
46
         */
47
        public function present() {
×
48
                $output = '';
×
49

50
                foreach ( $this->meta_fields as $key => $meta_field ) {
×
51
                        $form_key   = \esc_attr( WPSEO_Meta::$form_prefix . $key );
×
52
                        $meta_value = WPSEO_Meta::get_value( $key, $this->post->ID );
×
53

NEW
54
                        $output .= '<input type="hidden" id="' . $form_key . '" name="' . $form_key . '"  value="' . \esc_attr( $meta_value ) . '"/>' . "\n";
×
55
                }
56

57
                return $output;
×
58
        }
59
}
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