Skip to content

Commit

Permalink
Adding ef_fix_post_name_post
Browse files Browse the repository at this point in the history
Adding a new filter to modify the "post name" along with a
wpcom-helper.php function
  • Loading branch information
emrikol committed Apr 14, 2017
1 parent 9fbb3f2 commit b48fec2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/custom-status/custom-status.php
Expand Up @@ -1352,6 +1352,13 @@ function fix_custom_status_timestamp( $data, $postarr ) {
public function fix_post_name( $post_id, $post ) {
global $pagenow;

/*
* Filters the $post object that will be modified
*
* @param $post WP_Post Post object being processed.
*/
$post = apply_filters( 'ef_fix_post_name_post', $post );

// Only modify if we're using a pre-publish status on a supported custom post type
$status_slugs = wp_list_pluck( $this->get_custom_statuses(), 'slug' );
if ( 'post.php' != $pagenow
Expand Down
12 changes: 12 additions & 0 deletions wpcom-helper.php
Expand Up @@ -41,3 +41,15 @@ function edit_flow_wpcom_redirect_canonical( $redirect ) {

return $redirect;
}

// This should fix a caching race condition that can sometimes create a published post with an empty slug
add_filter( 'ef_fix_post_name_post', 'edit_flow_fix_fix_post_name' );
function edit_flow_fix_fix_post_name( $post ) {
global $wpdb;
$post_status = $wpdb->get_var( $wpdb->prepare( 'SELECT post_status FROM ' . $wpdb->posts . ' WHERE ID = %d', $post->ID ) );
if ( null !== $post_status ) {
$post->post_status = $post_status;
}

return $post;
}

0 comments on commit b48fec2

Please sign in to comment.