/** * 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; }
/** * return all terms taxonomies base post type * @param $post_type: post type name * @param $args: addition arguments */ function hwrp_get_all_terms_taxonomies($post_type, $args = array()) { if (!class_exists('HW_POST')) { HW_HOANGWEB::load_class('HW_POST'); } return HW_POST::get_all_terms_taxonomies($post_type, $args); }
/** * Main class constructor */ public function __construct() { include_once dirname(__FILE__) . '/widget/hw-widget-multitranslate.php'; //translate selector widget //load HW_mqtranslate class HW_HOANGWEB::register_class('HW_mqtranslate', dirname(__FILE__) . '/class-hw_mqtranslate.php'); HW_HOANGWEB::load_class('HW_mqtranslate'); add_action('wp_footer', array($this, '_hw_wp_footer')); }
public function __construct() { HW_HOANGWEB::load_class('HW_Validation'); //enable tab settings $this->enable_tab_settings(); $this->enable_submit_button(); //wp hooks $this->_setup_actions(); }
/** * initial */ private static function init() { if (class_exists('HW_HOANGWEB')) { //load twig template engine HW_HOANGWEB::load_class('Twig_Autoloader'); //if not work try this //if class not found try include directly //include_once(HW_HOANGWEB_PATH . '/lib/vendor/autoload.php'); } }
/** * construct */ public function __construct() { if (!$this->check_already()) { return; } if (class_exists('HW_HOANGWEB')) { //load twig template engine #HW_HOANGWEB::load_class('Twig_Autoloader'); //please load what just you used, because this library use in class 'HW_Twig_Template'. For reason, php play on hosting and it make sence to read you code, HW_HOANGWEB::load_class('HW_Twig_Template'); } $this->setup_hooks(); //init hooks }
/** * render map * @param $atts */ public function render_googlemap($atts = array()) { HW_HOANGWEB::load_class('HW_String'); $module = $this->_option('module'); $id = HW_String::generateRandomString(); //options $width = HW_Validation::format_unit(isset($atts['width']) ? $atts['width'] : ($module ? $module->get_field_value('width') : '')); $height = HW_Validation::format_unit(isset($atts['height']) ? $atts['height'] : ($module ? $module->get_field_value('height') : '')); $show_searchbox = isset($atts['show_searchbox']) ? (int) $atts['show_searchbox'] : ($module ? $module->get_field_value('show_searchbox') : ''); if (!empty($atts['location'])) { $location = $atts['location']; if (is_array($location)) { $location = json_encode($location); } } elseif (!empty($atts['address'])) { $location = '"' . $atts['address'] . '"'; } else { $location = '""'; } #$atts['location'] = isset($atts['location'])? HW_Gmap::getLocationFromAddress($atts['location']) : array(); #$location_json = json_encode($atts['location']); $input_box_id = 'pac-input-' . $id; //input box search location $map_canvas_id = 'map-canvas-' . $id; //map canvas $out = '<div class="hw-module-map-container">'; if ($show_searchbox) { $out .= '<input id="' . $input_box_id . '" class="controls hw-pac-input" type="text" placeholder="Tìm kiếm">'; } $out .= '<div id="' . $map_canvas_id . '" class="hw-map-canvas"></div>'; $out .= ' <style> .hw-map-canvas{ ' . ($width ? "width:{$width};" : '') . ' ' . ($height ? "height:{$height};" : '') . ' } </style> <script> jQuery(function($){ google.maps.event.addDomListener(window, "load", function(){ __hw_module_map.map_initialize("#' . $map_canvas_id . '","#' . $input_box_id . '",' . $location . '); }); }); </script> '; $out .= '</div>'; return $out; }
/** * buid condition select tag * @param $value * @param array $atts * @return string */ public static function get_conditions_select_tag($value, $atts = array()) { HW_HOANGWEB::load_class('HW_UI_Component'); $options = array(); $dynamic_settings = self::get_active_conditions_settings(); foreach ($dynamic_settings as $id => $item) { $options[$id] = $item['title']; } if (class_exists('HW_Conditions_Manager', false)) { $guide_link = '(<a href="' . HW_Conditions_Manager::admin_condition_mananger_link() . '" target="_blank">Thêm điều kiện</a>)'; } else { $guide_link = ''; } return HW_UI_Component::build_select_tag($options, $value, $atts, true) . $guide_link; }
/** * bind class to field which to build skin options * @param $field_obj: field type class instance */ public function __construct($field_obj, HW_SKIN $skin = null) { $this->fieldType_ref = $field_obj; //if current context for HW_SKIN class if (empty($skin) && $field_obj instanceof HW_SKIN) { $skin = $field_obj; } if (!empty($skin)) { $this->skin = $skin; } //save skin object add_filter('renderOptionField', array(__CLASS__, '_renderOptionField')); if (!class_exists('HW_UI_Component', false) && class_exists('HW_HOANGWEB')) { HW_HOANGWEB::load_class('HW_UI_Component'); } }
/** * load option widget * @param WP_Widget $t: widget object * @param array $instance: widget data */ function do_widget_feature($t, $instance = array()) { HW_HOANGWEB::load_class('HW_UI_Component'); $this->widget_instance = $instance; $is_hide = $this->get_field_value('hide_option'); $condition = $this->get_field_value('condition'); #$dynamic_settings = HW_Condition::get_active_conditions_settings(); ?> <fieldset><legend>Ẩn widget</legend> <p> <input type="checkbox" class="" name="<?php echo $this->get_field_name('hide_option'); ?> " id="<?php echo $this->get_field_id('hide_option'); ?> " <?php checked($is_hide); ?> /> <label for="<?php echo $this->get_field_id('hide_option'); ?> "><strong>Kích hoạt ẩn</strong></label> </p> <p> <label for="<?php echo $this->get_field_id('condition'); ?> "><strong>Điều kiện</strong></label> <?php echo HW_Condition::get_conditions_select_tag($condition, array('name' => $this->get_field_name('condition'), 'id' => $this->get_field_id('condition'))); ?> </p> </fieldset> <?php }
/** * register sidebar * @param $args * @param $assoc_args */ public function add_sidebar($args, $assoc_args) { $params = $this->get_cmd_args(); #var_dump($params); foreach ($params as $param) { //$name = $this->get_cmd_arg($assoc_args, 'name'); //$id = $this->get_cmd_arg($assoc_args, 'id', $name); if (!empty($param['name'])) { $name = $param['name']; } if (!empty($param['id'])) { $id = $param['id']; } else { $id = $name; } //valid sidebar id $id = preg_replace('#[\\s]+#', '-', $id); if (!$name) { $name = $id; } $desc = isset($param['description']) ? $param['description'] : ''; //$this->get_cmd_arg($assoc_args, 'description'); $before_widget = isset($param['before_widget']) ? $param['before_widget'] : ''; //$this->get_cmd_arg($assoc_args, 'before_widget'); $before_title = isset($param['before_title']) ? $param['before_title'] : ''; //$this->get_cmd_arg($assoc_args, 'before_title'); $after_title = isset($param['after_title']) ? $param['after_title'] : ''; //$this->get_cmd_arg($assoc_args, 'after_title'); $after_widget = isset($param['after_widget']) ? $param['after_widget'] : ''; //$this->get_cmd_arg($assoc_args, 'after_widget'); HW_HOANGWEB::load_class('HW_String'); $sidebar = array('id' => $id, 'name' => $name, 'description' => $desc, 'before_widget' => $before_widget, 'before_title' => $before_title, 'after_title' => $after_title, 'after_widget' => $after_widget); if (!empty($sidebar['id'])) { hwawc_register_sidebar($sidebar); WP_CLI::success(sprintf(' register sidebar `%s` successful.', $name)); } } }
/** * render facebook comment box * @param $atts attributes */ function _hw_fb_comment_display($atts) { HW_HOANGWEB::load_class('HW_UI_Component'); $inst = HW_Module_Comments::get(); $options = $inst->get_tab('facebook')->get_values(); $atts = array(); $appId = isset($options['appId']) ? $options['appId'] : ''; $width = !empty($options['width']) ? HW_Validation::format_unit($options['width']) : '100%'; $num_posts = !empty($options['num_posts']) ? $options['num_posts'] : '5'; $colorscheme = !empty($options['colorscheme']) ? $options['colorscheme'] : 'light'; $order_by = !empty($options['order_by']) ? $options['order_by'] : 'social'; //order_by $show_count = !empty($options['show_count']) ? $options['show_count'] : 0; $comment_text = !empty($options['comment_text']) ? $options['comment_text'] : __('Bình luận'); echo '<div id="fb-root"></div>'; #echo '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>'; echo "\r\n<script>(function(d, s, id) {\r\n var js, fjs = d.getElementsByTagName(s)[0];\r\n if (d.getElementById(id)) return;\r\n js = d.createElement(s); js.id = id;\r\n js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId={$appId}';\r\n fjs.parentNode.insertBefore(js, fjs);\r\n}(document, 'script', 'facebook-jssdk'));</script>"; //show count if ($show_count) { echo '<span class="fb-comments-count" data-href="' . get_permalink() . '"></span> ' . $comment_text; } if (isset($options['html5'])) { $atts['data-href'] = get_permalink(); $atts['data-width'] = $width; $atts['data-numposts'] = $num_posts; $atts['data-order-by'] = $order_by; $atts['data-colorscheme'] = $colorscheme; echo '<div class="fb-comments" ' . HW_UI_Component::generateAttributes($atts) . '></div>'; } else { $atts['href'] = get_permalink(); $atts['width'] = $width; $atts['num_posts'] = $num_posts; $atts['order_by'] = $order_by; $atts['width'] = $width; echo '<fb:comments ' . HW_UI_Component::generateAttributes($atts) . '></fb:comments>'; } }
/** * load option widget title link * @param WP_Widget $t: widget object * @param array $instance: widget data */ function do_widget_feature($t, $instance = array()) { HW_HOANGWEB::load_class('HW_UI_Component'); $this->widget_instance = $instance; $title = self::get_widget_title($t, $instance); $link = $this->get_field_value('link_widget_title'); //link targets $link_targets = array('_blank' => '_blank', '_self' => '_self', '_parent' => '_parent', '_top' => '_top'); ?> <fieldset><legend>Liên kết tiêu đề</legend> <!-- hidden fields --> <input type="hidden" name="<?php echo $this->get_field_name('title'); ?> " id="<?php echo $this->get_field_id('title'); ?> " value="<?php echo $title; ?> "/> <input type="hidden" name="<?php echo $this->get_field_name('widget_name'); ?> " id="<?php echo $this->get_field_id('widget_name'); ?> " value="<?php echo $t->id_base; ?> "/> <p><em>Chú ý: Đặt tiêu đề widget và nhấn lưu widget một lần nữa sau khi chọn liên kết.</em></p> <p> <label for="<?php echo $this->get_field_id('link_widget_title'); ?> "><strong>Trỏ Liên kết vào tiêu đề</strong></label> <input type="text" class="hwawc-hidden" name="<?php echo $this->get_field_name('link_widget_title'); ?> " id="<?php echo $this->get_field_id('link_widget_title'); ?> " value="<?php echo $link; ?> "/> <div> <button class="button" id="<?php echo $this->get_field_id('insert-link-btn'); ?> ">Chọn liên kết</button> <span class="link"> <?php if ($link) { ?> <a href="<?php echo $link; ?> " target="_blank">Mở liên kết</a> <?php } ?> </span> </div> <div> <label for="<?php $this->get_field_id('target_attr'); ?> "><strong>Target</strong></label> <?php echo HW_UI_Component::build_select_tag($link_targets, $this->get_field_value('target_attr'), array('name' => $this->get_field_name('target_attr'), 'id' => $this->get_field_id('target_attr'))); ?> </div> <script> var wpLinkL10n = {"title":"Insert\/edit link","update":"Update","save":"Add Link","noTitle":"(no title)","noMatchesFound":"No matches found."}; jQuery('#<?php echo $this->get_field_id('insert-link-btn'); ?> ').on('click', function(event) { event.preventDefault(); hw_awc_open_link_dialog(function(url){console.log(url); jQuery('#<?php echo $this->get_field_id('link_widget_title'); ?> ').val(url).attr('value',url); },'<?php echo $this->get_field_id('link_widget_title'); ?> ',jQuery(this).next()); return false; }); </script> </p> </fieldset> <?php }
/** * ajax handle * list terms taxonomy * @ajax hw_change_taxonomy */ public function _ajax_hw_change_taxonomy() { if (!wp_verify_nonce($_REQUEST['nonce'], "hw_change_tax_nonce")) { exit("No naughty business please"); } if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { HW_HOANGWEB::load_class('HW_POST'); if (!isset($_REQUEST['_tax'])) { $_REQUEST['_tax'] = 'category'; } //default tax $data = HW_POST::list_tax_terms($_REQUEST['_tax'], array('hide_empty' => 0)); $result['data'] = $data; $result = json_encode($result); echo $result; } else { header("Location: " . $_SERVER["HTTP_REFERER"]); } die; }
/** * 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; } }
/** * @hook plugins_loaded */ private function add_screen_options() { HW_HOANGWEB::load_class('HW_Screen_Option'); if (class_exists('HW_HELP', false)) { $hook_slug = HW_HELP::load_settings_page_hook_slug($this->menu, ''); } else { $hook_slug = ''; } $screen = HW_Screen_Option::get_instance('modules_manager', $hook_slug); #HW_Screen_Option::get('modules-manager')->get_option('xx'); $screen->add_options(array('per_page' => array('label' => 'Số lượng/trang', 'default' => '10'))); $screen->addition_text('Hiển thị danh sách Modules Hoangweb.'); }
<?php /** * Created by PhpStorm. * User: Hoang * Date: 15/06/2015 * Time: 21:23 */ //include admin table ui HW_HOANGWEB::load_class('HW_List_Table'); if (!class_exists('APF_hw_admin_table') && class_exists('HW_APF_FormField')) { class APF_hw_admin_table extends HW_APF_FormField { /** * Defines the field type slugs used for this field type. */ public $aFieldTypeSlugs = array('hw_admin_table', 'hw_admin_tables'); public $aDefaultKeys = array(); /** * Returns the field type specific CSS rules. */ protected function getStyles() { return ".admin-page-framework-input-label-container.hw_more_fields { padding-right: 2em; }\r\n\r\n "; } /** * return field type specific inline js * @return string */ protected function getScripts() {
/** * list all modules commands * @param $args * @param $assoc_args */ public function all_cmds($args, $assoc_args) { HW_HOANGWEB::load_class('HW_Ajax'); $Utilities = HW_CLI_Command_Utilities::get_instance(); HW_Ajax::result($Utilities->get_clis()); }
/** * return HTML for select tag of terms list from taxonomy * @param $tax * @param $focus * @param array $atts * @param array $args * @return string|void */ function hw_get_terms_list($tax, $focus, $atts = array(), $args = array()) { if (!$tax) { return; } HW_HOANGWEB::load_class('HW_UI_Component'); if (is_array($args)) { $args = array(); } $args['order'] = 'ASC'; $args['fields'] = 'all'; $args['hide_empty'] = 0; //build atts $attrs = HW_UI_Component::generateAttributes($atts); /*foreach($atts as $att => $v){ $a.=$att.'="'.$v.'" '; }*/ $out = __('Rỗng'); $terms_data = get_terms($tax, $args); if (is_wp_error($terms_data)) { return ''; } if (count($terms_data)) { $out = '<select ' . trim($attrs) . '>'; $out .= '<option value="">----All----</option>'; foreach ($terms_data as $item) { if (!isset($item->slug)) { continue; } if ($item->slug == $focus) { } $out .= '<option ' . selected($item->slug, $focus, false) . ' value="' . $item->slug . '">' . $item->name . '</option>'; } $out .= '</select>'; } return $out; }
/** * add new slider tab * @param $args * @param $assoc_args */ public function add_slider($args, $assoc_args) { //load necessary classes HW_HOANGWEB::load_class('HW_WP_Attachment'); //list( $name ) = $args; #params $title = $this->get_cmd_arg($assoc_args, 'title', HW_String::generateRandomString(10)); $slide_image_width = $this->get_cmd_arg($assoc_args, 'width', '730'); $slide_image_height = $this->get_cmd_arg($assoc_args, 'height', '280'); //source $source = $this->get_cmd_arg($assoc_args, 'source', 'upload'); $from = $this->get_cmd_arg($assoc_args, 'from_path', 'theme'); $source_path = $this->get_cmd_arg($assoc_args, 'source_path'); if ($from == 'theme') { $source_path = get_stylesheet_directory() . '/' . $source_path; } elseif ($from == 'plugin') { $source_path = HWML_PLUGIN_PATH . '/' . $source_path; } //number of slides $num = $this->get_cmd_arg($assoc_args, 'num', 3); if (!is_numeric($num)) { $num = 3; } //settings $slider_settings = $this->get_cmd_arg($assoc_args, 'settings', array()); if (is_string($slider_settings)) { $slider_settings = HW_Encryptor::decode64($slider_settings); } $attach_ids = array(); #get attachments ids if ($source == 'upload') { $count = 1; if ($handle = opendir($source_path)) { while (false !== ($entry = readdir($handle))) { if ($count > $num) { break; } //exceed max number of files allow to upload if ($entry != "." && $entry != ".." && HW_Validation::valid_image_ext($entry)) { #echo "$entry\n"; $attach_ids[] = HW_WP_Attachment::upload_attachment($source_path . DIRECTORY_SEPARATOR . $entry); $count++; } } closedir($handle); } } else { global $wpdb; $res = $wpdb->get_results("SELECT * from {$wpdb->posts} where post_type='attachment' and post_mime_type like '%image%' order by rand() limit {$num}"); foreach ($res as $row) { $attach_ids[] = $row->ID; } } /** * add slider tab */ $mlslider_post = array('post_content' => '', 'post_title' => wp_strip_all_tags($title), 'post_name' => sanitize_title($title), 'post_status' => 'publish', 'post_type' => 'hw-ml-slider', 'post_author' => '1', 'ping_status' => 'open', 'post_parent' => '0', 'post_excerpt' => '', 'post_date' => date('Y-m-d H:i:s'), 'post_date_gmt' => date('Y-m-d H:i:s'), 'comment_status' => 'open'); $slider_id = wp_insert_post($mlslider_post); /** * add metaslider setting for created above */ $settings_params = $this->get_params('metaslider_settings'); $settings = array('type' => 'flex', 'random' => 'false', 'cssClass' => '', 'printCss' => 'true', 'printJs' => 'true', 'width' => $slide_image_width, 'height' => $slide_image_height, 'spw' => 7, 'sph' => 5, 'delay' => '3000', 'sDelay' => 30, 'opacity' => 0.8, 'titleSpeed' => 500, 'effect' => 'fade', 'navigation' => 'true', 'links' => 'true', 'hoverPause' => 'true', 'theme' => '', 'direction' => 'horizontal', 'reverse' => 'false', 'animationSpeed' => '600', 'prevText' => '<', 'nextText' => '>', 'slices' => 15, 'center' => 'false', 'smartCrop' => 'true', 'carouselMode' => 'false', 'carouselMargin' => '5', 'easing' => 'linear', 'autoPlay' => 'true', 'fullWidth' => 'false', 'noConflict' => 'true', 'hw_mlcontainer_id' => 'false', 'smoothHeight' => 'false'); if (is_array($slider_settings) && count($slider_settings)) { $settings = array_merge($settings, $slider_settings); } $this->hwml_add_or_update_or_delete_meta($slider_id, 'settings', array_merge($settings, $settings_params)); /** * add images to slider */ foreach ($attach_ids as $slide_id) { //$slide_id = $row->ID; if ($this->hwml_slide_exists_in_slideshow($slider_id, $slide_id)) { continue; } $this->hwml_tag_slide_to_slider($slider_id, $slide_id); $this->hwml_add_or_update_or_delete_meta($slide_id, 'type', 'image'); $this->hwml_add_or_update_or_delete_meta($slide_id, 'crop_position', 'center-center'); //for crop tab, set crop position for current image $this->hwml_add_or_update_or_delete_meta($slide_id, 'title', 'demo-title-' . $slide_id); //for seo tab $this->hwml_add_or_update_or_delete_meta($slide_id, 'url', 'url-here-' . $slide_id); update_post_meta($slide_id, '_wp_attachment_image_alt', 'alt demo ' . $slide_id); //for seo tab $this->hwml_add_or_update_or_delete_meta($slide_id, 'new_window', 'true'); //$row->guid; } // Free up memory //$this->stop_the_insanity(); //WP_CLI::success( ' add slider successful.' ); $this->result(' add slider successful.'); }
/** * list terms taxonomy * @param $tax * @param $args * @param $field default get term id as select value * @return array */ function hwlct_list_tax_terms($tax, $args = array(), $field = 'id') { HW_HOANGWEB::load_class('HW_POST'); return HW_POST::list_tax_terms($tax, $args, $field); }
require_once 'lib/customizer-custom-controls/hw-theme-customizer.php'; /** * initialize */ require_once 'hw-install.php'; /** * register class */ //set autoload admin notices class HW_HOANGWEB::load_class('HW_WP_NOTICES'); //feature button toggle class HW_HOANGWEB::load_class('HW_ButtonToggle_widget'); //set autoload HW_POST class HW_HOANGWEB::load_class('HW_POST'); /** * acf untilities */ //include_once('classes/plugins/hw_acf_api.php'); HW_HOANGWEB::load_class('HW_ACF_API'); /** * featured */ //include_once('plugins/video/video.php'); add_action('admin_enqueue_scripts', 'HW_ButtonToggle_widget::_hwbtw_admin_enqueue_scripts', 10); //admin enqueue scripts add_filter('widget_update_callback', 'HW_ButtonToggle_widget::_hwbtw_in_widget_form_update', 10, 3); //update widget instance //start instance new HW_HOANGWEB(); #delete_option('hw_install_modules');exit(); #do_action('hw_hoangweb_loaded'); //load after all masterial loaded in this plugin
/** * constructor */ public function __construct() { $this->setup_actions(); //prepare actions //register system classes automatically /*self::register_class('AdminPageFramework', array( 'debug' => HW_HOANGWEB_PATH.'/lib/admin-page-framework/development/admin-page-framework.php', 'release' => HW_HOANGWEB_PATH.'/lib/admin-page-framework/admin-page-framework.min.php', 'class' => 'AdminPageFramework' ));*/ //load apf field type self::load_class('HW_APF_FormField'); //curl self::load_class('HW_URL'); //curl self::load_class('HW_CURL'); //curl self::load_class('HW_XML'); //xml self::load_class('HW_SESSION'); //php session self::load_class('HW_Logger'); //logging system self::load_class('HW_File_Directory'); //logging system self::load_class('HW_XMLRPC_Server'); //xmlrpc api //notices class HW_HOANGWEB::load_class('HW_WP_NOTICES'); //admin notice //auto load Twig template engine //HW_HOANGWEB::register_class('Twig_Loader_Filesystem', HW_HOANGWEB_PATH.'/lib/vendor/autoload.php'); //validation HW_HOANGWEB::load_class('HW_Validation'); //validation HW_HOANGWEB::load_class('HW_CLI_Command'); //wpcli command class if (!is_admin()) { self::load_class('HW_Twig_Template'); } //twig template //get more field types //self::init_fieldtypes(); //registers jquery libs stuff HW_Libraries::registers_jquery_libs(); }
/** * return valid field name from string * @param $str * @return mixed */ public static function valid_apf_field_name($str) { HW_HOANGWEB::load_class('HW_Validation'); return HW_Validation::valid_apf_slug($str); }
/** * valid classes attribute value * @param array|string $classes * @return string */ private function valid_classes_attr($classes) { HW_HOANGWEB::load_class('HW_Validation'); return HW_Validation::valid_classes_attr($classes); }
<?php //HW_WP::load_wp(); ini_set('display_errors', true); /* include ('../../../../classes/class-core.php'); if(!HW_WP::load_wp()) exit("Not found wordpress core."); HW_APF_FieldTypes::load_fieldtype('APF_hw_upload_field'); //valid data //APF_hw_upload_field::config(); //APF_hw_upload_field::valid_form_data(); */ HW_HOANGWEB::load_class('HW_Ajax'); //check if this is an ajax request if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { die; } $target_dir = !empty($config->uploads_folder) ? rtrim($config->uploads_folder, '/') . '/' : dirname(__FILE__) . "/uploads/"; $ajax = HW_Ajax::create(); //upload multiple files for ($i = 0; $i < APF_hw_upload_field::get_files_num(); $i++) { //validation if (!isset($_FILES['file-' . $i])) { break; } $file = $_FILES['file-' . $i]; $File_Name = strtolower($file['name']); $File_Ext = substr($File_Name, strrpos($File_Name, '.')); //get file extention
/** * enqueue stuff in library */ public function enqueue() { HW_HOANGWEB::load_class('HW_URL'); //load HW_URL utility $this->enqueue_libs(); //other libs of dependencies for this lib $this->enqueue_scripts(); //enqueue required scripts of this lib $this->enqueue_styles(); //enqueue required styles of this lib }
<?php /** Plugin Name: Classic **/ if (empty($instance['thumb_w'])) { $instance['thumb_w'] = '60'; } if (empty($instance['thumb_h'])) { $instance['thumb_h'] = '60'; } include 'theme-setting.php'; //show view all link #echo $view_all_link; HW_HOANGWEB::load_class('HW_POST'); HW_HOANGWEB::load_class('HW_String'); //other way to track count items HW_POST::reset_item_counter(); //fancybox if (isset($wfeatures['fancybox'])) { $fancybox_g1 = $wfeatures['fancybox']['data']->fancybox_group; $fancy_group = $wfeatures['fancybox']['data']->fancybox_group_rel; } else { $fancybox_g1 = ''; $fancy_group = ''; } if (!is_ajax()) { echo $before_widget; // Widget title echo $before_title . $open_title_link; if (isset($instance["widget_title"])) {
/** * ajax callback to get taxonomies for specific post type */ public function _hw_change_taxonomies_posttype() { if (!wp_verify_nonce($_REQUEST['nonce'], "hw_change_posttype_taxonomies_nonce")) { exit("No naughty business please"); } if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $post_types = $_REQUEST['posttype']; #if(is_string($post_types)) $post_types = preg_split('#[\s,]+#',$post_types); HW_HOANGWEB::load_class('HW_POST'); $data = HW_POST::get_posttypes_taxonomies($post_types); //get all taxonomies assigned to post types //get all posts by post types $posts_result = HW_POST::get_all_posts_by_posttypes($post_types); //$html = '<select'; $result['data'] = $data; $result['posts'] = $posts_result; $result = json_encode($result); echo $result; } else { header("Location: " . $_SERVER["HTTP_REFERER"]); } die; }
/** * main class constructor * @param $args * @param $options */ public function __construct($args = array(), $options = array()) { HW_HOANGWEB::load_class('HW_String'); $this->class = get_called_class(); //get called class }