Make WordPress Core

Ticket #19570: 19570-w-meta-func.diff

File 19570-w-meta-func.diff, 8.5 KB (added by wonderboymusic, 12 years ago)
  • wp-admin/css/wp-admin.css

    diff --git wp-admin/css/wp-admin.css wp-admin/css/wp-admin.css
    index 30c8080..b1340b9 100644
    input#link_url { 
    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;
  • wp-admin/edit-form-advanced.php

    diff --git wp-admin/edit-form-advanced.php wp-admin/edit-form-advanced.php
    index 7d142d9..07393c7 100644
    if ( 'attachment' == $post_type ) { 
    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);
    foreach ( get_object_taxonomies( $post ) as $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
    wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 
    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">
    326 <?php if ( post_type_supports($post_type, 'title') ) { ?>
     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                $class = $post_format == $slug ? 'nav-tab nav-tab-active' : 'nav-tab';
     340
     341                echo '<a class="' . $class . '" href="?format=' . $slug . '" data-wp-format="' . $slug . '">' . $label . '</a>';
     342        }
     343
     344        echo '</h2>';
     345}
     346?>
     347
     348<?php if ( post_type_supports( $post_type, 'title' ) ) { ?>
    327349<div id="titlediv">
    328350<div id="titlewrap">
    329351        <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo apply_filters( 'enter_title_here', __( 'Enter title here' ), $post ); ?></label>
    wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); 
    356378
    357379do_action( 'edit_form_after_title' );
    358380
    359 if ( post_type_supports($post_type, 'editor') ) {
     381// post format fields
     382if ( post_type_supports( $post_type, 'post-formats' ) ) {
     383        $format_meta = get_post_format_meta( $post_ID );
     384?>
     385<div class="post-formats-fields">
     386
     387<input type="hidden" name="post_format" id="post_format" value="<?php echo esc_attr( $post_format ); ?>" />
     388
     389<div class="wp_format_quote">
     390        <label for="_wp_format_quote"><?php _e( 'Quote' ); ?>:</label>
     391        <textarea name="_wp_format_quote" class="widefat"><?php
     392                if ( isset( $format_meta['quote'] ) )
     393                        echo esc_textarea( $format_meta['quote'] ); ?></textarea>
     394</div>
     395
     396<div class="wp_format_quote_source">
     397        <label for="_wp_format_quote_source"><?php _e( 'Source' ); ?>:</label>
     398        <input type="text" name="_wp_format_quote_source" value="<?php
     399                if ( isset( $format_meta['quote_source'] ) )
     400                        echo esc_attr( $format_meta['quote_source'] ); ?>" class="widefat" />
     401</div>
     402
     403<div class="wp_format_url">
     404        <label for="_wp_format_url"><?php _e( 'URL' ); ?>:</label>
     405        <input type="text" name="_wp_format_url" value="<?php
     406                if ( isset( $format_meta['url'] ) )
     407                        echo esc_url( $format_meta['url'] ); ?>" class="widefat" />
     408</div>
     409
     410<div class="wp_format_image">
     411        <label for="_wp_format_image"><?php _e( 'Image' ); ?>:</label>
     412        <input type="text" name="_wp_format_image" value="<?php
     413                if ( isset( $format_meta['image'] ) )
     414                        echo esc_attr( $format_meta['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
     420                if ( isset( $format_meta['gallery'] ) )
     421                        echo esc_attr( $format_meta['gallery'] ); ?>" class="widefat" />
     422</div>
     423
     424<div class="wp_format_media">
     425        <label for="_wp_format_media"><?php _e( 'Media' ); ?>:</label>
     426        <textarea name="_wp_format_media" class="widefat"><?php
     427                if ( isset( $format_meta['media'] ) )
     428                        echo esc_textarea( $format_meta['media'] ); ?></textarea>
     429</div>
     430
     431</div>
     432<?php
     433}
     434
     435if ( post_type_supports( $post_type, 'editor' ) ) {
    360436?>
    361437<div id="postdivrich" class="postarea">
    362438
  • wp-admin/includes/post.php

    diff --git wp-admin/includes/post.php wp-admin/includes/post.php
    index e4866ad..7f61675 100644
    function edit_post( $post_data = null ) { 
    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'] );
     197        }
     198
     199        $format_keys = array( 'quote', 'quote_source', 'image', 'gallery', 'media' );
     200        foreach ( $format_keys as $key ) {
     201                if ( isset( $post_data[ '_wp_format_' . $key ] ) )
     202                        update_post_meta( $post_ID, '_wp_format_' . $key, addslashes( wp_kses_post( stripslashes( $post_data['_wp_format_quote'] ) ) ) );
    200203        }
    201204
     205        if ( isset( $post_data[ '_wp_format_url' ] ) )
     206                update_post_meta( $post_ID, '_wp_format_url', addslashes( esc_url_raw( stripslashes( $post_data['_wp_format_url'] ) ) ) );
     207
    202208        // Meta Stuff
    203209        if ( isset($post_data['meta']) && $post_data['meta'] ) {
    204210                foreach ( $post_data['meta'] as $key => $value ) {
  • wp-admin/js/post.js

    diff --git wp-admin/js/post.js wp-admin/js/post.js
    index 15b7a9f..1e02b98 100644
    jQuery(document).ready( function($) { 
    791791                        });
    792792                });
    793793        }
     794
     795        // Post formats selection
     796        $('.post-format-select a').on( 'click', function(e){
     797                e.preventDefault();
     798                var elem = $(e.currentTarget);
     799                $('.post-format-select a.nav-tab-active').removeClass('nav-tab-active');
     800                elem.addClass('nav-tab-active').blur();
     801                $('#post_format').val(elem.data('wp-format'));
     802                $('#post-body-content').attr('class', 'wp-format-' + elem.data('wp-format'));
     803        });
    794804});