admin管理员组

文章数量:1317909

I have own class which extends WP_List_Table class and everything works just fine but bulk actions have some issue. They performs well (delete the row in the table, change state of the item etc.) however while they reloads it feils with following errors and notices:

Notice: Undefined offset: 0 in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/functions.php on line 773
Notice: Undefined offset: 0 in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/functions.php on line 813
Notice: Undefined offset: 0 in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/functions.php on line 818
Notice: Undefined offset: 1 in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/functions.php on line 818
Warning: Cannot modify header information - headers already sent by (output started at /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/formatting.php:5081) in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/pluggable.php on line 1179

I have find out thet it has to do something with $args of page, I tried to figure out what's wrong with my redirect and nothing found:

public function process_bulk_action() {

        //Detect when a bulk action is being triggered...
        if ( 'delete' === $this->current_action() ) {

            // In our file that handles the request, verify the nonce.
            $nonce = esc_attr( $_REQUEST['_wpnonce'] );

            if ( ! wp_verify_nonce( $nonce, 'sp_smazat_objednavku' ) ) {
                die( 'Go get a life script kiddies' );
            }
            else {
                self::smazat_objednavku( absint( $_GET['customer'] ) );

                        // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
                        // add_query_arg() return the current url$
                        wp_redirect( esc_url_raw(add_query_arg()) );                        
                exit;
            }

        }
//[...]
}

Could you see anything? If needed whole code is here:

I have own class which extends WP_List_Table class and everything works just fine but bulk actions have some issue. They performs well (delete the row in the table, change state of the item etc.) however while they reloads it feils with following errors and notices:

Notice: Undefined offset: 0 in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/functions.php on line 773
Notice: Undefined offset: 0 in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/functions.php on line 813
Notice: Undefined offset: 0 in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/functions.php on line 818
Notice: Undefined offset: 1 in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/functions.php on line 818
Warning: Cannot modify header information - headers already sent by (output started at /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/formatting.php:5081) in /home/www/interier-ricany.cz/www/bonus.interier-ricany.cz/wp-includes/pluggable.php on line 1179

I have find out thet it has to do something with $args of page, I tried to figure out what's wrong with my redirect and nothing found:

public function process_bulk_action() {

        //Detect when a bulk action is being triggered...
        if ( 'delete' === $this->current_action() ) {

            // In our file that handles the request, verify the nonce.
            $nonce = esc_attr( $_REQUEST['_wpnonce'] );

            if ( ! wp_verify_nonce( $nonce, 'sp_smazat_objednavku' ) ) {
                die( 'Go get a life script kiddies' );
            }
            else {
                self::smazat_objednavku( absint( $_GET['customer'] ) );

                        // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
                        // add_query_arg() return the current url$
                        wp_redirect( esc_url_raw(add_query_arg()) );                        
                exit;
            }

        }
//[...]
}

Could you see anything? If needed whole code is here: https://pastebin/D5mprA9x

Share Improve this question asked Apr 3, 2017 at 10:53 Karolína VyskočilováKarolína Vyskočilová 4291 gold badge8 silver badges23 bronze badges 3
  • with add_query_arg the first paramater is required : developer.wordpress/reference/functions/add_query_arg – mmm Commented Apr 3, 2017 at 11:09
  • @mmm hm, even if it's empty add_query_arg('') or there is wp_redirect() only, the problem remains – Karolína Vyskočilová Commented Apr 3, 2017 at 11:20
  • was having the same problem, I simply removed the wp_redirect and exit and it worked – Lucas Silva Commented Oct 29, 2020 at 21:32
Add a comment  | 

1 Answer 1

Reset to default 2

with add_query_arg the first paramater is required and it must be an array when it is alone :

add_query_arg([])

more informations here : http://developer.wordpress/reference/functions/add_query_arg

本文标签: wp list tableWPListTable bulk actions notice amp warning