WordPress.org

Make WordPress Core

Ticket #20419: 20419-override-post_status.patch

File 20419-override-post_status.patch, 1.3 KB (added by mintindeed, 21 months ago)

new patch - preferred

  • wp-includes/post.php

     
    28332833 * @return string unique slug for the post, based on $post_name (with a -1, -2, etc. suffix) 
    28342834 */ 
    28352835function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) { 
    2836         if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) 
     2836        if ( 'sample-' === substr( $post_status, 0, 7) ) 
     2837                $post_status = substr( $post_status, 7, strlen($post_status) ); 
     2838        elseif ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) 
    28372839                return $slug; 
    28382840 
    28392841        global $wpdb, $wp_rewrite; 
  • wp-admin/includes/post.php

     
    10341034        if ( !is_null($name) ) 
    10351035                $post->post_name = sanitize_title($name ? $name : $title, $post->ID); 
    10361036 
    1037         $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); 
     1037        $post->post_name = wp_unique_post_slug( $post->post_name, $post->ID, 'sample-' . $post->post_status, $post->post_type, $post->post_parent ); 
    10381038 
    10391039        $post->filter = 'sample'; 
    10401040