Server : Apache System : Linux pod-100823:apache2_74:v0.5.7 5.4.0-1138-gcp #147~18.04.1-Ubuntu SMP Mon Oct 7 21:46:26 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33.7 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system Directory : /nas/content/live/attorneyexperi/wp-content/plugins/diva/src/ |
<?php /** * Class PairedUrl. * * @package AmpProject\AmpWP */ namespace AmpProject\AmpWP; use AmpProject\AmpWP\Infrastructure\Service; /** * Service for manipulating a paired URL. * * @package AmpProject\AmpWP * @since 2.1 */ final class PairedUrl implements Service { /** * Strip paired query var. * * @param string $url URL (or REQUEST_URI). * @return string URL. */ public function remove_query_var( $url ) { $url = remove_query_arg( amp_get_slug(), $url ); $url = str_replace( '?#', '#', $url ); // See <https://core.trac.wordpress.org/ticket/44499>. return $url; } /** * Determine whether the given URL has the endpoint suffix. * * @param string $url URL (or REQUEST_URI). * @return bool Has endpoint suffix. */ public function has_path_suffix( $url ) { $path = wp_parse_url( $url, PHP_URL_PATH ); $pattern = sprintf( ':/%s/?$:', preg_quote( amp_get_slug(), ':' ) ); return (bool) preg_match( $pattern, $path ); } /** * Strip paired endpoint suffix. * * @param string $url URL (or REQUEST_URI). * @return string URL. */ public function remove_path_suffix( $url ) { return preg_replace( sprintf( ':/%s(?=/?(\?|#|$)):', preg_quote( amp_get_slug(), ':' ) ), '', $url ); } /** * Determine whether the given URL has the query var. * * @param string $url URL (or REQUEST_URI). * @return bool Has query var. */ public function has_query_var( $url ) { $parsed_url = wp_parse_url( $url ); if ( ! empty( $parsed_url['query'] ) ) { $query_vars = []; wp_parse_str( $parsed_url['query'], $query_vars ); if ( isset( $query_vars[ amp_get_slug() ] ) ) { return true; } } return false; } /** * Get paired AMP URL using query var (`?amp=1`). * * @param string $url URL (or REQUEST_URI). * @param string $value Value. Defaults to 1. * @return string AMP URL. */ public function add_query_var( $url, $value = '1' ) { return add_query_arg( amp_get_slug(), $value, $url ); } /** * Get paired AMP URL using a endpoint suffix. * * @todo The URL parsing and serialization logic here should ideally be put into a reusable class. * * @param string $url URL (or REQUEST_URI). * @return string AMP URL. */ public function add_path_suffix( $url ) { $url = $this->remove_path_suffix( $url ); $parsed_url = wp_parse_url( $url ); if ( false === $parsed_url ) { $parsed_url = []; } $parsed_url = array_merge( wp_parse_url( home_url( '/' ) ), $parsed_url ); if ( empty( $parsed_url['scheme'] ) ) { $parsed_url['scheme'] = is_ssl() ? 'https' : 'http'; } if ( empty( $parsed_url['host'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $parsed_url['host'] = ! empty( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : 'localhost'; } $parsed_url['path'] = trailingslashit( $parsed_url['path'] ); $parsed_url['path'] .= user_trailingslashit( amp_get_slug(), 'amp' ); $amp_url = $parsed_url['scheme'] . '://'; if ( ! empty( $parsed_url['user'] ) ) { $amp_url .= $parsed_url['user']; if ( ! empty( $parsed_url['pass'] ) ) { $amp_url .= ':' . $parsed_url['pass']; } $amp_url .= '@'; } $amp_url .= $parsed_url['host']; if ( ! empty( $parsed_url['port'] ) ) { $amp_url .= ':' . $parsed_url['port']; } $amp_url .= $parsed_url['path']; if ( ! empty( $parsed_url['query'] ) ) { $amp_url .= '?' . $parsed_url['query']; } if ( ! empty( $parsed_url['fragment'] ) ) { $amp_url .= '#' . $parsed_url['fragment']; } return $amp_url; } }