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; ?>
'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(){ ?>