Create a clickable name in WP_List_Table for Plugin Admin

I've been developing a plugin where I wanted to create a table, styled and working just like Wordpress's native Post/Page tables.

Following the guide below, I was able to create the table and load my database. The only thing I cannot figure out to do is how to make one of the row contents "clickable".

http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/

IE - making the "name" column clickable. I have the "edit, delete" buttons below the name, but that is not enough.

Any and all advice would be greatly appreciated. I looked at another plugin to see how they did this, and it looked like they broke the table apart and hardcoded the html for the table. I hope I don't have to do this.

EDIT:

The name of the post, Hello world!, as you can see, is a link / clickable.

SOLUTION

to make this work, I had to remove my custom column functions, which included my row actions. Turns out, you can simply call the row actions div! Here is the function that helped me, thanks to the Milo.

function single_row_columns($item) {
       list($columns, $hidden) = $this-get_column_info();
            foreach ($columns as $column_name = $column_display_name) {
                   $class = "class='$column_name column-$column_name'";

                   $style = '';
                   if (in_array($column_name, $hidden))
                         $style = ' style="display:none;"';

                   $attributes = "$class$style";

                   if ('cb' == $column_name) {
                   echo  "td $attributes";
                   echo 'input type="checkbox" name="id[]" value="%s" /', $item['ID'];
                   echo "/td";
                        }
               elseif ('galname' == $column_name) {
               echo "td $attributes";
               echo 'a href="#"', $item['galname'];
               echo "/a";

                   echo "div class='row-actions'span class='edit'";
           echo sprintf('a href="?page=%saction=%sgid=%s"Edit/a',$_REQUEST['page'],'edit',$item['id']);
                   echo "/span | span class='trash'";
           echo sprintf('a href="?page=%saction=%sgid=%s"Delete/a',$_REQUEST['page'],'delete',$item['id']);
           echo "/span/div/td";
                                                    }
            else {
                echo "td $attributes";
                echo $this-column_default( $item, $column_name );
                echo "/td";
            } } } 

Thanks so much! Jacob

Topic row-actions wp-list-table plugin-development wp-admin Wordpress

Category Web


The WP_List_Table class ultimately uses the single_row_columns method to output each table cell. If we look at that method, we'll see this part:

...
elseif ( method_exists( $this, 'column_' . $column_name ) ) {
    echo "<td $attributes>";
    echo call_user_func( array( &$this, 'column_' . $column_name ), $item );
    echo "</td>";
}
...

Add a method to your class for the column you want to add additional functionality / formatting to and name it 'column_' . $column_name, then output any additional markup you need wrapping the item content.


If you mean the "Quick Edit" feature of the posts and comments tables: I'm working on a tutorial for this feature but it will take some time to find an easy understandable solution. As you might have guessed it's a mixture of PHP, jQuery and Ajax.

I've searched the Net for any hints on how to implement the feature but the only available example is the source of the WordPress core.

About

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