/** * Render the settings page */ public function _wxr_settings_page() { $options = get_option('hw_wxr_settings'); ?> <div class="wrap"> <div id="icon-tools" class="icon32"><br /></div> <h2><?php screen_icon(); _e('HOANGWEB Settings'); ?> </h2> <form method="post" action="options.php" class="options_form"> <?php settings_fields('hw_wxr_settings_group'); ?> <table class="form-table"> <!-- <tr valign="top"> <th scop="row"> <label for="hw_wxr_settings[text]"><?php _e('Plugin Text'); ?> </label> </th> <td> <input class="regular-text" type="text" id="hw_wxr_settings[text]" style="width: 300px;" name="hw_wxr_settings[text]" value="<?php if (isset($options['text'])) { echo esc_attr($options['text']); } ?> "/> <p class="description"><?php _e('Enter some text for the plugin here.'); ?> </p> </td> </tr> <tr> <th scop="row"> <label for="hw_wxr_settings[label]"><?php _e('Label Text'); ?> </label> </th> <td> <input class="regular-text" type="text" id="hw_wxr_settings[label]" style="width: 300px;" name="hw_wxr_settings[label]" value="<?php if (isset($options['label'])) { echo esc_attr($options['label']); } ?> "/> <p class="description"><?php _e('Enter some text for the label here.'); ?> </p> </td> </tr> <tr valign="top"> <th scop="row"> <span><?php _e('Enable Feature'); ?> </span> </th> <td> <input class="checkbox" type="checkbox" id="hw_wxr_settings[enabled]" name="hw_wxr_settings[enabled]" value="1" <?php checked(1, isset($options['enabled'])); ?> /> <label for="hw_wxr_settings[enabled]"><?php _e('Enable some feature in this plugin?'); ?> </label> </td> </tr> --> </table> <?php #submit_button(); ?> </form> <div class="metabox-holder"> <div class="postbox"> <h3><span><?php _e('Export Settings'); ?> </span></h3> <div class="inside"> <form method="post"> <p><label><input type="radio" name="module" value="all" /> Tất cả</label></p> <?php foreach (HW_TGM_Module_Activation::get_modules() as $slug => $plugin) { if (empty($plugin['can_export']) || !HW_Module::is_active($slug)) { continue; } ?> <p><label><input type="radio" name="module" value="<?php echo esc_attr($plugin['slug']); ?> " /> <?php echo esc_html($plugin['name']); ?> </label></p> <?php } ?> <p><?php _e('Export the plugin settings for this site as a .json file. This allows you to easily import the configuration into another site.'); ?> </p> <p><input type="hidden" name="hw_wxr_action" value="export_settings" /></p> <p> <?php wp_nonce_field('hw_wxr_export_nonce', 'hw_wxr_export_nonce'); ?> <?php submit_button(__('Export'), 'secondary', 'submit', false); ?> </p> </form> </div><!-- .inside --> </div><!-- .postbox --> <div class="postbox"> <h3><span><?php _e('Import Settings'); ?> </span></h3> <div class="inside"> <p><?php _e('Import the plugin settings from a .json file. This file can be obtained by exporting the settings on another site using the form above.'); ?> </p> <!-- <form method="post" enctype="multipart/form-data"> <p> <input type="file" name="import_file"/> </p> <p> <input type="hidden" name="hw_wxr_action" value="import_settings" /> <?php wp_nonce_field('hw_wxr_import_nonce', 'hw_wxr_import_nonce'); ?> <?php submit_button(__('Import'), 'secondary', 'submit', false); ?> </p> </form> --> Nhấn <a href="<?php echo admin_url('admin.php?import=hw-wordpress'); ?> ">vào đây</a> để tiến hành Import dữ liệu. </div><!-- .inside --> </div><!-- .postbox --> </div><!-- .metabox-holder --> </div> <?php }
/** * setup form fields */ public function setUp() { $current_module_tab = hw__get('module'); //get current module setting tab $_GET['tab']==$_GET['module'] if (HW_HOANGWEB::is_current_screen(self::PAGE_SLUG) && hw__get('tab') && $current_module_tab && (!HW_Module::is_active($current_module_tab) || isset(self::$modules[$current_module_tab]) && !self::$modules[$current_module_tab]->option('enable_tab_settings'))) { wp_die('Xin lỗi: Module này chưa kích hoạt hoặc không có form cài đặt.'); } // Set the root menu (http://admin-page-framework.michaeluno.jp/en/v2/classes/AdminPageFramework_Menu.html) #$this->setRootMenuPage( 'Settings' ); // specifies to which parent menu to add. $this->setRootMenuPage('(H) Cấu hình modules', HW_HOANGWEB_URL . '/images/ie-gear-icon.png'); // Add the sub menus and the pages/ addSubMenuItems $this->addSubMenuItem(array('title' => 'Cấu hình modules', 'page_slug' => self::PAGE_SLUG)); /*$this->addSubMenuItem(array( 'title' => 'sdf', 'href' => self::get_module_setting_page('abc'), #'page_slug' => self::PAGE_SLUG ));*/ //define tabs $this->addInPageTabs(self::PAGE_SLUG, array('tab_slug' => 'modules-config', 'title' => __('Cấu hình chung'))); //add more tabs foreach (self::$modules as $name => $inst) { $info = HW_Plugins_Manager::get_module($name); if (!empty($info) && $inst->option('enable_tab_settings')) { $this->addInPageTab(array('tab_slug' => $name, 'title' => $info['name'])); // load + page slug + tab slug add_action('load_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, '_replyToAddFormElements')); //triggered before rendering the page. add_action('do_before_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'do_before_tab_hook')); // triggered in the middle of rendering the page. add_action('do_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'do_tab_hook')); //triggered after rendering the page add_action('do_after_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'do_after_tab_hook')); /** * filters */ //receives the output of the middle part of the page including form input fields. add_filter('content_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'content_tab_filter')); /* ==> find in : hw-hoangweb\lib\admin-page-framework\development //receives the output of the top part of the page. add_filter('head_'. self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'head_tab_filter')); // receives the output of the bottom part of the page. add_filter('foot_'. self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'foot_tab_filter')); //receives the exporting array sent from the tab page. add_filter('export_'. self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'export_tab_filter')); //receives the importing array submitted from the tab page. add_filter('import_'. self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'import_tab_filter')); */ #add_filter(''. self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'tab_filter')); //receives the output of the CSS rules applied to the tab page of the slug. add_filter('style_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'print_styles')); //receives the output of the JavaScript script applied to the tab page of the slug. add_filter('script_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'print_scripts')); //receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database. add_filter('validation_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, '_validation_tab_filter')); } } $this->setInPageTabTag('h2'); // sets the tag used for in-page tabs //submit button /*$this->addSettingFields( array( 'field_id' => 'submit_button', 'type' => 'submit', 'show_title_column' => false, ) );*/ }