• 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/integrations/third-party/wpml.php
1
<?php
2

3
namespace Yoast\WP\SEO\Integrations\Third_Party;
4

5
use Yoast\WP\SEO\Conditionals\Third_Party\WPML_Conditional;
6
use Yoast\WP\SEO\Integrations\Integration_Interface;
7

8
/**
9
 * WPML integration.
10
 *
11
 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- Known false positive with acronyms. Fix expected in YoastCS 3.x.
12
 */
13
class WPML implements Integration_Interface {
14

15
        /**
16
         * Initializes the integration.
17
         *
18
         * This is the place to register hooks and filters.
19
         *
20
         * @return void
21
         */
22
        public function register_hooks() {
23
                \add_action( 'wpseo_home_url', [ $this, 'filter_home_url_before' ] );
×
24
                \add_filter( 'home_url', [ $this, 'filter_home_url_after' ], 100 );
×
25
        }
26

27
        /**
28
         * Returns the conditionals based in which this loadable should be active.
29
         *
30
         * @return array
31
         */
32
        public static function get_conditionals() {
33
                return [ WPML_Conditional::class ];
×
34
        }
35

36
        /**
37
         * Adds a filter to WPML's wpml_get_home_url filter to ensure we get the unmanipulated home URL.
38
         */
39
        public function filter_home_url_before() {
40
                \add_filter( 'wpml_get_home_url', [ $this, 'wpml_get_home_url' ], 10, 2 );
×
41
        }
42

43
        /**
44
         * Removes the wpml_get_home_url filter to return the WPML, language-enriched home URL.
45
         *
46
         * @param string $home_url The filtered home URL.
47
         *
48
         * @return string The unfiltered home URL.
49
         */
50
        public function filter_home_url_after( $home_url ) {
51
                \remove_filter( 'wpml_get_home_url', [ $this, 'wpml_get_home_url' ], 10 );
×
52

53
                return $home_url;
×
54
        }
55

56
        /**
57
         * Returns the original URL instead of the language-enriched URL.
58
         * This method gets automatically triggered by the wpml_get_home_url filter.
59
         *
60
         * @param string $home_url The url altered by WPML. Unused.
61
         * @param string $url      The url that isn't altered by WPML.
62
         *
63
         * @return string The original url.
64
         */
65
        public function wpml_get_home_url( $home_url, $url ) {
66
                return $url;
×
67
        }
68
}
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