I’m creating a WordPress plugin the place the objective/ motion is to govern knowledge within the wp_usermeta desk, by extending the WP_List_Table class, and utilizing it within the WPPB.me boilerplate. I’ve been in a position to get my desk to work exterior of the boilerplate, for instance, if I simply put my motion features in the identical “wp-list-table-example-page.php”, after the code for the prolonged class itself. However, I need to use the boilerplate the place the _REQUEST’s could be despatched to separate pages within the ./partials folder (assuming that’s the proper approach). I’ve each row and bulk actions included by extending the WP_List_Table class. I’m caught on getting the actions to operate correctly; to load the customized ./partials pages I created within the boilerplate to carry out the requested actions when both a row is clicked, or the majority motion drop down is used with checkboxes in a desk column.
Right here’s what I’m working with within the file:
./wp-content/plugins/zapper/contains/class-zapper-list-table.php:
<?php
if(!outlined('PLUGIN_TEXT_DOMAIN')){
outline('PLUGIN_TEXT_DOMAIN', 'zapper');
}
if(!class_exists('WP_List_Table')){
require_once( ABSPATH . 'wp-admin/contains/display.php' );
require_once( ABSPATH . 'wp-admin/contains/class-wp-list-table.php' );
}
class Zapper_List_Table extends WP_List_Table
{
/* different prolonged WP_List_Table stuff withheld */
operate get_bulk_actions()
{
$actions = array(
'view_all' => __('View Multi', 'PLUGIN_TEXT_DOMAIN'),
'edit_all' => __('Edit Multi', 'PLUGIN_TEXT_DOMAIN')
);
return $actions;
}
public operate handle_table_actions() {
// verify for row actions
$the_table_action = $this->current_action();
if ( 'view_meta' === $the_table_action ) {
$nonce = wp_unslash( $_REQUEST['_wpnonce'] );
// confirm the nonce.
if ( ! wp_verify_nonce( $nonce, 'view_meta_nonce' ) ) {
$this->invalid_nonce_redirect();
}
else {
$this->page_view_meta( absint( $_REQUEST['user_id']) );
$this->graceful_exit();
}
}
if ( 'add_meta' === $the_table_action ) {
$nonce = wp_unslash( $_REQUEST['_wpnonce'] );
// confirm the nonce.
if ( ! wp_verify_nonce( $nonce, 'add_meta_nonce' ) ) {
$this->invalid_nonce_redirect();
}
else {
$this->page_add_meta( absint( $_REQUEST['user_id']) );
$this->graceful_exit();
}
}
// verify for bulk actions
if ( ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'bulk-edit' ) || ( isset( $_REQUEST['action2'] ) && $_REQUEST['action2'] === 'bulk-edit' ) ) {
$nonce = wp_unslash( $_REQUEST['_wpnonce'] );
// confirm the nonce.
if ( ! wp_verify_nonce( $nonce, 'bulk-users' ) ) {
$this->invalid_nonce_redirect();
}
else {
$this->page_bulk_edit( $_REQUEST['users']);
$this->graceful_exit();
}
}
}
public operate page_view_meta( $user_id ) {
$person = get_user_by( 'id', $user_id );
include_once( 'admin/partials/zapper-view-meta.php' );
var_dump($this->current_action);
}
public operate page_edit_meta( $user_id ) {
$person = get_user_by( 'id', $user_id );
include_once( 'admin/partials/zapper-edit-meta.php' );
}
public operate page_bulk_edit( $bulk_user_ids ) {
include_once( 'admin/partials/zapper-bulk-edit.php' );
}
}
?>
The end result when clicking a row motion is mainly nothing, it simply refreshes the web page. Utilizing the dropdown for a bulk motion– whereas no error is thrown by WP– it directs to a clean web page, with the next within the URL parameters:
?_wpnonce=183ef79f5e
&_wp_http_referer=/zapper/wp-admin/admin.php
?web page=zapper-table
&motion=edit_all
&paged=1
&factor[]=9
&factor[]=4
&factor[]=11
&action2=edit_all
In my earlier, profitable assessments, I don’t have the &_wp_http_referer or &paged=1 and I don’t perceive why it’s there on this trial. And that’s solely on a bulk motion request. Clearly I am doing one thing incorrect, as I’ve acquired two “?” within the URL params.
What have I’ve performed incorrect?
Thanks!