/** * Gets the post featured image. * * @since 1.0.0 * @package GeoDirectory * @param int|string $post_id The post ID. * @param string $size Optional. Thumbnail size. Default: thumbnail. * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. * @return bool|string Returns image html. */ function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) { $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); $html = geodir_show_image($image, $size, $no_image, false); if (!empty($html) && $echo) { echo $html; } elseif (!empty($html)) { return $html; } else { return false; } }
/** * Generates listing slider HTML. * * @since 1.0.0 * @package GeoDirectory * @global object $post The current post object. * @param array|string $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array|string $instance The settings for the particular instance of the widget. */ function geodir_listing_slider_widget_output($args = '', $instance = '') { // prints the widget extract($args, EXTR_SKIP); echo $before_widget; /** This filter is documented in geodirectory_widgets.php */ $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory')); /** * Filter the widget post type. * * @since 1.0.0 * @param string $instance['post_type'] Post type of listing. */ $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']); /** * Filter the widget's term. * * @since 1.0.0 * @param string $instance['category'] Filter by term. Can be any valid term. */ $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']); /** * Filter the widget listings limit. * * @since 1.0.0 * @param string $instance['post_number'] Number of listings to display. */ $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']); /** * Filter the widget listings limit shown at one time. * * @since 1.5.0 * @param string $instance['max_show'] Number of listings to display on screen. */ $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']); /** * Filter the widget slide width. * * @since 1.5.0 * @param string $instance['slide_width'] Width of the slides shown. */ $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']); /** * Filter widget's "show title" value. * * @since 1.0.0 * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0. */ $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']); /** * Filter widget's "slideshow" value. * * @since 1.0.0 * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically. */ $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']); /** * Filter widget's "animationLoop" value. * * @since 1.0.0 * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop. */ $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']); /** * Filter widget's "directionNav" value. * * @since 1.0.0 * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0. */ $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']); /** * Filter widget's "slideshowSpeed" value. * * @since 1.0.0 * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds. */ $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']); /** * Filter widget's "animationSpeed" value. * * @since 1.0.0 * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds. */ $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']); /** * Filter widget's "animation" value. * * @since 1.0.0 * @param string $instance['animation'] Controls the animation type, "fade" or "slide". */ $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']); /** * Filter widget's "list_sort" type. * * @since 1.0.0 * @param string $instance['list_sort'] Listing sort by type. */ $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']); $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL; wp_enqueue_script('geodirectory-jquery-flexslider-js'); ?> <script type="text/javascript"> jQuery(window).load(function () { jQuery('#geodir_widget_carousel').flexslider({ animation: "slide", selector: ".geodir-slides > li", namespace: "geodir-", controlNav: false, directionNav: false, animationLoop: false, slideshow: false, itemWidth: 75, itemMargin: 5, asNavFor: '#geodir_widget_slider', rtl: <?php echo is_rtl() ? 'true' : 'false'; /* fix rtl issue */ ?> }); jQuery('#geodir_widget_slider').flexslider({ animation: "<?php echo $animation; ?> ", selector: ".geodir-slides > li", namespace: "geodir-", controlNav: true, animationLoop: <?php echo $animationLoop; ?> , slideshow: <?php echo $slideshow; ?> , slideshowSpeed: <?php echo $slideshowSpeed; ?> , animationSpeed: <?php echo $animationSpeed; ?> , directionNav: <?php echo $directionNav; ?> , maxItems: <?php echo $max_show; ?> , <?php if ($slide_width) { echo "itemWidth: " . $slide_width . ","; } ?> sync: "#geodir_widget_carousel", start: function (slider) { jQuery('.geodir-listing-flex-loader').hide(); jQuery('#geodir_widget_slider').css({'visibility': 'visible'}); jQuery('#geodir_widget_carousel').css({'visibility': 'visible'}); }, rtl: <?php echo is_rtl() ? 'true' : 'false'; /* fix rtl issue */ ?> }); }); </script> <?php $query_args = array('posts_per_page' => $post_number, 'is_geodir_loop' => true, 'post_type' => $post_type, 'order_by' => $list_sort); if ($show_featured_only) { $query_args['show_featured_only'] = 1; } if ($category != 0 || $category != '') { $category_taxonomy = geodir_get_taxonomies($post_type); $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $category); $query_args['tax_query'] = array($tax_query); } // we want listings with featured image only $query_args['featured_image_only'] = 1; if ($post_type == 'gd_event') { $query_args['gedir_event_listing_filter'] = 'upcoming'; } // show only upcomming events $widget_listings = geodir_get_widget_listings($query_args); if (!empty($widget_listings) || isset($with_no_results) && $with_no_results) { if ($title) { echo $before_title . $title . $after_title; } global $post; $current_post = $post; // keep current post info $widget_main_slides = ''; $nav_slides = ''; $widget_slides = 0; foreach ($widget_listings as $widget_listing) { global $gd_widget_listing_type; $post = $widget_listing; $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img')); if (!empty($widget_image)) { if ($widget_image->height >= 200) { $widget_spacer_height = 0; } else { $widget_spacer_height = (200 - $widget_image->height) / 2; } $widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />'; $title = ''; if ($show_title) { $title = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>'; } $widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>'; $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; $widget_slides++; } } ?> <div class="flex-container" style="min-height:200px;"> <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div> <div id="geodir_widget_slider" class="geodir_flexslider"> <ul class="geodir-slides clearfix"><?php echo $widget_main_slides; ?> </ul> </div> <?php if ($widget_slides > 1) { ?> <div id="geodir_widget_carousel" class="geodir_flexslider"> <ul class="geodir-slides clearfix"><?php echo $nav_slides; ?> </ul> </div> <?php } ?> </div> <?php $GLOBALS['post'] = $current_post; setup_postdata($current_post); } echo $after_widget; }
/** * Prints Attachments meta box content. * * @since 1.0.0 * @package GeoDirectory * @global object $post The post object. * @global int $post_id The post ID. */ function geodir_post_attachments() { global $post, $post_id; wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); if (geodir_get_featured_image($post_id, 'thumbnail')) { echo '<h4>' . __('Featured Image', GEODIRECTORY_TEXTDOMAIN) . '</h4>'; geodir_show_featured_image($post_id, 'thumbnail'); } $image_limit = 0; ?> <h5 class="form_title"> <?php if ($image_limit != 0 && $image_limit == 1) { echo '<br /><small>(' . __('You can upload', GEODIRECTORY_TEXTDOMAIN) . ' ' . $image_limit . ' ' . __('image with this package', GEODIRECTORY_TEXTDOMAIN) . ')</small>'; } ?> <?php if ($image_limit != 0 && $image_limit > 1) { echo '<br /><small>(' . __('You can upload', GEODIRECTORY_TEXTDOMAIN) . ' ' . $image_limit . ' ' . __('images with this package', GEODIRECTORY_TEXTDOMAIN) . ')</small>'; } ?> <?php if ($image_limit == 0) { echo '<br /><small>(' . __('You can upload unlimited images with this package', GEODIRECTORY_TEXTDOMAIN) . ')</small>'; } ?> </h5> <?php $curImages = geodir_get_images($post_id); $place_img_array = array(); if (!empty($curImages)) { foreach ($curImages as $p_img) { $place_img_array[] = $p_img->src; } } if (!empty($place_img_array)) { $curImages = implode(',', $place_img_array); } // adjust values here $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls $svalue = $curImages; // this will be initial value of the above form field. Image urls. $multiple = true; // allow multiple files upload $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) ?> <div class="gtd-form_row clearfix" id="<?php echo $id; ?> dropbox" style="border:1px solid #999999; padding:5px;" align="center"> <input type="hidden" name="<?php echo $id; ?> " id="<?php echo $id; ?> " value="<?php echo $svalue; ?> "/> <div class="plupload-upload-uic hide-if-no-js <?php if ($multiple) { ?> plupload-upload-uic-multiple<?php } ?> " id="<?php echo $id; ?> plupload-upload-ui"> <h4><?php _e('Drop files to upload', GEODIRECTORY_TEXTDOMAIN); ?> </h4> <input id="<?php echo $id; ?> plupload-browse-button" type="button" value="<?php _e('Select Files', GEODIRECTORY_TEXTDOMAIN); ?> " class="button"/> <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?> "></span> <?php if ($width && $height) { ?> <span class="plupload-resize"></span> <span class="plupload-width" id="plupload-width<?php echo $width; ?> "></span> <span class="plupload-height" id="plupload-height<?php echo $height; ?> "></span> <?php } ?> <div class="filelist"></div> </div> <div class="plupload-thumbs <?php if ($multiple) { ?> plupload-thumbs-multiple<?php } ?> clearfix" id="<?php echo $id; ?> plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;"> </div> <span id="upload-msg"><?php _e('Please drag & drop the images to rearrange the order', GEODIRECTORY_TEXTDOMAIN); ?> </span> <span id="<?php echo $id; ?> upload-error" style="display:none"></span> </div> <?php }