A
A
Alexey Nikolaev2015-02-11 02:50:02
CMS
Alexey Nikolaev, 2015-02-11 02:50:02

How to add a "Select All" checkbox to the admin area of ​​your Wordpress plugin?

Hello!
In WP, as in all CMS, it is possible to select all records in the table by highlighting the checkbox. In the code of one of the plugins, it looks like this:

<th scope="col" class="manage-column column-cb check-column">
      <input type="checkbox" />
</th>

The checkbox next to each of the lines looks like this:
<td>
      <input class="icl_st_row_cb" type="checkbox" value="<?php echo $string_id ?>" />
</td>

The string_id variable is a unique string ID.
Everything works in this plugin. I did the same in mine - but I couldn’t get it to work (when you click on the checkbox, the rest of the checkboxes are not highlighted). How to implement it? I'm missing something, but I don't know what yet. How does this functionality work in WP? I don't want to make my own bikes.
PS A viable option is implemented WITHOUT using classes like WP_List_Tables, so that's clearly not the point.
I would be grateful for advice, references to articles, etc.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sydorenko, 2015-02-11
@San40

More than 100% sure that such functionality is implemented by more than one php. It was not without
a piece of js like this stackoverflow.com/questions/2228382/select-all-che....
In order for you to implement support for your js script in the admin part of WordPress, you should read this codex.wordpress.org/Plugin_API/Action_Reference/ad...
The idea is this:
1. Create an input type=checkbox in the form (as it already is) , give it a unique id (useful in step 2)
2. Create a js file for the administrative part of your plugin
3. Write in this script a code similar to the one in my first link, only for the id of your checkbox
4. Include this js file for the admin part of your plugin using the knowledge from my second link
...
5 ???

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question