/** * render map * @param $atts */ public function render_googlemap($atts = array()) { HW_HOANGWEB::load_class('HW_String'); $module = $this->_option('module'); $id = HW_String::generateRandomString(); //options $width = HW_Validation::format_unit(isset($atts['width']) ? $atts['width'] : ($module ? $module->get_field_value('width') : '')); $height = HW_Validation::format_unit(isset($atts['height']) ? $atts['height'] : ($module ? $module->get_field_value('height') : '')); $show_searchbox = isset($atts['show_searchbox']) ? (int) $atts['show_searchbox'] : ($module ? $module->get_field_value('show_searchbox') : ''); if (!empty($atts['location'])) { $location = $atts['location']; if (is_array($location)) { $location = json_encode($location); } } elseif (!empty($atts['address'])) { $location = '"' . $atts['address'] . '"'; } else { $location = '""'; } #$atts['location'] = isset($atts['location'])? HW_Gmap::getLocationFromAddress($atts['location']) : array(); #$location_json = json_encode($atts['location']); $input_box_id = 'pac-input-' . $id; //input box search location $map_canvas_id = 'map-canvas-' . $id; //map canvas $out = '<div class="hw-module-map-container">'; if ($show_searchbox) { $out .= '<input id="' . $input_box_id . '" class="controls hw-pac-input" type="text" placeholder="Tìm kiếm">'; } $out .= '<div id="' . $map_canvas_id . '" class="hw-map-canvas"></div>'; $out .= ' <style> .hw-map-canvas{ ' . ($width ? "width:{$width};" : '') . ' ' . ($height ? "height:{$height};" : '') . ' } </style> <script> jQuery(function($){ google.maps.event.addDomListener(window, "load", function(){ __hw_module_map.map_initialize("#' . $map_canvas_id . '","#' . $input_box_id . '",' . $location . '); }); }); </script> '; $out .= '</div>'; return $out; }
/** * render facebook comment box * @param $atts attributes */ function _hw_fb_comment_display($atts) { HW_HOANGWEB::load_class('HW_UI_Component'); $inst = HW_Module_Comments::get(); $options = $inst->get_tab('facebook')->get_values(); $atts = array(); $appId = isset($options['appId']) ? $options['appId'] : ''; $width = !empty($options['width']) ? HW_Validation::format_unit($options['width']) : '100%'; $num_posts = !empty($options['num_posts']) ? $options['num_posts'] : '5'; $colorscheme = !empty($options['colorscheme']) ? $options['colorscheme'] : 'light'; $order_by = !empty($options['order_by']) ? $options['order_by'] : 'social'; //order_by $show_count = !empty($options['show_count']) ? $options['show_count'] : 0; $comment_text = !empty($options['comment_text']) ? $options['comment_text'] : __('Bình luận'); echo '<div id="fb-root"></div>'; #echo '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>'; echo "\r\n<script>(function(d, s, id) {\r\n var js, fjs = d.getElementsByTagName(s)[0];\r\n if (d.getElementById(id)) return;\r\n js = d.createElement(s); js.id = id;\r\n js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId={$appId}';\r\n fjs.parentNode.insertBefore(js, fjs);\r\n}(document, 'script', 'facebook-jssdk'));</script>"; //show count if ($show_count) { echo '<span class="fb-comments-count" data-href="' . get_permalink() . '"></span> ' . $comment_text; } if (isset($options['html5'])) { $atts['data-href'] = get_permalink(); $atts['data-width'] = $width; $atts['data-numposts'] = $num_posts; $atts['data-order-by'] = $order_by; $atts['data-colorscheme'] = $colorscheme; echo '<div class="fb-comments" ' . HW_UI_Component::generateAttributes($atts) . '></div>'; } else { $atts['href'] = get_permalink(); $atts['width'] = $width; $atts['num_posts'] = $num_posts; $atts['order_by'] = $order_by; $atts['width'] = $width; echo '<fb:comments ' . HW_UI_Component::generateAttributes($atts) . '></fb:comments>'; } }
/** * @hook wp_footer */ function print_footer() { if (is_product()) { $setting = self::get()->get_values(); $thumbnailsContainer = isset($setting['smallthumb_container']) ? $setting['smallthumb_container'] : '.product .thumbnails'; $productImages = isset($setting['productImages']) ? $setting['productImages'] : '.product .images > a'; $mouseEvent = isset($setting['mouseEvent']) ? $setting['mouseEvent'] : 'mouseover'; //css generator $css = array($thumbnailsContainer . ' img' => array('width' => get_option('woocommerce_thumbnail_image_width') . 'px'), '.cloud-zoom-big' => array()); if (!empty($setting['zoombig_width'])) { $css['.cloud-zoom-big']['width'] = HW_Validation::format_unit($setting['zoombig_width']) . ' !important'; } if (!empty($setting['zoombig_height'])) { $css['.cloud-zoom-big']['height'] = HW_Validation::format_unit($setting['zoombig_height']) . ' !important'; } echo HW_UI_Component::generateCSS($css); ?> <script type="text/javascript"> jQuery(document).ready(function($){ var $thumbnailsContainer, $thumbnails,$productImages, addCloudZoom; $('a.zoom').unbind('click.fb'); $thumbnailsContainer = $('<?php echo $thumbnailsContainer; ?> '); $thumbnails = $('a', $thumbnailsContainer); $productImages = $('<?php echo $productImages; ?> '); addCloudZoom = function(el){ el.addClass('cloud-zoom').CloudZoom(); } if($thumbnails.length){ <?php if ($mouseEvent == 'click') { echo '$thumbnails.unbind(\'click\');'; } ?> $thumbnails.bind('<?php echo $mouseEvent; ?> ',function(){ var $image = $(this).clone(false); $image.insertAfter($productImages); $productImages.remove(); $productImages = $image; $('.mousetrap').remove(); addCloudZoom($productImages); return false; }) } addCloudZoom($productImages); }); </script> <?php } }
/** * @param $atts */ public function _gallery_shortcode($atts) { global $post; // If no attributes have been passed, the gallery should be pulled from the current post. $gallery_id = false; if (empty($atts)) { $gallery_id = $post->ID; $data = is_preview() ? $this->gallery->_get_gallery($gallery_id) : $this->gallery->get_gallery($gallery_id); } else { if (isset($atts['id'])) { $gallery_id = (int) $atts['id']; $data = is_preview() ? $this->gallery->_get_gallery($gallery_id) : $this->gallery->get_gallery($gallery_id); } else { if (isset($atts['slug'])) { $gallery_id = $atts['slug']; $data = is_preview() ? $this->gallery->_get_gallery_by_slug($gallery_id) : $this->gallery->get_gallery_by_slug($gallery_id); } else { // A custom attribute must have been passed. Allow it to be filtered to grab data from a custom source. $data = apply_filters('hw_envira_gallery_custom_gallery_data', false, $atts, $post); } } } // If there is no data to output or the gallery is inactive, do nothing. if (!$data || empty($data['gallery']) || isset($data['status']) && 'inactive' == $data['status'] && !is_preview()) { return; } // Get rid of any external plugins trying to jack up our stuff where a gallery is present. $this->plugin_humility(); // If this is a feed view, customize the output and return early. if (is_feed()) { return $this->do_feed_output($data); } $i = 1; $args = array(); $args['wrapper_id'] = sanitize_html_class($data['id']); $args['wrapper_class'] = $this->get_gallery_classes($data); $args['columns_class'] = $this->get_config('columns', $data); $galleries = array(); foreach ($data['gallery'] as $id => $item) { // Skip over images that are pending (ignore if in Preview mode). if (isset($item['status']) && 'pending' == $item['status'] && !is_preview()) { continue; } $gallery = array(); $image = $this->get_image_src($id, $item, $data); $gallery = array_merge($item); $gallery['index'] = $i; $gallery['id'] = $id; $gallery['item_classes'] = $this->get_gallery_item_classes($item, $i, $data); $gallery['margin_bottom'] = HW_Validation::format_unit($this->get_config('margin', $data)); $gallery['img_src'] = esc_url($image[0]); $gallery['img_width'] = esc_url($image[1]); $gallery['img_height'] = esc_url($image[2]); $thumb = wp_get_attachment_image_src($id, 'thumbnail'); $gallery['thumb_src'] = $thumb[0]; $gallery['thumb_width'] = $thumb[1]; $gallery['thumb_height'] = $thumb[2]; $gallery['placeholder'] = esc_url(plugins_url('assets/css/images/holder.gif', dirname(dirname(__FILE__)))); $galleries[$id] = $gallery; // Increment the iterator. $i++; } /*---start skin---*/ //$skin = $this->get_config( 'hw_skin', $data ); $skin = !empty($data['config']['hw_skin']) ? $data['config']['hw_skin'] : $this->get_config('hw_skin', array()); if (empty($skin['hash_skin'])) { return; } //get skin options $data['options'] = isset($skin['skin_options']) ? $skin['skin_options'] : array(); $data['json_options'] = HW_SKIN_Option::build_json_options($data['options']); //$this->skin->get_current(); //change sidebar params from skin return HW_SKIN::apply_skin_data($skin, array('callback_before' => array(__CLASS__, '_hw_skin_before_include_skin_file')), array('galleries' => $galleries, 'args' => $args, 'data' => $data), false); }
/** * display slideshow images */ public function display_small_images() { extract($this->get_params()); //get all images $images = $this->get_images(); $setting = $this->get_params(); $out = '<div id="hw-product-slideShow" class="hw-ImageCarouselBox" style="margin: 10px auto 0;">'; //slideshow small images $out .= '<div class="' . $smallthumb_container_class . ' listImages">'; if (is_array($images) && count($images)) { $out .= '<ul class="' . $smallthumb_class . '">'; foreach ($images as $img) { $thumb_small = wp_get_attachment_image_src($img->ID, 'thumbnail'); //_print($thumb_small);//array('90','90') $thumb = wp_get_attachment_image_src($img->ID, 'medium'); $out .= sprintf("<li class='%s'><a href='%s' class='cloud-zoom-gallery %s' title='%s' rel='useZoom: \"{$this->cloudzoom_id}\", smallImage: \"%s\"'><img src='%s' class='%s' alt='%s' /></a></li>", $smallthumb_item_class, $img->guid, $smallthumb_anchor_class, $img->post_title, $thumb[0], $thumb_small[0], $smallthumb_img_class, $img->post_title); } $out .= '</ul>'; } $out .= '</div>'; $out .= '</div>'; $out .= "<script>jQuery(function(){jQuery('#" . $this->cloudzoom_id . "').CloudZoom();});</script>"; //css $css = array('.cloud-zoom-big' => array()); if (!empty($setting['zoombig_width'])) { $css['.cloud-zoom-big']['width'] = HW_Validation::format_unit($setting['zoombig_width']) . ' !important'; } if (!empty($setting['zoombig_height'])) { $css['.cloud-zoom-big']['height'] = HW_Validation::format_unit($setting['zoombig_height']) . ' !important'; } $out .= $this->generateCSS($css); echo $out; }