Git Product home page Git Product logo

wp_list_table-class-plugin-example's Introduction

WP_List_Table-Class-Plugin-Example

A plugin demonstration on how to use WordPress WP_List_Table Class

Database SQL dump

CREATE TABLE IF NOT EXISTS `wp_customers` (
`ID` int(11) NOT NULL,
  `name` varchar(20) NOT NULL,
  `address` varchar(30) NOT NULL,
  `city` varchar(10) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;

INSERT INTO `wp_customers` (`ID`, `name`, `address`, `city`) VALUES
(1, 'Alfreds Futterkiste ', 'Obere Str. 57', 'Berlin'),
(2, 'Ana Trujillo ', 'Avda. de la Constitución 2222', 'México D.F'),
(3, 'Antonio Moreno', 'Mataderos 2312', 'México D.F'),
(4, 'Thomas Hardy ', '120 Hanover Sq.', 'London'),
(5, 'Christina Berglund ', 'Berguvsvägen 8 ', 'Lulea'),
(9, 'Hanna Moos', 'Forsterstr. 57', 'Mannheim'),
(10, 'Frédérique Citeaux', '24, place Kléber', 'Strasbourg'),
(11, 'Martín Sommer', 'C/ Araquil, 67', 'Madrid'),
(12, 'Laurence Lebihans', '12, rue des Bouchers', 'Marseille');

ALTER TABLE `wp_customers` ADD PRIMARY KEY (`ID`);
 
ALTER TABLE `wp_customers` MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;

Security

You should whitelist the orderby parameter your plugin / theme accept to avoid any form of sql injection. See #2

wp_list_table-class-plugin-example's People

Contributors

lovor01 avatar w3guy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wp_list_table-class-plugin-example's Issues

esc_sql() doesn't work on column names

Hey,

$sql .= ' ORDER BY ' . esc_sql( $_REQUEST['orderby'] ); $sql .= ! empty( $_REQUEST['order'] ) ? ' ' . esc_sql( $_REQUEST['order'] ) : ' ASC';

I think this is vulnerable to SQL injection via the method outlined here: [http://josephkeeler.com/2009/05/php-security-sql-injection-in-order-by/]

The problem is esc_sql() doesn't work when the user input isn't going between single-quotes. Like with column names.

It's super-unlikely this code would be exposed in a way that would allow it to be exploited, but it's worth noting, and perhaps adding a whitelist array of accepted values for orderby and order.

"Headers already sent" warning

I've been playing around with your great tutorial and I ran into the "headers already sent" warning while trying to delete an item. This also happens while using the bulk delete actions.

This is caused by the wp_redirect inside process_bulk_action.

May I ask you what were you trying to acomplish with wp_redirect(esc_url(add_query_arg())); exit;?
Without these lines of code the delete operations work just fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.