Making WordPress.org

Changeset 1473


Ignore:
Timestamp:
04/08/2015 07:13:30 PM (10 years ago)
Author:
obenland
Message:

WP.org Themes: Avoid updating the post date when a theme gets published after having been reinstated.

See https://wordpress.slack.com/archives/meta/p1428484661000249

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/admin-edit.php

    r1470 r1473  
    223223        'post_status' => 'draft',
    224224    ) );
     225
     226    /*
     227     * Mark it as reinstated, so the post date doesn't get overwritten when it's
     228     * published again.
     229     */
     230    add_post_meta( $post_id, '_wporg_themes_reinstated', true );
    225231
    226232    wp_redirect( add_query_arg( 'reinstated', 1, remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids', 'suspended' ), wp_get_referer() ) ) );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r1470 r1473  
    373373        $content = sprintf( __( 'Congratulations, your new theme %1$s is now available to the public at %2$s.', 'wporg-themes' ), $post->post_title, "https://wordpress.org/themes/{$post->post_name}" ) . "\n\n";
    374374
    375         /*
    376          * First time approval: Publish the theme.
    377          *
    378          * Uses `wp_update_post()` to also update post_time.
    379          */
    380         $post_date = current_time( 'mysql' );
    381         wp_update_post( array(
    382             'ID'            => $post_id,
    383             'post_status'   => 'publish',
    384             'post_date'     => $post_date,
    385             'post_date_gmt' => $post_date,
    386         ) );
     375        // First time approval: Publish the theme.
     376        $post_args = array(
     377            'ID'          => $post_id,
     378            'post_status' => 'publish',
     379        );
     380
     381        // Update post_time if it wasn't suspended before.
     382        if ( get_post_meta( $post_id, '_wporg_themes_reinstated', true ) ) {
     383            delete_post_meta( $post_id, '_wporg_themes_reinstated' );
     384        } else {
     385            $post_date = current_time( 'mysql' );
     386
     387            $post_args['post_date']     = $post_date;
     388            $post_args['post_date_gmt'] = $post_date;
     389        }
     390
     391        wp_update_post( $post_args );
    387392    }
    388393
Note: See TracChangeset for help on using the changeset viewer.