Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../src/integrat.../third-pa...
File: wpml.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Third_Party;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Conditionals\Third_Party\WPML_Conditional;
[4] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* WPML integration.
[8] Fix | Delete
*
[9] Fix | Delete
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- Known false positive with acronyms. Fix expected in YoastCS 3.x.
[10] Fix | Delete
*/
[11] Fix | Delete
class WPML implements Integration_Interface {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Initializes the integration.
[15] Fix | Delete
*
[16] Fix | Delete
* This is the place to register hooks and filters.
[17] Fix | Delete
*
[18] Fix | Delete
* @return void
[19] Fix | Delete
*/
[20] Fix | Delete
public function register_hooks() {
[21] Fix | Delete
\add_action( 'wpseo_home_url', [ $this, 'filter_home_url_before' ] );
[22] Fix | Delete
\add_filter( 'home_url', [ $this, 'filter_home_url_after' ], 100 );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Returns the conditionals based in which this loadable should be active.
[27] Fix | Delete
*
[28] Fix | Delete
* @return array
[29] Fix | Delete
*/
[30] Fix | Delete
public static function get_conditionals() {
[31] Fix | Delete
return [ WPML_Conditional::class ];
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Adds a filter to WPML's wpml_get_home_url filter to ensure we get the unmanipulated home URL.
[36] Fix | Delete
*/
[37] Fix | Delete
public function filter_home_url_before() {
[38] Fix | Delete
\add_filter( 'wpml_get_home_url', [ $this, 'wpml_get_home_url' ], 10, 2 );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Removes the wpml_get_home_url filter to return the WPML, language-enriched home URL.
[43] Fix | Delete
*
[44] Fix | Delete
* @param string $home_url The filtered home URL.
[45] Fix | Delete
*
[46] Fix | Delete
* @return string The unfiltered home URL.
[47] Fix | Delete
*/
[48] Fix | Delete
public function filter_home_url_after( $home_url ) {
[49] Fix | Delete
\remove_filter( 'wpml_get_home_url', [ $this, 'wpml_get_home_url' ], 10 );
[50] Fix | Delete
[51] Fix | Delete
return $home_url;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Returns the original URL instead of the language-enriched URL.
[56] Fix | Delete
* This method gets automatically triggered by the wpml_get_home_url filter.
[57] Fix | Delete
*
[58] Fix | Delete
* @param string $home_url The url altered by WPML. Unused.
[59] Fix | Delete
* @param string $url The url that isn't altered by WPML.
[60] Fix | Delete
*
[61] Fix | Delete
* @return string The original url.
[62] Fix | Delete
*/
[63] Fix | Delete
public function wpml_get_home_url( $home_url, $url ) {
[64] Fix | Delete
return $url;
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function