rebase on oct-10-2023
This commit is contained in:
@@ -222,7 +222,7 @@ function get_permalink( $post = 0, $leavename = false ) {
|
||||
) {
|
||||
|
||||
$category = '';
|
||||
if ( strpos( $permalink, '%category%' ) !== false ) {
|
||||
if ( str_contains( $permalink, '%category%' ) ) {
|
||||
$cats = get_the_category( $post->ID );
|
||||
if ( $cats ) {
|
||||
$cats = wp_list_sort(
|
||||
@@ -249,8 +249,10 @@ function get_permalink( $post = 0, $leavename = false ) {
|
||||
$category = get_category_parents( $category_object->parent, false, '/', true ) . $category;
|
||||
}
|
||||
}
|
||||
// Show default category in permalinks,
|
||||
// without having to assign it explicitly.
|
||||
/*
|
||||
* Show default category in permalinks,
|
||||
* without having to assign it explicitly.
|
||||
*/
|
||||
if ( empty( $category ) ) {
|
||||
$default_category = get_term( get_option( 'default_category' ), 'category' );
|
||||
if ( $default_category && ! is_wp_error( $default_category ) ) {
|
||||
@@ -260,13 +262,15 @@ function get_permalink( $post = 0, $leavename = false ) {
|
||||
}
|
||||
|
||||
$author = '';
|
||||
if ( strpos( $permalink, '%author%' ) !== false ) {
|
||||
if ( str_contains( $permalink, '%author%' ) ) {
|
||||
$authordata = get_userdata( $post->post_author );
|
||||
$author = $authordata->user_nicename;
|
||||
}
|
||||
|
||||
// This is not an API call because the permalink is based on the stored post_date value,
|
||||
// which should be parsed as local time regardless of the default PHP timezone.
|
||||
/*
|
||||
* This is not an API call because the permalink is based on the stored post_date value,
|
||||
* which should be parsed as local time regardless of the default PHP timezone.
|
||||
*/
|
||||
$date = explode( ' ', str_replace( array( '-', ':' ), ' ', $post->post_date ) );
|
||||
|
||||
$rewritereplace = array(
|
||||
@@ -496,13 +500,13 @@ function get_attachment_link( $post = null, $leavename = false ) {
|
||||
$parentlink = get_permalink( $post->post_parent );
|
||||
}
|
||||
|
||||
if ( is_numeric( $post->post_name ) || false !== strpos( get_option( 'permalink_structure' ), '%category%' ) ) {
|
||||
if ( is_numeric( $post->post_name ) || str_contains( get_option( 'permalink_structure' ), '%category%' ) ) {
|
||||
$name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker.
|
||||
} else {
|
||||
$name = $post->post_name;
|
||||
}
|
||||
|
||||
if ( strpos( $parentlink, '?' ) === false ) {
|
||||
if ( ! str_contains( $parentlink, '?' ) ) {
|
||||
$link = user_trailingslashit( trailingslashit( $parentlink ) . '%postname%' );
|
||||
}
|
||||
|
||||
@@ -692,7 +696,7 @@ function get_feed_link( $feed = '' ) {
|
||||
$permalink = $wp_rewrite->get_feed_permastruct();
|
||||
|
||||
if ( $permalink ) {
|
||||
if ( false !== strpos( $feed, 'comments_' ) ) {
|
||||
if ( str_contains( $feed, 'comments_' ) ) {
|
||||
$feed = str_replace( 'comments_', '', $feed );
|
||||
$permalink = $wp_rewrite->get_comment_feed_permastruct();
|
||||
}
|
||||
@@ -709,7 +713,7 @@ function get_feed_link( $feed = '' ) {
|
||||
$feed = get_default_feed();
|
||||
}
|
||||
|
||||
if ( false !== strpos( $feed, 'comments_' ) ) {
|
||||
if ( str_contains( $feed, 'comments_' ) ) {
|
||||
$feed = str_replace( 'comments_', 'comments-', $feed );
|
||||
}
|
||||
|
||||
@@ -1435,9 +1439,11 @@ function get_preview_post_link( $post = null, $query_args = array(), $preview_li
|
||||
* Retrieves the edit post link for post.
|
||||
*
|
||||
* Can be used within the WordPress loop or outside of it. Can be used with
|
||||
* pages, posts, attachments, and revisions.
|
||||
* pages, posts, attachments, revisions, global styles, templates, and template parts.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @since 6.3.0 Adds custom link for wp_navigation post types.
|
||||
* Adds custom links for wp_template_part and wp_template post types.
|
||||
*
|
||||
* @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`.
|
||||
* @param string $context Optional. How to output the '&' character. Default '&'.
|
||||
@@ -1469,10 +1475,15 @@ function get_edit_post_link( $post = 0, $context = 'display' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $post_type_object->_edit_link ) {
|
||||
$link = '';
|
||||
|
||||
if ( 'wp_template' === $post->post_type || 'wp_template_part' === $post->post_type ) {
|
||||
$slug = urlencode( get_stylesheet() . '//' . $post->post_name );
|
||||
$link = admin_url( sprintf( $post_type_object->_edit_link, $post->post_type, $slug ) );
|
||||
} elseif ( 'wp_navigation' === $post->post_type ) {
|
||||
$link = admin_url( sprintf( $post_type_object->_edit_link, (string) $post->ID ) );
|
||||
} elseif ( $post_type_object->_edit_link ) {
|
||||
$link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) );
|
||||
} else {
|
||||
$link = '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1817,7 +1828,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
|
||||
|
||||
if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {
|
||||
// Back-compat, $excluded_terms used to be $excluded_categories with IDs separated by " and ".
|
||||
if ( false !== strpos( $excluded_terms, ' and ' ) ) {
|
||||
if ( str_contains( $excluded_terms, ' and ' ) ) {
|
||||
_deprecated_argument(
|
||||
__FUNCTION__,
|
||||
'3.3.0',
|
||||
@@ -1984,7 +1995,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
|
||||
}
|
||||
$cache_key = "adjacent_post:$key:$last_changed";
|
||||
|
||||
$result = wp_cache_get( $cache_key, 'posts' );
|
||||
$result = wp_cache_get( $cache_key, 'post-queries' );
|
||||
if ( false !== $result ) {
|
||||
if ( $result ) {
|
||||
$result = get_post( $result );
|
||||
@@ -1997,7 +2008,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
|
||||
$result = '';
|
||||
}
|
||||
|
||||
wp_cache_set( $cache_key, $result, 'posts' );
|
||||
wp_cache_set( $cache_key, $result, 'post-queries' );
|
||||
|
||||
if ( $result ) {
|
||||
$result = get_post( $result );
|
||||
@@ -3021,7 +3032,7 @@ function _navigation_markup( $links, $css_class = 'posts-navigation', $screen_re
|
||||
*/
|
||||
$template = apply_filters( 'navigation_markup_template', $template, $css_class );
|
||||
|
||||
return sprintf( $template, sanitize_html_class( $css_class ), esc_html( $screen_reader_text ), $links, esc_html( $aria_label ) );
|
||||
return sprintf( $template, sanitize_html_class( $css_class ), esc_html( $screen_reader_text ), $links, esc_attr( $aria_label ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3636,7 +3647,7 @@ function plugins_url( $path = '', $plugin = '' ) {
|
||||
$plugin = wp_normalize_path( $plugin );
|
||||
$mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
|
||||
|
||||
if ( ! empty( $plugin ) && 0 === strpos( $plugin, $mu_plugin_dir ) ) {
|
||||
if ( ! empty( $plugin ) && str_starts_with( $plugin, $mu_plugin_dir ) ) {
|
||||
$url = WPMU_PLUGIN_URL;
|
||||
} else {
|
||||
$url = WP_PLUGIN_URL;
|
||||
@@ -3888,7 +3899,7 @@ function set_url_scheme( $url, $scheme = null ) {
|
||||
}
|
||||
|
||||
$url = trim( $url );
|
||||
if ( substr( $url, 0, 2 ) === '//' ) {
|
||||
if ( str_starts_with( $url, '//' ) ) {
|
||||
$url = 'http:' . $url;
|
||||
}
|
||||
|
||||
@@ -4427,7 +4438,7 @@ function get_avatar_data( $id_or_email, $args = null ) {
|
||||
if ( is_numeric( $id_or_email ) ) {
|
||||
$user = get_user_by( 'id', absint( $id_or_email ) );
|
||||
} elseif ( is_string( $id_or_email ) ) {
|
||||
if ( strpos( $id_or_email, '@md5.gravatar.com' ) ) {
|
||||
if ( str_contains( $id_or_email, '@md5.gravatar.com' ) ) {
|
||||
// MD5 hash.
|
||||
list( $email_hash ) = explode( '@', $id_or_email );
|
||||
} else {
|
||||
@@ -4722,7 +4733,7 @@ function get_the_privacy_policy_link( $before = '', $after = '' ) {
|
||||
/**
|
||||
* Returns an array of URL hosts which are considered to be internal hosts.
|
||||
*
|
||||
* By default the list of internal hosts is comproside of the PHP_URL_HOST of
|
||||
* By default the list of internal hosts is comprised of the host name of
|
||||
* the site's home_url() (as parsed by wp_parse_url()).
|
||||
*
|
||||
* This list is used when determining if a specificed URL is a link to a page on
|
||||
@@ -4745,7 +4756,7 @@ function wp_internal_hosts() {
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
* @param array $internal_hosts An array of internal URL hostnames.
|
||||
* @param string[] $internal_hosts An array of internal URL hostnames.
|
||||
*/
|
||||
$internal_hosts = apply_filters(
|
||||
'wp_internal_hosts',
|
||||
|
||||
Reference in New Issue
Block a user