Tuesday, June 28, 2022
HomeWordPress Developmentjavascript - Bulking enhancing now not working in WP 6.0

javascript – Bulking enhancing now not working in WP 6.0


Till lately, I used to be utilizing the next PHP and jQuery code for including bulk enhancing assist for a meta discipline (worth) in a customized put up sort (Guide):

PHP:

perform show_bulk_edit_book_metabox( $column_name, $post_type ) {
    static $print_nonce = true;
    if ( $print_nonce ) {
        $print_nonce = false;
        wp_nonce_field( plugin_basename( __FILE__ ), 'book_edit_nonce' );
    }

    change ( $column_name ) {
        case 'worth':
            ?>
        <fieldset class="inline-edit-col-right inline-edit-book">
            <div class="inline-edit-col column-<?php echo esc_attr( $column_name ); ?>">
                <label class="inline-edit-group">
                    <span class="title"><?php _e( 'Worth', 'my-domain' ); ?></span><enter sort="textual content" identify="worth" />
                </label>
            </div>
        </fieldset>
            <?php
        break;
    }
}
add_action( 'bulk_edit_custom_box', 'show_bulk_edit_book_metabox', 10, 2 );

JQUERY:

( perform( $ ) {
    $( '#bulk_edit' ).on( 'click on', perform() {
        // Outline the majority edit row.
        var $bulk_row = $( '#bulk-edit' );

        // Get the chosen put up ids which can be being edited.
        var $post_ids = new Array();
        $bulk_row.discover( '#bulk-titles' ).kids().every( perform() {
            $post_ids.push( $( this ).attr( 'id' ).substitute( /^(ttle)/i, '' ) );
        });

        // Get the info.
        var $nonce = $bulk_row.discover( 'enter[name="book_edit_nonce"]' ).val();
        var $worth = $bulk_row.discover( 'enter[name="price"]' ).val();

        // Save the info.
        $.ajax({
            url: ajaxurl, // It is a variable that WordPress has already outlined for us.
            sort: 'POST',
            async: false,
            cache: false,
            knowledge: {
                motion: 'save_bulk_edit_book', // That is the identify of our WP AJAX perform that we'll arrange subsequent.
                post_ids: $post_ids, // And these are the parameters we're passing to our perform.
                worth: $worth,
                book_edit_nonce: $nonce
            }
        });
    });

})( jQuery );

Apparently, WP 6.0 has made some accessibility markup adjustments to the majority edit display and the next a part of the code now not works:

$bulk_row.discover( '#bulk-titles' ).kids().every( perform() {
    $post_ids.push( $( this ).attr( 'id' ).substitute( /^(ttle)/i, '' ) );
});

As an alternative of getting the chosen put up IDs, I am getting an empty worth.
Any concept of which adjustments I ought to make to this code to make it work in WP 6.0?

Thanks upfront

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments