Make WordPress Core


Ignore:
Timestamp:
01/01/2015 08:34:19 PM (10 years ago)
Author:
wonderboymusic
Message:

If you set '_wp_page_template' for a post, and then switch to a theme that doesn't support the template, subsequent calls to wp_insert_post() will bail early without running a plethora of hooks. This shouldn't happen. We should set the template to 'default' and continue through the rest of the function. The function will still bail if $wp_error is true via wp_insert_post( $arr, true ).

Props nofearinc.
Fixes #25334.

File:
1 edited

Legend:

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

    r30982 r31020  
    34243424            if ( $wp_error ) {
    34253425                return new WP_Error('invalid_page_template', __('The page template is invalid.'));
    3426             } else {
    3427                 return 0;
    34283426            }
    3429         }
    3430         update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
     3427            update_post_meta( $post_ID, '_wp_page_template', 'default' );
     3428        } else {
     3429            update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
     3430        }
    34313431    }
    34323432
Note: See TracChangeset for help on using the changeset viewer.