/** * ajax handle callback * @hook wp_ajax_{hw_help_popup} */ function hw_ajax_hw_help_popup() { if (!wp_verify_nonce($_REQUEST['nonce'], "hw-module-help-nonce")) { exit("No naughty business please"); } if (!isset($_REQUEST['file'])) { return; } HW_HOANGWEB::load_class('HW_WP'); //enqueue syntax highlighter library if (class_exists('HW_Libraries', false)) { HW_Libraries::enqueue_jquery_libs('syntaxhighlighter_3.0.83'); HW_Libraries::get('syntaxhighlighter_3.0.83')->enqueue_scripts('shBrushJScript.js', 'shBrushXml.js', 'shBrushPhp.js'); } $file = HW_Encryptor::decrypt(urldecode($_REQUEST['file'])); if (file_exists($file)) { echo file_get_contents($file); } HW_WP::hw_clean_wp_head(); //wp_head(); wp_footer(); //init SyntaxHighlighter echo ' <script type="text/javascript"> //SyntaxHighlighter if(typeof SyntaxHighlighter != "undefined") SyntaxHighlighter.all(); </script> '; die; }
/** * @hook wp_enqueue_scripts */ public function _wp_enqueue_scripts() { //to add new library HW_Libraries::registers_jquery_libs('visible', array('scripts' => array('jquery.visible.min.js' => array('file' => 'jquery.visible.min.js', 'depends' => array('jquery'), 'required' => true)))); HW_Libraries::enqueue_jquery_libs('visible'); HW_Libraries::get('sticky')->enqueue_scripts('jquery.sticky.js'); //sticky js }
/** * background effect */ public static function do_bacground_effect() { //only frontend if (!is_admin() && hw_option('effect')) { $effect = hw_option('effect'); //snow effect if ($effect == 'snow') { HW_Libraries::get('bg-effects')->enqueue_scripts('snow.js'); } if ($effect == 'fireworks') { //wp_enqueue_script('FireWorksNewYear',plugins_url('js/effects/FireWorksNewYear.js',dirname(__FILE__)),array('jquery')); HW_Libraries::get('bg-effects')->enqueue_scripts('FireWorksNewYear.js'); } } }
/** * prepare settings * @param $instance: widget instance data */ private function init_settings($instance = array()) { if (!$instance || !is_array($instance) || !count($instance)) { $instance = $this->get_widget_instance(); } //get widget settings //scrolling content if ($this->enable_scrolling()) { $jcarousellite = HW_Libraries::get('sliders/jcarousellite'); $smoothDivScroll = HW_Libraries::get('sliders/smoothDivScroll'); $jcarousellite->enqueue_scripts('jquery.kinetic.min.js'); //add drag scrolling feature $jcarousellite->enqueue_scripts('jquery.mousewheel.min.js'); #wp_enqueue_script('jquery.kinetic.min.js',plugins_url('js/jquery.kinetic.min.js',__FILE__),array('jquery'),0,true); #wp_enqueue_script('jquery.mousewheel.min.js',plugins_url('js/jquery.mousewheel.min.js',__FILE__),array('jquery'),0,true); if ($instance['scroll_type'] == 'smoothdivscroll') { if ($this->is_vertical_scrolling()) { //enqueue query.smoothDivScroll, note this modified version of original smoothDivScroll to support vertical scrolling direction /*wp_register_script('jquery.smoothDivScroll-vertical-1.2.js',plugins_url('js/jquery.smoothDivScroll-vertical-1.2.js',__FILE__),array('jquery')); wp_enqueue_script('jquery.smoothDivScroll-vertical-1.2.js');*/ $smoothDivScroll->enqueue_scripts('jquery.smoothDivScroll-vertical-1.2.js'); } else { //wp_enqueue_script('jquery.smoothdivscroll-1.3-min.js',plugins_url('js/jquery.smoothdivscroll-1.3-min.js',__FILE__),array('jquery')); $smoothDivScroll->enqueue_scripts('jquery.smoothdivscroll-1.3-min.js'); } //wp_enqueue_style('smoothDivScroll.css',plugins_url('css/smoothDivScroll.css',__FILE__)); $smoothDivScroll->enqueue_styles('smoothDivScroll.css'); } if ($instance['scroll_type'] == 'jcarousellite') { #wp_enqueue_script('jquery.easing.1.3.js',plugins_url('js/jquery.easing.1.3.js',__FILE__),array('jquery')); #wp_enqueue_script('jquery.jcarousellite.min.js',plugins_url('js/jquery.jcarousellite.min.js',__FILE__),array('jquery')); $jcarousellite->enqueue_scripts('jquery.easing.1.3.js', 'jquery.jcarousellite.min.js', 'jquery.jcarousellite.pauseOnHover.js'); } } //load scrollbar lib if (isset($instance['enable_scrollbar']) && $instance['enable_scrollbar']) { //wp_enqueue_script('jquery.lionbars.0.3.js', HWTPL_PLUGIN_URL.'/js/jquery.lionbars.0.3.js', array('jquery')); } }
public function _wp_enqueue_scripts() { if (!is_admin()) { //enqueue sticky lib #HW_Libraries::enqueue_jquery_libs('sticky'); //best way HW_Libraries::get('sticky')->enqueue_scripts('jquery.sticky.js'); #wp_enqueue_script('jquery.sticky.js', plugins_url('asset/jquery.sticky.js', __FILE__)); } }
/** * register js libs * @param $name library name * @param $resource define resrouce */ public static function registers_jquery_libs($name = '', $resource = '') { //self::$jquery_libs ->this variable no longer use $init_libs = hw_get_autoload('jquery-libs'); if (is_callable($init_libs)) { call_user_func($init_libs); } if (!empty($name) && is_string($name) && is_array($resource)) { //do not allow override exists library if (!HW_Libraries::get($name)) { HW_Libraries::add($name, $resource); } //or HW_Libraries::add($name, $resource,false) } }
/** * @hook admin_enqueue_scripts */ public function admin_enqueue_scripts() { HW_Libraries::get('jquery-libs')->enqueue_scripts('jquery-ui-1.11.4.js'); HW_Libraries::get('jquery-libs')->enqueue_styles('jquery-ui-1.11.4.css'); HW_Libraries::enqueue_jquery_libs('blockUI'); wp_enqueue_style('hw-installer-css', HW_HOANGWEB_URL . '/css/installer.css'); //css for installation page wp_enqueue_script('hw-installer', HW_HOANGWEB_URL . '/js/installer.js', array('jquery')); wp_localize_script('hw-installer', '__hw_installer', array('ver' => '1.0')); }
/** * render scroll tabs * @param array $args * @param $options override options */ public function display_scrolltabs($args = array(), $options = array()) { //scroll tabs js HW_Libraries::get('easytabs')->enqueue_scripts('jquery.scrolltracker.js'); HW_Libraries::get('easytabs')->enqueue_scripts('jquery.vietcodex.track-content-tabs-scroll.js'); //prepare data if (isset($args['show_tabs']) && $args['show_tabs']) { echo $this->render_ui(); } do_action('hw_tabs_display_scrolltabs_after', $this); $config = $this->get_params(); extract($config); //option $opt = array('tabs_topSpacing' => 0, 'debug' => false, 'current_tab_class' => 'current-tab'); if ($config['current_tab_class']) { $opt['current_tab_class'] = $config['current_tab_class']; } if (is_array($options)) { $opt = array_merge($opt, $options); } echo "<script>\r\n jQuery(document).ready(function(\$){\r\n jQuery('.{$tabs_menu_class}').vcdx_trackContentPos(" . json_encode($opt) . ");\r\n });\r\n </script>"; }
<?php /** * HW Template: pikachoose-96 */ $options = isset($skin_data['skin_options']) ? $skin_data['skin_options'] : array(); $gallery_id = 'gallery-' . sanitize_html_class($args['wrapper_id']); // Gallery element if (!empty($options['css'])) { HW_Libraries::get('pikachoose-96')->enqueue_styles($options['css']); //addition css file } ?> <div class="pikachoose <?php echo sanitize_html_class($args['wrapper_class']); ?> " id="<?php echo $gallery_id; ?> "> <ul class="pikame" > <?php foreach ($galleries as $id => $item) { ?> <li><a href="<?php echo $item['url']; ?> "><img src="<?php echo $item['img_src']; ?>
/** * @param string $hash_skin: active hash skin string * @param $fname file name * @param $base_fname: base field name * @param $options_value: store all options values * @param $hash_skin: current skin hash */ public function prepare_skin_options_fields($fname, $options_value = '', $hash_skin = '', $base_fname = '') { //if($hash_skin) $this->set_active_skin($hash_skin); $theme_options = array(); $option_file = $this->get_file_skin_options($hash_skin); $theme_setting = $this->get_file_skin_setting(); if (file_exists($theme_setting)) { include $theme_setting; if (isset($theme['js-libs'])) { if (is_array($theme['js-libs'])) { $lib = trim(reset($theme['js-libs'])); } elseif (is_string($theme['js-libs'])) { $lib = trim($theme['js-libs']); } //fetch options from lib if (!empty($lib) && HW_Libraries::get($lib)) { $lib_options = HW_Libraries::get($lib)->get_lib_options(true); if (is_array($lib_options) && count($lib_options)) { $theme_options = array_merge($theme_options, $lib_options); } //valid } } //fetch default options if (isset($theme['default_options'])) { if (!empty($theme['default_options']) && is_string($theme['default_options']) && file_exists($theme['default_options'])) { $def_options = $this->get_file_skin_options($theme['default_options'], true); if (is_array($def_options) && count($def_options)) { $theme_options = array_merge($theme_options, $def_options); } } } if (file_exists(dirname(dirname($theme_setting)) . '/options.php')) { $auto_options = $this->get_file_skin_options(dirname(dirname($theme_setting)) . '/options.php', true); if (is_array($auto_options) && count($auto_options)) { $theme_options = array_merge($theme_options, $auto_options); } } } //get document $readme = $this->get_file_skin_resource('readme.html'); //_print($readme); if (file_exists($readme)) { $readme_link = $this->get_skin_url('readme.html'); } $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 //get field name/id if (!empty($this->widget_ref) && $this->widget_ref instanceof WP_Widget) { $myfield_id = $this->widget_ref->get_field_id($fname); $myfield_name = $this->widget_ref->get_field_name($fname); } else { $myfield_id = !empty($base_fname) ? $base_fname . '_' . $fname : $fname; $myfield_name = !empty($base_fname) ? $base_fname . '[' . $fname . ']' : $fname; } $theme_options_output = array(); if (file_exists($option_file)) { include $option_file; //load skin config options } //prepend default skin options if (!isset($theme_options)) { $theme_options = array(); } self::default_skin_options($theme_options); if (isset($theme_options) && is_array($theme_options)) { $skin_data = $this->get_skin_data($hash_skin); //get active skin data $parse_id = isset($skin_data['screenshot']) ? md5($skin_data['screenshot']) : md5(rand()); $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->renderOptionField($_field, $myfield_name, $myfield_id, $options_value); } $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>'; } $msg_id = 'hwskin_msg_' . $myfield_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_' . $this->valid_objname($myfield_id) . '_' . $parse_id . '_change_event'; //change event callback name $this->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 $theme_options_output[] = '<script> function ' . $hwskin_event_change_name . '(skin){ console.log(skin,"' . $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->saveCallbackJs4SkinChangeEvent('jQuery("#' . $msg_id . '").html("' . $notice_skin_option . '");'); } return implode("\n", $theme_options_output); }