Changeset 24388
- Timestamp:
- 05/30/2013 09:33:46 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r24092 r24388 57 57 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 58 58 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 59 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'show-post-format-ui',59 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 60 60 ); 61 61 -
trunk/wp-admin/admin-header.php
r24373 r24388 96 96 97 97 $admin_body_class .= ' wp-format-' . $post_format; 98 99 $show_post_format_ui = false;100 101 if ( apply_filters( 'enable_post_format_ui', true, $post ) ) {102 103 // If the user has explicitly set a screen option, use it, otherwise the UI is shown104 // when the theme supports formats, or if the site has formats assigned to posts.105 $post_format_user_option = get_user_option( 'post_formats_' . $post->post_type );106 if ( false !== $post_format_user_option )107 $show_post_format_ui = (bool) $post_format_user_option;108 else109 $show_post_format_ui = current_theme_supports( 'post-formats' ) || (bool) get_terms( 'post_format', array( 'number' => 1 ) );110 111 if ( ! $show_post_format_ui ) {112 $meta = get_post_format_meta( $post->ID );113 $format_meta_keys = array(114 'link' => array( 'linkurl' ),115 'image' => array( 'url', 'image' ),116 'quote' => array( 'quote_source_name', 'quote_source_url' ),117 'video' => array( 'video_embed' ),118 'audio' => array( 'audio_embed' ),119 );120 121 // If there's any structured post format data, enforce the UI display.122 $format_meta_keys = isset( $format_meta_keys[ get_post_format() ] ) ? $format_meta_keys[ get_post_format() ] : array();123 foreach ( $format_meta_keys as $key )124 if ( ! empty( $meta[ $key ] ) )125 $show_post_format_ui = true;126 }127 }128 129 if ( $show_post_format_ui )130 $admin_body_class .= ' wp-post-format-show-ui';131 98 } 132 99 -
trunk/wp-admin/edit-form-advanced.php
r24373 r24388 113 113 } 114 114 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 115 118 // all taxonomies 116 119 foreach ( get_object_taxonomies( $post ) as $tax_name ) { … … 125 128 else 126 129 add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name )); 127 }128 129 // post format130 $format_class = '';131 $post_format = '';132 $post_format_options = '';133 if ( post_type_supports( $post_type, 'post-formats' ) && apply_filters( 'enable_post_format_ui', true, $post ) ) {134 wp_enqueue_script( 'post-formats' );135 wp_enqueue_script( 'wp-mediaelement' );136 wp_enqueue_style( 'wp-mediaelement' );137 $post_format = get_post_format();138 139 if ( ! empty( $_REQUEST['format'] ) && in_array( $_REQUEST['format'], get_post_format_slugs() ) )140 $post_format = $_REQUEST['format'];141 142 if ( ! $post_format )143 $post_format = 'standard';144 145 $format_class = " class='wp-format-{$post_format}'";146 147 $all_post_formats = array(148 'standard' => array (149 'description' => __( 'Use the editor below to compose your post.' )150 ),151 'image' => array (152 'description' => __( 'Select or upload an image for your post.' )153 ),154 'gallery' => array (155 'description' => __( 'Use the Add Media button to select or upload images for your gallery.' )156 ),157 'link' => array (158 'description' => __( 'Add a link title and destination URL. Use the editor to compose optional text to accompany the link.' )159 ),160 'video' => array (161 'description' => __( 'Select or upload a video, or paste a video embed code into the box.' )162 ),163 'audio' => array (164 'description' => __( 'Select or upload an audio file, or paste an audio embed code into the box.' )165 ),166 'chat' => array (167 'description' => __( 'Copy a chat or Q&A transcript into the editor.' )168 ),169 'status' => array (170 'description' => __( 'Use the editor to compose a status update. What’s new?' )171 ),172 'quote' => array (173 'description' => __( 'Add a source name and link if you have them. Use the editor to compose the quote.' )174 ),175 'aside' => array (176 'description' => __( 'Use the editor to share a quick thought or side topic.' )177 )178 );179 180 foreach ( $all_post_formats as $slug => $attr ) {181 $class = '';182 if ( $post_format == $slug ) {183 $class = 'class="active"';184 $active_post_type_slug = $slug;185 }186 187 $url = add_query_arg( 'format', $slug );188 189 $post_format_options .= '<a ' . $class . ' href="' . esc_url( $url ) . '" data-description="' . $attr['description'] . '" data-wp-format="' . $slug . '" title="' . ucfirst( $slug ) . '"><div class="' . $slug . '"></div><span class="post-format-title">' . ucfirst( $slug ) . '</span></a>';190 }191 192 $current_post_format = array( 'currentPostFormat' => esc_html( $active_post_type_slug ) );193 wp_localize_script( 'post-formats', 'postFormats', $current_post_format );194 130 } 195 131 … … 380 316 <p><?php _e("You have lost your connection with the server, and saving has been disabled. This message will vanish once you've reconnected."); ?></p> 381 317 </div> 382 <?php if ( ! empty( $post_format_options ) ) : ?> 383 <div class="wp-post-format-ui"> 384 <div class="post-format-options"> 385 <?php echo $post_format_options; ?> 386 </div> 387 </div> 388 <?php endif; ?> 318 389 319 <form name="post" action="post.php" method="post" id="post"<?php do_action('post_edit_form_tag'); ?>> 390 320 <?php wp_nonce_field($nonce_action); ?> … … 412 342 <div id="poststuff"> 413 343 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 414 <div id="post-body-content"<?php echo $format_class; ?>> 415 <?php if ( ! empty( $all_post_formats ) ) : ?> 416 <div class="wp-post-format-ui"> 417 <div class="post-format-change"><span class="icon <?php echo esc_attr( 'wp-format-' . $post_format ); ?>"></span> <span class="post-format-description"><?php echo $all_post_formats[$post_format]['description']; ?></span></div> 418 </div> 419 <?php endif; ?> 344 <div id="post-body-content"> 345 420 346 <?php if ( post_type_supports($post_type, 'title') ) { ?> 421 347 <div id="titlediv"> … … 457 383 } 458 384 459 // post format fields460 if ( post_type_supports( $post_type, 'post-formats' ) && apply_filters( 'enable_post_format_ui', true, $post ) )461 require_once( './includes/post-formats.php' );462 463 385 if ( post_type_supports($post_type, 'editor') ) { 464 386 ?> … … 468 390 'dfw' => true, 469 391 'tabfocus_elements' => 'insert-media-button,save-post', 470 'editor_height' => in_array( $post_format, array( 'status', 'aside' ) ) ? 120 : 360392 'editor_height' => 360, 471 393 ) ); ?> 472 394 <table id="post-status-info" cellspacing="0"><tbody><tr> -
trunk/wp-admin/includes/ajax-actions.php
r24263 r24388 1127 1127 } 1128 1128 1129 function wp_ajax_show_post_format_ui() {1130 if ( empty( $_POST['post_type'] ) )1131 wp_die( 0 );1132 1133 check_ajax_referer( 'show-post-format-ui_' . $_POST['post_type'], 'nonce' );1134 1135 if ( ! $post_type_object = get_post_type_object( $_POST['post_type'] ) )1136 wp_die( 0 );1137 1138 if ( ! current_user_can( $post_type_object->cap->edit_posts ) )1139 wp_die( -1 );1140 1141 update_user_option( get_current_user_id(), 'post_formats_' . $post_type_object->name, empty( $_POST['show'] ) ? 0 : 1 );1142 1143 wp_die( 1 );1144 }1145 1146 1129 function wp_ajax_hidden_columns() { 1147 1130 check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); -
trunk/wp-admin/includes/post.php
r24304 r24388 1291 1291 $new_autosave['post_author'] = $post_author; 1292 1292 1293 // Auto-save revisioned meta fields.1294 foreach ( _wp_post_revision_meta_keys() as $meta_key ) {1295 if ( isset( $_POST[ $meta_key ] ) && get_post_meta( $new_autosave['ID'], $meta_key, true ) != $_POST[ $meta_key ] ) {1296 // Use the underlying delete_metadata and add_metadata vs delete_post_meta1297 // and add_post_meta to make sure we're working with the actual revision meta.1298 delete_metadata( 'post', $new_autosave['ID'], $meta_key );1299 1300 if ( ! empty( $_POST[ $meta_key ] ) )1301 add_metadata( 'post', $new_autosave['ID'], $meta_key, $_POST[ $meta_key ] );1302 }1303 }1304 1305 // Save the post format if different1306 if ( isset( $_POST['post_format'] ) && get_post_meta( $new_autosave['ID'], '_revision_post_format', true ) != $_POST['post_format'] ) {1307 delete_metadata( 'post', $new_autosave['ID'], '_revision_post_format' );1308 1309 if ( ! empty( $_POST['post_format'] ) )1310 add_metadata( 'post', $new_autosave['ID'], '_revision_post_format', $_POST['post_format'] );1311 }1312 1313 1293 return wp_update_post( $new_autosave ); 1314 1294 } -
trunk/wp-admin/includes/screen.php
r24282 r24388 964 964 echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />'; 965 965 echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; 966 } elseif ( 'post' == $this->base && post_type_supports( $this->post_type, 'post-formats' ) && apply_filters( 'enable_post_format_ui', true, $post ) ) {967 968 // If the user has explicitly set a screen option, use it, otherwise the UI is shown969 // when the theme supports formats, or if the site has formats assigned to posts.970 $post_format_user_option = get_user_option( 'post_formats_' . $post->post_type );971 if ( false !== $post_format_user_option )972 $show_post_format_ui = (bool) $post_format_user_option;973 else974 $show_post_format_ui = current_theme_supports( 'post-formats' ) || (bool) get_terms( 'post_format', array( 'number' => 1 ) );975 976 if ( ! $show_post_format_ui && 'auto-draft' != $post->post_status ) {977 $meta = get_post_format_meta( $post->ID );978 $format_meta_keys = array(979 'link' => array( 'linkurl' ),980 'image' => array( 'url', 'image' ),981 'quote' => array( 'quote_source_name', 'quote_source_url' ),982 'video' => array( 'video_embed' ),983 'audio' => array( 'audio_embed' ),984 );985 986 // If there's any structured post format data, enforce the UI display.987 $format_meta_keys = isset( $format_meta_keys[ get_post_format() ] ) ? $format_meta_keys[ get_post_format() ] : array();988 foreach ( $format_meta_keys as $key )989 if ( ! empty( $meta[ $key ] ) )990 $show_post_format_ui = true;991 }992 993 echo '<label for="show_post_format_ui">';994 echo '<input type="checkbox" id="show_post_format_ui"' . checked( $show_post_format_ui, true, false ) . ' />';995 echo __( 'Post Formats' ) . "</label>\n";996 966 } 997 967 ?> -
trunk/wp-includes/post.php
r24301 r24388 2677 2677 2678 2678 $maybe_empty = ! $post_content && ! $post_title && ! $post_excerpt && post_type_supports( $post_type, 'editor' ) 2679 && post_type_supports( $post_type, 'title' ) && post_type_supports( $post_type, 'excerpt' ) 2680 && ! in_array( get_post_format( $post_ID ), array( 'audio', 'video', 'quote', 'image' ) ); 2679 && post_type_supports( $post_type, 'title' ) && post_type_supports( $post_type, 'excerpt' ); 2681 2680 2682 2681 if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) { -
trunk/wp-includes/script-loader.php
r24369 r24388 416 416 ) ); 417 417 418 $scripts->add( 'post-formats', "/wp-admin/js/post-formats$suffix.js", array( 'media-models', 'wp-plupload' ), false, 1 );419 420 418 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 ); 421 419
Note: See TracChangeset
for help on using the changeset viewer.