• 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

93.75
/src/generators/schema/organization.php
1
<?php
2

3
namespace Yoast\WP\SEO\Generators\Schema;
4

5
use Yoast\WP\SEO\Config\Schema_IDs;
6

7
/**
8
 * Returns schema Organization data.
9
 */
10
class Organization extends Abstract_Schema_Piece {
11

12
        /**
13
         * Determines whether an Organization graph piece should be added.
14
         *
15
         * @return bool
16
         */
17
        public function is_needed() {
4✔
18
                return $this->context->site_represents === 'company';
4✔
19
        }
20

21
        /**
22
         * Returns the Organization Schema data.
23
         *
24
         * @return array The Organization schema.
25
         */
26
        public function generate() {
24✔
27
                $logo_schema_id = $this->context->site_url . Schema_IDs::ORGANIZATION_LOGO_HASH;
24✔
28

29
                if ( $this->context->company_logo_meta ) {
24✔
30
                        $logo = $this->helpers->schema->image->generate_from_attachment_meta( $logo_schema_id, $this->context->company_logo_meta, $this->context->company_name );
12✔
31
                }
32
                else {
33
                        $logo = $this->helpers->schema->image->generate_from_attachment_id( $logo_schema_id, $this->context->company_logo_id, $this->context->company_name );
12✔
34
                }
35

36
                $organization = [
12✔
37
                        '@type' => 'Organization',
24✔
38
                        '@id'   => $this->context->site_url . Schema_IDs::ORGANIZATION_HASH,
24✔
39
                        'name'  => $this->helpers->schema->html->smart_strip_tags( $this->context->company_name ),
24✔
40
                ];
12✔
41

42
                if ( ! empty( $this->context->company_alternate_name ) ) {
24✔
43
                        $organization['alternateName'] = $this->context->company_alternate_name;
12✔
44
                }
45

46
                $organization['url']   = $this->context->site_url;
24✔
47
                $organization['logo']  = $logo;
24✔
48
                $organization['image'] = [ '@id' => $logo['@id'] ];
24✔
49

50
                $same_as = \array_values( \array_unique( \array_filter( $this->fetch_social_profiles() ) ) );
24✔
51
                if ( ! empty( $same_as ) ) {
24✔
52
                        $organization['sameAs'] = $same_as;
24✔
53
                }
54

55
                if ( \is_array( $this->context->schema_page_type ) && \in_array( 'ProfilePage', $this->context->schema_page_type, true ) ) {
24✔
UNCOV
56
                        $organization['mainEntityOfPage'] = [
×
UNCOV
57
                                '@id' => $this->context->main_schema_id,
×
58
                        ];
59
                }
60

61
                return $organization;
24✔
62
        }
63

64
        /**
65
         * Retrieve the social profiles to display in the organization schema.
66
         *
67
         * @return array An array of social profiles.
68
         */
69
        private function fetch_social_profiles() {
24✔
70
                $profiles = $this->helpers->social_profiles->get_organization_social_profiles();
24✔
71

72
                if ( isset( $profiles['other_social_urls'] ) ) {
24✔
73
                        $other_social_urls = $profiles['other_social_urls'];
24✔
74
                        unset( $profiles['other_social_urls'] );
24✔
75
                        $profiles = \array_merge( $profiles, $other_social_urls );
24✔
76
                }
77

78
                /**
79
                 * Filter: 'wpseo_schema_organization_social_profiles' - Allows filtering social profiles for the
80
                 * represented organization.
81
                 *
82
                 * @param string[] $profiles
83
                 */
84
                $profiles = \apply_filters( 'wpseo_schema_organization_social_profiles', $profiles );
24✔
85

86
                return $profiles;
24✔
87
        }
88
}
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