debabratsharma
Forum Replies Created
-
I tried using wp list table but datas are not getting displayed from my custom table.
<?php
if ( ! class_exists( ‘WP_List_Table’ ) ) {
require_once( ABSPATH . ‘wp-admin/includes/class-wp-list-table.php’ );
}
class Customers_List extends WP_List_Table {/** Class constructor */
public function __construct() {parent::__construct( [
‘singular’ => __( ‘Course’, ‘sp’ ), //singular name of the listed records
‘plural’ => __( ‘Courses’, ‘sp’ ), //plural name of the listed records
‘ajax’ => false //should this table support ajax?] );
}
public static function get_customers( $per_page = 5, $page_number = 1 ) {
global $wpdb;
$sql = “SELECT * FROM wp_course”;
if ( ! empty( $_REQUEST[‘orderby’] ) ) {
$sql .= ‘ ORDER BY ‘ . esc_sql( $_REQUEST[‘orderby’] );
$sql .= ! empty( $_REQUEST[‘order’] ) ? ‘ ‘ . esc_sql( $_REQUEST[‘order’] ) : ‘ ASC’;
}$sql .= ” LIMIT $per_page”;
$sql .= ‘ OFFSET ‘ . ( $page_number – 1 ) * $per_page;
$result = $wpdb->get_results( $sql, ‘ARRAY_A’ );
return $result;
}public static function delete_customer( $id ) {
global $wpdb;$wpdb->delete(
“wp_course”,
[ ‘ID’ => $id ],
[ ‘%d’ ]
);
}
public static function record_count() {
global $wpdb;$sql = “SELECT COUNT(*) FROM wp_course”;
return $wpdb->get_var( $sql );
}public function no_items() {
_e( ‘No courses avaliable.’, ‘sp’ );
}function column_name( $item ) {
// create a nonce
$delete_nonce = wp_create_nonce( ‘sp_delete_customer’ );$title = ‘‘ . $item[‘name’] . ‘‘;
$actions = [
‘delete’ => sprintf( ‘Delete‘, esc_attr( $_REQUEST[‘page’] ), ‘delete’, absint( $item[‘ID’] ), $delete_nonce )
];return $title . $this->row_actions( $actions );
}public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case ‘courseName’:
case ‘fees’:
return $item[ $column_name ];
default:
return print_r( $item, true ); //Show the whole array for troubleshooting purposes
}
}function column_cb( $item ) {
return sprintf(
‘<input type=”checkbox” name=”bulk-delete[]” value=”%s” />’, $item[‘ID’]
);
}function get_columns() {
$columns = [
‘cb’ => ‘<input type=”checkbox” />’,
‘courseName’ => __( ‘Course Name’, ‘sp’ ),
‘fees’ => __( ‘Fees’, ‘sp’ ),
‘duration’ => __( ‘Duration’, ‘sp’ )
];return $columns;
}public function get_sortable_columns() {
$sortable_columns = array(
‘courseName’ => array( ‘name’, true ),
‘fees’ => array( ‘city’, false )
);return $sortable_columns;
}public function get_bulk_actions() {
$actions = [
‘bulk-delete’ => ‘Delete’
];return $actions;
}public function prepare_items() {
$this->_column_headers = $this->get_column_info();
/** Process bulk action */
$this->process_bulk_action();$per_page = $this->get_items_per_page( ‘customers_per_page’, 5 );
$current_page = $this->get_pagenum();
$total_items = self::record_count();$this->set_pagination_args( [
‘total_items’ => $total_items, //WE have to calculate the total number of items
‘per_page’ => $per_page //WE have to determine how many items to show on a page
] );$this->items = self::get_customers( $per_page, $current_page );
}public function process_bulk_action() {
//Detect when a bulk action is being triggered…
if ( ‘delete’ === $this->current_action() ) {// In our file that handles the request, verify the nonce.
$nonce = esc_attr( $_REQUEST[‘_wpnonce’] );if ( ! wp_verify_nonce( $nonce, ‘sp_delete_customer’ ) ) {
die( ‘Go get a life script kiddies’ );
}
else {
self::delete_customer( absint( $_GET[‘customer’] ) );wp_redirect( esc_url( add_query_arg() ) );
exit;
}}
// If the delete bulk action is triggered
if ( ( isset( $_POST[‘action’] ) && $_POST[‘action’] == ‘bulk-delete’ )
|| ( isset( $_POST[‘action2’] ) && $_POST[‘action2’] == ‘bulk-delete’ )
) {$delete_ids = esc_sql( $_POST[‘bulk-delete’] );
// loop over the array of record IDs and delete them
foreach ( $delete_ids as $id ) {
self::delete_customer( $id );}
wp_redirect( esc_url( add_query_arg() ) );
exit;
}
}}
?>
This the class file that I created. After that on functions.php i used this–
require_once ‘courses_display.php’;
//Prepare Table of elements
$wp_list_table = new Customers_List();
$wp_list_table->prepare_items();
$wp_list_table->display();Forum: Plugins
In reply to: [Fedex WooCommerce Shipping Method Plugin] Multiple shipper codeWhich free addon should i use with the plus version?
Forum: Plugins
In reply to: [Fedex WooCommerce Shipping Method Plugin] Multiple shipper codeok..Thanks for the info..
Forum: Plugins
In reply to: [Fedex WooCommerce Shipping Method Plugin] shipping ChargeOk if I have the premium version of the plugin then i can adjust the price
Actually sometimes I would like to remove the shipping charge for customer so that they can avail shipping free of cost. How can I achieve it?
ok…Can please tell me how can i remove the shipping charge for fedex ?
Actually i have two credentials , one for domestic & other for international from fedex. Which one should i use?
What shipping option should i use?
I am unable to find fedex as one of the method in shipping method? What can be the error?Shipping cost will be beared from customer?
yes, I now have entered 400066 as pincode. But I am unclear little bit. What does origin postal code mean? What do i need to do for domestic and international ?
This query works only for simple product, it doesn’t work for variable products. Please help me in this regard. I need to display all my variable and simple products that are marked for pre-order.
Forum: Plugins
In reply to: [Advanced AJAX Product Filters] Paid Plugin Enquiryi don’t have it live
Forum: Plugins
In reply to: [BP Simple Private] Admin area brokeni am using this BP Registration Options plugin which does the same work like your plugin i guess….although i m looking now for removing the toolbar and menu for all users except admin…..can you help me on that??
Forum: Reviews
In reply to: [Indic IME] AssameseIn the plugin page it is written that assamese language is supported but i couldn’t find it so please help me in this regard
Forum: Themes and Templates
In reply to: [MesoColumn] site optimizationhow can i do that?
Forum: Themes and Templates
In reply to: [MesoColumn] site optimizationI want to make my site in another language too….How can i do that??
Forum: Themes and Templates
In reply to: [MesoColumn] page source codecan i display an image outside the container to the right or left side?