Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Code is the problem or is a Google Chrome issue?

Here is the code:

/*-----------------------------------------------------------------------------------*/
/*  Create the widget
/*-----------------------------------------------------------------------------------*/
add_action('widgets_init', 'bd_post_types_init');

function bd_post_types_init(){

    register_widget('bd_post_types_widget');

}

/*-----------------------------------------------------------------------------------*/
/*  Widget class
/*-----------------------------------------------------------------------------------*/
class bd_post_types_widget extends WP_Widget {


    /*-----------------------------------------------------------------------------------*/
    /*  Widget Setup
    /*-----------------------------------------------------------------------------------*/
    function bd_post_types_widget(){

        // Widget settings
        $ops = array('classname' => 'post-types-widget', 'description' => __('Display any post type: recent or popular, as text link or thumbnail', THEME_NAME) );

        // Create the widget
        $this->WP_Widget('post-types-widget', 'Post Types (All in one)', $ops);

    }

    /*-----------------------------------------------------------------------------------*/
    /*  Display Widget
    /*-----------------------------------------------------------------------------------*/
    function widget($args, $instance){

        extract($args);

        $title = apply_filters('widget_title', $instance['title']);
        $count = $instance['count'];

        echo $before_widget;
        if (!empty($title)) echo $before_title . $title . $after_title;
        bd_post_types_widget($count, $instance['post-type'], $instance['type'], $instance['display'], $instance['category']);
        echo $after_widget;

    }

    /*-----------------------------------------------------------------------------------*/
    /*  Update Widget
    /*-----------------------------------------------------------------------------------*/
    function update($new_instance, $old_instance){
        $instance = $old_instance;

        $instance['title'] = $new_instance['title'];
        $instance['count'] = $new_instance['count'];
        $instance['type'] = $new_instance['type'];
        $instance['post-type'] = $new_instance['post-type'];
        $instance['display'] = $new_instance['display'];
        $instance['category'] = $new_instance['category'];

        return $instance;
    }

    /*-----------------------------------------------------------------------------------*/
    /*  Displays the widget settings controls on the widget panel
    /*-----------------------------------------------------------------------------------*/
    function form($instance){
        global $BD_theme;
            // Set up some default widget settings
            $defaults = array('title' => 'Recent Post', 'post-type' => '', 'count' =>'5', 'type' => 'thumbnail', 'display' => 'recent', 'category' => 'all');
            $instance = wp_parse_args((array) $instance, $defaults);

            $post_types = '';
            if(isset($BD_theme->options['post-types']) && is_array($BD_theme->options['post-types']))
                $post_types = $BD_theme->options['post-types'];

        ?>
        <p>
            <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', THEME_NAME); ?>:</label>
            <input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>">
        </p>

        <p>
            <label for="<?php echo $this->get_field_id('post-type'); ?>"><?php _e('Post Type', THEME_NAME ); ?>:</label><br>
            <select class="bd-cat-select" name="<?php echo $this->get_field_name('post-type'); ?>" id="<?php echo $this->get_field_id('post-type'); ?>">
                <option value="post" <?php if($instance['post-type']=='post') echo 'selected="selected"'; ?>>Post</option>
            <?php foreach($post_types as $k => $v): 
                $name = $k;     

                if(isset($v['name']))
                    $name = $v['name'].'s';

                if(isset($v['menu-name']))
                    $name = $v['menu-name'];
            ?>
                <option value="<?php echo $k; ?>" <?php if($instance['post-type']==$k) echo 'selected="selected"'; ?>><?php echo $name; ?></option>
            <?php endforeach ; ?>

            </select>
        </p>
        <p id="bd-blog-categories">
            <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Post Category (if post is selected)', THEME_NAME ); ?>:</label><br>
            <select  name="<?php echo $this->get_field_name('category'); ?>" id="<?php echo $this->get_field_id('category'); ?>">
                <?php 
                $bd_categories = get_categories();
                $bd_categories_tab = array();
                foreach($bd_categories as $category){
                    $bd_categories_tab['all'] = 'All';
                    $bd_categories_tab[$category->cat_ID] = $category->name;
                } 

                foreach($bd_categories_tab as $k => $v):?>

                <option value="<?php echo $k; ?>" <?php if($instance['category']==$k) echo 'selected="selected"'; ?>><?php echo $v; ?></option>
                <?php endforeach; ?>


            </select>
            <?php //debug($bd_categories_tab); ?>
        </p>
        <p>
            <label for="<?php echo $this->get_field_id('display'); ?>"><?php _e('Display', THEME_NAME ); ?>:</label><br>
            <select name="<?php echo $this->get_field_name('display'); ?>" id="<?php echo $this->get_field_id('display'); ?>">
                <option <?php if($instance['display']=='recent') echo 'selected="selected"'; ?>><?php _e('recent', THEME_NAME ); ?></option>
                <option <?php if($instance['display']=='featured') echo 'selected="selected"'; ?>><?php _e('featured', THEME_NAME ); ?></option>
                <option <?php if($instance['display']=='popular') echo 'selected="selected"'; ?>><?php _e('popular', THEME_NAME ); ?></option>
            </select>
        </p>
        <p>
            <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Number of post', THEME_NAME ); ?>:</label>
            <input class="widefat" type="text" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" value="<?php echo $instance['count']; ?>">
        </p>
        <p>
            <label for="<?php echo $this->get_field_id('type'); ?>"><?php _e('Type' ,THEME_NAME ); ?>:</label>
            <select name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>">
                <option <?php if($instance['type']=='thumbnail') echo 'selected="selected"'; ?>><?php _e('thumbnail', THEME_NAME ); ?></option>
                <option <?php if($instance['type']=='text') echo 'selected="selected"'; ?>><?php _e('text', THEME_NAME ); ?></option>
                <?php if($BD_theme->options['video'] != array()): ?>
                <option <?php if($instance['type']=='video') echo 'selected="selected"'; ?> value="video"><?php _e('video (only for video post types)', THEME_NAME ); ?></option>
                <?php endif; ?>

            </select>
        </p>
        <?php
    }



}

    /*-----------------------------------------------------------------------------------*/
    /*  Function
    /*-----------------------------------------------------------------------------------*/
    function bd_post_types_widget($count=5, $post_type, $type, $display, $category){
        global $wpdb, $BD_theme, $post, $bd_ID;
        $do_not_duplicate = array();
        if(is_single())
            //echo $bd_ID;
            $do_not_duplicate[] = $bd_ID;

        $is_video = (in_array($post_type, $BD_theme->options['video'])) && ($post_type!='post');

        //$do_not_duplicate[] = $post->ID;
        if($type!='text'){
            if($display=='recent'){
                $args = array( 
                    'post_type' => array($post_type) ,
                    'posts_per_page' => $count,
                    'meta_key'    => '_thumbnail_id',
                    'post__not_in' => $do_not_duplicate
                    );

            }elseif($display=='featured'){
                $args = array( 
                'post_type' => array($post_type) ,
                'orderby' => 'post_date',
                'meta_key'    => '_thumbnail_id',
                'posts_per_page' => $count,
                'post__not_in' => $do_not_duplicate,
                'meta_query' => array(
                                         array(
                                              'key'     => 'bd_featured',
                                              'value'   => 'on',
                                              'compare' => '='
                                              )
                                         )
                );

            }elseif($display=='popular'){

                $args = array( 
                'post_type' => array($post_type) ,
                'orderby' => 'comment_count',
                'meta_key'    => '_thumbnail_id',
                'order'    => 'DESC',
                'posts_per_page' => $count,
                'post__not_in' => $do_not_duplicate,
                );
            }
        }else{

            if($display=='recent'){
                $args = array( 
                    'post_type' => array($post_type) ,
                    'posts_per_page' => $count,
                    'post__not_in' => $do_not_duplicate

                    );

            }elseif($display=='featured'){
                $args = array( 
                'post_type' => array($post_type) ,
                'orderby' => 'post_date',
                'posts_per_page' => $count,
                'post__not_in' => $do_not_duplicate,
                'meta_query' => array(
                                         array(
                                              'key'     => 'bd_featured',
                                              'value'   => 'on',
                                              'compare' => '='
                                              )
                                         )
                );

            }elseif($display=='popular'){

                $args = array( 
                'post_type' => array($post_type) ,
                'orderby' => 'comment_count',
                'order'    => 'DESC',
                'posts_per_page' => $count,
                'post__not_in' => $do_not_duplicate,
                );
            }

        }

        if($post_type == 'post' && $category!='all'){
            $args['category__in'] = $category;
        }

        $loop = new WP_Query($args);
        if ( $type=='text'){
            echo "<ul class=\"square\">";
        }elseif ( $type=='thumbnail' || $type=='video'){
            echo '<div class="widget-thumbnails-list">';
        }
        while ($loop->have_posts()) : $loop->the_post();
        ?>
        <?php if ( $type=='video'): ?>
            <?php if($is_video): ?>
                <article>
                    <div class="frame" style="margin-top:15px; margin-bottom:5px">
                        <?php echo get_post_meta($post->ID, '_format_video_embed', true); ?>
                    </div>
                    <strong class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php _e('Permanent Link to', THEME_NAME); ?> <?php the_title(); ?>"><?php the_title(); ?></a></strong>
                                <br>
                    <small class="smooth"><?php echo get_the_time('F d, 20y'); ?></small>
                </article>

            <?php else: ?>
                <article>
                    <a href="<?php the_permalink(); ?>" class="widget-thumb-link">
                        <?php the_post_thumbnail('mini', array('class' => 'frame', 'title' => "")); ?>
                    </a>
                    <strong class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php _e('Permanent Link to', THEME_NAME); ?> <?php the_title(); ?>"><?php the_title(); ?></a></strong><br>
                    <small class="smooth"><?php echo get_the_time('F d, 20y'); ?></small><br>
                    <small class="smooth"><?php bd_comment_number(); ?></small>
                    <?php if( get_post_meta($post->ID, 'bd_rating', true)!=''): ?>
                    <br>
                    <span class="small-star-<?php echo str_replace('.5', '-5', get_post_meta($post->ID, 'bd_rating', true)); ?>"></span>
                    <?php endif; ?> 
                    <div class="clear"></div>
                </article>

            <?php endif; ?>

            <?php elseif ( ($type=='thumbnail') ): ?>
                <?php if($is_video): ?>
                    <article>
                        <div class="video-thumbnail">
                            <a class="video-thumbnail-link" href="<?php the_permalink(); ?>">
                                <?php the_post_thumbnail('video-thumbnail-img', array('class' => '')); ?>
                                <span class="play-button-thumb"></span>
                            </a>
                            <strong class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php _e('Permanent Link to', THEME_NAME); ?> <?php the_title(); ?>"><?php the_title(); ?></a></strong>
                            <br>
                            <small class="smooth"><?php echo get_the_time('F d, 20y'); ?></small><br>
                            <small class="smooth"><?php bd_comment_number(); ?></small>
                            <div class="clear"></div>
                        </div>
                    </article>

                <?php else: ?>
                    <article>
                        <a href="<?php the_permalink(); ?>" class="widget-thumb-link">
                            <?php the_post_thumbnail('mini', array('class' => 'frame effect', 'title' => "")); ?>
                        </a>
                        <strong class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php _e('Permanent Link to', THEME_NAME); ?> <?php the_title(); ?>"><?php the_title(); ?></a></strong>
                            <br>
                        <small class="smooth"><?php echo get_the_time('F d, 20y'); ?></small><br>
                        <small class="smooth"><?php bd_comment_number(); ?></small>

                        <?php if( get_post_meta($post->ID, 'bd_rating', true)!=''): ?>
                        <br>
                        <span class="small-star-<?php echo str_replace('.5', '-5', get_post_meta($post->ID, 'bd_rating', true)); ?>"></span>
                        <?php endif; ?> 
                        <div class="clear"></div>
                    </article>

            <?php endif; ?> 
            <div class="clear"></div>

            <?php else: // if text ?>
            <li>
                <a href="<?php the_permalink(); ?>" class="hover">
                    <?php echo get_the_title(); ?>
                </a>
            </li>
            <?php endif; ?> 
        <?php
        endwhile;
        if ( $type=='text'){
            echo "</ul>";
        }else{
            echo '</div>';
        }
        ?><div class="clear"></div><?php
    }        
share|improve this question
2  
Blocked? As in the widget doesn't appear at all? Are any errors or warnings shown in the Chrome console? –  Rachel Baker Jan 24 '13 at 15:02
    
The widget appears, but when I click the tabs (3 tabs: recent, popular, comments), nothing happen. Is locked on first tab. Only In Google Chrome. Works in Firefox and IE. –  Blanka Jan 24 '13 at 15:10
    
Sounds like a jQuery issue then, can you link to that code? Also check the Chrome development console. It may give you the fastest answer. –  Rachel Baker Jan 24 '13 at 15:19
    
Here is the link for jQuery code: code.google.com/p/socr/source/browse/trunk/SOCR_3.0/… –  Blanka Jan 24 '13 at 15:37
    
Chrome Developer Tools : Console –  brasofilo Jan 24 '13 at 15:41
add comment

1 Answer

up vote 0 down vote accepted

I find the problem. The issues are caused by Internet Download Manager extension. When is disable, the tabs works.

Is there a way to fix this compatibility?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.