Custom Fields
Re-Envisioned
Support MB Custom Table Custom Model needs additional hooks please

  • Creator
    Topic
  • #31092
    wgstjf
    Participant

    Hi guys,

    We're loving the new Custom Model capability, a huge leap forwards for WP!

    I appreciate that this is a very new feature for MB Custom Table but in trying to use it for the first time on a new client project we are coming up against some significant limitations. All the basic functionality is there but when you want to add content using standard WP hooks we find they don't exist (or at least not in a way we can find out).

    Please could you add the following capabilities to the ListTable class for Custom Table?

    1. extra_tablenav - So we can add custom filters for the table. Possibly as follows...

    
    /**
     * @param string $which
     */
    protected function extra_tablenav( $which ) {
        ?>
        <div class="alignleft actions">
        <?php
        if ( 'top' === $which ) {
            ob_start();
            do_action( 'restrict_manage_posts', $this->model->name, $which );
            $output = ob_get_clean();
    
            if ( ! empty( $output ) ) {
                echo $output;
                submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
            }
        }
        ?>
        </div>
    <?php
    }
    

    2. list_table_primary_column - So we can define a primary column for the table (that contains the row actions) to replace the currently hard-coded id column.

    3. Row Actions - So we can hook into and add/edit/delete row actions for custom functionality.

    4. In a perfect world... - We'd love to be able to hook into (and modify) the html created for the each of the table headers as we would like to be able to create an individual column search capability.

    In short, please can you add in the List table hooks that we are used to being able to use for a standard CPT.

    Thanks in advance guys.

    All the best,

    Will

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #31094
    wgstjf
    Participant

    Sorry, I know I bombarding you...

    Could you also add in some form of confirmation before items are deleted?

    A modification of the list-table.js to something like this would be perfect.

    
    // Delete an item.
    $( document ).on( 'click', '.row-actions .delete a', function( e ) {
        e.preventDefault();
        if (confirm('Are you sure you want to delete this item?  This action cannot be undone.')) { // Add this in
            const $this = $( this );
    
            $.post( ajaxurl, {
                action: 'mbct_delete_items',
                ids: [ parseInt( $this.data( 'id' ), 10 ) ],
                model: $( 'input[name="model"]' ).val(),
                _ajax_nonce: MbctListTable.nonceDelete,
            }, response => {
                if ( response.success ) {
                    $this.closest( 'tr' ).css( 'background', '#ff8383' ).hide( 'slow', function() {
                        $( this ).remove();
                    } );
                } else {
                    alert( response.data );
                }
            } );
        }
    } );
    
    #31103
    Long Nguyen
    Moderator

    Hi,

    Thanks for your suggestion.

    I will forward these to the development team to consider adding them to the plugin in future updates.

    #31107
    wgstjf
    Participant

    Thanks as always Long. Here's hoping they make it into the next release 🙂

    #31163
    wgstjf
    Participant

    One more request for the dev team if you can face it... 🙂

    It would be great to be able to target the various MB Custom Table admin views in CSS. Currently each screen in the admin area has the same body classes. In standard WordPress CPTs you can target classes such as 'edit-php' or 'post-php' to differentiate between a List Table view, or an Add or Edit one.

    Thanks in advance,

    Will

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.