wp_admin_canonical_url()
Removes single-use URL parameters and create canonical link based on new URL.
Removes specific query string parameters from a URL, create the canonical link, put it in the admin header, and change the current URL to match.
Хуки из функции
Возвращает
null
. Ничего (null).
Использование
wp_admin_canonical_url();
Список изменений
С версии 4.2.0 | Введена. |
Код wp_admin_canonical_url() wp admin canonical url WP 6.7.1
<?php function wp_admin_canonical_url() { $removable_query_args = wp_removable_query_args(); if ( empty( $removable_query_args ) ) { return; } // Ensure we're using an absolute URL. $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); $filtered_url = remove_query_arg( $removable_query_args, $current_url ); /** * Filters the admin canonical URL value. * * @since 6.5.0 * * @param string $filtered_url The admin canonical URL value. */ $filtered_url = apply_filters( 'wp_admin_canonical_url', $filtered_url ); ?> <link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url( $filtered_url ); ?>" /> <script> if ( window.history.replaceState ) { window.history.replaceState( null, null, document.getElementById( 'wp-admin-canonical' ).href + window.location.hash ); } </script> <?php }