-1

i want to change or remove change all lines in blankstate message which is echoed in below code.

         Protected function render_blank_state() {
        echo '<div class="woocommerce-BlankState">';
     
        echo '<h2 class="woocommerce-BlankState-message">' . esc_html__( 'When you receive a new order, it will appear here.', 'woocommerce' ) . '</h2>';
     //want to delete or change this below
        echo '<div class="woocommerce-BlankState-buttons">';
        echo '<a class="woocommerce-BlankState-cta button-primary button" target="_blank" href="https://docs.woocommerce.com/document/managing-orders/?utm_source=blankslate&utm_medium=product&utm_content=ordersdoc&utm_campaign=woocommerceplugin">' . esc_html__( 'Learn more about orders', 'woocommerce' ) . '</a>';
        echo '</div>';
     
        do_action( 'wc_marketplace_suggestions_orders_empty_state' );
     
        echo '</div>';

 ***CSS display :none; doesn't work***
Amit kumar
  • 1
  • 1
  • 5

1 Answers1

0

Since its echoed there is no way to change it within this code. When I go back a bit I see that the function is called from a function which is called from another function via a hook:

add_action( 'manage_posts_extra_tablenav', array( $this, 'maybe_render_blank_state' ) );

What you can do now is to remove this function from this hook first:

https://developer.wordpress.org/reference/functions/remove_action/

remove_action( 'manage_posts_extra_tablenav', 'maybe_render_blank_state', 999 );

Now you can go ahead and add your own function which does everything included in the below function:

add_action( 'manage_posts_extra_tablenav', 'custom_maybe_render_blank_state' );
function custom_maybe_render_blank_state( $which ) {
    global $post_type;

    // You need to log the post type and maybe add a check here
    if ( $post_type === 'check_list_table_type_here' && 'bottom' === $which ) {
        $counts = (array) wp_count_posts( $post_type );
        unset( $counts['auto-draft'] );
        $count = array_sum( $counts );

        if ( 0 < $count ) {
            return;
        }

//      $this->render_blank_state(); <- skip

        // Do your own code here including the one from render_blank_state() function

        echo '<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .tablenav.bottom .actions, .wrap .subsubsub  { display: none; } #posts-filter .tablenav.bottom { height: auto; } </style>';
    }
}

As I told this is a bit experimental so you need to investigate if this works.

Mr. Jo
  • 4,946
  • 6
  • 41
  • 100