Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/sitepres.../classes/utilitie...
File: class-wpml-slash-management.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class WPML_Slash_Management {
[2] Fix | Delete
[3] Fix | Delete
public function match_trailing_slash_to_reference( $url, $reference_url ) {
[4] Fix | Delete
if ( trailingslashit( $reference_url ) === $reference_url && ! $this->has_lang_param( $url ) ) {
[5] Fix | Delete
return trailingslashit( $url );
[6] Fix | Delete
} else {
[7] Fix | Delete
return untrailingslashit( $url );
[8] Fix | Delete
}
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* @param string $url
[13] Fix | Delete
*
[14] Fix | Delete
* @return bool
[15] Fix | Delete
*/
[16] Fix | Delete
private function has_lang_param( $url ) {
[17] Fix | Delete
return strpos( $url, '?lang=' ) !== false || strpos( $url, '&lang=' ) !== false;
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* @param string $url
[22] Fix | Delete
* @param string $method Deprecated.
[23] Fix | Delete
*
[24] Fix | Delete
* @return mixed|string
[25] Fix | Delete
*/
[26] Fix | Delete
public function maybe_user_trailingslashit( $url, $method = '' ) {
[27] Fix | Delete
$url_parts = wpml_parse_url( $url );
[28] Fix | Delete
[29] Fix | Delete
if ( ! $url_parts ) {
[30] Fix | Delete
return $url;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
$url_parts = $this->parse_missing_host_from_path( $url_parts );
[34] Fix | Delete
[35] Fix | Delete
if ( $this->is_root_url_with_trailingslash( $url_parts )
[36] Fix | Delete
|| $this->is_root_url_without_trailingslash_and_without_query_args( $url_parts )
[37] Fix | Delete
) {
[38] Fix | Delete
return $url;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
$path = isset( $url_parts['path'] ) ? $url_parts['path'] : '';
[42] Fix | Delete
[43] Fix | Delete
if ( ! $path && isset( $url_parts['query'] ) ) {
[44] Fix | Delete
$url_parts['path'] = '/';
[45] Fix | Delete
} elseif ( $this->is_file_path( $path ) ) {
[46] Fix | Delete
$url_parts['path'] = untrailingslashit( $path );
[47] Fix | Delete
} elseif ( $method ) {
[48] Fix | Delete
$url_parts['path'] = 'untrailingslashit' === $method ? untrailingslashit( $path ) : trailingslashit( $path );
[49] Fix | Delete
} else {
[50] Fix | Delete
$url_parts['path'] = $this->user_trailingslashit( $path );
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
return http_build_url( $url_parts );
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Follows the logic of WordPress core user_trailingslashit().
[58] Fix | Delete
* Can be called on plugins_loaded event, when $wp_rewrite is not set yet.
[59] Fix | Delete
*
[60] Fix | Delete
* @param $path
[61] Fix | Delete
*
[62] Fix | Delete
* @return string
[63] Fix | Delete
*/
[64] Fix | Delete
private function user_trailingslashit( $path ) {
[65] Fix | Delete
global $wp_rewrite;
[66] Fix | Delete
[67] Fix | Delete
if ( $wp_rewrite ) {
[68] Fix | Delete
return user_trailingslashit( $path );
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
$permalink_structure = get_option( 'permalink_structure' );
[72] Fix | Delete
$use_trailing_slashes = ( '/' === substr( $permalink_structure, - 1, 1 ) );
[73] Fix | Delete
[74] Fix | Delete
if ( $use_trailing_slashes ) {
[75] Fix | Delete
$path = trailingslashit( $path );
[76] Fix | Delete
} else {
[77] Fix | Delete
$path = untrailingslashit( $path );
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
return apply_filters( 'user_trailingslashit', $path, '' );
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* @param array $url_parts
[85] Fix | Delete
*
[86] Fix | Delete
* @return bool
[87] Fix | Delete
*/
[88] Fix | Delete
private function is_root_url_without_trailingslash_and_without_query_args( array $url_parts ) {
[89] Fix | Delete
return ! isset( $url_parts['path'] ) && ! isset( $url_parts['query'] );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* @param array $url_parts
[94] Fix | Delete
*
[95] Fix | Delete
* @return bool
[96] Fix | Delete
*/
[97] Fix | Delete
private function is_root_url_with_trailingslash( array $url_parts ) {
[98] Fix | Delete
return isset( $url_parts['path'] ) && '/' === $url_parts['path'];
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* @see Test_WPML_Lang_Domains_Converter::check_domains_and_subdir
[103] Fix | Delete
*
[104] Fix | Delete
* @param array $url_parts
[105] Fix | Delete
*
[106] Fix | Delete
* @return array
[107] Fix | Delete
*/
[108] Fix | Delete
public function parse_missing_host_from_path( array $url_parts ) {
[109] Fix | Delete
if ( ! isset( $url_parts['host'] ) && isset( $url_parts['path'] ) ) {
[110] Fix | Delete
$domain_and_subdir = explode( '/', $url_parts['path'] );
[111] Fix | Delete
$domain = $domain_and_subdir[0];
[112] Fix | Delete
$url_parts['host'] = $domain;
[113] Fix | Delete
array_shift( $domain_and_subdir );
[114] Fix | Delete
[115] Fix | Delete
if ( $domain_and_subdir ) {
[116] Fix | Delete
$url_parts['path'] = preg_replace( '/^(' . $url_parts['host'] . ')/', '', $url_parts['path'] );
[117] Fix | Delete
} else {
[118] Fix | Delete
unset( $url_parts['path'] );
[119] Fix | Delete
}
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
return $url_parts;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* @param string $path
[127] Fix | Delete
*
[128] Fix | Delete
* @return bool
[129] Fix | Delete
*/
[130] Fix | Delete
private function is_file_path( $path ) {
[131] Fix | Delete
$pathinfo = pathinfo( $path );
[132] Fix | Delete
return isset( $pathinfo['extension'] ) && $pathinfo['extension'];
[133] Fix | Delete
}
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function