__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Templately\Core\Importer;
/**
* Originally made by Elementor
*/
class URL {
/**
* Migrate url to the current permalink structure.
* The function will also check and change absolute url to relative one by the base url.
* This is currently supports only "Post Name" permalink structure to any permalink structure.
*
* @param string $url The url that should be migrated.
* @param string|Null $base_url The base url that should be clean from the url.
*
* @return string The migrated url || the $url if it couldn't find a match in the current permalink structure.
*/
public static function migrate( string $url, $base_url = '' ): string {
$full_url = $url;
if ( ! empty( $base_url ) ) {
$base_url = preg_quote( $base_url, '/' );
$url = preg_replace( "/^{$base_url}/", '', $url );
}
$parsed_url = wp_parse_url( $url );
if ( $url === $full_url && ! empty( $parsed_url['host'] ) ) {
return $full_url;
}
if ( ! empty( $parsed_url['path'] ) ) {
$page = get_page_by_path( $parsed_url['path'] );
if ( ! $page ) {
return $full_url;
}
$permalink = get_permalink( $page->ID );
}
if ( empty( $permalink ) ) {
return $full_url;
}
if ( ! empty( $parsed_url['query'] ) ) {
parse_str( $parsed_url['query'], $parsed_query );
// Clean WP permalinks query args to prevent collision with the new permalink.
unset( $parsed_query['p'] );
unset( $parsed_query['page_id'] );
$permalink = add_query_arg( $parsed_query, $permalink );
}
if ( ! empty( $parsed_url['fragment'] ) ) {
$permalink .= '#' . $parsed_url['fragment'];
}
return wp_make_link_relative( $permalink );
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Exception | Folder | 0750 |
|
|
| Parsers | Folder | 0750 |
|
|
| Runners | Folder | 0750 |
|
|
| Utils | Folder | 0750 |
|
|
| Elementor.php | File | 4.94 KB | 0640 |
|
| Form.php | File | 1.16 KB | 0640 |
|
| FullSiteImport.php | File | 55.64 KB | 0640 |
|
| Import.php | File | 2.9 KB | 0640 |
|
| LogHelper.php | File | 4 KB | 0640 |
|
| URL.php | File | 1.64 KB | 0640 |
|
| WPImport.php | File | 57.02 KB | 0640 |
|