prefix."fare"; $wpdb->query($wpdb->prepare("UPDATE $table_name SET mile=%s,stop=%s,seat=%s,minute=%s,diskmmile=%d,curr=%s,color=%s WHERE fare_id=%d",$mile,$stop,$seat,$minute,$diskmmile,$curr,$bcolor,1)); } if (($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['addcar']) ) { $cartype=sanitize_text_field($_POST['cartype']); $carfare=sanitize_text_field($_POST['carfare']); $carfare=filter_var( $carfare, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $table_name = $wpdb->prefix."cartypes"; $wpdb->query($wpdb->prepare("INSERT INTO $table_name(name,fare) VALUES(%s,%s)",array($cartype,$carfare))); } class asi_plugin_admin { /** verbingo_plugin father class */ private $asi_settings_key = 'asi_setting'; private $addcar_settings_key = 'asi_addcar'; private $plugin_options_key = 'asi_options'; private $plugin_settings_tabs = array(); private $localleft = 'left'; function __construct() { add_action( 'init', array( &$this, 'asi_scripts_admin')); add_action( 'init', array( &$this, 'load_settings')); add_action( 'admin_init', array( &$this, 'register_asi_fare_settings' )); add_action( 'admin_init', array( &$this, 'register_addcar_settings' )); add_action( 'admin_init', array( &$this, 'Get_selected_car' )); add_action( 'admin_init', array( &$this, 'Get_selected_fare' )); add_action( 'admin_menu', array( &$this, 'add_admin_menus' )); } function Get_selected_car() { global $wpdb; $table_name = $wpdb->prefix."cartypes"; $cartypes = $wpdb->get_results("SELECT * FROM $table_name",ARRAY_A); return $cartypes; } function Get_selected_fare() { global $wpdb; $table_name = $wpdb->prefix."fare"; $fares = $wpdb->get_results("SELECT * FROM $table_name",ARRAY_A); return $fares; } /** UTILITY FUNCTIONS * */ private function sections($head, $text = '') { echo '

' . $head . '

'; echo '
'; if ($text) echo '

' . $text . '

'; } private function sectiontop() { echo '
'; } private function header($head) { echo '

'.$head.'

'; } function asi_scripts_admin() { $google_map_api = 'https://maps.google.com/maps/api/js?sensor=true&libraries=places&language=en-AU'; wp_enqueue_script('google-places', $google_map_api); wp_register_style('asi_style', plugins_url('css/asi_style.css',__FILE__)); wp_enqueue_style('asi_style'); wp_register_script('asi_script', plugins_url('js/asi_script.js', __FILE__ ),array('jquery')); wp_enqueue_script('asi_script'); } // Load Settings function load_settings() { $this->general_settings = (array) get_option( $this->asi_settings_key ); $this->advanced_settings = (array) get_option( $this->addcar_settings_key ); // Merge with defaults $this->general_settings = array_merge( array( 'general_option' => 'General value' ), $this->general_settings ); $this->advanced_settings = array_merge( array( 'advanced_option' => 'Advanced value' ), $this->advanced_settings ); } // Register Language Tab Setting function register_asi_fare_settings() { $this->plugin_settings_tabs[$this->asi_settings_key] = 'Settings'; register_setting( $this->asi_settings_key, $this->asi_settings_key ); add_settings_section( 'section_fare', '', array( &$this, 'section_asi_fare_desc' ), $this->asi_settings_key ); } // Call Language Setting Page function section_asi_fare_desc() { $fares=$this->Get_selected_fare(); if($fares[0]['diskmmile']==0){ $kmselected="";$milesselected="selected";}else{$milesselected="";$kmselected="selected";} $selectdistance=''; $this->sections(__('Fare Settings','asi')); echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
Fare per mile
Fare per stop
Fare per seat
Fare per minute
Type of distance'.$selectdistance.'
Currency Type
Background color
'; echo '
'; $this->sectiontop(); } // Register Advance Settings function register_addcar_settings() { $this->plugin_settings_tabs[$this->addcar_settings_key] = 'Car Type'; register_setting( $this->addcar_settings_key, $this->addcar_settings_key ); add_settings_section( 'section_addcar', 'Add Car Type', array( &$this, 'section_addcar_desc' ), $this->addcar_settings_key ); } function section_addcar_desc() { $cartypes=$this->Get_selected_car(); echo '
'; $i=1; echo ''; foreach($cartypes as $car) { echo ''; $i++; } echo '
S.NoCar TypeCar FeeAction
'.$i.''.$car['name'].''.$car['fare'].'
'; echo ''; echo ''; echo ''; echo '
Car Type
Car Fee
'; } // Add Menu Here function add_admin_menus() { add_menu_page('asi_dashboard', 'Fare Calculator', 'manage_options', $this->plugin_options_key, array( &$this, 'plugin_options_page' ),''.plugins_url("img/", __FILE__).'asiimg.png'); } function plugin_options_page() { $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->asi_settings_key; ?>
plugin_options_tabs(); ?>
asi_settings_key; $scren=screen_icon(); echo ''; } } add_action( 'plugins_loaded', create_function( '', '$asi_admin_side = new asi_plugin_admin;' ) ); ?>