/** * 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; }
/** * constructor * @param $class */ public function __construct($class) { parent::__construct($class, null); HW_Libraries::enqueue_jquery_libs('ckeditor'); //load ckeditor lib $this->enqueue_assets(); }
/** * @wp_hook admin_enqueue_scripts * @return mixed|void */ public function admin_enqueue_scripts() { global $wp_scripts; $aField = $this->getFieldData(); $data = array('no_image' => $this->get_property('no_image')); //form action //if($this->get_property('internal_form_action')) { $this->config = array('action_url' => $this->get_property('upload'), 'action_path' => $this->get_property('upload_file'), 'uploads_folder' => $this->get_property('uploads_path'), 'uploads_url' => $this->get_property('uploads_directory_uri'), 'image_type' => $this->get_property('image_type'), 'random_filename' => $this->get_property('random_filename'), 'allow_types' => $this->get_property('allow_types'), 'maxsize' => $this->get_property('maxsize'), 'redirect' => $this->get_property('redirect'), 'success_callback_js' => $this->get_property('success_callback_js'), 'error_callback_js' => $this->get_property('error_callback_js')); //} //else $data['upload_handle'] = $this->get_property('upload'); $id = md5($this->get_field_name()); $data[$id] = $this->config; $handle = $this->enqueue_script('assets/upload.js', array('jquery'), 'hw-apf-field-upload'); if ($handle) { self::$script_handle = $handle; $wp_scripts->add_data($handle, $id, $data[$id]); } if (!$handle) { //$wp_scripts->add_data(self::$script_handle, $id, $data[$id] ); //echo '<textarea>';print_r($wp_scripts);echo '</textarea>'; $this->add_data(self::$script_handle, '__hw_apf_field_upload', $id, $data[$id]); } elseif ($handle) { $this->localize_script($handle, '__hw_apf_field_upload', $data); } $this->enqueue_style('assets/style.css'); //jquery form lib HW_Libraries::enqueue_jquery_libs('jquery-libs/form'); }
/** * @hook wp_enqueue_scripts */ public function enqueue_scripts() { if (!is_admin()) { $this->enqueue_style('asset/custom-cloudzoom.css'); //load cloudzoom lib HW_Libraries::enqueue_jquery_libs('cloudzoom'); } }
/** * @hook admin_enqueue_scripts */ public function admin_enqueue_scripts() { if ($this->is_module_setting_page()) { HW_Libraries::enqueue_jquery_libs('jquery-colorbox'); $this->enqueue_script('assets/scripts.js'); $this->enqueue_style('assets/style.css'); } }
/** * for backend */ public function _admin_enqueue_scripts() { if (HW_HOANGWEB::is_current_screen('widgets')) { //ckeditor HW_Libraries::enqueue_jquery_libs('ckeditor'); wp_enqueue_script('media'); wp_enqueue_media(); } }
/** * @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); }
/** * construct method * @param $args * @param $options */ public function __construct($args = array(), $options = array()) { parent::__construct($args, $options); //load cloudzoom lib HW_Libraries::enqueue_jquery_libs('cloudzoom'); $this->cloudzoom_id = HW_String::generateRandomString(); //valid if (!is_array($args)) { $args = array(); } //params $default_params = array('images_from_current_post' => '0', 'zoombig_width' => '300px', 'zoombig_height' => '', 'container_id' => 'cloudzoom-container', 'container_class' => '', 'thumb_anchor_class' => 'cloudzoom-thumb-anchor-class', 'thumb_img_class' => 'cloudzoom-thumb-img-class', 'smallthumb_container_class' => 'cloudzoom-smallthumb-container', 'smallthumb_class' => 'cloudzoom-smallthumb-class', 'smallthumb_item_class' => 'cloudzoom-smallthumb-item-class', 'smallthumb_anchor_class' => 'cloudzoom-smallthumb-anchor-class', 'smallthumb_img_class' => 'cloudzoom-smallthumb-img-class'); if (class_exists('HW_Module_Cloudzoom') && HW_Module_Cloudzoom::is_active()) { $setting = HW_Module_Cloudzoom::get(); $params['images_from_current_post'] = $setting->get_field_value('images_from_current_post'); $params['zoombig_width'] = $setting->get_field_value('zoombig_width'); $params['zoombig_height'] = $setting->get_field_value('zoombig_height'); $params['container_id'] = $setting->get_field_value('container_id'); $params['container_class'] = $setting->get_field_value('container_class'); $params['thumb_anchor_class'] = $setting->get_field_value('thumb_anchor_class'); $params['thumb_img_class'] = $setting->get_field_value('thumb_img_class'); $params['smallthumb_container_class'] = $setting->get_field_value('smallthumb_container_class'); $params['smallthumb_class'] = $setting->get_field_value('smallthumb_class'); $params['smallthumb_item_class'] = $setting->get_field_value('smallthumb_item_class'); $params['smallthumb_anchor_class'] = $setting->get_field_value('smallthumb_anchor_class'); $params['smallthumb_img_class'] = $setting->get_field_value('smallthumb_img_class'); } $this->set_params($default_params); if (is_array($args)) { $this->set_params($args); } //cloud options if (is_array($options)) { $this->set_options($options); } }
/** * @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')); }
public function _wp_enqueue_scripts() { if (!is_admin()) { //enqueue fancybox lib HW_Libraries::enqueue_jquery_libs('fancybox'); } }
/** * @hook admin_enqueue_scripts */ public function _admin_enqueue_scripts() { HW_Libraries::enqueue_jquery_libs('jquery-colorbox'); }
/** * display ads on the website */ public function _hw_footer_setup_flra() { if (function_exists('hwlib_load_library')) { $mobile_detect = hwlib_load_library('HW_Mobile_Detect'); // if ($mobile_detect->object->isMobile() && !hw_option('ads_active_mobile')) { return; //do not show ads on mobile device } } //show ads if (hw_option('enable_flra')) { $id = rand(); $id_left_ad = 'hw_divAdLeft_' . $id; $id_right_ad = 'hw_divAdRight_' . $id; $effect = hw_option('ads_effects'); $lad_width = hw_option('lad_width', 150); //left ad width $rad_width = hw_option('rad_width', 150); //right ad width $mcontent_div = hw_option('mcontent_div'); //div main wrapper #$mcontent_width = hw_option('mcontent_width', 1000); ?> <style> #<?php echo $id_right_ad; ?> , #<?php echo $id_left_ad; ?> { display: block;z-index: 1e+19;position: absolute; } .hw-side-ads{ position: absolute !important; width: <?php echo $lad_width; ?> px; display: none; top:0px; } <?php if ($effect == 'fixed_to_top') { ?> <?php if ($mcontent_div) { echo "\r\n {$mcontent_div} {position:relative !important;}\r\n "; } ?> #<?php echo $id_right_ad; ?> .hw-ad-right{ <?php if ($rad_width) { echo "width: {$rad_width}px"; } ?> } #<?php echo $id_left_ad; ?> .hw-ad-left{ left:-<?php echo $lad_width + 10; ?> px; <?php if ($rad_width) { echo "width: {$lad_width}px"; } ?> } <?php } ?> </style> <!-- banner truot 2 ben --> <div id="<?php echo $id_right_ad; ?> " style=""><!-- left: 286.5px; --> <div class="hw-side-ads hw-ad-right"><?php echo hw_option('ad_left'); ?> </div> </div> <div id="<?php echo $id_left_ad; ?> " style=""><!-- left: 1486.5px; --> <div class="hw-side-ads hw-ad-left"><?php echo hw_option('ad_right'); ?> </div> </div> <script> var hw_ads = { /** * return ads setting */ hw_ads_settings: function() { var mcontent_div = '<?php echo hw_option('mcontent_div', ''); ?> '; var MainContentW = 0; //for default var LeftBannerW = <?php echo hw_option('lad_width', 150); ?> ; var RightBannerW = <?php echo hw_option('rad_width', 150); ?> ; var LeftAdjust = 0; var RightAdjust = 0; var TopAdjust = <?php echo hw_option('top_adjust', 20); ?> ; return { mcontent_div: mcontent_div, MainContentW: MainContentW, LeftBannerW:LeftBannerW, RightBannerW:RightBannerW, LeftAdjust: LeftAdjust, RightAdjust: RightAdjust, TopAdjust : TopAdjust } }, /** * This will check if the element is entirely visible in the current viewport */ elementInViewport:function (el) { if(typeof el =='string') el = jQuery(el).get(0); return jQuery(el).visible(); /* var top = el.offsetTop; var left = el.offsetLeft; var width = el.offsetWidth; var height = el.offsetHeight; while(el.offsetParent) { el = el.offsetParent; top += el.offsetTop; left += el.offsetLeft; } return ( top >= window.pageYOffset && left >= window.pageXOffset && (top + height) <= (window.pageYOffset + window.innerHeight) && (left + width) <= (window.pageXOffset + window.innerWidth) ); */ }, /** * You could modify this simply to determine if any part of the element is visible in the viewport: * @param el * @returns {boolean} */ elementInViewport2: function(el) { if(typeof el =='string') el = jQuery(el).get(0); var top = el.offsetTop; var left = el.offsetLeft; var width = el.offsetWidth; var height = el.offsetHeight; while(el.offsetParent) { el = el.offsetParent; top += el.offsetTop; left += el.offsetLeft; } return ( top < (window.pageYOffset + window.innerHeight) && left < (window.pageXOffset + window.innerWidth) && (top + height) > window.pageYOffset && (left + width) > window.pageXOffset ); } }; jQuery(document).ready(function(){ hw_ads.ads_settings = hw_ads.hw_ads_settings(); //update MainContentW if(hw_ads.ads_settings.mcontent_div && jQuery(hw_ads.ads_settings.mcontent_div).length) { hw_ads.ads_settings.MainContentW = jQuery(hw_ads.ads_settings.mcontent_div).width(); hw_ads.ads_settings.ads_container = jQuery(hw_ads.ads_settings.mcontent_div); } else { var ads_container = jQuery('<div/>').addClass('hw-ads-container').css({ position: 'absolute',width:'100%',margin:'auto',top: hw_ads.ads_settings.TopAdjust + 'px'}); ads_container.appendTo('body:eq(0)'); hw_ads.ads_settings.MainContentW = ads_container.width(); //update main content width hw_ads.ads_settings.ads_container = ads_container; } }); </script> <?php //following scrollbar if ($effect == 'follow_scrollbar') { ?> <script> (function(){ /** * float top div */ function hw_FloatTopDiv() { startLX = ((document.body.clientWidth - hw_ads.ads_settings.MainContentW)/2)- hw_ads.ads_settings.LeftBannerW-hw_ads.ads_settings.LeftAdjust , startLY = hw_ads.ads_settings.TopAdjust+80; startRX = ((document.body.clientWidth - hw_ads.ads_settings.MainContentW)/2)+ hw_ads.ads_settings.MainContentW+ hw_ads.ads_settings.RightAdjust , startRY = hw_ads.ads_settings.TopAdjust+80; var d = document; function ml(id) { var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id]; el.sP=function(x,y){this.style.left=x + 'px';this.style.top=y + 'px';}; el.x = startRX; el.y = startRY; return el; } function m2(id) { var e2=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id]; e2.sP=function(x,y){this.style.left=x + 'px';this.style.top=y + 'px';}; e2.x = startLX; e2.y = startLY; return e2; } window.stayTopLeft=function() { if (document.documentElement && document.documentElement.scrollTop) var pY = document.documentElement.scrollTop; else if (document.body) var pY = document.body.scrollTop; if (document.body.scrollTop > 30){startLY = 3;startRY = 3;} else { startLY = hw_ads.ads_settings.TopAdjust; startRY = hw_ads.ads_settings.TopAdjust; }; ftlObj.y += (pY+startRY-ftlObj.y)/16; ftlObj.sP(ftlObj.x, ftlObj.y); ftlObj2.y += (pY+startLY-ftlObj2.y)/16; ftlObj2.sP(ftlObj2.x, ftlObj2.y); setTimeout("stayTopLeft()", 1); } ftlObj = ml("<?php echo $id_right_ad; ?> "); //stayTopLeft(); ftlObj2 = m2("<?php echo $id_left_ad; ?> "); stayTopLeft(); } /** * show ads div */ function hw_ShowAdDiv() { var objAdDivRight = document.getElementById("<?php echo $id_right_ad; ?> "); var objAdDivLeft = document.getElementById("<?php echo $id_left_ad; ?> "); if (document.body.clientWidth < hw_ads.ads_settings.MainContentW) { objAdDivRight.style.display = "none"; objAdDivLeft.style.display = "none"; } else { objAdDivRight.style.display = "block"; objAdDivLeft.style.display = "block"; hw_FloatTopDiv(); } } //events jQuery(document).ready(function(){ //show ad div hw_ShowAdDiv(); window.onresize=hw_ShowAdDiv; //show ads jQuery(".hw-side-ads").show(); }); })(); </script> <?php } elseif ($effect == 'fixed_to_top') { HW_Libraries::enqueue_jquery_libs('sticky'); ?> <script> jQuery(document).ready(function(){ var ads_container= null, ad_right =hw_ads.ads_settings.MainContentW+10, ad_left = hw_ads.ads_settings.LeftBannerW+10; //setting /*if(!hw_ads.elementInViewport('#<?php echo $id_right_ad; ?> ')) { }*/ hw_ads.ads_settings.ads_container.prepend(jQuery("#<?php echo $id_left_ad; ?> ")/*.html()*/); hw_ads.ads_settings.ads_container.prepend(jQuery("#<?php echo $id_right_ad; ?> ")/*.html()*/); //jQuery(hw_ads.ads_settings.mcontent_div).remove(); if(hw_ads.ads_settings.MainContentW < jQuery(window).width()) { ad_right +=hw_ads.ads_settings.RightBannerW; } jQuery('#<?php echo $id_right_ad; ?> .hw-ad-right').css({"right": - (ad_right)}); //fixed ad left setTimeout(function(){ console.log(hw_ads.elementInViewport('#<?php echo $id_left_ad; ?> .hw-side-ads'),ad_left); if(hw_ads.elementInViewport('#<?php echo $id_left_ad; ?> .hw-side-ads') == false){ ad_left = -10; } jQuery('#<?php echo $id_left_ad; ?> .hw-ad-left').css({"left": - (ad_left)}); },50); //show ads jQuery(".hw-side-ads").show(); jQuery("#<?php echo $id_right_ad; ?> ").sticky({topSpacing: hw_ads.ads_settings.TopAdjust}); jQuery("#<?php echo $id_left_ad; ?> ").sticky({topSpacing: hw_ads.ads_settings.TopAdjust}); }); </script> <?php } ?> <?php } }
/** * generate skins select tag * @param $wfname: skin name * @param $value: current skin hash string * @param array $atts: array format key-pair present HTML attributes * @param string $theme: support skin dropdown with image or either using simple with large screenshot. Accept: 'dropdown_ddslick','simple' * @param mixed $data: input data, accept name of data in string want to fetch or array generated by methods get_skins|get_files_skins */ public function get_skins_select_tag($wfname, $value = '', $atts = array(), $theme = self::DROPDOWN_DDSSLICK_THEME, $data = self::SKIN_FILES) { $widget = $this->widget_ref; //get current widget //if(!is_object($widget)) return; //validate //put lib to style dropdown if ($theme == self::DROPDOWN_DDSSLICK_THEME) { //wp_enqueue_script(self::DROPDOWN_DDSSLICK_THEME); HW_Libraries::enqueue_jquery_libs('components-ui/dropdown_ddslick'); } if (is_object($widget) && $widget instanceof WP_Widget) { //if whether object reference of widget $preview_holder = $widget->get_field_id($this->instance_uniqueID('skin_preview')); //preview holder id if ($wfname) { $name = $widget->get_field_name($wfname); } elseif (isset($atts['name'])) { $name = $widget->get_field_name($atts['name']); } //get key 'name' from $atts if ($wfname) { $id = $widget->get_field_id($wfname); } elseif (isset($atts['id'])) { $id = $widget->get_field_id($atts['id']); } //get key 'id' from $atts } else { $preview_holder = $this->instance_uniqueID('skin_preview'); if ($wfname) { $name = $wfname; } elseif (isset($atts['name'])) { $name = $atts['name']; } if ($wfname) { $id = $this->uniqueID($wfname); } elseif (isset($atts['id'])) { $id = $this->uniqueID($atts['id']); } } //set skin preview holder $this->set_skin_preview_id($preview_holder); //set attributes requirement if (!is_array($atts)) { $atts = array(); } if (!isset($atts['name'])) { $atts['name'] = $name; } //you can define attr 'name' with $atts param if (!isset($atts['id']) && !empty($id)) { $atts['id'] = self::valid_objname($id); } //override id attribute if not exists in $atts //override onchange event $atts['onchange'] = "hw_skin_{$this->skin_obj_name()}.skin_change_event(this.value,'" . $this->get_skin_preview_id() . "')"; //get stored data of widget that link to this skin maker /*if(count($this->data())){ $w_instance = $this->data(); }*/ $w_instance = self::get_widget_instance($widget); if (!$value && isset($w_instance[$wfname])) { $value = $w_instance[$wfname]; } //get current skin hash string $out = ''; if (is_object($widget->skin)) { //if(!isset($this->skins_data)) $this->skins_data = $this->load_skins_data(); //detect call by ajax when you save widget instance->nested in method 'generate_skin_options_tag' //get skins data, note: $skins= $widget->skin->myskins(); ->wrong $data = $this->get_skins_data($data); $last_group = 0; //group skins //build attrs & select tag $options_tag = $this->generate_skin_options_tag($value, $data, $theme); $out .= '<select ' . self::array2attrs($atts) . '>'; $out .= $options_tag['options']; $out .= '</select>'; if ($theme !== self::DROPDOWN_DDSSLICK_THEME) { //display current skin screenshot if ($this->custom_skins_preview == false) { $out .= $this->get_skins_preview_screen($value); } } if ($theme == self::DROPDOWN_DDSSLICK_THEME) { $out .= '<input type="hidden" ' . self::array2attrs($atts) . ' value="' . $value . '"/>'; //hiden field to save choose skin by user $out .= '<script>jQuery(document).ready(function($){ if(' . (count($options_tag['skins']) ? 1 : 0) . '){ $("#' . $atts['id'] . '").ddslick({ onSelected:function(data){ var active_skin = data.selectedData.value; $("input#' . $atts['id'] . '").val(active_skin); /*add skin change event*/ hw_skin_' . $this->skin_obj_name() . '.skin_change_event(active_skin,"' . $preview_holder . '"); }, "height":"' . $this->ddslick_settings['height'] . '", "width":"' . $this->ddslick_settings['width'] . '", "background":"' . $this->ddslick_settings['background'] . '", "imagePosition":"' . $this->ddslick_settings['imagePosition'] . '", }); $("#' . $atts['id'] . '").ddslick("select",{index:' . $options_tag['selectedIndex'] . '}); } });</script>'; } } else { $out .= 'class "HW_SKIN" not exists.'; } return $out; }
/** * @hook admin_enqueue_scripts */ public function admin_enqueue_scripts() { $this->enqueue_script('admin-tooltip.js'); HW_Libraries::enqueue_jquery_libs('tooltips/tooltipster'); }
/** * enqueue assets for js+css file * @hook wp_enqueue_scripts */ public static function _enqueue_scripts() { global $wp_styles; $current = self::get_current_template(false); $config = $current['object']->get_config_data(); #$current['object'] $active_assets = array(); $assets = $config->item('assets') ? $config->item('assets') : array(); //->item('assets'); /* * From WP * Adds JavaScript to pages with the comment form to support * sites with threaded comments (when in use). */ if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } //common assets if (!empty($assets['__all__'])) { $active_assets = array_merge($active_assets, $assets['__all__']); } if (!empty($assets[$current['name']])) { //get assets for current context $active_assets = array_merge($active_assets, $assets[$current['name']]); } foreach ($active_assets as $file) { //valid file path if (!is_dir($file['name']) && !file_exists($file['name'])) { $url = get_stylesheet_directory_uri() . '/' . $file['name']; } else { $url = $file['name']; } if (!HW_URL::valid_url($url)) { continue; } $handle = isset($file['handle']) ? $file['handle'] : md5($file['name']); //for js if ($file['type'] == 'js') { if (HW_URL::valid_url($url)) { wp_enqueue_script($handle, $url, $file['depends']); } continue; } elseif ($file['type'] == 'css') { wp_enqueue_style(md5($file['name']), $url, $file['depends']); continue; } } if (is_object($current) && method_exists($current, 'enqueue_scripts')) { call_user_func(array($current, 'enqueue_scripts')); //addition stuff } //default js if (!is_admin()) { HW_Libraries::enqueue_jquery_libs('pageload/nprogress'); } //show progressbar while page loading }
/** * put stylesheet & js together on admin head page */ public function _hw_awc_admin_enqueue_scripts() { global $wp_customize; //get working page if (class_exists('HW_HOANGWEB') && HW_HOANGWEB::is_current_screen(array('widgets', 'hw_sidebar_widgets_settings')) || !empty($wp_customize)) { wp_enqueue_style('hw-awc-style', HW_AWC_URL . '/style.css'); wp_enqueue_script('hw-awc-script', HW_AWC_URL . '/js/hw-awc-admin-js.js', array('jquery')); #wp_enqueue_script('jscolor', HW_AWC_URL.('/js/jscolor/jscolor.js')); //jscolor lib HW_Libraries::enqueue_jquery_libs('colors/jscolor'); wp_localize_script('hw-awc-script', 'HW_AWC', array()); //create js object for this module //load media upload box in admin wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); wp_enqueue_script('media-upload'); } /*if(HW_HOANGWEB::is_current_screen('widgets')){ //wp link popup moved to new widget feature // need these styles wp_enqueue_style('wp-jquery-ui-dialog'); wp_enqueue_style('editor.min.css', includes_url('css/editor.min.css'), null); }*/ }
/** * @hook do_before_{page-slug}_{modules-config tab} */ public function _do_before_tab_hook() { HW_Libraries::enqueue_jquery_libs('menus/superfish'); }
/** * @hook admin_enqueue_scripts * enqueue scripts/styles */ public function _admin_enqueue_scripts() { if (HW_HOANGWEB::is_current_screen('hoangweb-theme-options')) { HW_Libraries::enqueue_jquery_libs('jquery-colorbox'); //jquery colorbox lib } }