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

Yoast / wordpress-seo / 5066322038

pending completion
5066322038

push

github

GitHub
Merge pull request #20316 from Yoast/JRF/ghactions-run-more-selectively

2550 of 29012 relevant lines covered (8.79%)

0.32 hits per line

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

0.0
/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() {
18
                return $this->context->site_represents === 'company';
×
19
        }
20

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

29
                if ( $this->context->company_logo_meta ) {
×
30
                        $logo = $this->helpers->schema->image->generate_from_attachment_meta( $logo_schema_id, $this->context->company_logo_meta, $this->context->company_name );
×
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 );
×
34
                }
35

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

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

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

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

55
                return $organization;
×
56
        }
57

58
        /**
59
         * Retrieve the social profiles to display in the organization schema.
60
         *
61
         * @return array An array of social profiles.
62
         */
63
        private function fetch_social_profiles() {
64
                $profiles = $this->helpers->social_profiles->get_organization_social_profiles();
×
65

66
                if ( isset( $profiles['other_social_urls'] ) ) {
×
67
                        $other_social_urls = $profiles['other_social_urls'];
×
68
                        unset( $profiles['other_social_urls'] );
×
69
                        $profiles = \array_merge( $profiles, $other_social_urls );
×
70
                }
71

72
                /**
73
                 * Filter: 'wpseo_schema_organization_social_profiles' - Allows filtering social profiles for the
74
                 * represented organization.
75
                 *
76
                 * @api string[] $profiles
77
                 */
78
                $profiles = \apply_filters( 'wpseo_schema_organization_social_profiles', $profiles );
×
79

80
                return $profiles;
×
81
        }
82
}
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