WordPress.org

Make WordPress Core

Ticket #19570: 19570.2.diff

File 19570.2.diff, 8.8 KB (added by helen, 8 years ago)

fields

  • wp-admin/includes/post.php

     
    193193
    194194        // Post Formats
    195195        if ( isset( $post_data['post_format'] ) ) {
    196                 if ( current_theme_supports( 'post-formats', $post_data['post_format'] ) )
    197                         set_post_format( $post_ID, $post_data['post_format'] );
    198                 elseif ( '0' == $post_data['post_format'] )
    199                         set_post_format( $post_ID, false );
     196                set_post_format( $post_ID, $post_data['post_format'] );
    200197        }
    201198
     199        if ( isset( $post_data[ '_wp_format_quote' ] ) ) {
     200                update_post_meta( $post_ID, '_wp_format_quote', addslashes( wp_kses_post( stripslashes( $post_data['_wp_format_quote'] ) ) ) );
     201        }
     202
     203        if ( isset( $post_data[ '_wp_format_quote_source' ] ) ) {
     204                update_post_meta( $post_ID, '_wp_format_quote_source', addslashes( wp_kses_post( stripslashes( $post_data['_wp_format_quote_source'] ) ) ) );
     205        }
     206
     207        if ( isset( $post_data[ '_wp_format_url' ] ) ) {
     208                update_post_meta( $post_ID, '_wp_format_url', addslashes( esc_url_raw( stripslashes( $post_data['_wp_format_url'] ) ) ) );
     209        }
     210
     211        if ( isset( $post_data[ '_wp_format_image' ] ) ) {
     212                update_post_meta( $post_ID, '_wp_format_image', addslashes( wp_kses_post( stripslashes( $post_data['_wp_format_image'] ) ) ) );
     213        }
     214
     215        if ( isset( $post_data[ '_wp_format_gallery' ] ) ) {
     216                update_post_meta( $post_ID, '_wp_format_gallery', addslashes( wp_kses_post( stripslashes( $post_data['_wp_format_gallery'] ) ) ) );
     217        }
     218
     219        if ( isset( $post_data[ '_wp_format_media' ] ) ) {
     220                update_post_meta( $post_ID, '_wp_format_media', addslashes( wp_kses_post( stripslashes( $post_data['_wp_format_media'] ) ) ) );
     221        }
     222
    202223        // Meta Stuff
    203224        if ( isset($post_data['meta']) && $post_data['meta'] ) {
    204225                foreach ( $post_data['meta'] as $key => $value ) {
  • wp-admin/js/post.js

     
    791791                        });
    792792                });
    793793        }
     794
     795        // Post formats selection
     796        $('.post-format-select a').on( 'click', function(e){
     797                e.preventDefault();
     798                var $this = $(this),
     799                        format = $this.data('wpFormat');
     800                $('.post-format-select a.nav-tab-active').removeClass('nav-tab-active');
     801                $this.addClass('nav-tab-active').blur();
     802                $('#post_format').val(format);
     803                $('#post-body-content').attr('class', 'wp-format-' + format );
     804        });
    794805});
  • wp-admin/edit-form-advanced.php

     
    112112        add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' );
    113113}
    114114
    115 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
    116         add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' );
    117 
    118115// all taxonomies
    119116foreach ( get_object_taxonomies( $post ) as $tax_name ) {
    120117        $taxonomy = get_taxonomy($tax_name);
     
    129126                add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name ));
    130127}
    131128
     129// post format
     130$post_format = get_post_format();
     131$format_class = '';
     132if ( ! $post_format && post_type_supports( $post_type, 'post-formats' ) )
     133        $post_format = 'standard';
     134if ( $post_format )
     135        $format_class = " class='wp-format-{$post_format}'";
     136
    132137if ( post_type_supports($post_type, 'page-attributes') )
    133138        add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core');
    134139
     
    322327<div id="poststuff">
    323328
    324329<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
    325 <div id="post-body-content">
     330<div id="post-body-content"<?php echo $format_class; ?>>
     331
     332<?php
     333if ( post_type_supports( $post_type, 'post-formats' ) ) {
     334        $all_post_formats = get_post_format_strings();
     335
     336        echo '<h2 class="nav-tab-wrapper post-format-select">';
     337
     338        foreach ( $all_post_formats as $slug => $label ) {
     339                if ( $post_format == $slug )
     340                        $class = 'nav-tab nav-tab-active';
     341                else
     342                        $class = 'nav-tab';
     343
     344                echo '<a class="' . $class . '" href="?format=' . $slug . '" data-wp-format="' . $slug . '">' . $label . '</a>';
     345        }
     346
     347        echo '</h2>';
     348}
     349?>
     350
    326351<?php if ( post_type_supports($post_type, 'title') ) { ?>
    327352<div id="titlediv">
    328353<div id="titlewrap">
     
    356381
    357382do_action( 'edit_form_after_title' );
    358383
     384// post format fields
     385if ( post_type_supports( $post_type, 'post-formats' ) ) {
     386        $format_quote = get_post_meta( $post_ID, '_wp_format_quote', true );
     387        $format_quote_source = get_post_meta( $post_ID, '_wp_format_quote_source', true );
     388        $format_url = get_post_meta( $post_ID, '_wp_format_url', true );
     389        $format_image = get_post_meta( $post_ID, '_wp_format_image', true );
     390        $format_gallery = get_post_meta( $post_ID, '_wp_format_gallery', true );
     391        $format_media = get_post_meta( $post_ID, '_wp_format_media', true );
     392?>
     393<div class="post-formats-fields">
     394
     395<input type="hidden" name="post_format" id="post_format" value="<?php echo esc_attr( $post_format ); ?>" />
     396
     397<div class="wp_format_quote">
     398        <label for="_wp_format_quote"><?php _e( 'Quote' ); ?>:</label>
     399        <textarea name="_wp_format_quote" class="widefat"><?php echo esc_textarea( $format_quote ); ?></textarea>
     400</div>
     401
     402<div class="wp_format_quote_source">
     403        <label for="_wp_format_quote_source"><?php _e( 'Source' ); ?>:</label>
     404        <input type="text" name="_wp_format_quote_source" value="<?php echo esc_attr( $format_quote_source ); ?>" class="widefat" />
     405</div>
     406
     407<div class="wp_format_url">
     408        <label for="_wp_format_url"><?php _e( 'URL' ); ?>:</label>
     409        <input type="text" name="_wp_format_url" value="<?php echo esc_url( $format_url ); ?>" class="widefat" />
     410</div>
     411
     412<div class="wp_format_image">
     413        <label for="_wp_format_image"><?php _e( 'Image' ); ?>:</label>
     414        <input type="text" name="_wp_format_image" value="<?php echo esc_attr( $format_image ); ?>" class="widefat" />
     415</div>
     416
     417<div class="wp_format_gallery">
     418        <label for="_wp_format_gallery"><?php _e( 'Gallery' ); ?>:</label>
     419        <input type="text" name="_wp_format_gallery" value="<?php echo esc_attr( $format_gallery ); ?>" class="widefat" />
     420</div>
     421
     422<div class="wp_format_media">
     423        <label for="_wp_format_media"><?php _e( 'Media' ); ?>:</label>
     424        <textarea name="_wp_format_media" class="widefat"><?php echo esc_textarea( $format_media ); ?></textarea>
     425</div>
     426
     427</div>
     428<?php
     429}
     430
    359431if ( post_type_supports($post_type, 'editor') ) {
    360432?>
    361433<div id="postdivrich" class="postarea">
  • wp-admin/css/wp-admin.css

     
    30893089        margin: 2px 0 2px -2px;
    30903090}
    30913091
    3092 #post-status-select, #post-format {
     3092#post-status-select {
    30933093        line-height: 2.5em;
    30943094        margin-top: 3px;
    30953095}
    30963096
     3097/* Post formats form */
     3098#post-body-content.wp-format-standard .post-formats-fields,
     3099#post-body-content.wp-format-aside .post-formats-fields,
     3100#post-body-content.wp-format-status .post-formats-fields,
     3101#post-body-content.wp-format-chat .post-formats-fields,
     3102#post-body-content.wp-format-link .wp_format_quote,
     3103#post-body-content.wp-format-gallery .wp_format_quote,
     3104#post-body-content.wp-format-image .wp_format_quote,
     3105#post-body-content.wp-format-video .wp_format_quote,
     3106#post-body-content.wp-format-audio .wp_format_quote,
     3107#post-body-content.wp-format-link .wp_format_quote_source,
     3108#post-body-content.wp-format-gallery .wp_format_quote_source,
     3109#post-body-content.wp-format-image .wp_format_quote_source,
     3110#post-body-content.wp-format-video .wp_format_quote_source,
     3111#post-body-content.wp-format-audio .wp_format_quote_source,
     3112#post-body-content.wp-format-gallery .wp_format_url,
     3113#post-body-content.wp-format-video .wp_format_url,
     3114#post-body-content.wp-format-audio .wp_format_url,
     3115#post-body-content.wp-format-link .wp_format_image,
     3116#post-body-content.wp-format-gallery .wp_format_image,
     3117#post-body-content.wp-format-quote .wp_format_image,
     3118#post-body-content.wp-format-video .wp_format_image,
     3119#post-body-content.wp-format-audio .wp_format_image,
     3120#post-body-content.wp-format-link .wp_format_gallery,
     3121#post-body-content.wp-format-image .wp_format_gallery,
     3122#post-body-content.wp-format-quote .wp_format_gallery,
     3123#post-body-content.wp-format-video .wp_format_gallery,
     3124#post-body-content.wp-format-audio .wp_format_gallery,
     3125#post-body-content.wp-format-link .wp_format_media,
     3126#post-body-content.wp-format-gallery .wp_format_media,
     3127#post-body-content.wp-format-image .wp_format_media,
     3128#post-body-content.wp-format-quote .wp_format_media {
     3129        display: none;
     3130}
     3131
    30973132/* Post Screen */
    30983133#post-body #normal-sortables {
    30993134        min-height: 50px;