Make WordPress Core

Ticket #24327: 24327.2.diff

File 24327.2.diff, 4.0 KB (added by kovshenin, 13 years ago)
  • wp-admin/includes/screen.php

     
    936936
    937937                $columns = get_column_headers( $this );
    938938                $hidden  = get_hidden_columns( $this );
     939                $post    = get_post();
    939940
    940941                ?>
    941942                <div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>">
     
    962963                                                echo '<label for="wp_welcome_panel-hide">';
    963964                                                echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
    964965                                                echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
    965                                         } elseif ( 'post' == $this->base && post_type_supports( $this->post_type, 'post-formats' ) && apply_filters( 'enable_post_format_ui', true, $GLOBALS['post'] ) ) {
    966                                                 $user_wants = get_user_option( 'post_formats_' . $this->post_type );
    967                                                 if ( false !== $user_wants ) {
    968                                                         // User wants what user gets.
    969                                                         $show_post_format_ui = (bool) $user_wants;
    970                                                 } else {
    971                                                         // UI is shown when the theme supports formats, or if the site has formats assigned to posts.
    972                                                         $show_post_format_ui = current_theme_supports( 'post-formats' ) || get_terms( 'post_format', array( 'number' => 1 ) );
     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 shown
     969                                                // 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                                                else
     974                                                        $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;
    973991                                                }
     992
    974993                                                echo '<label for="show_post_format_ui">';
    975994                                                echo '<input type="checkbox" id="show_post_format_ui"' . checked( $show_post_format_ui, true, false ) . ' />';
    976995                                                echo __( 'Post Formats' ) . "</label>\n";
  • wp-admin/admin-header.php

     
    107107                        $show_post_format_ui = (bool) $post_format_user_option;
    108108                else
    109109                        $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                }
    110127        }
    111128
    112129        if ( $show_post_format_ui )