Make WordPress Core


Ignore:
Timestamp:
12/03/2012 02:38:10 AM (13 years ago)
Author:
nacin
Message:

Bring Featured Images back into the main media dialog.

Most users don't realize that the Featured Image meta box exists; if they do, few use it.

Restores the old meta box UI, including the admin_post_thumbnail_html filter. If a plugin is using _wp_post_thumbnail_html() in conjunction with Thickbox elsewhere, it will also magically still work.

Specific underlying changes:

  • Converts the modal view to use the view manager, which means that a call to open() will automatically call render and attach if necessary.
  • Doesn't automatically set a state in wp.media, to allow code to customize the states to be added before activation.

props koopersmith.
fixes #21776.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ajax-actions.php

    r22967 r22979  
    16751675
    16761676function wp_ajax_set_post_thumbnail() {
     1677    $json = ! empty( $_REQUEST['json'] );
     1678
    16771679    $post_ID = intval( $_POST['post_id'] );
    1678     if ( !current_user_can( 'edit_post', $post_ID ) )
    1679         wp_die( -1 );
     1680    if ( !current_user_can( 'edit_post', $post_ID ) ) {
     1681        $json ? wp_send_json_error() : wp_die( -1 );
     1682    }
    16801683    $thumbnail_id = intval( $_POST['thumbnail_id'] );
    16811684
     
    16831686
    16841687    if ( $thumbnail_id == '-1' ) {
    1685         if ( delete_post_thumbnail( $post_ID ) )
    1686             wp_die( _wp_post_thumbnail_html( null, $post_ID ) );
    1687         else
    1688             wp_die( 0 );
    1689     }
    1690 
    1691     if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )
    1692         wp_die( _wp_post_thumbnail_html( $thumbnail_id, $post_ID ) );
    1693     wp_die( 0 );
     1688        if ( delete_post_thumbnail( $post_ID ) ) {
     1689            $return = _wp_post_thumbnail_html( null, $post_ID );
     1690            $json ? wp_send_json_success( $return ) : wp_die( $return );
     1691        } else {
     1692            $json ? wp_send_json_error() : wp_die( 0 );
     1693        }
     1694    }
     1695
     1696    if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) {
     1697        $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
     1698        $json ? wp_send_json_success( $return ) : wp_die( $return );
     1699    }
     1700
     1701    $json ? wp_send_json_error() : wp_die( 0 );
    16941702}
    16951703
Note: See TracChangeset for help on using the changeset viewer.