Make WordPress Core

Changeset 17065


Ignore:
Timestamp:
12/19/2010 09:12:13 PM (14 years ago)
Author:
nacin
Message:

Support post formats in Press This. fixes #15795, props greuben for initial patch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/press-this.php

    r16900 r17065  
    2828function press_it() {
    2929    // define some basic variables
     30    $quick = array();
    3031    $quick['post_status'] = 'draft'; // set as draft first
    3132    $quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null;
     
    6566        $quick['ID'] = $post_ID;
    6667        wp_update_post($quick);
     68
     69        // Post formats
     70        if ( current_theme_supports( 'post-formats' ) && isset( $_POST['post_format'] ) ) {
     71            $post_formats = get_theme_support( 'post-formats' );
     72            if ( is_array( $post_formats ) ) {
     73                $post_formats = $post_formats[0];
     74                if ( in_array( $_POST['post_format'], $post_formats ) )
     75                    set_post_format( $post_ID, $_POST['post_format'] );
     76                elseif ( '0' == $_POST['post_format'] )
     77                    set_post_format( $post_ID, false );
     78            }
     79        }
     80
    6781    }
    6882    return $post_ID;
     
    469483
    470484            <div id="submitdiv" class="stuffbox">
    471                 <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
    472                     <br/>
    473                 </div>
    474                 <h3><?php _e('Publish') ?></h3>
    475485                <div class="inside">
    476486                    <p>
     
    485495                        <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" id="saving" style="display:none;" />
    486496                    </p>
     497                    <?php if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) :
     498                            $post_formats = get_theme_support( 'post-formats' );
     499                            if ( is_array( $post_formats[0] ) ) :
     500                                $default_format = get_option( 'default_post_format', '0' );
     501                        ?>
     502                    <p>
     503                        <label for="post_format"><?php _e( 'Post Format:' ); ?>
     504                        <select name="post_format" id="post_format">
     505                            <option value="0"><?php _e( 'Standard' ); ?></option>
     506                        <?php foreach ( $post_formats[0] as $format ): ?>
     507                            <option<?php selected( $default_format, $format ); ?> value="<?php echo esc_attr( $format ); ?>"> <?php echo esc_html( get_post_format_string( $format ) ); ?></option>
     508                        <?php endforeach; ?>
     509                        </select></label>
     510                    </p>
     511                    <?php endif; endif; ?>
    487512                </div>
    488513            </div>
Note: See TracChangeset for help on using the changeset viewer.