/** * Sets up the form. * * Alternatively you may use load_{instantiated class name} method. */ public function load($oAdminWidget) { //get all hwml shortcodes $hwml_data = HWMLShortcode_Manager::get_hwml_slideshow_posts(); HW_UI_Component::empty_select_option($hwml_data); //register form fields $this->addSettingFields(array('field_id' => 'title', 'type' => 'text', 'title' => __('Tiêu đề', 'hwml'), 'default' => ''), array('field_id' => 'slider', 'type' => 'select', 'label' => $hwml_data, 'title' => __('Chọn slider', 'hwml'), 'description' => ''), array('field_id' => 'use_default_slider', 'type' => 'checkbox', 'title' => 'Lấy slider mặc định', 'description' => 'Sử dụng slider đã thiết lập mặc định <a href="' . HW_NHP_Main_Settings::get_setting_page_url() . '" target="_blank">tại đây</a>.'), array()); }
/** * load option grid posts * @param WP_Widget $t: widget object * @param array $instance: widget data */ function do_widget_feature($t, $instance = array()) { $this->widget_instance = $instance; //maybe update widget instance $enable_fancybox = $this->get_field_value('awc_enable_fancybox'); echo '<div class="awc-widget-feature-fancybox"><fieldset><legend>Fancybox</legend>'; if (class_exists('HW_NHP_Main_Settings', false)) { echo '<p><a href="' . HW_NHP_Main_Settings::get_setting_page_url() . '" target="_blank">Kích hoạt & cấu hình fancybox</a></p>'; } echo '<div ><input type="checkbox" name="' . $this->get_field_name('awc_enable_fancybox') . '" id="' . $this->get_field_id('awc_enable_fancybox') . '" ' . esc_attr($enable_fancybox ? 'checked="checked"' : '') . '/>'; echo '<label for="' . $this->get_field_id('awc_enable_fancybox') . '"><strong>Kích hoạt fancybox</strong></label></div>'; //grids column #echo '<div><label for="'.$t->get_field_id('awc_grid_fancybox').'"><strong>Số cột posts grid:</strong></label>'; #echo '<input size="5" type="text" name="'.$t->get_field_name('awc_grid_fancybox').'" id="'.$t->get_field_id('awc_grid_fancybox').'" value="'.$instance['awc_grid_fancybox'].'"/></div>'; echo '<div> <span>Cài đặt options</span><br/> <label><input type="radio" name="' . $this->get_field_name('use_default_opts') . '" class="' . $this->get_field_id('use_default_opts') . '" id="' . $this->get_field_id('use_default_opts') . '" value="default" ' . ($this->get_field_value('use_default_opts') == 'default' ? "checked='checked'" : "") . '/> Mặc định</label> <label><input type="radio" name="' . $this->get_field_name('use_default_opts') . '" class="' . $this->get_field_id('use_default_opts') . '" id="' . $this->get_field_id('use_default_opts') . '" value="extend" ' . ($this->get_field_value('use_default_opts') == 'extend' ? "checked='checked'" : "") . '/> Mới</label> </div>'; if (file_exists(plugin_dir_path(__FILE__) . '/options.php')) { include plugin_dir_path(__FILE__) . '/options.php'; } if (isset($theme_options)) { $class = $this->get_field_value('use_default_opts') == 'default' ? 'hw-hidden' : ''; echo '<div id="' . $this->get_field_id('fancybox-settings') . '" class="' . $class . '">'; echo $this->build_options($theme_options); echo '</div>'; } echo '<script> jQuery(function($) { $(".' . $this->get_field_id('use_default_opts') . '").click(function(e) { var setting_container = "#' . $this->get_field_id('fancybox-settings') . '"; if($(this).val() == "default") { $(setting_container).hide(); } else $(setting_container).show().removeClass("hw-hidden"); }); }); </script> '; echo '</fieldset></div>'; }
/** * load options fixed widget feature * @param WP_Widget $t: widget object * @param array $instance: widget data */ function do_widget_feature($t, $instance = array()) { $this->widget_instance = $instance; //maybe update widget instance $enable_fixed = $this->get_field_value('awc_enable_fixed_widget'); $lib = $this->get_field_value('awc_fixedobj_lib'); echo '<div class="awc-widget-feature-fixed_widget"><fieldset><legend>Fixed widget</legend>'; if (class_exists('HW_NHP_Main_Settings', false)) { echo '<p><a href="' . HW_NHP_Main_Settings::get_setting_page_url() . '" target="_blank">Kích hoạt & cấu hình fixed widget</a></p>'; } echo '<div ><input type="checkbox" name="' . $this->get_field_name('awc_enable_fixed_widget') . '" id="' . $this->get_field_id('awc_enable_fixed_widget') . '" ' . esc_attr($enable_fixed ? 'checked="checked"' : '') . '/>'; echo '<label for="' . $this->get_field_id('awc_enable_fixed_widget') . '"><strong>Kích hoạt fixed widget</strong></label></div>'; //grids column echo '<label for="' . $this->get_field_id('awc_fixedobj_lib') . '"><strong>Chọn thư viện</strong></label>'; $fixed_libs = array('sticky' => 'Sticky', 'sticky-kit' => 'Sticky Kit'); echo HW_UI_Component::build_select_tag($fixed_libs, $lib, array('name' => $this->get_field_name('awc_fixedobj_lib'), 'id' => $this->get_field_id('awc_fixedobj_lib'))); #echo '<div><label for="'.$t->get_field_id('awc_grid_fancybox').'"><strong>Số cột posts grid:</strong></label>'; #echo '<input size="5" type="text" name="'.$t->get_field_name('awc_grid_fancybox').'" id="'.$t->get_field_id('awc_grid_fancybox').'" value="'.$instance['awc_grid_fancybox'].'"/></div>'; /*echo '<div> <span>Cài đặt options</span><br/> </div>';*/ if ($lib == 'sticky-kit') { if (file_exists(plugin_dir_path(__FILE__) . '/options-sticky-kit.php')) { include plugin_dir_path(__FILE__) . '/options-sticky-kit.php'; } } elseif (file_exists(plugin_dir_path(__FILE__) . '/options.php')) { include plugin_dir_path(__FILE__) . '/options.php'; } //build theme options if (isset($theme_options)) { echo '<div id="' . $this->get_field_id('fixed_widget-settings') . '" class="">'; echo $this->build_options($theme_options); echo '</div>'; } echo '<script> jQuery(function($) { }); </script> '; echo '</fieldset></div>'; }
/** * setup site metadata * @param $command */ public function setup_site_meta($command, $args) { #$this->command_log('setup site meta');return; //get current template context $theme_config = $this->get_option('theme_config'); //parse config file for current theme #site meta if ($theme_config->item('site')) { $site = $theme_config->item('site'); HW_NHP_Main_Settings::update_data(array('last_tab' => '1')); //fix current tab //update site info (name & description, phone...) HW__Site::update_site_info($site); //update logo if (!empty($site['logo'])) { //get relative path from current theme directory if (!HW_URL::valid_url($site['logo'])) { $site['logo'] = get_stylesheet_directory_uri() . '/' . $site['logo']; } HW__Site::set_logo($site['logo']); } //set banner if exists if (!empty($site['banner'])) { //get relative path from current theme directory if (!HW_URL::valid_url($site['banner'])) { $site['banner'] = get_stylesheet_directory_uri() . '/' . $site['banner']; } HW__Site::set_banner($site['banner']); } //update user info $user = _hw_global('admin')->load_api('HW_WP_User'); $user->update_user(array('user_email' => $site['email'], 'user_url' => 'http://hoangweb.com', 'description' => $site['footer_text'])); } if ($theme_config->item('configuration')) { } $this->command_log('setup site meta'); }
/** * update site information * @param $info * @param $set_related */ public static function update_site_info($info, $set_related = true) { if (is_string($info)) { $info = array('name' => $info); } //blog name if (isset($info['name'])) { $info['site_name'] = $info['name']; update_option('blogname', $info['name']); } //blogdescription if (isset($info['description'])) { $info['slogan'] = $info['description']; update_option('blogdescription', $info['description']); } //update admin email if (!empty($info['email'])) { $info['email'] = '*****@*****.**'; } update_option('admin_email', $info['email']); //flush permalink update_option('permalink_structure', '/%category%/%postname%.html'); flush_rewrite_rules(); if (!isset($info['wp_head_script'])) { $info['wp_head_script'] = '<script>/*generated by hoangweb engine*/</script>'; } //set relate options & other HW_NHP_Main_Settings::update_data($info); }