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: https://develop.svn.wordpress.org/trunk@16174 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith
2010-11-04 07:41:07 +00:00
parent 8b0f87ebfd
commit ef54c47f7a
9 changed files with 81 additions and 5 deletions
File diff suppressed because one or more lines are too long
+1 -1
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;
}
+27
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
+13
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 )
+18
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");
+1 -1
View File
File diff suppressed because one or more lines are too long