/** * do widget feature in frondend if it actived * @param $t * @param $instance */ public function do_widget_feature_frontend($t, $instance) { //widget id $current_widget_id = "{$t->id_base}-{$t->number}"; $lib = $this->get_field_value('awc_fixedobj_lib'); //fixed object lib $options = $this->get_options(); $json_config = HW_SKIN_Option::build_json_options($options); //parse fancybox setting to json data //for sticky js if ($lib == 'sticky') { echo '<script> jQuery(document).ready(function($) { $("#' . $current_widget_id . '").sticky(' . $json_config . '); }); </script>'; } else { echo '<script> jQuery(document).ready(function($) { $("#' . $current_widget_id . '").stick_in_parent(' . $json_config . '); }); </script>'; } }
/** * do on website * @param string $selector jquery selector * @return mixed|void */ public function run($selector) { $json_config = HW_SKIN_Option::build_json_options($this->get_options()); //parse fancybox setting to json data echo '<script> jQuery(document).ready(function($) { /* Apply fancybox to multiple items */ jQuery("' . $selector . '").fancybox(' . $json_config . '); }); </script>'; }
/** * @hook admin_enqueue_scripts */ public function admin_enqueue_scripts() { #if($this->is_module_setting_page()) { HW_Libraries::enqueue_jquery_libs('jquery-colorbox'); #} $data = self::get()->get_values(); if (class_exists('HW_SKIN_Option')) { $data_json = HW_SKIN_Option::build_json_options($data); if ($data_json) { $data = (array) json_decode($data_json); } } $handle = $this->enqueue_script('colorbox-module.js'); $this->localize_script($handle, '__hw_module_colorbox', $data); }
/** * build json object for js consuming, clone this static method to class HW_SKIN_Option * extend from `HW_SKIN_Option::build_json_options` * @param $data * @param $except */ public static function build_json_options($data, $except = array(), $js_obj_keys_value = array()) { /*if(is_string($except)) $except = explode(',', $except); if(is_array($data)) { $json = array(); //excludes options foreach ($except as $key) { if(isset($data[$key])) unset($data[$key]); } foreach ($data as $key => $value) { if(empty($value)) continue; //valid value if( $value == '__TRUE__') $value = true; //on if($value == '__FALSE__') $value = false; //off if(is_numeric($value)) $value = (int) $value; $json[$key] = $value; } return json_encode($json); }*/ return HW_SKIN_Option::build_json_options($data, $except, $js_obj_keys_value); }
function hwmenu_init_skin($arg, $theme) { $user_options = $theme['args'][1]; //get user options //valid if ($theme['function'] !== __FUNCTION__) { return; } //ddsmoothmenu if (isset($user_options) && isset($user_options['enable_ddsmoothmenu']) && $user_options['enable_ddsmoothmenu'] == '__TRUE__') { $args = array('mainmenuid' => $user_options['container_id'], 'orientation' => $user_options['dd_orientation'], 'classname' => $user_options['dd_classname'], 'method' => $user_options['dd_method'], 'arrowswap' => $user_options['hw_arrowswap']); ?> <script> jQuery(document).ready(function() { ddsmoothmenu.init(<?php echo HW_SKIN_Option::build_json_options($args); ?> ); }); </script> <?php } }
/** * init scrolling * @param $theme: user theme setting (depricated) */ private function init_content_options($args = array()) { extract($args); if (!isset($instance)) { $instance = $this->get_widget_instance(); } $hwtpl_wrapper_id = $this->get_holder_id($instance['widget_id']); if ($this->enable_scrolling() && $instance['scroll_type'] == 'smoothdivscroll') { //for smoothdivscroll //validation if (!isset($instance['scroll_interval'])) { $instance['scroll_interval'] = '10'; } //default 10 of interval for smoothdivscroll if (!isset($instance['scroll_width']) || !$instance['scroll_width']) { //full width $instance['scroll_width'] = '100%'; } ?> <style> #<?php echo $hwtpl_wrapper_id; ?> .smoothDivScroll { <?php if (isset($instance['scroll_height'])) { echo 'height:' . $this->format_unit($instance['scroll_height']) . ';'; } ?> <?php if (isset($instance['scroll_width'])) { echo 'width:' . $this->format_unit($instance['scroll_width']) . ';'; } else { echo 'width: 100%;'; } ?> position: relative; } </style> <script type="text/javascript"> // Initialize the plugin with no custom options jQuery(document).ready(function ($) { // None of the options are set <?php if ($this->is_vertical_scrolling()) { ?> jQuery("#<?php echo $hwtpl_wrapper_id; ?> .smoothDivScroll").smoothDivScroll_vertical({ <?php } else { ?> jQuery("#<?php echo $hwtpl_wrapper_id; ?> .smoothDivScroll").smoothDivScroll({ <?php } ?> manualContinuousScrolling: false, autoScrollingMode: "onStart", mousewheelScrolling: "allDirections", hotSpotScrolling:false, <?php if (isset($instance['scroll_interval'])) { ?> autoScrollingInterval:'<?php echo $instance['scroll_interval']; ?> ', <?php } ?> <?php if (isset($instance['scroll_direction'])) { ?> autoScrollingDirection:'<?php echo $instance['scroll_direction']; ?> ', <?php } ?> }); // Mouse over jQuery("#<?php echo $hwtpl_wrapper_id; ?> .smoothDivScroll").bind("mouseover", function(){ <?php if ($this->is_vertical_scrolling()) { ?> $(this).smoothDivScroll_vertical("stopAutoScrolling");<?php } else { ?> $(this).smoothDivScroll("stopAutoScrolling"); <?php } ?> }); // Mouse out jQuery("#<?php echo $hwtpl_wrapper_id; ?> .smoothDivScroll").bind("mouseout", function(){ <?php if ($this->is_vertical_scrolling()) { ?> $(this).smoothDivScroll_vertical("startAutoScrolling");<?php } else { ?> $(this).smoothDivScroll("startAutoScrolling"); <?php } ?> }); }); </script> <script type="text/javascript"> </script> <?php } /** * for jcarousellite lib */ if ($this->enable_scrolling() && $instance['scroll_type'] == 'jcarousellite') { $option = array('mouseWheel' => true, 'start' => 0); //valid if (!isset($instance['scroll_width']) || !$instance['scroll_width']) { //full width $instance['scroll_width'] = '100%'; } if (!isset($instance['scroll_interval'])) { $instance['scroll_interval'] = '800'; } //default 800 of interval if (!isset($instance['scroll_delay'])) { $instance['scroll_delay'] = '800'; } //default 800 of time delay //auto scrolling & delay between 2 slides if (isset($instance['auto_scroll_mode']) && $instance['auto_scroll_mode'] && isset($instance['scroll_delay'])) { $option['auto'] = (int) $instance['scroll_delay']; } if (isset($instance['visible_scroll_num']) && is_numeric($instance['visible_scroll_num'])) { //visble $option['visible'] = (int) $instance['visible_scroll_num']; } if (isset($instance['scroll_interval']) && is_numeric($instance['scroll_interval'])) { //scroll speed $option['speed'] = (int) $instance['scroll_interval']; } if (isset($instance['scroll_num'])) { $option['scroll'] = (int) $instance['scroll_num']; } // scroll number of slides if (isset($instance['scroll_easing']) && $instance['scroll_easing']) { $option['easing'] = $instance['scroll_easing']; } //easing effects //scrolling direction if ($this->is_vertical_scrolling()) { $option['vertical'] = true; } else { $option['vertical'] = false; } //merge options if (isset($theme['scroll_options']['jcarousellite']) && is_array($theme['scroll_options']['jcarousellite'])) { $option = array_merge($option, $theme['scroll_options']['jcarousellite']); } if (!empty($skin_options)) { $option = array_merge($option, $skin_options); } $option_obj = HW_SKIN_Option::build_json_options($option); //json_encode($option) ?> <style> #<?php echo $hwtpl_wrapper_id; ?> .<?php echo $instance['scroll_type']; ?> { <?php if (isset($instance['scroll_height'])) { echo 'height:' . $this->format_unit($instance['scroll_height']) . ';'; } ?> <?php if (isset($instance['scroll_width'])) { echo 'width:' . $this->format_unit($instance['scroll_width']) . ';'; } else { echo 'width: 100%;'; } ?> position: relative; } </style> <script type="text/javascript"> jQuery(document).ready(function($) { var jcarousel_lite = $("#<?php echo $hwtpl_wrapper_id; ?> .<?php echo $instance['scroll_type']; ?> ").jCarouselLite(<?php echo $option_obj; ?> ); }); </script> <?php } //$this->init_widget_features($args); //call before include skin file }
/** * get qtranslate switcher */ public static function get_qtrans_switcher() { $mqtrans_skin = hw_option('mqtrans_skin'); //get mqtrans skin $other_service = hw_option('enable_googletranslate'); //use google translate? if (isset($mqtrans_skin['hash_skin']) && isset($mqtrans_skin['hwskin_config'])) { $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($mqtrans_skin); //skin options //$skin_options = $mqtrans_skin['skin_options']; $html = ''; //output $file = $skin->instance->get_skin_file($skin->hash_skin); //load footer template if (file_exists($file)) { HW_HOANGWEB::load_class('HW_String'); HW_HOANGWEB::load_class('HW_Twig_Template'); HW_HOANGWEB::load_class('HW_mqtranslate'); //get theme setting file $setting = $skin->instance->get_file_skin_setting(); //(new HW_SKIN); if (file_exists($setting)) { include $setting; } //skin options $skin_options_file = $skin->instance->get_file_skin_options(); //(new HW_SKIN)->enqueue_files_from_skin() $skin_options = isset($mqtrans_skin['skin_options']) ? $mqtrans_skin['skin_options'] : array(); //user options $skin_options = HW_SKIN::merge_skin_options_values($skin_options, $setting, $skin_options_file); $data = array(); //data send to twig template /*active google translate*/ if ($other_service) { $TranslateElement_opts = array('pageLanguage' => 'vi'); //layout $layout = self::get_googletrans_layout_param(isset($skin_options['display_mode']) ? $skin_options['display_mode'] : ''); if ($layout) { $TranslateElement_opts['layout'] = $layout; } //include languages if (!empty($skin_options['specific_langs']) && is_array($skin_options['specific_langs'])) { $TranslateElement_opts['includedLanguages'] = join($skin_options['specific_langs'], ','); } $data['google_translate_ID'] = !empty($skin_options['google_translate_ID']) ? $skin_options['google_translate_ID'] : HW_String::generateRandomString(); } else { //prepare data for template if (class_exists('HW_mqtranslate')) { // make sure use __autoload $data = HW_mqtranslate::generateLanguageSelectCode(); } } //get templates folder from skin if (isset($theme) && isset($theme['templates_folder'])) { $tpl = $theme['templates_folder']; } else { $tpl = ''; } if (class_exists('HW_Twig_Template')) { $twig = HW_Twig_Template::create($skin->instance->get_file_skin_resource($tpl)); if (isset($data)) { $twig->set_template_data($data); } //inject data to current twig for skin using } ob_start(); //google translate if (isset($TranslateElement_opts)) { $json = HW_SKIN_Option::build_json_options($TranslateElement_opts, null, 'layout'); echo '<script type="text/javascript"> function googleTranslateElementInit() { new google.translate.TranslateElement(' . $json . ', "' . $data['google_translate_ID'] . '"); } </script> '; } $content = $skin->instance->render_skin_template(compact('wrapper', 'active_langs', 'text'), false); //data, return=false if ($content !== false) { echo $content; } if ($skin->instance->allow_skin_file()) { include $file; } $html = ob_get_contents(); if ($html && ob_get_length()) { ob_end_clean(); } } //valid if (!isset($theme['styles'])) { $theme['styles'] = array(); } if (!isset($theme['scripts'])) { $theme['scripts'] = array(); } //put stuff from skin if (count($theme['styles']) || count($theme['scripts'])) { $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']); } return $html; } }
<img src="<?php echo $item['img_src']?>" data-thumb="<?php echo $item['thumb_src']?>"> <?php }?> </div> <div class="photor__viewportControl"> <div class="photor__viewportControlPrev"></div> <div class="photor__viewportControlNext"></div> </div> </div> <div class="photor__thumbs"> <div class="photor__thumbsWrap"></div> </div> </div> */ ?> <script> jQuery(document).ready( function($) { jQuery( '#<?php echo $gallery_id; ?> ' ).photor(<?php echo HW_SKIN_Option::build_json_options($options); ?> ); } ); </script>
<?php /** * HW Template: photowall */ $options = isset($skin_data['skin_options']) ? $skin_data['skin_options'] : array(); $options['el'] = '#envira-gallery-' . sanitize_html_class($args['wrapper_id']); // Gallery element $photos = array(); foreach ($galleries as $id => $item) { $photos[$id] = array('id' => $id, 'img' => esc_url($item['img_src']), 'width' => $item['img_width'], 'height' => $item['img_height'], 'th' => array('src' => esc_url($item['thumb_src']), 'width' => $item['thumb_width'], 'height' => $item['thumb_height'], 'zoom_src' => $item['thumb_src'], 'zoom_factor' => 1.5)); } $hw_tpl->_display('gallery.twig', array('galleries' => $galleries, 'args' => $args, 'json_options' => HW_SKIN_Option::build_json_options($options), 'photos' => $photos)); /* ?> <div id="envira-gallery-<?php echo sanitize_html_class( $args['wrapper_id'] ) ?>" class="envira-gallery-public envira-gallery-<?php echo sanitize_html_class( $args['wrapper_class'] ) ?>-columns envira-clear isotope" data-envira-columns="<?php echo $args['columns_class']?>"> <div class="body"> </div> <?php */ /*foreach($galleries as $id => $item) { echo '<div id="envira-gallery-item-' . sanitize_html_class( $id ) . '" class="' . $item['item_classes'] . '" style="margin-bottom: ' . $item['margin_bottom'] . '" >'; echo '<a href="' . esc_url( $item['link'] ) . '" class="envira-gallery-' . sanitize_html_class( $data['id'] ) . ' envira-gallery-link" rel="enviragallery' . sanitize_html_class( $data['id'] ) . '" title="' . esc_attr( $item['title'] ) . '" data-thumbnail="' . esc_url( $item['thumb'] ) . '">'; echo '<img id="envira-gallery-image-' . sanitize_html_class( $id ) . '" class="envira-gallery-image-' . $item['index'] . '" src="' . $item['src'] . '" data-envira-src="' . $item['src'] . '" alt="' . esc_attr( $item['alt'] ) . '" title="' . esc_attr( $item['title'] ) . '" />'; echo '</a>'; echo '</div>'; }*/ /* ?>
/** * HW_SKIN::apply_skin_data callback before * @param $context * @param $params */ public function _hw_skin_apply_skin_data_callback_before($params) { extract($params); //params $marquee_wrapper = 'hw-marquee-container'; if (isset($skin) && isset($hash_skin)) { //$skin_data = $skin->get_skin_data($hash_skin); //marquee params if (!isset($skin_options)) { $skin_options = array(); } $json_config = HW_SKIN_Option::build_json_options($skin_options); } return array('marquee_wrapper' => $marquee_wrapper, 'marquee_id' => uniqid($this->id), 'json_config' => $json_config); }
/** * @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); }