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 class, but have hit a wall.

function column_name( $item ) {
  $title = 'strong' . $item['projectName'] . '/strong';

  $actions = [
    'edit'    = sprintf( 'a href="?page=%saction=%sproject=%s"Edit/a',
      $_REQUEST['page'], 'edit', $item['projectID'] ),
    'delete'  = sprintf( 'a href="?page=%saction=%sproject=%s"Delete/a',
      $_REQUEST['page'], 'delete', $item['projectID'] )
  ];

  return $title . $this-row_actions( $actions );
}

When I click edit, all that happens is a url change. I am not sure how to actually generate a form/admin page to edit/update a project when the edit button is clicked. I am also getting a redirection error when "delete" is clicked, which I plan on getting to later. I assume for delete I just need to make sure I have the proper SQL statement to remove the project from the database.

Thank you in advance for your help.

Topic row-actions wp-list-table Wordpress sql

Category Web


Apparently the right way to do this is to get the suffix returned by your custom page that normally displays the table and use it to hook into the page load before any admin content is rendered.

add_action('admin_menu', function() {
    $page_hook_suffix = add_submenu_page( # or related function
        …
        function() {
            # content of table page
        }
    );
    if ($page_hook_suffix) {
        add_action("load-$page_hook_suffix", function() {
           # verify nonces, handle actions, redirect, etc.
        });
    }
});

About

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