/**
         * do widget feature in frondend if it actived
         * @param $t
         * @param $instance
         */
        public function do_widget_feature_frontend($t, $instance)
        {
            //widget id
            $current_widget_id = "{$t->id_base}-{$t->number}";
            $lib = $this->get_field_value('awc_fixedobj_lib');
            //fixed object lib
            $options = $this->get_options();
            $json_config = HW_SKIN_Option::build_json_options($options);
            //parse fancybox setting to json data
            //for sticky js
            if ($lib == 'sticky') {
                echo '<script>
        jQuery(document).ready(function($) {
            $("#' . $current_widget_id . '").sticky(' . $json_config . ');

        });
        </script>';
            } else {
                echo '<script>
        jQuery(document).ready(function($) {
            $("#' . $current_widget_id . '").stick_in_parent(' . $json_config . ');

        });
        </script>';
            }
        }
        /**
         * do on website
         * @param string $selector jquery selector
         * @return mixed|void
         */
        public function run($selector)
        {
            $json_config = HW_SKIN_Option::build_json_options($this->get_options());
            //parse fancybox setting to json data
            echo '<script>
        jQuery(document).ready(function($) {
            /* Apply fancybox to multiple items */

            jQuery("' . $selector . '").fancybox(' . $json_config . ');

        });
        </script>';
        }
示例#3
0
 /**
  * @hook admin_enqueue_scripts
  */
 public function admin_enqueue_scripts()
 {
     #if($this->is_module_setting_page()) {
     HW_Libraries::enqueue_jquery_libs('jquery-colorbox');
     #}
     $data = self::get()->get_values();
     if (class_exists('HW_SKIN_Option')) {
         $data_json = HW_SKIN_Option::build_json_options($data);
         if ($data_json) {
             $data = (array) json_decode($data_json);
         }
     }
     $handle = $this->enqueue_script('colorbox-module.js');
     $this->localize_script($handle, '__hw_module_colorbox', $data);
 }
    function hwmenu_init_skin($arg, $theme)
    {
        $user_options = $theme['args'][1];
        //get user options
        //valid
        if ($theme['function'] !== __FUNCTION__) {
            return;
        }
        //ddsmoothmenu
        if (isset($user_options) && isset($user_options['enable_ddsmoothmenu']) && $user_options['enable_ddsmoothmenu'] == '__TRUE__') {
            $args = array('mainmenuid' => $user_options['container_id'], 'orientation' => $user_options['dd_orientation'], 'classname' => $user_options['dd_classname'], 'method' => $user_options['dd_method'], 'arrowswap' => $user_options['hw_arrowswap']);
            ?>
        <script>
            jQuery(document).ready(function() {
                ddsmoothmenu.init(<?php 
            echo HW_SKIN_Option::build_json_options($args);
            ?>
);
            });

        </script>
    <?php 
        }
    }
    /**
     * init scrolling
     * @param $theme: user theme setting (depricated)
     */
    private function init_content_options($args = array())
    {
        extract($args);
        if (!isset($instance)) {
            $instance = $this->get_widget_instance();
        }
        $hwtpl_wrapper_id = $this->get_holder_id($instance['widget_id']);
        if ($this->enable_scrolling() && $instance['scroll_type'] == 'smoothdivscroll') {
            //for smoothdivscroll
            //validation
            if (!isset($instance['scroll_interval'])) {
                $instance['scroll_interval'] = '10';
            }
            //default 10 of interval for smoothdivscroll
            if (!isset($instance['scroll_width']) || !$instance['scroll_width']) {
                //full width
                $instance['scroll_width'] = '100%';
            }
            ?>
			<style>
			#<?php 
            echo $hwtpl_wrapper_id;
            ?>
 .smoothDivScroll
			{

				<?php 
            if (isset($instance['scroll_height'])) {
                echo 'height:' . $this->format_unit($instance['scroll_height']) . ';';
            }
            ?>
				<?php 
            if (isset($instance['scroll_width'])) {
                echo 'width:' . $this->format_unit($instance['scroll_width']) . ';';
            } else {
                echo 'width: 100%;';
            }
            ?>
				position: relative;
			}
			</style>
			<script type="text/javascript">
			// Initialize the plugin with no custom options
             jQuery(document).ready(function ($) {
                // None of the options are set
                <?php 
            if ($this->is_vertical_scrolling()) {
                ?>
                    jQuery("#<?php 
                echo $hwtpl_wrapper_id;
                ?>
 .smoothDivScroll").smoothDivScroll_vertical({
                <?php 
            } else {
                ?>
                    jQuery("#<?php 
                echo $hwtpl_wrapper_id;
                ?>
 .smoothDivScroll").smoothDivScroll({
                <?php 
            }
            ?>
                    manualContinuousScrolling: false,
                    autoScrollingMode: "onStart",
                    mousewheelScrolling: "allDirections",
                    hotSpotScrolling:false,
                    <?php 
            if (isset($instance['scroll_interval'])) {
                ?>
                    autoScrollingInterval:'<?php 
                echo $instance['scroll_interval'];
                ?>
',
                    <?php 
            }
            ?>
                    <?php 
            if (isset($instance['scroll_direction'])) {
                ?>
                    autoScrollingDirection:'<?php 
                echo $instance['scroll_direction'];
                ?>
',
                    <?php 
            }
            ?>

                });
                // Mouse over
                jQuery("#<?php 
            echo $hwtpl_wrapper_id;
            ?>
 .smoothDivScroll").bind("mouseover", function(){
                    <?php 
            if ($this->is_vertical_scrolling()) {
                ?>
$(this).smoothDivScroll_vertical("stopAutoScrolling");<?php 
            } else {
                ?>
                        $(this).smoothDivScroll("stopAutoScrolling");
                    <?php 
            }
            ?>
                });

                // Mouse out
                jQuery("#<?php 
            echo $hwtpl_wrapper_id;
            ?>
 .smoothDivScroll").bind("mouseout", function(){
                    <?php 
            if ($this->is_vertical_scrolling()) {
                ?>
$(this).smoothDivScroll_vertical("startAutoScrolling");<?php 
            } else {
                ?>
                        $(this).smoothDivScroll("startAutoScrolling");
                    <?php 
            }
            ?>
                });
              });

			</script>
			<script type="text/javascript">
			
			</script>
			<?php 
        }
        /**
         * for jcarousellite lib
         */
        if ($this->enable_scrolling() && $instance['scroll_type'] == 'jcarousellite') {
            $option = array('mouseWheel' => true, 'start' => 0);
            //valid
            if (!isset($instance['scroll_width']) || !$instance['scroll_width']) {
                //full width
                $instance['scroll_width'] = '100%';
            }
            if (!isset($instance['scroll_interval'])) {
                $instance['scroll_interval'] = '800';
            }
            //default 800 of interval
            if (!isset($instance['scroll_delay'])) {
                $instance['scroll_delay'] = '800';
            }
            //default 800 of time delay
            //auto scrolling & delay between 2 slides
            if (isset($instance['auto_scroll_mode']) && $instance['auto_scroll_mode'] && isset($instance['scroll_delay'])) {
                $option['auto'] = (int) $instance['scroll_delay'];
            }
            if (isset($instance['visible_scroll_num']) && is_numeric($instance['visible_scroll_num'])) {
                //visble
                $option['visible'] = (int) $instance['visible_scroll_num'];
            }
            if (isset($instance['scroll_interval']) && is_numeric($instance['scroll_interval'])) {
                //scroll speed
                $option['speed'] = (int) $instance['scroll_interval'];
            }
            if (isset($instance['scroll_num'])) {
                $option['scroll'] = (int) $instance['scroll_num'];
            }
            // scroll number of slides
            if (isset($instance['scroll_easing']) && $instance['scroll_easing']) {
                $option['easing'] = $instance['scroll_easing'];
            }
            //easing effects
            //scrolling direction
            if ($this->is_vertical_scrolling()) {
                $option['vertical'] = true;
            } else {
                $option['vertical'] = false;
            }
            //merge options
            if (isset($theme['scroll_options']['jcarousellite']) && is_array($theme['scroll_options']['jcarousellite'])) {
                $option = array_merge($option, $theme['scroll_options']['jcarousellite']);
            }
            if (!empty($skin_options)) {
                $option = array_merge($option, $skin_options);
            }
            $option_obj = HW_SKIN_Option::build_json_options($option);
            //json_encode($option)
            ?>
            <style>
                #<?php 
            echo $hwtpl_wrapper_id;
            ?>
 .<?php 
            echo $instance['scroll_type'];
            ?>
                {
                <?php 
            if (isset($instance['scroll_height'])) {
                echo 'height:' . $this->format_unit($instance['scroll_height']) . ';';
            }
            ?>
                <?php 
            if (isset($instance['scroll_width'])) {
                echo 'width:' . $this->format_unit($instance['scroll_width']) . ';';
            } else {
                echo 'width: 100%;';
            }
            ?>
                    position: relative;
                }
            </style>
        <script type="text/javascript">
            jQuery(document).ready(function($) {
                var jcarousel_lite = $("#<?php 
            echo $hwtpl_wrapper_id;
            ?>
 .<?php 
            echo $instance['scroll_type'];
            ?>
").jCarouselLite(<?php 
            echo $option_obj;
            ?>
);

            });
        </script>
            <?php 
        }
        //$this->init_widget_features($args);   //call before include skin file
    }
 /**
  * get qtranslate switcher
  */
 public static function get_qtrans_switcher()
 {
     $mqtrans_skin = hw_option('mqtrans_skin');
     //get mqtrans skin
     $other_service = hw_option('enable_googletranslate');
     //use google translate?
     if (isset($mqtrans_skin['hash_skin']) && isset($mqtrans_skin['hwskin_config'])) {
         $skin = APF_hw_skin_Selector_hwskin::resume_hwskin_instance($mqtrans_skin);
         //skin options
         //$skin_options = $mqtrans_skin['skin_options'];
         $html = '';
         //output
         $file = $skin->instance->get_skin_file($skin->hash_skin);
         //load footer template
         if (file_exists($file)) {
             HW_HOANGWEB::load_class('HW_String');
             HW_HOANGWEB::load_class('HW_Twig_Template');
             HW_HOANGWEB::load_class('HW_mqtranslate');
             //get theme setting file
             $setting = $skin->instance->get_file_skin_setting();
             //(new HW_SKIN);
             if (file_exists($setting)) {
                 include $setting;
             }
             //skin options
             $skin_options_file = $skin->instance->get_file_skin_options();
             //(new HW_SKIN)->enqueue_files_from_skin()
             $skin_options = isset($mqtrans_skin['skin_options']) ? $mqtrans_skin['skin_options'] : array();
             //user options
             $skin_options = HW_SKIN::merge_skin_options_values($skin_options, $setting, $skin_options_file);
             $data = array();
             //data send to twig template
             /*active google translate*/
             if ($other_service) {
                 $TranslateElement_opts = array('pageLanguage' => 'vi');
                 //layout
                 $layout = self::get_googletrans_layout_param(isset($skin_options['display_mode']) ? $skin_options['display_mode'] : '');
                 if ($layout) {
                     $TranslateElement_opts['layout'] = $layout;
                 }
                 //include languages
                 if (!empty($skin_options['specific_langs']) && is_array($skin_options['specific_langs'])) {
                     $TranslateElement_opts['includedLanguages'] = join($skin_options['specific_langs'], ',');
                 }
                 $data['google_translate_ID'] = !empty($skin_options['google_translate_ID']) ? $skin_options['google_translate_ID'] : HW_String::generateRandomString();
             } else {
                 //prepare data for template
                 if (class_exists('HW_mqtranslate')) {
                     // make sure use __autoload
                     $data = HW_mqtranslate::generateLanguageSelectCode();
                 }
             }
             //get templates folder from skin
             if (isset($theme) && isset($theme['templates_folder'])) {
                 $tpl = $theme['templates_folder'];
             } else {
                 $tpl = '';
             }
             if (class_exists('HW_Twig_Template')) {
                 $twig = HW_Twig_Template::create($skin->instance->get_file_skin_resource($tpl));
                 if (isset($data)) {
                     $twig->set_template_data($data);
                 }
                 //inject data to current twig for skin using
             }
             ob_start();
             //google translate
             if (isset($TranslateElement_opts)) {
                 $json = HW_SKIN_Option::build_json_options($TranslateElement_opts, null, 'layout');
                 echo '<script type="text/javascript">
                 function googleTranslateElementInit() {
                     new google.translate.TranslateElement(' . $json . ', "' . $data['google_translate_ID'] . '");
                 }
                 </script>
                 ';
             }
             $content = $skin->instance->render_skin_template(compact('wrapper', 'active_langs', 'text'), false);
             //data, return=false
             if ($content !== false) {
                 echo $content;
             }
             if ($skin->instance->allow_skin_file()) {
                 include $file;
             }
             $html = ob_get_contents();
             if ($html && ob_get_length()) {
                 ob_end_clean();
             }
         }
         //valid
         if (!isset($theme['styles'])) {
             $theme['styles'] = array();
         }
         if (!isset($theme['scripts'])) {
             $theme['scripts'] = array();
         }
         //put stuff from skin
         if (count($theme['styles']) || count($theme['scripts'])) {
             $skin->instance->enqueue_files_from_skin($theme['styles'], $theme['scripts']);
         }
         return $html;
     }
 }
            <img src="<?php echo $item['img_src']?>" data-thumb="<?php echo $item['thumb_src']?>">
            <?php }?>

        </div>

        <div class="photor__viewportControl">
            <div class="photor__viewportControlPrev"></div>
            <div class="photor__viewportControlNext"></div>
        </div>

    </div>

    <div class="photor__thumbs">
        <div class="photor__thumbsWrap"></div>
    </div>

</div>
*/
?>
<script>
    jQuery(document).ready( function($) {
        jQuery( '#<?php 
echo $gallery_id;
?>
' ).photor(<?php 
echo HW_SKIN_Option::build_json_options($options);
?>
);

    } );
</script>
<?php

/**
 * HW Template: photowall
 */
$options = isset($skin_data['skin_options']) ? $skin_data['skin_options'] : array();
$options['el'] = '#envira-gallery-' . sanitize_html_class($args['wrapper_id']);
// Gallery element
$photos = array();
foreach ($galleries as $id => $item) {
    $photos[$id] = array('id' => $id, 'img' => esc_url($item['img_src']), 'width' => $item['img_width'], 'height' => $item['img_height'], 'th' => array('src' => esc_url($item['thumb_src']), 'width' => $item['thumb_width'], 'height' => $item['thumb_height'], 'zoom_src' => $item['thumb_src'], 'zoom_factor' => 1.5));
}
$hw_tpl->_display('gallery.twig', array('galleries' => $galleries, 'args' => $args, 'json_options' => HW_SKIN_Option::build_json_options($options), 'photos' => $photos));
/*
?>

<div id="envira-gallery-<?php echo sanitize_html_class( $args['wrapper_id'] ) ?>" class="envira-gallery-public envira-gallery-<?php echo  sanitize_html_class( $args['wrapper_class'] ) ?>-columns envira-clear isotope" data-envira-columns="<?php echo $args['columns_class']?>">
    <div class="body">
    </div>
<?php
*/
/*foreach($galleries as $id => $item) {
    echo '<div id="envira-gallery-item-' . sanitize_html_class( $id ) . '" class="' . $item['item_classes'] . '" style="margin-bottom: ' . $item['margin_bottom'] . '" >';
    echo '<a href="' . esc_url( $item['link'] ) . '" class="envira-gallery-' . sanitize_html_class( $data['id'] ) . ' envira-gallery-link" rel="enviragallery' . sanitize_html_class( $data['id'] ) . '" title="' . esc_attr( $item['title'] ) . '" data-thumbnail="' . esc_url( $item['thumb'] ) . '">';

    echo '<img id="envira-gallery-image-' . sanitize_html_class( $id ) . '" class="envira-gallery-image-' . $item['index'] . '" src="' . $item['src'] . '" data-envira-src="' . $item['src'] . '" alt="' . esc_attr( $item['alt'] ) . '" title="' . esc_attr( $item['title'] ) . '" />';
    echo '</a>';
    echo '</div>';
}*/
/*
?>
 /**
  * render theme option field
  * @param $aField
  */
 private function renderOptionField($field, $field_name, $wrapper = true, $repeat = true)
 {
     if (!isset($field['type'])) {
         $field['type'] = 'checkbox';
     }
     //default set checkbox option
     //valid field type
     if (!in_array($field['type'], HW_SKIN_Option::allow_field_types())) {
         return;
     }
     if (!isset($field['id'])) {
         $field['id'] = mt_rand(5, 15);
     }
     //random id if not found
     $tag = '';
     $name = $field_name . '[skin_options][' . $field['id'] . ']';
     //field name
     $id = $this->field['id'] . '_nhp_theme_option_' . $field['id'];
     //field id
     $title = isset($field['title']) && $field['title'] ? $field['title'] : $field['id'];
     $desc = isset($field['desc']) ? $field['desc'] : '';
     //field value
     if (isset($this->value['skin_options']) && isset($this->value['skin_options'][$field['id']])) {
         $value = $this->value['skin_options'][$field['id']];
     } else {
         $value = '';
     }
     if ($wrapper) {
         $tag .= '<p style="margin-bottom:14px;">';
     }
     $field = HW_SKIN_Option::build_option_field($field, array('id' => $id, 'name' => $name, 'title' => $title, 'desc' => $desc, 'value' => $value), $tag, array(&$this, '_renderOptionField_callback'), array('field_name' => $field_name));
     /*if($field['type'] == 'checkbox') {  //checkbox
                 $tag .= '<label for="'.$id.'"><strong>'.$title.'</strong><br/>
                     <input type="'.$field['type'].'" name="'.$name.'" id="'.$id.'" '.($value? 'checked="checked"':'').'/>
                     </label><br/><em>'.$desc.'</em>';
             }
             elseif($field['type'] == 'text'){   //text
                 $tag .= '<label for="'.$id.'"><strong>'.$title.'</strong><br/>
                     <input type="'.$field['type'].'" name="'.$name.'" id="'.$id.'" value="'.($value).'"/>
                     </label><br/><em>'.$desc.'</em>';
             }
     
             elseif($field['type'] == 'select' && isset($field['options'])) {    //select
                 if(is_string($field['options'])) $field['options'] = explode(',',$field['options']);
     
                 $tag .= '<label for="'.$id.'"><strong>'.$title.'</strong><br/><select name="'.$name.'" id="'.$id.'">';
                 if(is_array($field['options']))
                     foreach($field['options'] as $option){
                         $tag .= '<option value="'.esc_attr($option).'" '.($option == $value? 'selected':'').'>'.$option.'</option>';
                     }
                 $tag .= '</select></label>';
                 $tag .= '<br/><em>'.$desc.'</em>';
     
             }
             elseif($field['type'] == 'string'){ //string field
                 if(isset($field['title'])) $tag .= "<h3>{$field['title']}</h3>";
                 if(isset($field['desc'])) $tag .= "<div>{$field['desc']}</div>";
             }
             */
     if ($wrapper) {
         $tag .= '</p>';
     }
     if ($repeat == true && isset($field['repeat'])) {
         //repeat current field
         if (isset($field['repeat']) && is_numeric($field['repeat'])) {
             for ($i = 1; $i < $field['repeat']; $i++) {
                 //- first repeat field
                 $save_id = $field['id'];
                 $field['id'] .= '_' . $i;
                 $field['title'] = $field['id'];
                 //sync for title
                 $tag .= $this->renderOptionField($field, $field_name, false, false);
                 $field['id'] = $save_id;
             }
         }
     }
     return $tag;
 }
 /**
  * render theme option field
  * @param $aField
  */
 public function renderOptionField($field, $_name, $_id, $values = null, $wrapper = true, $repeat = true)
 {
     if (!isset($field['type'])) {
         $field['type'] = 'text';
     }
     //default set checkbox option
     //valid field type
     if (!in_array($field['type'], array('select', 'checkbox', 'text', 'string', 'hidden'))) {
         return;
     }
     if (!isset($field['name'])) {
         $field['name'] = '';
         //valid field name
         //return ;  //allow type='string'
     }
     //filter field setting before render field form
     $field = apply_filters('hw_nhp_renderOptionField', $field);
     $tag = '';
     $name = $_name . '[' . $field['name'] . ']';
     //field name
     $id = $_id . '_' . $field['name'];
     //field id
     $title = isset($field['title']) ? $field['title'] : $field['name'];
     $desc = isset($field['description']) ? $field['description'] : '';
     //field value
     if (!empty($values) && isset($values[$field['name']])) {
         $value = esc_attr($values[$field['name']]);
     } else {
         $value = isset($field['value']) ? esc_attr($field['value']) : '';
         //default field value
     }
     $field_atts = array('id' => $id, 'name' => $name, 'value' => $value, 'title' => $title, 'desc' => $desc);
     if ($wrapper) {
         $tag .= '<p style="margin-bottom:14px;">';
     }
     HW_SKIN_Option::build_option_field($field, $field_atts, $tag);
     if ($wrapper) {
         $tag .= '</p>';
     }
     //repeat the field
     if ($repeat == true && isset($field['repeat'])) {
         //repeat current field
         if (isset($field['repeat']) && is_numeric($field['repeat'])) {
             for ($i = 1; $i < $field['repeat']; $i++) {
                 //- first repeat field
                 $save_id = $field['id'];
                 $field['id'] .= '_' . $i;
                 $field['title'] = $field['id'];
                 //sync for title
                 $tag .= $this->renderOptionField($field, $_name, $_id, $values, false, false);
                 $field['id'] = $save_id;
             }
         }
     }
     return $tag;
 }
 /**
  * HW_SKIN::apply_skin_data callback before
  * @param $context
  * @param $params
  */
 public function _hw_skin_apply_skin_data_callback_before($params)
 {
     extract($params);
     //params
     $marquee_wrapper = 'hw-marquee-container';
     if (isset($skin) && isset($hash_skin)) {
         //$skin_data = $skin->get_skin_data($hash_skin);
         //marquee params
         if (!isset($skin_options)) {
             $skin_options = array();
         }
         $json_config = HW_SKIN_Option::build_json_options($skin_options);
     }
     return array('marquee_wrapper' => $marquee_wrapper, 'marquee_id' => uniqid($this->id), 'json_config' => $json_config);
 }
        /**
         * get input output
         * @param $aField
         * @return string
         */
        private function _getInputs($aField)
        {
            $_aOutput = array();
            foreach ((array) $aField['label'] as $_sSlug => $_sLabel) {
                $_aAttributes = isset($aField['attributes'][$_sSlug]) && is_array($aField['attributes'][$_sSlug]) ? $aField['attributes'][$_sSlug] + $aField['attributes'] : $aField['attributes'];
                /*$aAttributes = array(
                			//'name'	=>	"{$_aAttributes['name']}[{$_sSlug}]",
                			'name'	=>	"{$_aAttributes['name']}",   #[hash_skin]
                			'id'	=>	"{$aField['input_id']}_{$_sSlug}",
                			//'value'	=>	isset( $aField['attributes']['value'][ $_sSlug ] ) ? $aField['attributes']['value'][ $_sSlug ] : '',
                			'value'	=>	isset( $aField['attributes']['value'] ) ? $aField['attributes']['value'] : '',
                		); 
                		$_aAttributes = $aAttributes+ $_aAttributes;
                		*/
                $enable_skin_condition = $this->get_field_value('enable_skin_condition');
                //show skin condition field
                //get hash skin value
                $hash_skin_value = isset($aField['attributes']['value']['hash_skin']) ? $aField['attributes']['value']['hash_skin'] : '';
                //get skin config
                $skin_config_value = isset($aField['attributes']['value']['hwskin_config']) ? esc_attr($aField['attributes']['value']['hwskin_config']) : '';
                if (!$skin_config_value) {
                    $skin_config_value = esc_attr($this->skin_config);
                }
                $notice_skin_option = 'Vui lòng nhấn save để tùy chỉnh options của theme này nếu có.';
                //skin options notice
                //valid skin options file for this skin
                if ($hash_skin_value) {
                    $option_file = $this->skin->get_file_skin_options($hash_skin_value);
                    //get document
                    $readme = $this->skin->get_file_skin_resource('readme.html');
                    //_print($readme);
                    if (file_exists($readme)) {
                        $readme_link = $this->skin->get_skin_url('readme.html');
                    }
                    if (file_exists($option_file)) {
                        include $option_file;
                    }
                    //prepend default options
                    if (!isset($theme_options)) {
                        $theme_options = array();
                    }
                    HW_SKIN_Option::default_skin_options($theme_options);
                    if (isset($theme_options) && is_array($theme_options)) {
                        $skin_data = $this->skin->get_skin_data($hash_skin_value);
                        //get active skin data
                        $parse_id = md5($skin_data['screenshot']);
                        $theme_options_output = array();
                        $theme_options_output[] = '<hr/><div class="hw-skin-options-holder" data-collapse="accordion persist" id="' . $parse_id . '">';
                        $theme_options_output[] = '<h2>Tùy biến skin</h2><div class="skin-options">';
                        //toggle title
                        //create fields
                        foreach ($theme_options as $_field) {
                            $theme_options_output[] = $this->skin_options->renderOptionField_APF($_field, $aField, $_aAttributes, $_sSlug);
                        }
                        $theme_options_output[] = '</div></div>';
                        //close parse_id div tag
                        $theme_options_output[] = '<div class="hw-skin-options-notice" style="display: none;color:red !important;">' . $notice_skin_option . '</div>';
                    }
                }
                $skin_config_field_id = $aField['input_id'] . '_' . $_sSlug . '_hwskinconfig';
                //$this->generateAttributes( $_aAttributes )
                $atts = array('name' => "{$_aAttributes['name']}[hash_skin]", 'id' => "{$aField['input_id']}_{$_sSlug}");
                $msg_id = 'hwskin_msg_' . $atts['id'];
                //div message id
                $theme_options_output[] = '<div class="message hw-skin-options-notice" id="' . $msg_id . '"></div>';
                if (isset($readme_link)) {
                    $theme_options_output[] = '<a href="' . $readme_link . '" target="_blank">Xem tài liệu</a>';
                }
                if (isset($parse_id)) {
                    $hwskin_event_change_name = 'hwskin_field_' . $atts['id'] . '_' . $parse_id . '_change_event';
                    //change event callback name
                    $this->skin->saveCallbackJs4SkinChangeEvent("if(typeof {$hwskin_event_change_name} == 'function')" . $hwskin_event_change_name . '(skin);');
                    //$this->skin->saveCallbackJs4SkinChangeEvent('$("#'.$skin_config_field_id.'").val(skin.screenshot);');  //call this before render skins selector
                    $_aOutput[] = '<script>
                        function hwskin_field_' . $atts['id'] . '_' . $parse_id . '_change_event(skin){
                            //console.log(skin.md5,"' . $parse_id . '");
                            if(skin.md5 === "' . $parse_id . '"){
                                jQuery("#' . $parse_id . '").removeClass("hw-skin-options-none").show();jQuery("#' . $parse_id . '").next().hide();
                                jQuery("#' . $parse_id . '").find("input,select").removeAttr("disabled").css({"display":""});
                            }
                            else{
                                jQuery("#' . $parse_id . '").addClass("hw-skin-options-none").hide();jQuery("#' . $parse_id . '").next().show();
                                jQuery("#' . $parse_id . '").find("input,select").attr({"disabled":"disabled"}).css("display","none");
                            }

                        }
                        </script>
                    ';
                } else {
                    $this->skin->saveCallbackJs4SkinChangeEvent('jQuery("#' . $msg_id . '").html("' . $notice_skin_option . '")');
                }
                $field_output = $this->skin->get_skins_select_tag(null, $hash_skin_value, $atts, false);
                //skin select tag
                //field condition for skin consuming
                if ($enable_skin_condition) {
                    $field_condition = $this->skin->create_skin_template_condition_field($_aAttributes['name'], $aField['attributes']['value'], array('class' => 'hw-skin-condition'));
                } else {
                    $field_condition = '';
                }
                $_aOutput[] = "<div class='admin-page-framework-input-label-container my_custom_field_type'>" . "<label for='{$aField['input_id']}_{$_sSlug}'>" . "<span class='admin-page-framework-input-label-string' style='min-width:" . $aField['label_min_width'] . "px;'>" . $_sLabel . "</span>" . PHP_EOL . "" . $field_output . "" . "<input type='hidden' name='{$_aAttributes['name']}[hwskin_config]' id='{$skin_config_field_id}' value='" . $skin_config_value . "'/>" . "</label>" . $field_condition . "</div>";
                if (isset($theme_options_output)) {
                    $_aOutput = array_merge($_aOutput, $theme_options_output);
                }
                if (isset($aField['hwskin_field_output_callback']) && is_callable($aField['hwskin_field_output_callback'])) {
                    //filter field output
                    $_aOutput = call_user_func($aField['hwskin_field_output_callback'], $_aOutput, $this->skin, $field_output);
                } else {
                    $_aOutput = apply_filters('hwskin_field_output', $_aOutput, $this->skin, $field_output);
                }
                //filter with hook of version
            }
            return implode(PHP_EOL, $_aOutput);
        }
 /**
  * @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);
 }
示例#14
0
 /**
  * construct method
  * @param unknown $widget
  * @param string $apply_plugin
  * @param string $skin_folder
  * @param string $skin_name
  * @param string $default_skin_path
  */
 function __construct($widget, $apply_plugin = '', $skin_folder = '', $skin_name = '', $default_skin_path = '')
 {
     if (is_object($widget)) {
         $this->widget_ref = $widget;
     }
     if ($skin_folder) {
         $this->skin_folder = $skin_folder;
         //skin folder. note: you can set path to skin folder like this: 'folder1/folder2'
     }
     if ($skin_name) {
         $this->skin_name = $skin_name;
     }
     //skin name
     $this->add_skin_name_list($skin_name);
     //add list allow skin name
     $this->is_main = true;
     //this can be modify by sub-skin
     $this->skinID = null;
     //skin id
     $this->_apply_plugin = $this->apply_plugin = $apply_plugin;
     if (!is_dir($apply_plugin) && is_dir(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $apply_plugin)) {
         $this->apply_plugin = rtrim(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $apply_plugin, DIRECTORY_SEPARATOR);
     }
     if ($default_skin_path) {
         $this->_default_skin_path = $default_skin_path;
     }
     //default skins folder locate in this plugins
     /*if(!is_dir($default_skin_path)) { //since we use relative path to skin file
           $default_skin_path = rtrim($this->apply_plugin,'/').'/'.ltrim($default_skin_path,'/');
       }
       */
     $this->default_skin_path = $default_skin_path;
     //plugin_dir_path(__FILE__).'/skins';
     $this->skins_holders = array(WP_CONTENT_DIR => array('folder' => 0, 'url' => WP_CONTENT_URL, 'group' => 'WP_CONTENT'), $this->apply_plugin => array('folder' => $this->_default_skin_path, 'url' => 'get_ref_plugin_url', 'group' => self::DEFAULT_GROUP), get_stylesheet_directory() => array('folder' => 0, 'url' => get_bloginfo('template_url'), 'group' => 'Theme'));
     //get file types
     self::$FILE_TYPES = array('link' => 'gif,png,jpeg,jpg,bmp,tif', 'file' => 'php');
     if (empty($this->template_header_info)) {
         $this->template_header_info = array('name' => 'HW Template', 'description' => 'Description', 'author' => 'Author', 'uri' => 'Author URI');
     }
     //init actions
     $this->setup_actions();
     if ($this->widget_ref instanceof WP_Widget && isset($this->widget_ref->id)) {
         //maintain reference widget id
         //$this->number = $this->widget_ref->number;
         $this->id = $this->widget_ref->id;
     }
     //init default ddslick params
     $this->set_dropdown_ddslick_setting();
     $this->enable_template_engine();
     //by default enable skin template & disable skin file
     //next instance indentifier
     self::$count++;
     //init skin options manager
     parent::__construct($this);
 }