Using wp_list_table how to trigger update function "inline"?

Ok, i have used wp_list_table to read data from a custom db table and i like to be able to update the database table by clicking the correspondig cell. Defaults are 0 and when clicked the value is set to 1. so by clicking the cell updateVisitor() will be triggered "inline" my function which i isn't part of the Visitors extend WP_list_table class function updateVisitor($id){ global $wpdb; $query = $wpdb->prepare( "UPDATE tbl_visitor SET visitorPayed =BINARY(visitorPayed=1) WHERE visitorID = %d", intval($id) …
Category: Web

custom_list_table edit/delete bulk actions

so... this is a brand new chapter for me, i've googled for a solution and found loads but nothing working for me unfortunately. function column_title($item){ $actions = array( 'edit' => sprintf('<a href="?page=%s&action=%s&ID=%s">Edit</a>',$_REQUEST['page'],'edit',$item['ID']), 'delete' => sprintf('<a href="?page=%s&action=%s&ID=%s">Delete</a>',$_REQUEST['page'],'delete',$item['ID']), ); return sprintf('%1$s %2$s', $item['ID'], $this->row_actions($actions) ); } above i've added a delete and edit action, and i think i've used the sprintf the proper way but i'm not sure, database table contains the following columns ID, usr_id, date, begin, end, pause, egenb, tot, …
Category: Web

Get the selected posts IDs to use in bulk edit AJAX call

The WordPress codex for bulk_edit_custom_box, along with this bulk edit example use the following piece of JavaScript to create an array of selected post IDs to send with the AJAX call that updates the posts. $bulk_row.find( '#bulk-titles' ).children().each( function() { $post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) ); }); The full code surrounding this snippet is below. My list tables have input fields for meta values, and the inline quick edit works successfully, but bulk edit fails. When …
Category: Web

Using WP_List_Table and search_box(): How to Paginate the Found Search Results When Sending by Method «Post»?

I am using a custom WP_List_Table-Class in order to display a custom table with hotels in the dashboard. I can skip through the pages with the pagination on the top right as expected. The search form is also added with $my_list_table_instance->search_box( 'Search', 'search_id' ); and it is working fine, but only for the first page. Inside the form, I have the two hidden fields for the pagination: // List and form output $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRIPPED ); $paged …
Category: Web

WP_LIST_TABLE bulk action

I created a class extend WP_List_Table and created method for bulk actions like this : function get_bulk_actions() { $actions = array( 'synchronize' => 'Synchronize', 'delete' => 'Delete from Shareino', ); return $actions; } and another method for processing their : function process_bulk_action() { //Detect when a bulk action is being triggered... if ('delete' === $this->current_action()) { wp_die('Items deleted (or they would be if we had items to delete)!'); } } This action's display in a dropbox but when i select …
Category: Web

How to handle my row actions on a custom list table in the admin section

I have set up a plugin that because of the amount of data being used I set up a custom table and have extended the WP_List_Table class. I know that is not recommended, but Custom Post Types just won't offer what I need. I plan on including a copy of the WP_List_Table class when releasing this project to prevent any unwanted bugs... Anyhow, I have the following code and have went through a lot of tutorials on extending the WP_List_Table …
Category: Web

How to Arrange Posts by Size in the WordPress Dashboard?

This may be a lame question, but I can't find an answer to this. Let's say you have a ton of empty posts that you want to delete. Obviously those who have some content will have more size. Is there any option to sort posts by size in WordPress dashboard? Even better, is there any option to automatically prevent posts from beeing published without any content? Through fuctions.php maybe? Would appreciate your help!
Category: Web

Trigger jQuery to add events after AJAX-loading table in admin plugin

I created a small Wordpress plugin which has some admin-panels. I am using the WP_List_Table class to display some data, but this HTML-table is ajax loaded. Because of the ajax-loading, jQuery doesn't add functionality to the table, in particular the toggle functionality in a mobile (responsive) view. The toggle button appears, but clicking it does not show the hidden columns. This is the HTML that is added after the ajax-call: <table class="wp-list-table widefat fixed striped table-view-list "> <thead> <tr> <th …
Category: Web

Fallback media image for featured image not working in admin column

I want to display a fallback image if a custom post type does not have a featured image set and displayed in a custom admin table column. However all that is being output is the image url and not the image from the media library. I have used wp_get_attachment_image_src() to output the image, though I may not be going about it correctly? // fill column header content function cpt_columns_content($column_id, $post_id) { if ($column_id == 'last_modified') { echo get_post_field('post_modified', $post_id); } …
Category: Web

sortable columns for multiple custom post types not working

I have two custom post types named professor and campus. To each of these CPT's I have added two custom admin columns named image and last_modified, which currently display correctly on both CPT's admin tables. I have also filtered each CPT by post_type, however the manage_edit-post_sortable_columns is not displaying the titles as sortable in the admin tables. I thought if I used manage_edit-post_sortable_columns I could target the ones I have conditionally checked for? Am I missing something? Here is the …
Category: Web

wp_create_nonce doesn't verify when using WP_List_Table

I've created an admin page where I'm displaying a list of a MySQL Table using WP_List_Table. In this table I need to be able to delete a record when I want to. And that's where I have a problem. To delete a record I've set up the following code. class Genres_List extends WP_List_Table { [...] public static function delete_genre( $id ) { global $wpdb; $wpdb->delete( "{$wpdb->prefix}genres", [ 'id' => $id ], [ '%d' ] ); } function column_cb( $item ) …
Category: Web

Add custom column to post list table

I have a custom post type called Book and I want to add the publisher and book author custom columns in the edit page. I also want to fetch a specific value from each fields (I created two fields for the above columns) to display in those two additional columns. I actually can display with this code below but the point is I have to declare variable (for example: the $value variable) for each data. So could you please share …
Category: Web

WP_list_table prepare_items()

I create custom WP_list_table with side form like (adding new category form), but when i submit that form wp_list_table doesn't refresh. When I once again refresh page information appears.I use wp_list_table_example plugin everything is the same except for geting example_data and form. class TT_Example_List_Table extends WP_List_Table { function __construct(){ global $status, $page; //Set parent defaults parent::__construct( array( 'singular' => 'movie', //singular name of the listed records 'plural' => 'movies', //plural name of the listed records 'ajax' => false //does this …
Category: Web

WP_List_Table can't create filter link

I create a List table by extending WP_List_Table and showing data from an array. The problem is when searching the URL it adds nonce & _wp_http_referer automatically and a weird structure like that. fin.local/wp-admin/admin.php?page=fin-options&s=273372321&_wpnonce=d11043d6b4&_wp_http_referer=%2Fwp-admin%2Fadmin.php%3Fpage%3Dfin-options&paged=1 Also, there is a column called status. I want to make some filter links for the status value.
Category: Web

specific rows style for in custom list table using WP_List_Table

I am building a custom WordPress plugin where I create a custom list table for entities in a custom database table, extending the WP_List_Table class. Everything works as expected but I want to style each row based on the value of a specific column of the row that is returned from the DB. The iteration of the columns for each row happens inside the column_default() function: /** * Render a column when no column specific method exists. * * @param …
Category: Web

Wp_List_Table is showing as no class found named wp list table

I Developed a plugin I wanted to show data in wordpress table in admn area for which Wp_List_Table clas is used to do that I tried to use this but the problem is that it not being able to properly implement something is wrong I do not know what this is wrong which is causing this error so now let me define what exactly is the problem First let me post the code of my plugin along with file path …
Category: Web

Bulk Action in wp_list_table

I only want to do bulk action on delete function. I have research so many example on google but still cant make it. Will be so much appreciate if someone be able to help me out on this. Below are my codes. When Select and choose delete on drop down and click apply, nothing is happen. public function get_bulk_actions(){ $action = array( "delete" =>"Delete" ); return $action; } public function get_columns(){ $columns = array( "cb"=>"<input type='checkbox'/>", "No"=>"No", "Name"=>"Name", "Email"=>"Email", "Unique_Code"=>"Unique …
Category: Web

wp_list_table search box does not show

I'm using wordpress 3.8 and a custom class derived from WP_List_Table. Why is there no search form? My code in plugin class: function __construct() { register_activation_hook( __FILE__, array( $this, 'swb_plugin_install' ) ); register_deactivation_hook( __FILE__, array( $this, 'swb_plugin_deactivate' ) ); register_uninstall_hook( __FILE__, array( $this, 'swb_plugin_remove' ) ); add_action( 'wp_head', array( $this, 'swb_header' ) ); add_action( 'admin_menu', array( $this, 'swb_admin_page' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'swb_admin_script' ) ); } function swb_admin_resellers() { $list_obj = new SWB_Resellers_List_Table(); if( isset($_POST['s']) ){ $list_obj->prepare_items($_POST['s']); } …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.