WordPress.org

Plugin Directory

Changeset 543864


Ignore:
Timestamp:
05/13/12 20:45:58 (2 years ago)
Author:
jeremyfelt
Message:

Fixes issue where saving options when post formats were *not* enabled would cause errors.

Now properly supports themes that have enabled post formats, even those without any additional formats registered.

Location:
automatic-featured-image-posts/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • automatic-featured-image-posts/trunk/automatic-featured-image-posts.php

    r531151 r543864  
    44Plugin URI: http://www.jeremyfelt.com/wordpress/plugins/automatic-featured-image-posts/ 
    55Description: Automatically creates a new post with an assigned featured image from every image upload. 
    6 Version: 0.6 
     6Version: 0.7 
    77Author: Jeremy Felt 
    88Author URI: http://www.jeremyfelt.com 
     
    175175    } 
    176176 
     177    /** 
     178     * Output the text related to selecting the post formats to be assigned when a featured 
     179     * image is automatically added. 
     180     */ 
    177181    public function output_default_post_format_text() { 
    178182        global $_wp_theme_features; 
     
    181185        if ( ! isset( $afip_options[ 'default_post_format' ] ) ) 
    182186            $afip_options[ 'default_post_format' ] = 'standard'; 
    183  
    184187        ?> 
    185188        <select id="afip_default_post_format" name="afip_options[default_post_format]"> 
    186             <option value="standard" <?php selected( $afip_options[ 'default_post_format' ], 'standard' ); ?>>Standard</option> 
    187189            <?php 
    188                 if ( isset( $_wp_theme_features[ 'post-formats' ] ) ) { 
     190                if ( isset( $_wp_theme_features[ 'post-formats' ] ) && is_array( $_wp_theme_features[ 'post-formats' ] ) ) { 
    189191                    foreach ( $_wp_theme_features[ 'post-formats' ] as $post_format_array ){ 
    190192                        foreach ( $post_format_array as $post_format ) { 
    191             ?> 
    192                         <option value="<?php echo esc_attr( $post_format ); ?>" <?php selected( $afip_options[ 'default_post_format' ], esc_attr( $post_format ) ); ?>><?php echo esc_html( ucwords( $post_format ) ); ?></option> 
    193             <?php 
     193                            ?> 
     194                            <option value="<?php echo esc_attr( $post_format ); ?>" <?php selected( $afip_options[ 'default_post_format' ], esc_attr( $post_format ) ); ?>><?php echo esc_html( ucwords( $post_format ) ); ?></option> 
     195                            <?php 
     196                        } 
     197                        if ( ! in_array( 'standard', $post_format_array ) ) { 
     198                            ?> 
     199                            <option value="standard" <?php selected( $afip_options[ 'default_post_format' ], 'standard' ); ?>>Standard</option> 
     200                            <?php 
    194201                        } 
    195202                    } 
     203                } else { 
     204                    ?> 
     205                    <option value="standard" <?php selected( $afip_options[ 'default_post_format' ], 'standard' ); ?>>Standard</option> 
     206                    <?php 
    196207                } 
    197208        ?> 
     
    213224        $valid_post_format_options = array( 'standard' ); 
    214225 
    215         if ( isset( $_wp_theme_features[ 'post-formats' ] ) ) { 
     226        if ( isset( $_wp_theme_features[ 'post-formats' ] ) && is_array( $_wp_theme_features[ 'post-formats' ] ) ) { 
    216227            foreach ( $_wp_theme_features[ 'post-formats' ] as $post_format_array ) { 
    217228                foreach ( $post_format_array as $post_format ) { 
     
    227238            $input[ 'default_post_type' ] = 'post'; 
    228239 
    229         if ( ! in_array( $input[ 'default_post_format' ], $valid_post_format_options ) ) 
     240        if ( isset( $input[ 'default_post_format' ] ) && ! in_array( $input[ 'default_post_format' ], $valid_post_format_options ) ) 
    230241            $input[ 'default_post_format' ] = 'standard'; 
    231242 
     
    264275     * data that WordPress already uses. May be fun to revisit sometime though to allow for more data from Lightroom, etc. 
    265276     * 
    266      * @param $post_id int The post ID of the attachment that was just added from an image uplad. 
     277     * @param $post_id int The post ID of the attachment that was just added from an image upload. 
    267278     * @return mixed Only used when breaking from the script 
    268279     */ 
  • automatic-featured-image-posts/trunk/readme.txt

    r531151 r543864  
    66Requires at least: 3.2.1 
    77Tested up to: 3.4 
    8 Stable tag: 0.6 
     8Stable tag: 0.7 
    99 
    1010Automatic Featured Image Posts creates a new post with a Featured Image every time an image is uploaded. 
     
    6060== Changelog == 
    6161 
     62= 0.7 = 
     63* Fix a couple bugs with saving options when post formats aren't yet enabled. 
     64 
    6265= 0.6 = 
    6366*  Add filters to allow themes and plugins to change the post title, categories, and content before creation 
     
    8790== Upgrade Notice == 
    8891 
     92= 0.7 = 
     93* Bug fixes when saving options while post formats are not enabled 
     94 
    8995= 0.6 = 
    9096*  NEW - Filters added for post title, categories, and content. 
Note: See TracChangeset for help on using the changeset viewer.