/** * @param array $tab_info * @param array $options */ public function __construct($tab_info = array(), $options = array()) { parent::__construct($tab_info, $options); //valid if (!is_array($options)) { $options = array(); } if (!is_array($tab_info)) { $tab_info = array(); } if (empty($tab_container)) { $tab_container = HW_String::generateRandomString(); } $default_options = array('animate' => false, 'animationSpeed' => '1000', 'updateHash' => false); //easytabs options $this->set_options(array_merge($default_options, $options)); //params $params = array('container_id' => 'hw-tabs-container', 'container_class' => $tab_container, 'tabs_menu_class' => 'tabs_menu_class', 'current_tab_class' => '', 'tab_content_class' => ''); if (class_exists('HW_Module_Tabs') && HW_Module_Tabs::is_active()) { $setting = HW_Module_Tabs::get(); $params['container_id'] = $setting->get_field_value('container_id', 'hw-tabs-container'); $params['tabs_menu_class'] = $setting->get_field_value('tabs_menu_class'); $params['current_tab_class'] = $setting->get_field_value('current_tab_class'); $params['tab_content_class'] = $setting->get_field_value('tab_content_class'); } $this->set_params($tab_info, $params); /*$this->info['container_id'] = $tab_container; $this->info['tabs_menu_class'] = $tab_container;*/ }
/** * 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; }
/** * construct method * @param $args * @param $options */ public function __construct($args = array(), $options = array()) { parent::__construct($args, $options); //load cloudzoom lib HW_Libraries::enqueue_jquery_libs('cloudzoom'); $this->cloudzoom_id = HW_String::generateRandomString(); //valid if (!is_array($args)) { $args = array(); } //params $default_params = array('images_from_current_post' => '0', 'zoombig_width' => '300px', 'zoombig_height' => '', 'container_id' => 'cloudzoom-container', 'container_class' => '', 'thumb_anchor_class' => 'cloudzoom-thumb-anchor-class', 'thumb_img_class' => 'cloudzoom-thumb-img-class', 'smallthumb_container_class' => 'cloudzoom-smallthumb-container', 'smallthumb_class' => 'cloudzoom-smallthumb-class', 'smallthumb_item_class' => 'cloudzoom-smallthumb-item-class', 'smallthumb_anchor_class' => 'cloudzoom-smallthumb-anchor-class', 'smallthumb_img_class' => 'cloudzoom-smallthumb-img-class'); if (class_exists('HW_Module_Cloudzoom') && HW_Module_Cloudzoom::is_active()) { $setting = HW_Module_Cloudzoom::get(); $params['images_from_current_post'] = $setting->get_field_value('images_from_current_post'); $params['zoombig_width'] = $setting->get_field_value('zoombig_width'); $params['zoombig_height'] = $setting->get_field_value('zoombig_height'); $params['container_id'] = $setting->get_field_value('container_id'); $params['container_class'] = $setting->get_field_value('container_class'); $params['thumb_anchor_class'] = $setting->get_field_value('thumb_anchor_class'); $params['thumb_img_class'] = $setting->get_field_value('thumb_img_class'); $params['smallthumb_container_class'] = $setting->get_field_value('smallthumb_container_class'); $params['smallthumb_class'] = $setting->get_field_value('smallthumb_class'); $params['smallthumb_item_class'] = $setting->get_field_value('smallthumb_item_class'); $params['smallthumb_anchor_class'] = $setting->get_field_value('smallthumb_anchor_class'); $params['smallthumb_img_class'] = $setting->get_field_value('smallthumb_img_class'); } $this->set_params($default_params); if (is_array($args)) { $this->set_params($args); } //cloud options if (is_array($options)) { $this->set_options($options); } }
/** * implement widget features * @param array $args */ public function init_widget_features($args = array()) { extract($args); if (!isset($instance)) { $instance = $this->get_widget_instance(); } $features = array(); //widget feature fancybox $fancybox = HW_AWC::get_widget_feature($this, 'fancybox'); if ($fancybox && HW_AWC::check_widget_feature($this, 'fancybox') && $fancybox->is_active($instance) && isset($skin_options)) { $features['fancybox'] = array('object' => $fancybox, 'data' => array()); if (!empty($skin_options['fancybox_images_group'])) { $fancybox_group = $skin_options['fancybox_images_group']; $fancybox_group_rel = base64_encode($fancybox_group); } else { $fancybox_group = HW_String::generateRandomString(); $fancybox_group_rel = HW_String::generateRandomString(); } $fancybox->run('.' . preg_replace('#^[\\s\\.]#', '', $fancybox_group)); $features['fancybox']['data'] = (object) array('fancybox_group' => $fancybox_group, 'fancybox_group_rel' => $fancybox_group_rel); } return $features; }
/** * 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; } }
/** * add new slider tab * @param $args * @param $assoc_args */ public function add_slider($args, $assoc_args) { //load necessary classes HW_HOANGWEB::load_class('HW_WP_Attachment'); //list( $name ) = $args; #params $title = $this->get_cmd_arg($assoc_args, 'title', HW_String::generateRandomString(10)); $slide_image_width = $this->get_cmd_arg($assoc_args, 'width', '730'); $slide_image_height = $this->get_cmd_arg($assoc_args, 'height', '280'); //source $source = $this->get_cmd_arg($assoc_args, 'source', 'upload'); $from = $this->get_cmd_arg($assoc_args, 'from_path', 'theme'); $source_path = $this->get_cmd_arg($assoc_args, 'source_path'); if ($from == 'theme') { $source_path = get_stylesheet_directory() . '/' . $source_path; } elseif ($from == 'plugin') { $source_path = HWML_PLUGIN_PATH . '/' . $source_path; } //number of slides $num = $this->get_cmd_arg($assoc_args, 'num', 3); if (!is_numeric($num)) { $num = 3; } //settings $slider_settings = $this->get_cmd_arg($assoc_args, 'settings', array()); if (is_string($slider_settings)) { $slider_settings = HW_Encryptor::decode64($slider_settings); } $attach_ids = array(); #get attachments ids if ($source == 'upload') { $count = 1; if ($handle = opendir($source_path)) { while (false !== ($entry = readdir($handle))) { if ($count > $num) { break; } //exceed max number of files allow to upload if ($entry != "." && $entry != ".." && HW_Validation::valid_image_ext($entry)) { #echo "$entry\n"; $attach_ids[] = HW_WP_Attachment::upload_attachment($source_path . DIRECTORY_SEPARATOR . $entry); $count++; } } closedir($handle); } } else { global $wpdb; $res = $wpdb->get_results("SELECT * from {$wpdb->posts} where post_type='attachment' and post_mime_type like '%image%' order by rand() limit {$num}"); foreach ($res as $row) { $attach_ids[] = $row->ID; } } /** * add slider tab */ $mlslider_post = array('post_content' => '', 'post_title' => wp_strip_all_tags($title), 'post_name' => sanitize_title($title), 'post_status' => 'publish', 'post_type' => 'hw-ml-slider', 'post_author' => '1', 'ping_status' => 'open', 'post_parent' => '0', 'post_excerpt' => '', 'post_date' => date('Y-m-d H:i:s'), 'post_date_gmt' => date('Y-m-d H:i:s'), 'comment_status' => 'open'); $slider_id = wp_insert_post($mlslider_post); /** * add metaslider setting for created above */ $settings_params = $this->get_params('metaslider_settings'); $settings = array('type' => 'flex', 'random' => 'false', 'cssClass' => '', 'printCss' => 'true', 'printJs' => 'true', 'width' => $slide_image_width, 'height' => $slide_image_height, 'spw' => 7, 'sph' => 5, 'delay' => '3000', 'sDelay' => 30, 'opacity' => 0.8, 'titleSpeed' => 500, 'effect' => 'fade', 'navigation' => 'true', 'links' => 'true', 'hoverPause' => 'true', 'theme' => '', 'direction' => 'horizontal', 'reverse' => 'false', 'animationSpeed' => '600', 'prevText' => '<', 'nextText' => '>', 'slices' => 15, 'center' => 'false', 'smartCrop' => 'true', 'carouselMode' => 'false', 'carouselMargin' => '5', 'easing' => 'linear', 'autoPlay' => 'true', 'fullWidth' => 'false', 'noConflict' => 'true', 'hw_mlcontainer_id' => 'false', 'smoothHeight' => 'false'); if (is_array($slider_settings) && count($slider_settings)) { $settings = array_merge($settings, $slider_settings); } $this->hwml_add_or_update_or_delete_meta($slider_id, 'settings', array_merge($settings, $settings_params)); /** * add images to slider */ foreach ($attach_ids as $slide_id) { //$slide_id = $row->ID; if ($this->hwml_slide_exists_in_slideshow($slider_id, $slide_id)) { continue; } $this->hwml_tag_slide_to_slider($slider_id, $slide_id); $this->hwml_add_or_update_or_delete_meta($slide_id, 'type', 'image'); $this->hwml_add_or_update_or_delete_meta($slide_id, 'crop_position', 'center-center'); //for crop tab, set crop position for current image $this->hwml_add_or_update_or_delete_meta($slide_id, 'title', 'demo-title-' . $slide_id); //for seo tab $this->hwml_add_or_update_or_delete_meta($slide_id, 'url', 'url-here-' . $slide_id); update_post_meta($slide_id, '_wp_attachment_image_alt', 'alt demo ' . $slide_id); //for seo tab $this->hwml_add_or_update_or_delete_meta($slide_id, 'new_window', 'true'); //$row->guid; } // Free up memory //$this->stop_the_insanity(); //WP_CLI::success( ' add slider successful.' ); $this->result(' add slider successful.'); }
/** * add break line */ public function addBreakLine() { $this->addField(array('field_id' => uniqid(HW_String::generateRandomString(5)), 'type' => 'hw_html', 'show_title_column' => false, 'description' => '<hr/>')); }