mGeneral[$field])) return $this->mGeneral[$field]; return ''; } #================================================= public function add_plugin_page() { add_menu_page( __('Holiday Manager',ADSHO_TEXT_DOMAIN), __('Holiday Manager',ADSHO_TEXT_DOMAIN), "manage_options", "MenHoSettings", array( $this, 'create_admin_page'), ADSHO_IMAGE_URL.'icon16.png' ); add_submenu_page( "MenHoSettings", __('Settings',ADSHO_TEXT_DOMAIN) ,__('Settings',ADSHO_TEXT_DOMAIN), 'manage_options', "MenHoSettings", array( $this, 'create_admin_page' )); } #================================================= public function create_admin_page() { global $wpdb; // Set class property $this->mGeneral = adsho_GetOptions( ADSHO_OPTIONS_GENERAL ); $table_name = $wpdb->prefix . ADSHO_TBLHOLIDAYS; $this->HOLIDAY = $wpdb->get_results("SELECT * FROM $table_name ORDER BY Name;"); if( isset( $_GET[ 'tab' ] ) ) $this->active_tab = sanitize_text_field($_GET[ 'tab' ]); else $this->active_tab = ADSHO_ID_PAGE1; ?>

icon

active_tab == ADSHO_ID_PAGE1 ) { settings_fields( ADSHO_ID_SETTINGS ); do_settings_sections( ADSHO_ID_PAGE1 ); } else if ( $this->active_tab == ADSHO_ID_PAGE2 ) { settings_fields( ADSHO_ID_SETTINGS ); do_settings_sections( ADSHO_ID_PAGE2 ); } ?> active_tab == ADSHO_ID_PAGE1 ) submit_button(); print '
'; print __('Translated by: ad-software', ADSHO_TEXT_DOMAIN); print '
'; ?>
'active' ) ); add_settings_field( 'showerror', // ID __('Show Errors', ADSHO_TEXT_DOMAIN), // Title array( $this, 'callback_showerror' ), // Callback ADSHO_ID_PAGE1, // Page ADSHO_ID_SEC1, // Section array( 'label_for' => 'showerror' ) ); add_settings_field( 'tplpath', // ID __('Template folder', ADSHO_TEXT_DOMAIN), // Title array( $this, 'callback_tplpath' ), // Callback ADSHO_ID_PAGE1, // Page ADSHO_ID_SEC1, // Section array( 'label_for' => 'tplpath' ) ); add_settings_field( 'realtest', // ID __('Online Test', ADSHO_TEXT_DOMAIN), // Title array( $this, 'callback_realtest' ), // Callback ADSHO_ID_PAGE1, // Page ADSHO_ID_SEC1, // Section array( 'label_for' => 'realtest' ) ); add_settings_section( ADSHO_ID_SEC1, // ID __('Help', ADSHO_TEXT_DOMAIN), // Title array( $this, 'print_info_help' ), // Callback ADSHO_ID_PAGE2 // Page ); add_settings_field( 'resetdb', // ID __('Reset Database', ADSHO_TEXT_DOMAIN), // Title array( $this, 'callback_resetdb' ), // Callback ADSHO_ID_PAGE1, // Page ADSHO_ID_SEC1, // Section array( 'label_for' => 'resetdb' ) ); } // Sanitize each setting field as needed #================================================= public function validate_general( $input ) { $temp = adsho_GetOptions( ADSHO_OPTIONS_GENERAL ); // general //============ // active if ( isset( $input['active'] ) ) $temp['active'] = sanitize_text_field( $input['active'] ); if ( isset( $input['tplpath'] ) ) $temp['tplpath'] = sanitize_text_field( $input['tplpath'] ); if ( isset( $input['showerror'] ) ) $temp['showerror'] = sanitize_text_field( $input['showerror'] ); // checkname if ( isset( $input['checkname'] ) ) $temp['checkname'] = sanitize_text_field( $input['checkname'] ); // checkdate if ( isset( $input['checkdate'] ) ) { $tmp = sanitize_text_field( $input['checkdate'] ); $temp['checkdate'] = ''; if (!empty($tmp ) ) { $da = date_parse($tmp); if (checkdate($da["month"], $da["day"], $da["year"])) { $temp['checkdate'] = $da["year"]."-".$da["month"]."-".$da["day"]; if (!empty($da["hour"]) && !empty($da["minute"])) $temp['checkdate'] .= " ".$da["hour"].":".$da["minute"]; } else { add_settings_error('main', ' ' , __("Wrong date format (use: yyyy-mm-dd hh:mm)", ADSHO_TEXT_DOMAIN), 'updated'); return; } } } if ( isset( $input['checkaction'] ) ) $temp['checkaction'] = sanitize_text_field( $input['checkaction'] ); return $temp; } // Print the Section text #================================================= public function print_info_general(){ } #================================================= public function print_info_help(){ ?>
  1. : [ads-holiday name="test"].




",ADSHO_OPTIONS_GENERAL); echo sprintf("", ADSHO_OPTIONS_GENERAL, $this->getSetting('active') == "on" ? "checked" : ""); echo " ( ".date("Y-m-d H:i:s", current_time( 'timestamp' ) )." )"; } #================================================= public function callback_tplpath() { echo sprintf("",ADSHO_OPTIONS_GENERAL); echo sprintf("", ADSHO_OPTIONS_GENERAL, $this->getSetting('showerror') == "on" ? "checked" : ""); } #================================================= public function callback_realtest() { echo sprintf(""; echo " ".__('with', ADSHO_TEXT_DOMAIN)." "; echo sprintf(""; echo " ".__('on date', ADSHO_TEXT_DOMAIN)." "; echo sprintf("", ADSHO_OPTIONS_GENERAL, $this->getSetting('checkdate') ); } #================================================= public function callback_resetdb() { echo sprintf(""); } #================================================= private function getPostS($Post) { if (isset($_POST[$Post])) return sanitize_text_field($_POST[$Post]); return ""; } #================================================= private function getPostN($Post) { if (isset($_POST[$Post])) return intval($_POST[$Post]); return 0; } #================================================= public function reset_script() { ?>