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("project_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) { $projecttheme_get_cat_pic_attached = projecttheme_get_cat_pic_attached($term->term_id); $link = get_term_link($term->slug, "project_cat"); $image = projecttheme_generate_thumb3($projecttheme_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 . '" />'; 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('auctiontheme_all_categories_page_id')) .'">'.__('See More Categories','ProjectTheme').'</a></b></div>'; } } else { echo 'There are no categories defined. Define them from backend.'; } echo $after_widget; }
function projectTheme_theme_cate_images_settings() { $id_icon = 'icon-options-general-img'; $ttl_of_stuff = 'ProjectTheme - ' . __('Category Images', 'ProjectTheme'); global $menu_admin_pricerrtheme_theme_bull; //------------------------------------------------------ $arr = array("yes" => __("Yes", 'ProjectTheme'), "no" => __("No", 'ProjectTheme')); echo '<div class="wrap">'; echo '<div class="icon32" id="' . $id_icon . '"><br/></div>'; echo '<h2 class="my_title_class_sitemile">' . $ttl_of_stuff . '</h2>'; ?> <style> .crme_brullet { padding:2px; background:white; border:1px solid #ccc; } .expl_expl { padding:5px; margin-bottom:15px; font-size:13px; font-family:Arial, Helvetica, sans-serif } </style> <script type="text/javascript"> function delete_this_my_pic(id) { $.ajax({ method: 'get', url : '<?php echo get_bloginfo('siteurl'); ?> /index.php?_ad_delete_pid='+id, dataType : 'text', success: function (text) { window.location.reload(); return false; } }); //alert("a"); return false; } </script> <div class="updated"> <p>Here you can set the images for each main category. The images are used in the widget called "ProjectTheme - Category Thumbs" and is used in front page.</p> </div> <div id="usual2" class="usual"> <ul> <li><a href="#tabs1"><?php _e('Set Images', 'ProjectTheme'); ?> </a></li> </ul> <div id="tabs1"> <?php $categories = get_terms('project_cat', array('parent' => '0', 'hide_empty' => 0)); if (count($categories) > 0) { ?> <input type="hidden" id="my_term_id_general" value="-1" /> <table class="sitemile-table" width="650"> <tr> <td><strong><?php echo __('Category Name', 'ProjectTheme'); ?> </strong></td> <td><strong><?php echo __('Upload Picture', 'ProjectTheme'); ?> </strong></td> <td><strong><?php echo __('Current Picture', 'ProjectTheme'); ?> </strong></td> </tr> <script> jQuery(function(jQuery) { jQuery(document).ready(function(){ jQuery('.add_my_image').click(open_media_window); }); function open_media_window() { var term_id = jQuery(this).attr('rel'); jQuery("#my_term_id_general").val(term_id); tb_show('', 'media-upload.php?type=image&TB_iframe=true&term_id=' + term_id); return false; } window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); var cla = jQuery('img',html).attr('class'); vv = cla.split('wp-image-') ; var attachment_id = vv[1] ; //jQuery(html).data('id'); term_id = jQuery("#my_term_id_general").val(); jQuery.ajax({url:"<?php echo get_home_url(); ?> /?set_image_for_term=1&term_id=" + term_id + "&attachment_ids=" + attachment_id, success:function(result){ }}); jQuery("#image_for_term_id_" + term_id).html("<img class='crme_brullet' src='" + imgurl +"' width='40' />"); tb_remove(); } }); </script> <?php foreach ($categories as $cat) { $projecttheme_get_cat_pic_attached = projecttheme_get_cat_pic_attached($cat->term_id); ?> <tr> <td><?php echo $cat->name; ?> </td> <td> <a href="#" class="add_my_image button " rel="<?php echo $cat->term_id; ?> " ><?php _e('Select/Add Your Image', 'ProjectTheme'); ?> </a> </td> <td> <div id="image_for_term_id_<?php echo $cat->term_id; ?> "> <?php if ($projecttheme_get_cat_pic_attached == false) { ?> <?php _e('No image attached.', 'ProjectTheme'); ?> <?php } else { ?> <img src="<?php echo projecttheme_generate_thumb2($projecttheme_get_cat_pic_attached, 45, 35); ?> " width="45" height="35" class="crme_brullet" /> <a href="" onclick="return delete_this_my_pic('<?php echo $projecttheme_get_cat_pic_attached; ?> ')"><img src="<?php bloginfo('template_url'); ?> /images/delete.gif" border="0" /></a> <?php } ?> </div> </td> </tr> <?php } ?> </table> <?php } ?> </div> <?php echo '</div>'; }