Make WordPress Core


Ignore:
Timestamp:
01/08/2019 03:46:58 AM (6 years ago)
Author:
pento
Message:

Permalinks: Add a pre_wp_unique_post_slug filter.

Returning a non-null value on this fillter will cause wp_unique_post_slug() to return early with that value, skipping potentially expensive database queries on some sites.

Props coffee2code, javorszky, iCaleb.
Fixes #21112.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r44347 r44454  
    41184118    }
    41194119
     4120    /**
     4121     * Filters the post slug before it is generated to be unique.
     4122     *
     4123     * Returning a non-null value will short-circuit the
     4124     * unique slug generation, returning the passed value instead.
     4125     *
     4126     * @since 5.1.0
     4127     *
     4128     * @param string $override_slug Short-circuit return value.
     4129     * @param string $slug          The desired slug (post_name).
     4130     * @param int    $post_ID       Post ID.
     4131     * @param string $post_status   The post status.
     4132     * @param string $post_type     Post type.
     4133     * @param int    $post_parent   Post parent ID.
     4134     */
     4135    $override_slug = apply_filters( 'pre_wp_unique_post_slug', null, $slug, $post_ID, $post_status, $post_type, $post_parent );
     4136    if ( null !== $override_slug ) {
     4137        return $override_slug;
     4138    }
     4139
    41204140    global $wpdb, $wp_rewrite;
    41214141
Note: See TracChangeset for help on using the changeset viewer.