WordPress.org

Ready to get started?Download WordPress

Forums

Latest Custom Post Type Updates
[resolved] Bug - in_array() datatype conflict (1 post)

  1. Eric McNiece
    Member
    Posted 1 year ago #

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/site/public_html/rsl.site.ca/wp-content/plugins/latest-custom-post-type-updates/options.php on line 190
    /> Posts

    Local function appears as so:

    <p> <!-- POST TYPE FOR WIDGET -->
        <label 	for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Types:'); ?></label>
            <?php
            // Filter out post types that are internal such as attachments or internal theme post types used for options.
            $args = array(
                'show_ui' => true,
            );
            $post_types = get_post_types($args, 'objects');
            foreach($post_types as $post_type=>$vars) {
                echo '<br /><input type="checkbox"
    				name="'.$this->get_field_name('post_type').'[]"
    				value="'.$post_type.'"';
                	if( in_array($post_type, $instance['post_type'] ) ) echo 'checked="checked"';
                echo ' /> '.$vars->labels->name.'';
            }
            ?>
        </select>
    </p>

    Suggested fix: Check is_array() before executing in_array().

    <p> <!-- POST TYPE FOR WIDGET -->
        <label 	for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Types:'); ?></label>
            <?php
            // Filter out post types that are internal such as attachments or internal theme post types used for options.
            $args = array(
                'show_ui' => true,
            );
            $post_types = get_post_types($args, 'objects');
            foreach($post_types as $post_type=>$vars) {
                echo '<br /><input type="checkbox"
    				name="'.$this->get_field_name('post_type').'[]"
    				value="'.$post_type.'"';
    				if( is_array( $instance['post_type'])){
    	            	if( in_array($post_type, $instance['post_type'] ) ) echo 'checked="checked"';
    				}
                echo ' /> '.$vars->labels->name.'';
            }
            ?>
        </select>
    </p>

    http://wordpress.org/extend/plugins/latest-custom-post-type-updates/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.