add_theme_support( 'post-formats', array( 'aside', 'image', 'etc' ) ); Add UI for choosing a post format, and save the choice. see #14746

git-svn-id: http://svn.automattic.com/wordpress/trunk@16174 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2010-11-04 07:41:07 +00:00
parent c9190e667c
commit 17fbb0e123
9 changed files with 81 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -1954,7 +1954,7 @@ input#link_url {
padding: 6px;
}
#post-status-select {
#post-status-select, #post-format {
line-height: 2.5em;
margin-top: 3px;
}

View File

@ -154,6 +154,33 @@ echo esc_html( $visibility_trans ); ?></span>
</div><?php // /misc-pub-section ?>
<?php
$post_formats = get_theme_support( 'post-formats' );
if ( is_array( $post_formats[0] ) ) :
$post_format = get_post_format( $post->ID );
if ( !$post_format )
$post_format = '0';
$post_format_display = ( $post_format ) ? $post_format : __('Default');
?>
<div class="misc-pub-section" id="post-formats"><label for="post-format"><?php _e( 'Format:' ); ?></label>
<b><span id="post-format-display"><?php echo esc_html( $post_format_display ); ?></span></b> <a href="#post-formats-select" class="edit-post-format hide-if-no-js"><?php _e('Edit'); ?></a>
<div id="post-formats-select" class="hide-if-js">
<input type="hidden" id="old-post-format" value="<?php echo esc_attr( $post_format ); ?>" />
<select id="post-format" name="post_format">
<option value="0" <?php selected( $post_format, '0' ); ?>><?php _e('Default'); ?></option>
<?php foreach ( $post_formats[0] as $format ) : ?>
<option value="<?php echo esc_attr( $format ); ?>" <?php selected( $post_format, $format ); ?>><?php echo esc_html( $format ); ?></option>
<?php endforeach; ?>
</select>
<a href="#post-formats" class="save-post-format hide-if-no-js button"><?php _e('OK'); ?></a>
<a href="#post-formats" class="cancel-post-format hide-if-no-js"><?php _e('Cancel'); ?></a>
</div>
</div><?php // /misc-pub-section ?>
<?php endif; ?>
<?php
// translators: Publish box date formt, see http://php.net/date

View File

@ -177,6 +177,19 @@ function edit_post( $post_data = null ) {
}
}
// Post Formats
if ( current_theme_supports( 'post-formats' ) && isset( $post_data['post_format'] ) ) {
$formats = get_theme_support( 'post-formats' );
if ( is_array( $formats ) ) {
$formats = $formats[0];
if ( in_array( $post_data['post_format'], $formats ) ) {
set_post_format( $post_ID, $post_data['post_format'] );
} elseif ( '0' == $post_data['post_format'] ) {
set_post_format( $post_ID, false );
}
}
}
// Meta Stuff
if ( isset($post_data['meta']) && $post_data['meta'] ) {
foreach ( $post_data['meta'] as $key => $value )

View File

@ -484,6 +484,24 @@ jQuery(document).ready( function($) {
updateVisibility();
});
$('.edit-post-format', '#post-formats').click(function () {
$('#post-formats-select').slideDown("normal");
$(this).hide();
});
$('.cancel-post-format', '#post-formats-select').click(function () {
$('#post-formats-select').slideUp("normal");
$('#post-format').val( $('#old-post-format').val() );
$('#post-format-display').text( $('option:selected', '#post-formats-select').text() );
$('.edit-post-format').show();
});
$('.save-post-format', '#post-formats-select').click(function () {
$('#post-formats-select').slideUp("normal");
$('#post-format-display').text( $('option:selected', '#post-formats-select').text() );
$('.edit-post-format').show();
});
$('#timestampdiv').siblings('a.edit-timestamp').click(function() {
if ($('#timestampdiv').is(":hidden")) {
$('#timestampdiv').slideDown("normal");

File diff suppressed because one or more lines are too long

View File

@ -77,6 +77,9 @@ function twentyten_setup() {
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
// Temporarily add Post Format support
add_theme_support( 'post-formats', array( 'aside', 'video', 'image' ) );
// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );

View File

@ -301,7 +301,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' );
$scripts->add_data( 'postbox', 'group', 1 );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20100526' );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20101104' );
$scripts->add_data( 'post', 'group', 1 );
$scripts->localize( 'post', 'postL10n', array(
'tagsUsed' => __('Tags used on this post:'),
@ -467,7 +467,7 @@ function wp_default_styles( &$styles ) {
// Any rtl stylesheets that don't have a .dev version for ltr
$no_suffix = array( 'farbtastic' );
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20101027' );
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20101104' );
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20101102' );
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );

View File

@ -1665,6 +1665,21 @@ function add_theme_support( $feature ) {
$_wp_theme_features[$feature] = array_slice( func_get_args(), 1 );
}
/**
* Gets the theme support arguments passed when registering that support
*
* @since 3.1
* @param string $feature the feature to check
* @return array The array of extra arguments
*/
function get_theme_support( $feature ) {
global $_wp_theme_features;
if ( !isset( $_wp_theme_features[$feature] ) )
return false;
else
return $_wp_theme_features[$feature];
}
/**
* Allows a theme to de-register its support of a certain feature
*