/**
  * create hw_skin instance
  * @param $ref
  */
 public static function create_skin_manager(&$ref)
 {
     if (class_exists('HW_SKIN')) {
         $skin = new HW_SKIN($ref, HWRP_PLUGIN_PATH, 'hw_relatedposts_skins', 'hw-relatedposts-skin.php', 'skins');
         $skin->plugin_url = HWRP_PLUGIN_URL;
         //set plugin url or url to app that use hw_skin
         $skin->enable_external_callback = false;
         //turn off/on external callback
         $skin->custom_skins_preview = true;
         //use own skins viewer
         /*$skin->set_template_header_info(array(    //since all module use common template header: HW Template, importer/exporter that use same
               'name' => 'HWRP Template',
               'description' => 'Description',
               'author' => 'Author'
           ));*/
         $skin->add_skin_name_list(array('hw-category-posts.php'));
         $skin->match_skin_name_list('#hw-yarpp-template-.*#');
         //set migrate data + compatible vars from active skin if found together (new)
         //set migrate data with this skin
         $skin->migrate(array('cat_posts' => 'wp_query', 'metaFields' => array(), 'arrExlpodeFields' => array('title', 'excerpt', 'comment_num', 'date', 'thumb', 'author'), 'instance' => array(), 'hwtpl_wrapper_id' => 'hwtpl_wrapper_id-hw-loop-template', 'hwtpl_scrollbar_wrapper_class' => 'hwtpl_scrollbar_wrapper_class-hw-loop-template', 'hwtpl_pagination_class' => 'hwtpl_pagination_class', 'awc_enable_grid_posts' => false, 'before_widget' => '', 'after_widget' => '', 'open_title_link' => '', 'close_title_link' => '', 'before_title' => '', 'widget_title' => '', 'after_title' => ''));
         $skin->enable_template_engine();
         if (is_object($ref)) {
             $ref->skin = $skin;
         }
     }
 }
    function hw_wpcf7_contact_form_css($form)
    {
        wp_enqueue_style('hw-wpcf7-default-skin', HW_SKIN::current()->get_skin_url('style.css'));
        ?>

    <?php 
    }
Ejemplo n.º 3
0
 /**
  * @param array $new_data
  * @param array $old_data
  * @return array
  */
 function validate($new_data, $old_data)
 {
     $options = wp_parse_args($new_data, $old_data);
     foreach (array('style', 'num_pages', 'num_larger_page_numbers', 'larger_page_numbers_multiple') as $key) {
         $options[$key] = absint(@$options[$key]);
     }
     foreach (array('use_pagenavi_css', 'always_show') as $key) {
         $options[$key] = intval(@$options[$key]);
     }
     HW_SKIN::save_enqueue_skin(array('type' => 'resume_skin', 'skin' => $options['hw_skin'], 'object' => 'pagenavi', 'status' => 1));
     return $options;
 }
 /**
  * render current pagenavi skin
  * @param $html
  */
 public static function render_pagination_skin($html = '')
 {
     //get hoangweb scb options
     $options = HWPageNavi_Core::getOptions()->get();
     //$options = PageNavi_Core::$options->get();    //other way
     if (isset($options['hw_skin']['hwskin_config']) && isset($options['hw_skin']['hash_skin'])) {
         #$skin = HW_SKIN::resume_skin($options['hw_skin']['hwskin_config']);
         $skin = HW_SKIN::resume_hwskin_instance($options['hw_skin']);
         if (!empty($skin)) {
             $file = $skin->instance->get_skin_file($options['hw_skin']['hash_skin']);
             if (file_exists($file)) {
                 $theme_setting = $skin->instance->get_file_skin_setting();
                 //extract theme setting from skin
                 //load theme setting
                 if (file_exists($theme_setting)) {
                     include $theme_setting;
                 }
                 //custom wp_pagenavi output by skin
                 $html = hw_paginav_output($file, $html);
                 //valid theme setting
                 /*if(!isset($theme['styles']) || !is_array($theme['styles'])) $theme['styles'] = array();
                                     if(!isset($theme['scripts']) || !is_array($theme['scripts'])) $theme['scripts'] = array();
                 
                                     if(count($theme['styles']) || count($theme['scripts'])) {
                                         //put css within head tag
                                         $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                                     }*/
                 $skin_assets = array('skin_file' => $file);
                 if (isset($theme)) {
                     $skin_assets['theme_settings'] = $theme;
                 }
                 HW_SKIN::enqueue_skin_assets(array_merge($skin_assets, (array) $skin));
                 return isset($theme) && is_array($theme) ? $theme : array();
             }
         }
     }
 }
 /**
  * get template for current context
  */
 public static function get_current_context_template()
 {
     global $post;
     $taxonomies_template = hw_get_setting(array('my_taxonomy_settings', 'taxonomies_template'), array());
     //taxonomy template
     foreach ($taxonomies_template as $item) {
         if (!isset($item['enable']) || strtolower($item['enable']) == 'off' || !$item['enable']) {
             continue;
         }
         //taxonomy template
         if ((is_tax() || is_category()) && (!empty($item['term']) && (is_tax($item['taxonomy'], $item['term']) || is_category($item['term'])) || (empty($item['term']) || $item['term'] == -1))) {
             $item['found'] = 'taxonomy';
             $item['template'] = base64_decode($item['template']);
             //get real path
             /*if(file_exists($item['template'])) {
                   $template = $item['template'];
               }
               else*/
             if (file_exists(locate_template($item['template']))) {
                 $item['template'] = locate_template($item['template']);
             }
             //return $item;
             break;
         }
         //single template
         if (is_single() && (!empty($item['term']) && in_category($item['term'], $post) || $item['term'] == -1)) {
             $item['found'] = 'single';
             $item['single_template'] = base64_decode($item['single_template']);
             //decode path
             /*if(file_exists($item['single_template'])) {
                   return $item['single_template'];
               }
               else*/
             if (file_exists(locate_template($item['single_template']))) {
                 $item['single_template'] = locate_template($item['single_template']);
             }
             //return $item;
             break;
         }
     }
     if (isset($item['found'])) {
         if (isset($item['loop_template']) && isset($item['loop_template']['hwskin_config'])) {
             //parse loop template
             $item['skin'] = HW_SKIN::resume_skin($item['loop_template']['hwskin_config']);
         }
         return $item;
     }
 }
Ejemplo n.º 6
0
 /**
  * display widget content on website
  * @param $args
  * @param $instance
  */
 public function widget($args, $instance)
 {
     extract($args);
     //filter widget title
     $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     // Title
     $hash_skin = empty($instance['skin']) ? 'default' : $instance['skin'];
     //valid instance
     if (!isset($instance['phone_icon'])) {
         $instance['phone_icon'] = '';
     }
     if (!isset($instance['mail_icon'])) {
         $instance['mail_icon'] = '';
     }
     //by hoangweb.com
     if ($this->skin) {
         $nums = $this->_number;
         //load skin
         $file = $this->skin->get_skin_file($hash_skin);
         if (file_exists($file)) {
             $skin_setting = $this->skin->get_file_skin_setting($hash_skin, false);
             $skin_options = $this->skin->get_file_skin_options($hash_skin, false);
             if (file_exists($skin_setting)) {
                 //get setting file
                 include $skin_setting;
             }
             //init theme setting
             if (empty($theme)) {
                 $theme = array();
             }
             $theme['styles'] = array();
             $theme['scripts'] = array();
             //parse widget data
             $data = HW_Yahoo_Skype_status::parse_onlinesupport_data($instance);
             if (!is_array($data)) {
                 $data = array();
             }
             include $file;
             $this->skin->render_skin_template(array('current_skin' => HW_SKIN::current(), 'before_widget' => $before_widget, 'before_title' => $before_title, 'after_title' => $after_title, 'after_widget' => $after_widget, 'instance' => $instance, 'data' => $data, 'yk' => $this), true, $hash_skin);
             //$this->skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']); //enqueue stuff from skin
             //enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin, 'hash_skin' => $instance['skin'], 'skin_file' => $file, 'theme_settings' => $theme));
         }
     } else {
         echo 'not found class HW_SKIN.';
     }
 }
Ejemplo n.º 7
0
 /**
  * @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);
 }
 /**
  * resume hw_skin instance from this field type value
  * @param $apf_hwskin_aValue
  */
 public static function resume_hwskin_instance($apf_hwskin_aValue = array())
 {
     return HW_SKIN::resume_hwskin_instance($apf_hwskin_aValue);
 }
 /**
  * This is the Widget
  * @param $args
  * @param $instance
  */
 public function widget($args, $instance)
 {
     global $post;
     extract($args);
     // Widget options
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     // Title
     $this_taxonomy = $instance['taxonomy'];
     // Taxonomy to show
     $hierarchical = !empty($instance['hierarchical']) ? '1' : '0';
     $showcount = !empty($instance['count']) ? '1' : '0';
     $hide_empty = !empty($instance['hide_empty']) ? '1' : '0';
     $depth = !empty($instance['depth']) ? $instance['depth'] : 0;
     //skin
     $use_skin = !empty($instance['use_skin']) ? 1 : 0;
     $use_skin_options = !empty($instance['extend_skin_options']) ? 1 : 0;
     $skin = isset($instance['skin']) ? $instance['skin'] : '';
     //saved active hash skin
     //skin settings
     $skin_setting = isset($instance['skin_settings']) ? $instance['skin_settings'] : '';
     if ($skin) {
         $skin_setting_file = $this->skin->get_file_skin_setting($skin);
         //current skin setting
         $skin_options = $this->skin->get_file_skin_options();
         //current skin options
         if (file_exists($skin_setting_file)) {
             include $skin_setting_file;
         }
         if (file_exists($skin_options)) {
             include $skin_options;
         }
         if (isset($theme) && isset($theme['options'])) {
             $default_options = $theme['options'];
         }
         if (isset($default_options) && isset($theme_options)) {
             $skin_setting = HW_SKIN::merge_skin_options_values($skin_setting, $default_options, $theme_options);
         }
     }
     //widget feature field: grid_posts
     $grid_posts = HW_AWC::get_widget_feature($this, 'grid_posts');
     $awc_enable_grid_posts = false;
     //disable by default
     if ($grid_posts && HW_AWC::check_widget_feature($this, 'grid_posts')) {
         $awc_enable_grid_posts = $grid_posts->is_active($instance);
         if ($awc_enable_grid_posts) {
             $awc_grid_posts_cols = $grid_posts->get_field_value('awc_grid_posts_cols');
         }
     }
     $show_option_none = !empty($instance['show_option_none']) ? $instance['show_option_none'] : '';
     if (array_key_exists('orderby', $instance)) {
         $orderby = $instance['orderby'];
     } else {
         $orderby = 'count';
     }
     if (array_key_exists('ascdsc', $instance)) {
         $ascdsc = $instance['ascdsc'];
     } else {
         $ascdsc = 'desc';
     }
     if (array_key_exists('exclude', $instance)) {
         $exclude = join(',', (array) $instance['exclude']);
     } else {
         $exclude = '';
     }
     if (array_key_exists('dropdown', $instance)) {
         $dropdown = $instance['dropdown'];
     } else {
         $dropdown = false;
     }
     #child of arg
     if (array_key_exists('childof', $instance)) {
         $childof = $instance['childof'];
     } else {
         $childof = '';
     }
     //get current category/taxonomy
     if (isset($instance['childof_current_term']) && $instance['childof_current_term'] && (is_category() || is_tax())) {
         $obj = get_queried_object();
         //get current page data
         $childof = $obj->term_id;
         //get current term in template
     }
     $show_subcat_by_parent = isset($instance['show_subcat_by_parent']) ? (bool) $instance['show_subcat_by_parent'] : false;
     $categories_by_current_post = isset($instance['categories_by_current_post']) ? (bool) $instance['categories_by_current_post'] : false;
     $args['skin'] = $skin;
     $args['skin_setting'] = $skin_setting;
     $data = array('show_subcat_by_parent' => $show_subcat_by_parent, 'categories_by_current_post' => $categories_by_current_post, 'skin' => $skin, 'skin_setting' => $skin_setting);
     // Output
     $tax = $this_taxonomy;
     if ($dropdown) {
         $taxonomy_object = get_taxonomy($tax);
         $args = array('show_option_all' => false, 'show_option_none' => '', 'orderby' => $orderby, 'order' => $ascdsc, 'show_count' => $showcount, 'hide_empty' => $hide_empty, 'child_of' => $childof, 'exclude' => $exclude, 'echo' => 0, 'hierarchical' => $hierarchical, 'name' => $taxonomy_object->query_var, 'id' => 'hwlct-widget-' . $tax, 'depth' => $depth, 'taxonomy' => $tax, 'hide_if_empty' => (bool) $hide_empty, 'walker' => new hwlctwidget_Taxonomy_Dropdown_Walker(), 'mydata' => $data);
     } else {
         $args = array('show_option_all' => false, 'orderby' => $orderby, 'order' => $ascdsc, 'style' => 'list', 'show_count' => $showcount, 'hide_empty' => $hide_empty, 'use_desc_for_title' => 1, 'child_of' => $childof, 'exclude' => $exclude, 'hierarchical' => $hierarchical, 'title_li' => '', 'show_option_none' => apply_filters('hwlct_show_option_none', $show_option_none), 'number' => null, 'echo' => 0, 'depth' => $depth, 'taxonomy' => $tax, 'mydata' => $data);
         $args['walker'] = new hwlctwidget_Taxonomy_Walker($args);
     }
     $args = apply_filters('hwlct_wp_list_categories_args', $args, $instance);
     //filter args
     if ($use_skin && $this->skin) {
         //load skin
         $skin = $this->skin;
         //$file = $this->skin->get_skin_instance('x')->get_skin_link(empty($instance['skin1'])? 'default':$instance['skin1']);
         $file = $this->skin->get_skin_file(empty($instance['skin']) ? 'default' : $instance['skin']);
         if (file_exists($file)) {
             HW_POST::reset_item_counter();
             $terms_data = get_categories($args);
             //get terms data
             foreach ($terms_data as $id => &$term) {
                 //wrap with timber
                 $term = new HW_TimberTerm($term->term_id, $term->taxonomy);
                 //class
                 $classes = array('item-box');
                 if ($awc_enable_grid_posts && isset($awc_grid_posts_cols) && class_exists('HW_POST')) {
                     $classes = HW_POST::get_item_class($awc_grid_posts_cols, $classes);
                 }
                 if (class_exists('HW_POST')) {
                     $term->add_class(HW_POST::item_class($classes, false));
                 }
                 //term image custom field
                 /*if(function_exists('get_field')) $image = get_field('image',$term);
                   else $image = '';
                   if(!$image) $image = HW_SKIN::current()->get_skin_url('images/placeholder.png');*/
             }
             //skin template
             $content = $this->skin->render_skin_template(compact('terms_data', 'tax'), false);
             if ($content !== false) {
                 echo $content;
             }
             //init theme setting
             $theme['styles'] = array();
             //declare stylesheets file
             $theme['scripts'] = array();
             //declare js files
             if ($this->skin->allow_skin_file()) {
                 include $file;
             }
             //enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin, 'hash_skin' => $instance['skin'], 'skin_file' => $file, 'skin_settings' => $theme, 'skin_options' => $skin_setting));
         }
     } else {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         if ($dropdown) {
             echo '<form action="' . get_bloginfo('url') . '" method="get">';
             echo apply_filters('hwlct_wp_dropdown_categories', wp_dropdown_categories($args), $args, $instance);
             echo '<input type="submit" value="go &raquo;" /></form>';
         } else {
             echo apply_filters('hwlct_wp_list_categories', wp_list_categories($args), $args, $instance);
         }
         echo $after_widget;
     }
     if ($use_skin && !class_exists('HW_SKIN')) {
         echo 'HW_SKIN class không tìm thấy.';
     }
     //notice
 }
 /**
  * renderOptionField callback (experimental)
  * @param $field: field setting
  */
 public function renderOptionField_callback($field)
 {
     /*if($field['type'] == 'template') {
           $field['type'] = 'select';
           //if($this->get_from_context() == 'renderOptionField_APF') $this->renderOptionField_APF($field);
       }
       */
     if ($field['type'] == 'template') {
         //template
         $data = $this->get_list_templates();
         $field['options'] = array(self::DEFAULT_TEMPLATE => __('Mặc định'));
         //override args
         foreach ($data as $file) {
             $field['options'][HW_SKIN::encrypt($file['file_path'])] = $file['name'];
         }
         //$field['type'] = 'select';
         //$tag .= $this->renderOptionField_APF($field, $aField,$_aAttributes,$_sSlug,false,false);   //render select tag
     }
     return $field;
 }
Ejemplo n.º 11
0
 /**
  * if this callback of the hook that mean you not link specific menu to wp_nav_menu
  * @hook filter 'wp_nav_menu_args'
  * @param $args
  */
 public function _modify_nav_menu_args($args)
 {
     //get current menu name
     $menu = self::get_menu_name($args);
     /**
      * get menu skin
      * first entry for through out menu filters
      */
     $skin = HW_NavMenu_Metabox_settings::get_menu_setting('skin', $menu);
     $enable_skin = HW_NavMenu_Metabox_settings::get_menu_setting('enable_skin', $menu);
     $enable_filter_menu = HW_NavMenu_Metabox_settings::get_menu_setting('enable_filter_menu', $menu);
     //add other menu setting to menu args
     $addition_menu_args = array('show_searchbox', 'remove_ul_wrap', 'only_anchor_tag_nav_menu', 'show_home_menu', 'allow_tags_nav_menu', 'show_icon');
     foreach ($addition_menu_args as $option) {
         $args[$option] = HW_NavMenu_Metabox_settings::get_menu_setting($option, $menu);
     }
     if ($enable_filter_menu && $enable_skin && $skin) {
         //parse SKIN object
         $this->skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($skin);
         //parse into HW_SKIN object & saved as property
         $this->skin->file = $this->skin->instance->get_skin_file($this->skin->hash_skin);
         $options_config = $this->skin->instance->get_file_skin_options($this->skin->hash_skin);
         //theme options configuration
         $theme_setting = $this->skin->instance->get_file_skin_setting();
         //theme setting file
         //register twig loader
         if (class_exists('HW_Twig_Template')) {
             //Twig_Autoloader::register();
             //$loader = new Twig_Loader_Filesystem($this->skin->instance->get_file_skin_resource('tpl'));
             $this->twig = HW_Twig_Template::create($this->skin->instance->get_file_skin_resource('tpl'));
             #$this->twig = new Twig_Environment($loader);
             $args['twig'] = $this->twig->get();
             //reference twig object
         }
         if (file_exists($this->skin->file)) {
             $theme = array();
             $theme['styles'] = array();
             //init
             $theme['scripts'] = array();
             $theme['filters'] = array();
             //allow filters
             //keep this info (ex: menu) with filter that bind to callback to compare from current filter args
             $theme['menu'] = $menu;
             $user_options = array();
             //skin options
             if (file_exists($theme_setting)) {
                 include $theme_setting;
             }
             //theme setting
             if (file_exists($options_config)) {
                 include $options_config;
             }
             //options file
             if (isset($theme_options)) {
                 //$theme_options variable already exists in skin options
                 //$skin_options_config = hwskin_parse_theme_options($theme_options);
                 //get addition skin options value
                 $skin_options = isset($skin['skin_options']) ? $skin['skin_options'] : array();
                 if (empty($skin_options)) {
                     $skin_options = array();
                 }
                 //please go menu setting page & press on save button
                 $exclude_options = array('menu');
                 foreach ($exclude_options as $opt) {
                     if (isset($skin_options[$opt])) {
                         unset($skin_options[$opt]);
                     }
                 }
                 $user_options = HW_SKIN::get_skin_options($skin_options, $theme['args'], $theme_options);
                 $args = array_merge($args, $user_options);
                 //sync skin options with $args
                 //hope $args share to all remain menu filters in order to render final output menu to user
                 /*foreach($skin_options as $arg => $value){
                       $field_setting = $skin_options_config[$arg];
                       if(!isset($args[$arg])) $args[$arg] = '';   //set menu args from skin
                       //append if exists setting
                       if(isset($field_setting['method']) && $field_setting['method'] == 'append' && !empty($value)){
                           if(!in_array($value, preg_split('#[\s]+#',$args[$arg]))){
                               $args[$arg] .= (!empty($args[$arg])? ' ':'').trim($value);
                           }
                       }
                       //override setting if not exists
                       if(isset($field_setting['method']) && $field_setting['method'] == 'override' && !empty($value)){
                           $args[$arg] = $value;
                       }
                   }*/
             }
             //make sure have no ouput at here
             HW_SKIN::include_skin_file($this->skin->file);
             //extract wp_nav_menu_args from skin file
             /*if(isset($theme['args']) && is_array($theme['args'])){
                   //$args = array_merge($args, $theme['args']);
                   foreach($theme['args'] as $arg => $val){
                       if(isset($args[$arg])) $args[$arg] .= (!empty($args[$arg])? ' ':'').$val;     //append
                       else $args[$arg] = $val;    //create if not exists
                   }
               }*/
             $this->skin->instance->do_filters($theme['filters'], array($theme, $user_options));
             //do filters & actions that defined in skin
             //$this->skin->instance->enqueue_files_from_skin(null/*$theme['styles']*/, $theme['scripts']);    //put stuff from skin (note: css enqueue before)
             //new way for enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin->instance, 'hash_skin' => $this->skin->hash_skin, 'skin_file' => $this->skin->file, 'theme_settings' => $theme, 'theme_options' => $args));
             //languages selector on the website
             $show_langs_switcher = HW_NavMenu_Metabox_settings::get_menu_setting('show_langs_switcher', $menu);
             //show search form in nav menu
             if ($show_langs_switcher) {
                 //get langs switcher output
                 $args['langs_switcher'] = hw_get_qtrans_switcher();
             }
             #$args = array_merge($args, $skin_options); //filtered values in above
             //if(isset($args['show_items_separator'])) ;
         }
         $args['walker'] = new HW_Nav_Menu_Walker();
     }
     $this->menu_args = (object) $args;
     //save current menu args
     /*if( 'primary' == $args['theme_location'] )
             {
                 $args['depth'] = -1;
                 $args['container_id'] = 'my_primary_menu';
             }
             if('menu1' == $args['menu']){    #maybe old wp version
                 $args['walker'] = new custom_walker();
             }
             //for custom menu widget
             if(isset($args['menu']) && isset($args['menu']->name) && $args['menu']->name == 'menu-header')
             {
     
             }*/
     return $args;
 }
    /**
     * Field Render Function.
     *
     * Takes the vars and outputs the HTML for the field in the settings
     *
     * @since NHP_Options 1.0
     */
    function render()
    {
        //valid
        if (!class_exists('HW_SKIN')) {
            echo 'Cần kích hoạt plugin HW SKIN.';
            return;
        }
        $style = $this->get_field_value('display');
        //display mode
        $class = isset($this->field['class']) ? 'class="' . $this->field['class'] . '" ' : '';
        $field_name = $this->args['opt_name'] . '[' . $this->field['id'] . ']';
        //base field name
        $value = isset($this->value['hash_skin']) ? $this->value['hash_skin'] : '';
        //get hash skin value
        $obj_name = HW_SKIN::valid_objname($this->field['id']);
        $default_skin_file = base64_encode(serialize($this->skin->get_default_skin_file(true)));
        $active_skin_file = $this->skin->get_skin_link($value, true);
        //$skin_info = $this->skin->set_active_skin($value);
        //$skin_info = $this->skin->get_skin_info($value);
        if (isset($this->skin)) {
            $this->skin->saveCallbackJs4SkinChangeEvent($obj_name . '_choose_skin_callback(skin);');
            switch ($style) {
                case 'ddslick':
                    echo $this->skin->get_skins_select_tag($field_name . '[hash_skin]', $value, array(), HW_SKIN::DROPDOWN_DDSSLICK_THEME, HW_SKIN::SKIN_LINKS);
                    break;
                case 'list':
                    echo $this->skin->get_skins_listview($field_name . '[hash_skin]', $value, HW_SKIN::SKIN_LINKS);
                    break;
                default:
                    echo $this->skin->get_skins_select_tag($field_name . '[hash_skin]', $value, array(), false, HW_SKIN::SKIN_LINKS);
            }
            #_print($this->skin->get_skin_link( $this->value));
            echo '<input type="hidden" name="' . $field_name . '[hwskin_link_default_skin_file]" value="' . $default_skin_file . '"/>';
            echo '<input type="hidden" id="' . $this->field['id'] . '_hwskin_save_link" name="' . $field_name . '[hwskin_link_file_url]" value="' . base64_encode(serialize($active_skin_file[0])) . '"/>';
            echo '<input type="hidden" name="' . $field_name . '[hwskin_link_source]" value="' . $active_skin_file[1] . '"/>';
            echo '<script>
		        //save skin file into new nhp field
		      function ' . $obj_name . '_choose_skin_callback(skin){
		        jQuery("#' . $this->field['id'] . '_hwskin_save_link").val(skin.screenshot);
		      }

		    </script>';
        } else {
            echo '<p>Không thể tạo skin, vì thiếu tham số của trường này.</p>';
        }
        echo isset($this->field['desc']) && !empty($this->field['desc']) ? ' <span class="description">' . $this->field['desc'] . '</span>' : '';
    }
Ejemplo n.º 13
0
 /**
  * get footer, instead of calling get_footer()
  * @param $slug from get_footer() param
  */
 public static function get_footer($slug = '')
 {
     $footer_skin = hw_option('footer_skin');
     //get footer skin
     //skin options
     if (!empty($footer_skin) && !empty($footer_skin['skin_options'])) {
         $skin_options = $footer_skin['skin_options'];
         extract($skin_options);
     }
     if (isset($footer_skin['hash_skin']) && isset($footer_skin['hwskin_config'])) {
         $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($footer_skin);
         $file = $skin->instance->get_skin_file($skin->hash_skin);
         //get theme setting file
         $setting = $skin->instance->get_file_skin_setting();
         //(new HW_SKIN);
         if (file_exists($setting)) {
             include $setting;
         }
         $skin->instance->render_skin_template(compact('col', 'col_1', 'col_2', 'col_3'), true);
         //render skin twig template
         //load footer template
         if ($skin->instance->allow_skin_file() && file_exists($file)) {
             include_once $file;
         }
         //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']);
           }
           */
         if (isset($theme['filters'])) {
             $skin->instance->do_filters($theme['filters'], $theme);
         }
         //do skin filter/action
         //enqueue stuff from skin using new way
         HW_SKIN::enqueue_skin_assets(array_merge(array('skin_file' => $file, 'theme_settings' => $theme), (array) $skin));
     } else {
         get_footer($slug);
         //include default footer-$slug.php
     }
     do_action('hw_get_footer');
     //modify footer output, you can add close html tag for example to make fit your wp theme
 }
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     //$content = isset($instance['content'])? $instance['content'] : '';  //marquee content
     $source = isset($instance['source']) ? $instance['source'] : 'content';
     //data source
     $data = isset($instance['data']) ? $instance['data'] : array();
     if (isset($data[$source])) {
         //get data content
         $content = $data = $data[$source];
     }
     //parse source for slides
     if ($source == 'slides' && is_numeric($data)) {
         $data = hwmq_get_mlslider_data($data);
     }
     //skin
     $hash_skin = isset($instance['skin']) ? $instance['skin'] : 'default';
     // before and after widget arguments are defined by themes
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     // This is where you run the code and display the output
     if ($this->skin) {
         $skin_options = isset($instance['skin_settings']) ? $instance['skin_settings'] : array();
         HW_SKIN::apply_skin_data(array('instance' => $this->skin, 'hash_skin' => $hash_skin, 'skin_options' => $skin_options), array('callback_before' => array($this, '_hw_skin_apply_skin_data_callback_before'), 'callback_after' => array($this, '_hw_skin_apply_skin_data_callback_after')), array('instance' => $instance, 'data' => $data));
     }
     echo $args['after_widget'];
 }
Ejemplo n.º 15
0
/**
 * get skins setting
 * @param array $where
 * @return array
 */
function hwskin_get_skins_enqueues($where = array('status' => 1))
{
    global $wpdb;
    $data = array();
    $where_mark = '';
    $where_value = array();
    foreach ($where as $field => $val) {
        $where_mark .= "{$field} = %s and ";
        $where_value[] = $val;
    }
    //valid
    $where_mark = trim($where_mark, 'and ');
    $query = "SELECT * FROM " . HW_SKIN::SKINS_SETTINGS_DB . " " . ($where_mark ? 'WHERE ' . $where_mark : '');
    $result = $wpdb->get_results($wpdb->prepare($query, $where_value));
    //loop all skins
    foreach ($result as $skin) {
        $key = $skin->blog_id . '_' . $skin->object;
        if (isset($data[$key])) {
            continue;
        }
        $data[$key] = array();
        $skin_config = unserialize($skin->skin);
        /*if($skin['type'] == 'resume_skin') {
        
                    //parse hw_skin instance
                    if(isset($skin_config['hw_skin_config']) && isset($skin_config['hw_skin'])) {   //for old version
                        $skin_obj = HW_SKIN::resume_skin($skin_config['hw_skin_config']);
        
                    }
                }
                elseif($skin['type'] == 'APF_field' || $skin['type'] == 'NHP_field') {
        
                }*/
        if (isset($skin_config['hash_skin']) && isset($skin_config['hwskin_config'])) {
            $skin_obj = HW_SKIN::resume_hwskin_instance($skin_config);
            //
            $data[$key] = $skin_obj;
        }
        #if(isset($skin_obj)) $data[$key]['instance'] = $skin_obj;
    }
    return $data;
}
Ejemplo n.º 16
0
 /**
  * @param $xml
  * @param array $namespaces
  * @return array
  */
 public function build_skin_data(SimpleXMLElement $xml, $namespaces = null)
 {
     if (empty($namespaces)) {
         $namespaces = $this->namespaces;
     }
     #$node=dom_import_simplexml($xml);//dom_import_simplexml()
     #$n = $xml->getNameSpaces(false);_print($node->localName.','.$node->textContent);
     #$xml->getDocNamespaces(0);
     #if(empty($n)) return;
     HW_HOANGWEB::load_class('HW_File_Directory');
     if (empty($namespaces)) {
         $namespaces = $this->valid_namespaces($xml);
     }
     $skin_tag = $xml->xpath('params:skin_encoded');
     $data = array();
     if (!empty($skin_tag) || count($xml->xpath('params:skin_instance'))) {
         $params = $xml->children($namespaces['params']);
         $hash_skin = array();
         $skin_config = array();
         $apply_plugin = '';
         $skin_name = '';
         $skin_data = array();
         $screenshot = '';
         $screenshot_ext = 'jpg';
         /*if(isset($skin->apply_plugin)) {    //apply skin
               $apply_plugin = (string) $skin->apply_plugin ;
           }
           else*/
         if (isset($skin_data['apply_plugin'])) {
             $apply_plugin = $skin_data['apply_plugin'];
         } else {
             $apply_plugin = '';
             //leave empty for hw-hoangweb plugin
         }
         //for skin link
         if (!empty($params->skin_file) && HW_XML::count_childs($params->skin_file)) {
             $atts = $params->skin_file->attributes();
             //if(!isset($atts['name'])) $atts['name'] = 'url';  //skin_config
             //get skin data
             if (isset($atts['instance']) && isset($this->skins_data[(string) $atts['instance']])) {
                 $skin_data = $this->skins_data[(string) $atts['instance']];
             }
             $skin = $params->skin_file->children($namespaces['skin']);
             $hash_skin['type'] = '';
             //get source
             if (isset($skin->source)) {
                 $hash_skin['source'] = (string) $skin->source;
             } else {
                 $hash_skin['source'] = 'plugin';
             }
             $file_link = (string) $skin->file;
             $skin_file_name = isset($atts['name']) ? (string) $atts['name'] : 'url';
             //get group
             if (isset($skin->group)) {
                 $group = (string) $skin->group;
             } elseif (isset($skin_config['group'])) {
                 $group = $skin_config['group'];
             } elseif (isset($skin_data['group'])) {
                 $group = $skin_data['group'];
             }
             //$hash_skin = HW_SKIN::valid_holder_path($apply_plugin, $hash_skin);
             /*$file_url = HW_File_Directory::generate_url(HW_HOANGWEB_PLUGINS_URL,$apply_plugin,
                   $skin_config['default_skin_path'], $group, $file_link
               );
               //$hash_skin['screenshot_url'] = $hash_skin['file_url'] = $file_url;
               */
             $hash_skin['file'] = $hash_skin['name'] = $file_link;
             //$data[isset($atts['name'])? (string) $atts['name']: 'url'] = $file_url ;
         }
         //parse hash_skin value
         if (isset($params->skin_encoded) && HW_XML::count_childs($params->skin_encoded)) {
             $atts = $params->skin_encoded->attributes();
             //if(!isset($atts['name'])) $atts['name'] = 'hash_skin';  //default hash_skin field-> not allow to update
             if (isset($atts['instance']) && isset($this->skins_data[(string) $atts['instance']])) {
                 $skin_data = $this->skins_data[(string) $atts['instance']];
             }
             #$params->skin_encoded->xpath('skin:skins_path');
             $skin = $params->skin_encoded->children($namespaces['skin']);
             if (isset($skin->apply_plugin)) {
                 //apply skin
                 $apply_plugin = (string) $skin->apply_plugin;
             } elseif (isset($skin_data['apply_plugin'])) {
                 $apply_plugin = $skin_data['apply_plugin'];
             } else {
                 $apply_plugin = '';
                 //leave empty for hw-hoangweb plugin
             }
             //get source
             if (isset($skin->source)) {
                 $hash_skin['source'] = (string) $skin->source;
             } else {
                 $hash_skin['source'] = 'plugin';
             }
             //skin name
             /*if(isset($skin->skin_name)) {
                   $skin_name = (string) $skin->skin_name;
               }
               else*/
             if (isset($skin_data['skin_name'])) {
                 $skin_name = $skin_data['skin_name'];
             }
             //$hash = array('skins_path', '');
             $hash_skin['holder'] = $apply_plugin;
             if ($apply_plugin) {
                 $hash_skin = HW_SKIN::valid_holder_path($apply_plugin, $hash_skin);
             } else {
                 //refer to hw-hoangweb plugin
                 if (!file_exists($hash_skin['holder'])) {
                     $hash_skin['holder'] = '';
                     #HW_HOANGWEB_PATH. DIRECTORY_SEPARATOR;
                     $hash_skin['holder_url'] = '';
                     //HW_HOANGWEB_URL ;
                 }
             }
             if (isset($skin->screenshot)) {
                 //screenshot
                 $screenshot = (string) $skin->screenshot;
             }
             /*elseif(isset($skin_data['screenshot'])) {
                   $screenshot = $skin_data['screenshot'];
               }*/
             if (isset($skin->skin_type)) {
                 //skin type
                 $hash_skin['type'] = (string) $skin->skin_type;
             } elseif (isset($skin_data['skin_type'])) {
                 $hash_skin['type'] = $skin_data['skin_type'];
             }
             //group
             if (isset($skin->group)) {
                 $hash_skin['group'] = (string) $skin->group;
             } elseif (isset($skin_data['group'])) {
                 $hash_skin['group'] = $skin_data['group'];
             } else {
                 $hash_skin['group'] = '';
             }
             if (isset($skin->default_folder)) {
                 //skins path
                 $hash_skin['default_folder'] = (string) $skin->default_folder;
             } elseif (isset($skin_data['default_skin_path'])) {
                 $hash_skin['default_folder'] = $skin_data['default_skin_path'];
             }
             //skin_folder
             if ($hash_skin['type'] == 'file') {
                 $hash_skin['skin_folder'] = $hash_skin['default_folder'] . '/' . $hash_skin['group'];
             } else {
                 $hash_skin['skin_folder'] = $hash_skin['default_folder'];
             }
             if ($hash_skin['type'] === 'link') {
                 //path
                 $hash_skin['path'] = rtrim($hash_skin['group'], '\\/') . '/';
             } else {
                 if (isset($skin->skin)) {
                     //skin folder
                     $hash_skin['path'] = (string) $skin->skin;
                 } elseif (isset($skin_data['default_skin'])) {
                     $hash_skin['path'] = $skin_data['default_skin'];
                 }
             }
             $hash_skin['path'] = rtrim($hash_skin['path'], '\\/') . '/';
             //valid
             $full_holder = HW_SKIN::get_skin_realpath(array('path' => $hash_skin['holder']), $hash_skin['source'])->path;
             $skin_path = HW_File_Directory::generate_path($full_holder, $hash_skin['default_folder'], $hash_skin['group'], $hash_skin['path']);
             //screenshot mimetype
             /*if(isset($skin->screenshot_mimetype)) {   //no, we auto find screenshot mimetype
                   $screenshot_ext = (string) $skin->screenshot_mimetype;
               }*/
             $screenshot_ext = file_exists($skin_path . '/screenshot.png') ? 'png' : 'jpg';
             //skin name
             if ($hash_skin['type'] == 'file' && $skin_name) {
                 $hash_skin['filename'] = $skin_name;
             }
             #else $hash_skin['file'] = $skin_name; //for skin link, do it above
             if (isset($skin->title) && !isset($hash_skin['name'])) {
                 //title
                 $hash_skin['name'] = (string) $skin->title;
             } else {
                 if (isset($hash_skin['holder']) && isset($hash_skin['default_folder']) && !isset($hash_skin['name'])) {
                     if (isset($skin_data['template_header'])) {
                         $header = $skin_data['template_header'];
                     } else {
                         $header = array('name' => 'HW Template', 'description' => 'Description', 'author' => 'Author', 'uri' => 'Author URI');
                     }
                     if ($hash_skin['type'] == 'file') {
                         $skin_file = HW_File_Directory::generate_path($full_holder, $hash_skin['default_folder'], $hash_skin['group'], $hash_skin['path']) . '/' . $skin_name;
                     } else {
                         $skin_file = HW_File_Directory::generate_path($full_holder, $hash_skin['default_folder'], $hash_skin['path']) . '/' . $skin_name;
                     }
                     $temp_header = HW_SKIN::get_template_data($skin_file, 0, $header);
                     $hash_skin['name'] = $temp_header['name'];
                 }
             }
             $hash_skin['skin_url'] = HW_File_Directory::generate_url($hash_skin['holder_url'], $hash_skin['skin_folder'], $hash_skin['path']);
             if (isset($skin_file_name) && isset($file_link)) {
                 $hash_skin['file_url'] = HW_File_Directory::generate_url($hash_skin['skin_url'], $file_link);
                 $data[$skin_file_name] = $hash_skin['screenshot_url'] = $hash_skin['file_url'];
             }
             /*if($screenshot && !isset($hash_skin['screenshot_url'])) {  //skin screenshot
                   $hash_skin['screenshot_url'] = $screenshot;
                   if(!HW_Validation::hw_valid_url($hash_skin['screenshot_url'])) {
                       $hash_skin['screenshot_url'] = HW_File_Directory::generate_path(HW_HOANGWEB_PLUGINS_URL, $hash_skin['screenshot_url']);
                   }
               }
               else*/
             if (!isset($hash_skin['screenshot_url'])) {
                 $hash_skin['screenshot_url'] = HW_File_Directory::generate_url($hash_skin['skin_url'], 'screenshot.' . ltrim($screenshot_ext, '.'));
                 //default jpg mimetype
             }
             //valid hash skin value
             if (count($hash_skin) < 7) {
                 return;
             }
             //$hash_skin = hwArray::sortArrayByArray($hash_skin, array('skins_path','skin_folder','skin_url','skin_type','title','screenshot','skin_name'));
             if (isset($hash_skin['type']) && $hash_skin['type'] == 'file') {
                 $hash_skin_value = HW_SKIN::generate_skin_path($hash_skin);
             } else {
                 $hash_skin_value = HW_SKIN::generate_skin_file($hash_skin);
             }
             #__print(($hash_skin));exit;
             $data[isset($atts['name']) ? (string) $atts['name'] : 'hash_skin'] = $hash_skin_value;
         }
         //parse skin config
         if (isset($params->skin_instance)) {
             $atts = $params->skin_instance->attributes();
             //if(!isset($atts['name'])) $atts['name'] = 'skin_config';  //skin_config
             if (isset($atts['instance']) && isset($this->skins_data[(string) $atts['instance']])) {
                 $skin_data = $this->skins_data[(string) $atts['instance']];
             }
             $skin = $params->skin_instance->children($namespaces['skin']);
             //get default values
             if (isset($skin->apply_plugin) && !$apply_plugin) {
                 //apply_plugin
                 $apply_plugin = (string) $skin->apply_skin;
             } elseif (isset($skin_data['apply_plugin']) && !$apply_plugin) {
                 $apply_plugin = $skin_data['apply_plugin'];
             }
             if (isset($skin->skin_name) && !$skin_name) {
                 //skin_name
                 $skin_name = (string) $skin->skin_name;
             } elseif (isset($skin_data['skin_name']) && !$skin_name) {
                 $skin_name = $skin_data['skin_name'];
             }
             //grab
             /*if(isset($skin->apply_current_path)) {  //apply_current_path
                   $skin_config['apply_current_path'] = (string) $skin->apply_current_path;
                   if(!file_exists($skin_config['apply_current_path'])) {
                       $skin_config['apply_current_path'] = HW_File_Directory::generate_path(HW_HOANGWEB_PLUGINS, $skin_config['apply_current_path']);
                   }
               }
               if(isset($skin->plugin_url)) {  //plugin_url
                   $skin_config['plugin_url'] = (string) $skin->plugin_url;
                   if(!HW_Validation::hw_valid_url($skin_config['plugin_url'])) {
                       $skin_config['plugin_url'] = HW_File_Directory::generate_path(HW_HOANGWEB_PLUGINS_URL , $skin_config['plugin_url']);
                   }
               }*/
             if (isset($skin->other_folder)) {
                 //other_folder
                 $skin_config['other_folder'] = (string) $skin->other_folder;
             } elseif (isset($skin_data['other_folder'])) {
                 $skin_config['other_folder'] = $skin_data['other_folder'];
             }
             if ($skin_name) {
                 //skin_name
                 $skin_config['skin_name'] = $skin_name;
             }
             if (isset($skin->default_skin_path)) {
                 //default_skin_path
                 $skin_config['default_skin_path'] = (string) $skin->default_skin_path;
             } elseif (isset($skin_data['default_skin_path'])) {
                 $skin_config['default_skin_path'] = $skin_data['default_skin_path'];
             }
             if (isset($skin->group)) {
                 //group
                 $skin_config['group'] = (string) $skin->group;
             } elseif (isset($skin_data['group'])) {
                 $skin_config['group'] = $skin_data['group'];
             }
             if (isset($skin->enable_external_callback)) {
                 //enable_external_callback
                 $skin_config['enable_external_callback'] = (string) $skin->enable_external_callback;
             } elseif (isset($skin_data['enable_external_callback'])) {
                 $skin_config['enable_external_callback'] = $skin_data['enable_external_callback'];
             }
             //allow skin names
             if (isset($skin->allows_skin_names)) {
                 $skin_config['allows_skin_names'] = HW_XML::xml2array($skin->allows_skin_names->children(), 'param', 'params');
             } elseif (isset($skin_data['allows_skin_names'])) {
                 $skin_config['allows_skin_names'] = $skin_data['allows_skin_names'];
             }
             //properties
             if (isset($skin->properties)) {
                 $skin_config['properties'] = HW_XML::xml2array($skin->properties->children(), 'param', 'params');
             } elseif (isset($skin_data['properties'])) {
                 $skin_config['properties'] = $skin_data['properties'];
             }
             //options
             if (isset($skin->options)) {
                 $skin_config['options'] = HW_XML::xml2array($skin->properties->children(), 'param', 'params');
             } elseif (isset($skin_data['options'])) {
                 $skin_config['options'] = $skin_data['options'];
             }
             if ($apply_plugin && !isset($skin_config['apply_current_path'])) {
                 //$skin_config["apply_current_path"] = HW_File_Directory::generate_path(HW_HOANGWEB_PLUGINS,$apply_plugin);
                 $skin_config["apply_current_path"] = $apply_plugin;
             }
             if ($apply_plugin && !isset($skin_config['plugin_url'])) {
                 //$skin_config['plugin_url'] = HW_File_Directory::generate_path(HW_HOANGWEB_PLUGINS_URL, $apply_plugin);
                 $skin_config['plugin_url'] = $apply_plugin;
             }
             //other params
             $other_config_params = HW_XML::xml2array($params->skin_instance->children(), 'param', 'params');
             //fix
             if (!isset($other_config_params['allows_skin_names'])) {
                 $other_config_params['allows_skin_names'] = array();
             } elseif (isset($skin_data['allows_skin_names'])) {
                 $other_config_params['allows_skin_names'] = $skin_data['allows_skin_names'];
             }
             if (isset($skin_config['skin_name']) && !in_array($skin_config['skin_name'], $other_config_params['allows_skin_names'])) {
                 $other_config_params['allows_skin_names'][] = $skin_config['skin_name'];
             }
             if (!empty($other_config_params)) {
                 $skin_config = array_merge($skin_config, $other_config_params);
             }
             $data[isset($atts['name']) ? (string) $atts['name'] : 'skin_config'] = HW_SKIN::generate_skin_config($skin_config);
         }
         //other params
         $data = array_merge($data, HW_XML::xml2array($xml));
         /*$atts = $xml->attributes(); //get attributes
           if(isset($atts['name'])) {
               $data = array((string)$atts['name'] => $data);
           }*/
         return count($data) ? $data : null;
     }
 }
 /**
  * check you theme exists function bind to this hook 'dynamic_sidebar_params' before use this.
  * @param array $params: sidebar widgets params
  */
 public function _hw_awc_widget_change_params($params)
 {
     global $wp_registered_widgets;
     global $wp_registered_sidebars;
     $this_id = $params[0]['id'];
     // Get the id for the current sidebar we're processing
     $widget_id = $params[0]['widget_id'];
     $widget_obj = $wp_registered_widgets[$widget_id];
     $widget_opt = get_option($widget_obj['callback'][0]->option_name);
     $widget_num = $widget_obj['params'][0]['number'];
     $arr_registered_widgets = wp_get_sidebars_widgets();
     // Get an array of ALL registered widgets
     if (!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) {
         // Check if the current sidebar has no widgets
         return $params;
         // No widgets in this sidebar... bail early.
     }
     if (!is_active_sidebar($this_id)) {
         return $params;
     }
     //this sidebar should be actived
     $current_widget = $widget_opt[$widget_num];
     //get current widget
     //check if this sidebar have any modified from user setting
     $enable_override_sidebar = HW_AWC_Sidebar_Settings::get_sidebar_setting('enable_override_sidebar', $this_id);
     //parse settings
     if (isset($current_widget['bgcolor_widget'])) {
         $color_widget = self::valid_hex_color($current_widget['bgcolor_widget']);
     }
     //callback
     if (!is_admin()) {
         $wp_registered_widgets[$widget_id]['original_callback'] = $wp_registered_widgets[$widget_id]['callback'];
         $wp_registered_widgets[$widget_id]['callback'] = array($this, '_hw_custom_widget_callback_function');
     }
     /**
      * apply skin for specific widget
      */
     if ($enable_override_sidebar && isset($current_widget['widget_skin'])) {
         //get widget skin
         $skin_data = HW_AWC_Sidebar_Settings::get_sidebar_setting($current_widget['widget_skin'], $this_id);
         if (isset($skin_data['hash_skin'])) {
             $hash_skin = $skin_data['hash_skin'];
         }
         if (isset($skin_data['hwskin_config'])) {
             $skin_config = $skin_data['hwskin_config'];
         }
         if (isset($skin_config) && $skin_config && isset($hash_skin)) {
             $skin = HW_SKIN::resume_skin($skin_config);
             //resume HW_SKIN with given config
             if (method_exists($skin, 'get_skin_file')) {
                 $file = $skin->get_skin_file($hash_skin);
             }
             if (isset($file) && file_exists($file)) {
                 $theme = array();
                 //valid
                 include $file;
                 //don't use include_one or require_once, and don't create function in skin file because will cause duplicate function
                 $wp_registered_sidebars[$this_id]['skin'] = $skin;
                 //bring skin object into params
                 /**
                  * override sidebar param
                  */
                 if (isset($theme['params']) && is_array($theme['params'])) {
                     $params[0] = array_merge($params[0], $theme['params']);
                 }
                 /**
                  * this snipet from WP Core (wp-includes/widgets.php) - since version 4.0
                  * Substitute HTML id and class attributes into before_widget
                  */
                 $classname_ = self::format_widget_sidebar_params($widget_id);
                 $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $widget_id, $classname_);
                 /**
                  * enqueue css & js -> depricated
                  */
                 /*if(!isset($theme['styles'])) $theme['styles'] = array();
                                     if(!isset($theme['scripts'])) $theme['scripts'] = array();
                 
                                     if(count($theme['styles']) || count($theme['scripts'])) {
                                         $skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                                     }*/
             }
         }
     }
     $params[0] = self::format_sidebar_params($this_id, $params[0], $current_widget);
     //$params[0] = array_merge($params[0], $new_params);
     /*clear widget title*/
     if (isset($current_widget['awc_clear_widget_title']) && $current_widget['awc_clear_widget_title']) {
         //clear before_title & after_title
         $params[0]['before_title'] = '';
         $params[0]['after_title'] = '';
         //valid HTML combine from before_widget + after_widget
         $tidyconfig = array('indent' => false, 'show-body-only' => true, 'clean' => false, 'output-xhtml' => true, 'input-xml' => true);
         $sign_str = '_______';
         $html = $params[0]['before_widget'] . $sign_str . $params[0]['after_widget'];
         $html = HW_String::tidy_cleaning($html, $tidyconfig, 'body');
         //hwawc_tidy_cleaning($html,$tidyconfig,'body');
         $t = explode($sign_str, $html);
         if (count($t) == 2) {
             $params[0]['before_widget'] = $t[0];
             //get new before widget
             $params[0]['after_widget'] = $t[1];
             //get new after_widget param
         }
     }
     /**
      * show widgets with order number
      */
     if ($enable_override_sidebar && HW_AWC_Sidebar_Settings::get_sidebar_setting('alphabe_widgets', $this_id)) {
         global $hwawc_widget_num;
         // Global a counter array
         if (!$hwawc_widget_num) {
             // If the counter array doesn't exist, create it
             $hwawc_widget_num = array();
         }
         if (isset($hwawc_widget_num[$this_id])) {
             // See if the counter array has an entry for this sidebar
             $hwawc_widget_num[$this_id]++;
         } else {
             // If not, create it starting with 1
             $hwawc_widget_num[$this_id] = 1;
         }
         $class_id = 'widget-' . $hwawc_widget_num[$this_id];
         $class = 'class="';
         // Add a widget number class for additional styling options
         //if(!$this->exists_class($class_id, $params[0]['before_widget'])) {
         $class .= $class_id . ' ';
         //}
         if ($hwawc_widget_num[$this_id] == 1) {
             // If this is the first widget
             //if(!$this->exists_class('widget-first', $params[0]['before_widget']))
             $class .= 'widget-first ';
         } elseif ($hwawc_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) {
             // If this is the last widget
             //if(!$this->exists_class('widget-last', $params[0]['before_widget']))
             $class .= 'widget-last ';
         }
         $params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']);
         // Insert our new classes into "before widget"
     }
     //finally
     if ($enable_override_sidebar) {
         //mark modify before_widget class by adding new class for this plugin to prevent conflict other css in your theme
         $params[0]['before_widget'] = str_replace('class="', 'class="hw-awc-override ', $params[0]['before_widget']);
     }
     return $params;
 }
 /**
  * form HTML to output on website, but we will include selected skin for this form
  */
 public function _hw_wpcf7_form_elements($html)
 {
     $skin = $this->current->prop('hw_wpcf7_skin');
     //get current contact form skin
     $custom_css = $this->current->prop('hw_custom_css');
     //get custom css for this form
     $enable_skin = $this->current->prop('hw_wpcf7_use_skin');
     //check whether this skin is active for the contact form
     if ($enable_skin !== 'on') {
         return $html;
     }
     //don't use private skin for this form
     //get skin file
     $file = $this->setting->skin->get_skin_file($skin);
     if (file_exists($file)) {
         $theme[] = array();
         ob_start();
         include_once $file;
         if (!isset($theme['styles'])) {
             $theme['styles'] = array();
         }
         if (!isset($theme['scripts'])) {
             $theme['scripts'] = array();
         }
         /*if(count($theme['styles']) || count($theme['scripts'])){    //enqueue stuff from skin
               $this->setting->skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
           }*/
         //enqueue stuff from skin
         HW_SKIN::enqueue_skin_assets(array('instance' => $this->setting->skin, 'hash_skin' => $skin, 'skin_file' => $file, 'theme_settings' => $theme));
         //addition css
         echo '<style>';
         echo $this->format_custom_css($custom_css);
         echo '</style>';
         do_action('hw_wpcf7_contact_form_css', $this->current);
         $content = ob_get_contents();
         ob_clean();
         $html .= $content;
     }
     return $html;
 }
 /**
  * return skin file url for skin link type
  * @param $hash_skin
  * @return mixed
  */
 public static function get_skin_link($value)
 {
     //if(!empty($value['url'])) $url = $value['url'];
     if (!empty($value['hash_skin'])) {
         return HW_SKIN::get_skin_link_url($value['hash_skin']);
     }
 }
                <li class="rss"><a href="#"><img src="<?php 
echo HW_SKIN::current()->get_skin_url('images/rss.png');
?>
" alt="Rss"></a></li>
                <li class="youtube"><a href="<?php 
echo hw_option('youtube_url');
?>
" target="_blank"><img src="<?php 
echo HW_SKIN::current()->get_skin_url('images/youtube.png');
?>
" alt="You Tube"></a></li>
                <li class="google-plus"><a href="<?php 
echo hw_option('gplus_url');
?>
" target="_blank"><img src="<?php 
echo HW_SKIN::current()->get_skin_url('images/gplus.png');
?>
" alt="Googel PLus"></a></li>
            </ul>
        </div>
        <div>
            <p><img src="<?php 
echo get_theme_mod('image_logo');
?>
" alt="home" width="94" height="47">&nbsp; &nbsp;</p>
        </div>


        <?php 
wp_footer();
?>
Ejemplo n.º 21
0
    echo $file['index'];
    ?>
                    </div>
                    <div class="centerCol">
                        <p style="margin-top: 11px;">
                                                        <span class="docNo">
                                                            </span>
                            <?php 
    printf('%s %s %s %s', $file['icon'], $file['link_before'], $file['link'], $file['link_after']);
    ?>
                        </p>
                    </div>
                    <div class="rightCol">
                        <div class="downloadButton">
                            <?php 
    printf('<a href="%s" target="_blank" ><input type="image" name="btnDownload" id="" src="%s" style="border-width:0px;width:25px"></a>', $file['url'], HW_SKIN::current()->get_skin_url('images/Sign-Download-icon.png'));
    ?>

                        </div>
                        <div class="downloadNo">
                            (<?php 
    echo $file['count'];
    ?>
)
                        </div>
                    </div>
                </div>
                <?php 
}
?>
 /**
  * output breadcrumb navxt
  */
 public function display()
 {
     //get bcn settings
     $setting = $this->get_settings();
     $display = 'normal';
     $linked = isset($setting['hw_allow_trail_link']) && $setting['hw_allow_trail_link'] ? true : false;
     $reverse = isset($setting['hw_bcn_reverse']) && $setting['hw_bcn_reverse'] ? true : false;
     if (isset($setting['hw_active_skin']) && $setting['hw_active_skin'] && class_exists('HW_SKIN') && isset($setting['hw_skin']) && isset($setting['hw_skin']['hwskin_config'])) {
         #$skin = HW_SKIN::resume_skin($setting['hw_skin']['hwskin_config']);
         $skin = HW_SKIN::resume_hwskin_instance($setting['hw_skin']);
         if (!empty($skin)) {
             $file = $skin->instance->get_skin_file($setting['hw_skin']['hash_skin']);
             $content = $skin->instance->render_skin_template(0, false);
             if ($content !== false) {
                 echo $content;
             }
             //if(file_exists($file)) {
             //get theme setting from setting file or skin file
             $setting = $skin->instance->get_file_skin_setting();
             if (file_exists($setting)) {
                 include $setting;
             } else {
                 include $file;
             }
             if (isset($theme['display']) && $theme['display'] == 'list') {
                 $display = 'list';
             }
             //how to output breadcrumb
             $opt = array('hseparator' => '>>');
             breadcrumb_navxt::setup_options($opt);
             //valid setting
             if (empty($theme['styles'])) {
                 $theme['styles'] = array();
             }
             if (empty($theme['scripts'])) {
                 $theme['scripts'] = array();
             }
             if (!empty($theme['filters'])) {
                 //do filters & actions that defined in skin
                 $skin->instance->do_filters($theme['filters'], $theme);
             }
             /*if(count($theme['styles']) || count($theme['scripts'])) {   //enqueue stuff from theme
                   $skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
               }*/
             //enqueue stuff from skin using new way
             HW_SKIN::enqueue_skin_assets(array_merge(array('skin_file' => $file, 'theme_settings' => $theme), (array) $skin));
             //}
         }
     }
     //how to ouput breadcrumb function
     if ($display == 'list') {
         $output = bcn_display_list(true, $linked, $reverse);
     } else {
         $output = bcn_display(true, $linked, $reverse);
     }
     echo '<div class="hw-breadcrumb">';
     echo apply_filters('hw_breadcrumb_output', $output, $this);
     echo '</div>';
 }
 /**
  * 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;
     }
 }
 /**
  * The pre-defined validation callback method.
  *
  * The following hooks are available:
  *	- validation_{instantiated class name}_{field id} – [3.0.0+] receives the form submission value of the field that does not have a section. The first parameter: ( string|array ) submitted input value. The second parameter: ( string|array ) the old value stored in the database.
  *	- validation_{instantiated class name}_{section_id}_{field id} – [3.0.0+] receives the form submission value of the field that has a section. The first parameter: ( string|array ) submitted input value. The second parameter: ( string|array ) the old value stored in the database.
  *	- validation_{instantiated class name}_{section id} – [3.0.0+] receives the form submission values that belongs to the section.. The first parameter: ( array ) the array of submitted input values that belong to the section. The second parameter: ( array ) the array of the old values stored in the database.
  *	- validation_{page slug}_{tab slug} – receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
  *	- validation_{page slug} – receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
  *	- validation_{instantiated class name} – receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
  */
 public function validation_HW_Livechat_settings($aInput, $aOldInput)
 {
     if (isset($aInput['chat_skin']['skin_options'])) {
         //make sure exists current skin
         $options = $aInput['chat_skin']['skin_options'];
         //user skin options
         //resume hw_skin
         if (isset($aInput['chat_skin']['hash_skin']) && isset($aInput['chat_skin']['hwskin_config'])) {
             $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($aInput['chat_skin']);
             //
             if ($skin && isset($aInput['chat_skin']['hash_skin'])) {
                 $hash_skin = $aInput['chat_skin']['hash_skin'];
                 //current active skin
                 $skin_setting_file = $skin->instance->get_file_skin_setting($hash_skin);
                 //current skin setting
                 $skin_options = $skin->instance->get_file_skin_options();
                 //current skin options
                 if (file_exists($skin_setting_file)) {
                     include $skin_setting_file;
                 }
                 if (file_exists($skin_options)) {
                     include $skin_options;
                 }
                 if (isset($theme) && isset($theme['options'])) {
                     $default_options = $theme['options'];
                 } else {
                     $default_options = array();
                 }
                 if (isset($theme_options)) {
                     $options = HW_SKIN::merge_skin_options_values($options, $default_options, $theme_options);
                     //__save_session('y2',$options);
                     /*$_SESSION['y3']=$skin_setting;
                       $_SESSION['y4']=$default_options;*/
                 }
             }
         }
         //get demo live chat embed code
         if (isset($options['enable_demo_chat']) && strtolower($options['enable_demo_chat']) == 'on' && isset($options['demo_embedcode'])) {
             $aInput['chat_embed_code'] = $options['demo_embedcode'];
             //clear enable_demo_chat option to able to update 'enable_demo_chat' skin option in next time
             unset($aInput['chat_skin']['skin_options']['enable_demo_chat']);
         }
     }
     //save current skin for enqueue
     if (!empty($aInput['chat_skin'])) {
         HW_SKIN::save_enqueue_skin(array('type' => 'resume_skin', 'skin' => $aInput['chat_skin'], 'object' => 'livechat', 'status' => $aInput['enable_livechat']));
     }
     return $aInput;
 }
    ?>
" title="<?php 
    the_title_attribute();
    ?>
">
                                <?php 
    if (function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") && in_array("thumb", $arrExlpodeFields) && has_post_thumbnail()) {
        ?>
                                    <?php 
        the_post_thumbnail('thumbnail', array($instance["thumb_w"], $instance["thumb_h"], 'style' => "width:100px;height:70px", 'class' => 'img'));
        ?>
                                <?php 
    } else {
        ?>
                                    <img src="<?php 
        echo HW_SKIN::current()->get_skin_url('images/placeholder.png');
        ?>
" width="50px"/>
                                <?php 
    }
    ?>
                            </a>
                        </div>
                        <div class="picture-shadow"></div>
                        <h2 class="title">
                            <a href="<?php 
    the_permalink();
    ?>
" title="<?php 
    the_title_attribute();
    ?>
 /**
  * add custom fields to current slider settings
  * @param array $aFields: basic options
  * @param object $slider: current slider data
  * @hook hw_metaslider_basic_settings
  */
 public function _hwmlslider_metaslider_basic_settings($aFields, $slider)
 {
     //get current theme screenshot
     $theme = $slider->get_setting('theme');
     $data = $this->skin->get_skin_data($theme);
     if ($data) {
         $thumb = '<img src="' . $data['screenshot'] . '" onError="this.onerror=null;this.src=\'' . HW_SKIN::get_image('error.jpg') . '\'"/>';
     } else {
         $thumb = '';
     }
     //save current skin to db
     if (isset($_POST['settings']['theme'])) {
         $this->skin->save_skin_assets(array('skin' => array('hash_skin' => $theme), 'object' => 'hw-override-mlslider-' . $slider->id));
     }
     //override exists 'theme' field
     $aFields['theme'] = array('priority' => 40, 'type' => 'theme', 'value' => $theme, 'label' => __("Theme", "metaslider"), 'class' => 'effect coin flex responsive nivo', 'helptext' => __("Slideshow theme", "metaslider"), 'options' => array());
     //add theme preview holder
     $aFields['hw_theme_thumbnail'] = array('priority' => 41, 'type' => 'navigation', 'label' => __("<div id='ml_theme_thumb'>{$thumb}</div>", "hwml"), 'class' => 'option coin flex nivo responsive', 'value' => '', 'helptext' => __("Giao diện theme", "hwml"), 'options' => array());
     //modify metaslider container id
     $aFields['hw_mlcontainer_id'] = array('priority' => 42, 'type' => 'text', 'value' => $slider->get_setting('hw_mlcontainer_id'), 'label' => __("div ID chứa slider", "hwml"), 'class' => 'effect coin flex responsive nivo', 'helptext' => __("<p class='hwml-tipsy-tooltip'>Thay đổi thuộc tính <strong>ID</strong> của thẻ DIV chứa slider<br/><img src='" . HWML_PLUGIN_URL . '/images/metaslider-container-id.jpg' . "'/></p>", "hwml"));
     return $aFields;
 }
 /**
  * save contact form settings
  * @param object $contact_form: current contact form instance;
  */
 public function _hw_wpcf7_save_contact_form($contact_form)
 {
     $properties = $contact_form->get_properties();
     $additional_settings = array();
     //set additional_settings
     //$properties = array();
     //enable private skin
     if (isset($_POST['hw_wpcf7_use_skin'])) {
         $properties['hw_wpcf7_use_skin'] = trim($_POST['hw_wpcf7_use_skin']);
     } else {
         $properties['hw_wpcf7_use_skin'] = 'off';
     }
     //get selected skin
     if (isset($_POST['hw_wpcf7_skin'])) {
         //contact form skin
         $properties['hw_wpcf7_skin'] = trim($_POST['hw_wpcf7_skin']);
     }
     //skin setting
     if (isset($_POST['hw_wpcf7skin_setting'])) {
         $properties['hw_wpcf7skin_setting'] = $_POST['hw_wpcf7skin_setting'];
     }
     if (isset($_POST['hw_custom_css'])) {
         //custom css
         $properties['hw_custom_css'] = trim($_POST['hw_custom_css']);
     }
     /*form attributes*/
     if (isset($_POST['hw_form_class_attr'])) {
         $properties['hw_form_class_attr'] = trim($_POST['hw_form_class_attr']);
     }
     //form class attr
     if (isset($_POST['hw_form_id_attr'])) {
         $properties['hw_form_id_attr'] = trim($_POST['hw_form_id_attr']);
     }
     //form id attr
     if (isset($_POST['hw_form_name_attr'])) {
         $properties['hw_form_name_attr'] = trim($_POST['hw_form_name_attr']);
     }
     //form name attr
     if (isset($_POST['hw_form_enctype_attr'])) {
         $properties['hw_form_enctype_attr'] = trim($_POST['hw_form_enctype_attr']);
     }
     //form enctype
     //save storage hook
     if (isset($_POST['hwcf_data_hook'])) {
         $properties['hwcf_data_hook'] = trim($_POST['hwcf_data_hook']);
     }
     /**
      * google form hook
      */
     if (isset($_POST['hw_gformID'])) {
         //save google form ID
         $properties['hw_gformID'] = trim($_POST['hw_gformID']);
     }
     if (isset($_POST['enable_email_by_gapp'])) {
         //enable send mail through google form ID
         $properties['enable_email_by_gapp'] = trim($_POST['enable_email_by_gapp']);
     } else {
         $properties['enable_email_by_gapp'] = 'off';
     }
     //enable default gform from hoangweb google acc
     if (isset($_POST['hw_default_gform'])) {
         $properties['hw_gformID'] = hw_wpcf7_default_gform();
         unset($_POST['hw_default_gform']);
         //clear this option
     }
     //populate form event
     if (isset($_POST['hw_sent_ok_redirect_page'])) {
         $properties['hw_sent_ok_redirect_page'] = trim($_POST['hw_sent_ok_redirect_page']);
     }
     //on_sent_ok js event after form success sent data
     if (isset($_POST['hw_on_sent_ok_js_event'])) {
         $properties['hw_on_sent_ok_js_event'] = trim($_POST['hw_on_sent_ok_js_event']);
         $additional_settings[] = 'on_sent_ok: "' . esc_attr($properties['hw_on_sent_ok_js_event']) . '"';
     }
     //on_submit js event after form submit whatever event send error
     if (isset($_POST['hw_on_submit_js_event'])) {
         $properties['hw_on_submit_js_event'] = trim($_POST['hw_on_submit_js_event']);
         $additional_settings[] = 'on_submit: "' . esc_attr($properties['hw_on_submit_js_event']) . '"';
     }
     //web hook url
     if (isset($_POST['hook_url'])) {
         $properties['hook_url'] = trim($_POST['hook_url']);
     }
     //$current = WPCF7_ContactForm::get_current();
     //__save_session('properties',$properties);__save_session('temp',$this->template->get_form_template($properties['hw_form_template']));
     if (isset($_POST['hw_form_template']) && $_POST['hw_form_template'] !== $properties['hw_form_template'] && isset($properties['hw_form_template']) && $this->template->get_form_template(trim($_POST['hw_form_template']))) {
         //form template
         $properties['hw_form_template'] = trim($_POST['hw_form_template']);
         //save form template
         $new_fields = $this->template->parse_form_template_fields($properties['hw_form_template']);
         //update exists form to new selected template
         $properties['form'] = $new_fields;
         //update mail template
         $properties['mail'] = $this->template->mail_template($properties['hw_form_template']);
     }
     //update additional_settings to this form
     if (count($additional_settings)) {
         $properties['additional_settings'] = join("\n", $additional_settings);
     }
     $contact_form->set_properties($properties);
     //update cf settings
     #__save_session('_POST',$_POST);
     //save current skin for enqueue
     if (!empty($properties['hw_wpcf7_skin'])) {
         $this->skin->save_skin_assets(array('skin' => array('hash_skin' => $properties['hw_wpcf7_skin'], 'hwskin_condition' => $properties['hw_wpcf7skin_setting']['hwskin_condition'], 'theme_options' => $properties['hw_wpcf7skin_setting']['skin_options']), 'status' => $properties['hw_wpcf7_use_skin'] == 'off' ? 0 : 1, 'object' => 'hw-wpcf7'));
     }
 }
Ejemplo n.º 28
0
 /**
  * since yarpp v4.2.5
  * @param $posts: related posts result
  * @param array $args: keys 'function','args','related_ID'
  */
 public function _yarpp_results($posts, $args)
 {
     global $wp_query;
     $wp_query->posts = $posts;
     /*$cat_posts = $wp_query;
       $arrExlpodeFields = array('title');*/
     /*if(isset($args['args']['compatible_vars']) && is_array($args['args']['compatible_vars'])){
           $this->compatible_vars = array_merge($this->compatible_vars, $args['args']['compatible_vars']);
       }
       $this->compatible_vars = array_merge($this->compatible_vars, $args['args']['skin']->instance->get_migrate());
       foreach($this->compatible_vars as $var => $val){
           $$var = is_string($val) && isset($$val)? $$val : $val;
       }
       */
     //default sidebar params
     $sidebar_params = array('before_widget' => '<div id="%1$s" class="hw-widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>');
     //valid posts
     if (!isset($args['args']['skin'])) {
         return $posts;
     }
     $hwrp = $skin = $args['args']['skin'];
     if (isset($args['args']['hwrp_current'])) {
         $hwrp = (object) $args['args']['hwrp_current'];
         //get current post type related data
     }
     //migrate vars
     $migrate_data = $skin->instance->get_migrate();
     extract($migrate_data);
     //get sidebar wrapper
     if (isset($skin->box_skin)) {
         global $wp_registered_sidebars;
         $sidebar = $args['args']['skin']->box_skin;
         $sidebar_widget_skin = $args['args']['skin']->box_widget_skin;
         //override sidebar skin box with other
         $sidebar_params = array();
         //extract($sidebar_params);   //extract sidebar param
         if ($sidebar_widget_skin) {
             //get change default sidebar skin, here we create 4 holder: sidebar_default, skin1,skin2,skin3
             $skin_data = HW_AWC_Sidebar_Settings::get_sidebar_setting($sidebar_widget_skin, $sidebar);
             HW_SKIN::apply_skin_data($skin_data, array($this, '_hw_skin_resume_skin_data'), array('sidebar' => $sidebar, 'sidebar_widget_skin' => $sidebar_widget_skin, 'sidebar_params' => &$sidebar_params));
             $sidebar_params = HW_AWC::format_widget_sidebar_params(null, $sidebar, array('classname' => 'hw-related-posts hw-awc-override', 'sidebar_params' => $sidebar_params));
         }
     }
     //check related content from widget config
     if (!empty($skin->widget_config)) {
         $widget_instance = AWC_WidgetFeature_saveconfig::get_widget_setting_instance($skin->widget_config, array('widget' => 'hw_taxonomy_post_list_widget', 'group' => 'main_loop'));
         //valid data
         if (!isset($widget_instance['query_data'])) {
             $widget_instance['query_data'] = 'current_context';
         }
         //get global $wp_query
         //override sidebar params from awc feature assign to widget
         if (isset($sidebar_params) && isset($sidebar)) {
             $sidebar_params = HW_AWC::format_sidebar_params($sidebar, $sidebar_params, $widget_instance);
         }
     }
     /**
      * display related content
      */
     if (!isset($widget_instance)) {
         extract($sidebar_params);
     }
     //extract sidebar param if not use HWTPL config
     if (isset($before_widget)) {
         echo $before_widget;
     }
     //widget title
     if (isset($before_title)) {
         echo $before_title;
     }
     echo apply_filters('hw_related_posts_title', $hwrp->title);
     if (isset($after_title)) {
         echo $after_title;
     }
     //do action before
     do_action('hoangweb_before_loop');
     do_action('hw_yarpp_results_before', $hwrp);
     if (isset($widget_instance)) {
         /**
          * output widget, when using the_widget to show widget content,
          * note that you set up & enable sidebar skin at /admin.php?page=hw_sidebar_widgets_settings this mean sidebar apply to yarpp it work for that skin
          * And no related to active sidebar that using on website, which call by function 'dynamic_sidebar' /hw_dynamic_sidebar
          */
         the_widget('HW_Taxonomy_Post_List_widget', $widget_instance, $sidebar_params);
     } else {
         if (isset($args['args']['template'])) {
             include $args['args']['template'];
         }
     }
     //do action after
     do_action('hw_yarpp_results_after', $hwrp);
     do_action('hoangweb_after_loop');
     if (isset($after_widget)) {
         echo $after_widget;
     }
     return false;
     //disable behavior as default $yarpp->display_related do
 }
 /**
  * load widget template
  * @param array $instance: widget instance (optional)	 
  * @param array $data: array of data need to be extract to current context
  */
 private function load_widget_template(&$instance = array(), $data = array())
 {
     //extract data
     if (isset($this->shared) && is_array($this->shared)) {
         extract($this->shared);
     } else {
         if (is_array($data)) {
             extract($data);
         }
     }
     //extract variables from array $args that get from 'widget' method
     if (isset($args)) {
         extract($args);
     }
     if (!is_array($instance) || !count($instance)) {
         $instance = $this->hw_parse_data();
         $instance = $instance['instance'];
     } else {
         $this->get_widget_instance($instance);
     }
     //by hoangweb.com
     if ($this->skin) {
         //load skin
         $file = $this->skin->get_skin_file(empty($instance['skin']) ? 'default' : $instance['skin']);
         if (file_exists($file)) {
             /**
              * pagination skin
              */
             $paginav = $this->skin->get_skin_instance('pagination')->get_skin_file(empty($instance['pagination_skin']) ? 'default' : $instance['pagination_skin']);
             //skin settings
             /*
             $paginav_skin_setting = isset($instance['skin_setting'])? $instance['skin_setting'] : '';
             
             $skin_setting_file = $this->skin->get_file_skin_setting(); //current skin setting
             $skin_options = $this->skin->get_file_skin_options();      //current skin options
             
             if(file_exists($skin_setting_file)) include ($skin_setting_file);
             if(file_exists($skin_options)) include ($skin_options);
             
             if(isset($theme) && isset($theme['options'])) $default_options = $theme['options'];
             if(isset($default_options) && isset($theme_options)) {
                 $paginav_skin_setting = HW_SKIN::merge_skin_options_values($paginav_skin_setting, $default_options, $theme_options);
             }
             */
             /**
              * scrollbar skin
              */
             $scrollbar = $this->skin->get_skin_instance('scrollbar')->get_skin_file(empty($instance['scrollbar_skin']) ? 'default' : $instance['scrollbar_skin']);
             //widget feature: grid_posts
             $grid_posts = HW_AWC::get_widget_feature($this, 'grid_posts');
             $awc_enable_grid_posts = false;
             //disable by default
             if ($grid_posts && HW_AWC::check_widget_feature($this, 'grid_posts')) {
                 $awc_enable_grid_posts = $grid_posts->is_active($instance);
                 if ($awc_enable_grid_posts) {
                     $awc_grid_posts_cols = $grid_posts->get_field_value('awc_grid_posts_cols');
                 }
             }
             /**
              * init some variables
              */
             $theme = array();
             //declare stylesheets file
             //content wrapper ID
             $hwtpl_wrapper_id = $this->get_holder_id($instance['widget_id']);
             $hwtpl_scrollbar_wrapper_class = '';
             //scrollbar content wrapper css class
             $hwtpl_pagination_class = '';
             //for pagination
             /**
              * load pagination component
              */
             if (file_exists($paginav)) {
                 include $paginav;
                 //valid
                 if (!isset($theme['scripts'])) {
                     $theme['scripts'] = array();
                 }
                 if (!isset($theme['styles'])) {
                     $theme['styles'] = array();
                 }
                 //migrate skin from pagination module
                 if ($instance['use_default_pagenav_skin'] && hw_is_active_module('pagination')) {
                     $theme = HWPageNavi_Core::render_pagination_skin();
                 } elseif (count($theme['styles']) || count($theme['scripts'])) {
                     $this->skin->get_skin_instance('pagination')->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                     //enqueue stuff from skin
                     /*HW_SKIN::enqueue_skin_assets(array(
                           'instance' => $this->skin,
                           'hash_skin' => $instance['skin'],
                           'skin_file' => $file,
                           'skin_settings' => $theme,
                           'skin_options' => $skin_setting
                       ));*/
                 }
                 //parse template tags
                 $hwtpl_pagination_class = isset($theme['pagination_class']) ? $theme['pagination_class'] : '';
                 $this->share_data('pagination', $theme);
             }
             //_print($this->skin->get_active_skin()); //enqueue stuff from skin
             /**
              * load scrollbar component
              */
             if (isset($instance['enable_scrollbar']) && $instance['enable_scrollbar'] && file_exists($scrollbar)) {
                 //load skin resource
                 $scrollbar_options_config = $this->skin->get_skin_instance('scrollbar')->get_file_skin_options(empty($instance['scrollbar_skin']) ? 'default' : $instance['scrollbar_skin']);
                 //theme options configuration
                 $scrollbar_theme_setting = $this->skin->get_skin_instance('scrollbar')->get_file_skin_setting();
                 //load theme-setting.php
                 //theme options
                 $scrollbar_theme_options = isset($instance['scrollbar_skin_setting']) ? $instance['scrollbar_skin_setting'] : array();
                 //scrollbar skin options
                 //reset
                 $theme['styles'] = array();
                 //declare stylesheets file
                 $theme['scripts'] = array();
                 //declare js files
                 $theme['options'] = array();
                 if (!empty($scrollbar_options_config) && file_exists($scrollbar_options_config)) {
                     include $scrollbar_options_config;
                     //include define scrollbar theme options
                 }
                 if (!empty($scrollbar_theme_setting) && file_exists($scrollbar_theme_setting)) {
                     include $scrollbar_theme_setting;
                     //scrollbar theme setting
                 }
                 if (isset($theme_options) && isset($theme)) {
                     $default = isset($theme['options']) ? $theme['options'] : array();
                     $result = HW_SKIN::get_skin_options($scrollbar_theme_options, $default, $theme_options);
                     $scrollbar_theme_options = array_merge($scrollbar_theme_options, $result);
                 }
                 /*
                 //best way but use old way as above do
                 $scrollbar_skin_setting = isset($instance['scrollbar_skin_setting'])? $instance['scrollbar_skin_setting'] : '';
                 
                                    $scrollbarskin_setting_file = $this->skin->get_skin_instance('scrollbar')->get_file_skin_setting(); //current skin setting
                                    $scrollbar_skin_options = $this->skin->get_skin_instance('scrollbar')->get_file_skin_options();      //current skin options
                 
                                    if(file_exists($scrollbarskin_setting_file)) include ($scrollbarskin_setting_file);
                                    if(file_exists($scrollbar_skin_options)) include ($scrollbar_skin_options);
                 
                                    if(isset($theme) && isset($theme['options'])) $scrollbar_default_options = $theme['options'];
                                    if(isset($scrollbar_default_options) && isset($theme_options)) {
                 $scrollbar_skin_setting = HW_SKIN::merge_skin_options_values($scrollbar_skin_setting, $scrollbar_default_options, $theme_options);
                                    }
                 */
                 //parse template tags
                 $hwtpl_scrollbar_wrapper_class = isset($theme['scrollbar_css']) ? $theme['scrollbar_css'] : '';
                 include $scrollbar;
                 //valid
                 /*if(!isset($theme['scripts'])) $theme['scripts'] = array();
                                        if(!isset($theme['styles'])) $theme['styles'] = array();
                 
                                        if(count($theme['styles']) || count($theme['scripts'])) {
                                            $this->skin->get_skin_instance('scrollbar')->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
                                        }*/
                 //enqueue stuff from skin
                 HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin->get_skin_instance('scrollbar'), 'hash_skin' => $instance['scrollbar_skin'], 'skin_file' => $scrollbar, 'skin_settings' => $theme, 'skin_options' => $scrollbar_theme_options));
                 $this->init_scrollbar_options($scrollbar_theme_options, $theme);
             }
             /**
              * load main skin
              */
             $options_config = $this->skin->get_file_skin_options();
             $skin_setting = $this->skin->get_file_skin_setting();
             if (file_exists($skin_setting)) {
                 include $skin_setting;
             }
             //theme options
             $skin_options = isset($instance['skin_setting']) ? $instance['skin_setting'] : array();
             $skin_options = HW_SKIN::merge_skin_options_values($skin_options, $skin_setting, $options_config);
             //params
             if (empty($instance['intermediate_image_sizes']) && !empty($instance['thumb_w']) && !empty($instance['thumb_h'])) {
                 $image_size = array($instance['thumb_w'], $instance['thumb_h']);
             } elseif (!empty($instance['intermediate_image_sizes'])) {
                 $image_size = $instance['intermediate_image_sizes'];
             } else {
                 $image_size = 'thumbnail';
             }
             //reset
             $theme['styles'] = array();
             //declare stylesheets file
             $theme['scripts'] = array();
             //declare js files
             $theme['options'] = array();
             //refresh theme options
             //widget features
             $wfeatures = $this->init_widget_features(array('theme' => $theme, 'skin_options' => $skin_options, 'instance' => $instance));
             //render skin template power by twig
             $data = array('hwtpl_scrollbar_wrapper_class', 'cat_posts', 'full_image_src', 'fancy_group', 'fancybox_g1', 'arrExlpodeFields', 'image_size', 'wfeatures', 'hwtpl_wrapper_id', 'args', 'instance', 'open_title_link', 'close_title_link');
             $data = compact($data);
             $data['context'] = $this;
             //reference to this object
             $content = $this->skin->render_skin_template($data, false);
             if ($content !== false) {
                 echo $content;
             }
             include $file;
             //valid
             /*if(!isset($theme['scripts'])) $theme['scripts'] = array();
                                if(!isset($theme['styles'])) $theme['styles'] = array();
             
                                if(count($theme['styles']) || count($theme['scripts'])) {
                                    $this->skin->enqueue_files_from_skin($theme['styles'], $theme['scripts']); //enqueue stuff from skin
                                }*/
             //enqueue stuff from skin
             HW_SKIN::enqueue_skin_assets(array('instance' => $this->skin, 'hash_skin' => $instance['skin'], 'skin_file' => $file, 'skin_settings' => $theme, 'skin_options' => $skin_options));
             //init scrolling
             //add_action('wp_footer',array(&$this, 'init_content_options'),1000);	//don't use wp hook to setup scroll
             $this->init_content_options(array('theme' => $theme, 'skin_options' => $skin_options, 'instance' => $instance));
         }
     } else {
         echo __('not found class HW_SKIN.');
     }
 }
Ejemplo n.º 30
0
 /**
  * merge skin option values
  * @param array $user_theme_options user skin options data
  * @param array $default  default option define at theme-setting.php
  * @param array $theme_options options file (options.php) in current skin folder
  */
 public static function merge_skin_options_values($user_theme_options, $default, $_theme_options)
 {
     //parse default skin options from skin setting file (theme-setting.php)
     if (is_string($default) && !empty($default) && file_exists($default)) {
         include $default;
         if (isset($theme) && is_array($theme) && isset($theme['options'])) {
             $default = $theme['options'];
         }
     }
     //include theme options (options.php)
     if (is_string($_theme_options) && file_exists($_theme_options)) {
         include $_theme_options;
     }
     //valid
     if (!is_array($default)) {
         $default = array();
     }
     if (isset($theme_options) && !is_array($theme_options)) {
         $theme_options = array();
     }
     //- note that: skin options value either set in options file or skin file or both. But get options from theme setting for default.
     //merge skin options with persistent options in skin theme setting file:
     if (isset($theme_options)) {
         //$default = isset($theme['options']) ? $theme['options'] : array();
         $result = HW_SKIN::get_skin_options($user_theme_options, $default, $theme_options);
         $user_theme_options = array_merge($user_theme_options, $result);
     }
     //valid data, here is example of removing unused key
     if (isset($user_theme_options['template_file'])) {
         unset($user_theme_options['template_file']);
     }
     return $user_theme_options;
 }