scossdl_off_rewriter()WPSCache 1.0

Rewriter of URLs, used as replace-callback.

Called by #scossdl_off_filter.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

scossdl_off_rewriter( $match );
$match (обязательный)
-

Код scossdl_off_rewriter() WPSCache 1.12.0

function scossdl_off_rewriter( $match ) {
	global $ossdl_off_blog_url, $ossdl_https, $ossdl_off_excludes, $ossdl_arr_of_cnames;
	static $count_cnames = null, $include_dirs = null;

	// Set up static variables. Run once only.
	if ( ! isset( $count_cnames ) ) {
		$count_cnames = count( $ossdl_arr_of_cnames );
		$include_dirs = scossdl_off_additional_directories();
	}

	if ( $ossdl_https && str_starts_with( $match[0], 'https' ) ) {
		return $match[0];
	}

	if ( scossdl_off_exclude_match( $match[0], $ossdl_off_excludes ) ) {
		return $match[0];
	}

	if ( preg_match( '`(' . $include_dirs . ')`', $match[0] ) ) {
		$offset = scossdl_string_mod( $match[1], $count_cnames );
		return str_replace( $ossdl_off_blog_url, $ossdl_arr_of_cnames[ $offset ], $match[0] );
	}

	return $match[0];
}