Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to update my plugin and have proper feedback, like the WordPress update/upgrade mechanism. How is this effect done?

Essentially I have a script I want to run that has lots of processing, and with each run through the loop, output another line to the screen. Is this done with the output buffer?

share|improve this question
    
Did this solution work for you? –  Brian Fegter Mar 2 '12 at 4:01
    
Thanks, Brian, I looked at flushing the buffer and managed to use the straight PHP functions to get the result I needed. The trick was outputting my feedback in the right spot on the page to have it shown in the middle, where you would expect. –  MechEngineer Mar 16 '12 at 14:43
add comment

1 Answer 1

up vote 2 down vote accepted

Yes, WordPress uses output buffering for displaying these messages. There's a nifty function you can use within your loop called show_message() which utilizes wp_ob_end_flush_all();

function show_message($message) {
    if ( is_wp_error($message) ){
        if ( $message->get_error_data() )
            $message = $message->get_error_message() . ': ' . $message->get_error_data();
        else
            $message = $message->get_error_message();
    }
    echo "<p>$message</p>\n";
    wp_ob_end_flush_all();
    flush();
}

You might wish to abstract this to your own function as there is a feature in the queue to migrate this to a method within WP_Error. It's possible this function will become deprecated in the future.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.