function widget($args, $instance)
 {
     extract($args);
     echo $before_widget;
     if ($instance['title']) {
         echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title;
     }
     global $width_widget_categories, $height_widget_categories;
     $widget_id = $args['widget_id'];
     $width = $width_widget_categories;
     $height = $height_widget_categories;
     $only_these = $instance['only_these'];
     $size_string = 'my_size_widget';
     //--------------------------------------------------
     $terms_k = get_terms("job_cat", "parent=0&hide_empty=0");
     global $wpdb;
     $arr = array();
     if ($only_these == "1") {
         $terms = array();
         foreach ($terms_k as $trm) {
             if ($instance['term_' . $trm->term_id] == $trm->term_id) {
                 array_push($terms, $trm);
             }
         }
     }
     //-----------------------------
     if (count($terms) < count($terms_k)) {
         $disp_btn = 1;
     } else {
         $disp_btn = 0;
     }
     $count = count($terms);
     $i = 0;
     if ($count > 0) {
         // echo '<style>#'.$widget_id.' .my_image_div_cat_name { width: '.round(100/$nr).'%}</style>';
         foreach ($terms as $term) {
             $pricerrtheme_get_cat_pic_attached = pricerrtheme_get_cat_pic_attached($term->term_id);
             $link = get_term_link($term->slug, "job_cat");
             $image = pricerrtheme_generate_thumb3($pricerrtheme_get_cat_pic_attached, 'my_category_image_thing');
             echo '<div class="my_category_image_holder"><div class="my_image_div">';
             echo '<a href="' . $link . '">';
             echo '<img src="' . $image . '" width="' . $width . '" height="' . $height . '" />';
             echo '</a></div>';
             echo '<div class="my_image_div_cat_name"><div class="padd10">';
             echo '<a href="' . $link . '">' . $term->name . '</a>';
             echo '</div></div>';
             echo '</div>';
         }
         //=========================================================================
         if ($disp_btn == 1) {
             echo '<div class="see-more-tax"><b><a href="' . get_permalink(get_option('PricerrTheme_all_categories_page_id')) . '">' . __('See More Categories', 'PricerrTheme') . '</a></b></div>';
         }
     } else {
         _e('There are no categories defined.', 'PricerrTheme');
     }
     echo $after_widget;
 }
Example #2
0
function PricerrTheme_get_first_post_image2($pid, $image_string_name)
{
    //---------------------
    // build the exclude list
    $exclude = array();
    $args = array('order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => get_the_ID(), 'meta_key' => 'another_reserved1', 'meta_value' => '1', 'numberposts' => -1, 'post_status' => null);
    $attachments = get_posts($args);
    if ($attachments) {
        foreach ($attachments as $attachment) {
            $url = $attachment->ID;
            array_push($exclude, $url);
        }
    }
    //-----------------
    $args = array('order' => 'ASC', 'orderby' => 'post_date', 'post_type' => 'attachment', 'post_parent' => $pid, 'exclude' => $exclude, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => 1);
    $attachments = get_posts($args);
    if ($attachments) {
        foreach ($attachments as $attachment) {
            $url = wp_get_attachment_url($attachment->ID);
            return pricerrtheme_generate_thumb3($attachment->ID, $image_string_name);
        }
    } else {
        return get_bloginfo('template_url') . '/images/nopic.jpg';
    }
}