[wp-hackers] wp_redirect extremly slow
Andrew Nacin
wp at andrewnacin.com
Wed Jan 12 22:52:21 UTC 2011
On Wed, Jan 12, 2011 at 5:48 PM, 24/7 <24-7 at gmx.net> wrote:
> Hi,
>
> i work with my own little framework and got some sort of small setup
> procedure. Therefore i question if the setup process is already done
> or if there should be a redirect to the setup page. My problem is,
> that the redirect via wp_redirect often ends up needing 30sec.+ Has
> someone any explanation for this?
>
> <?php
> // Note: Just example code. Typing errors happened in here
>
> class myInit() {
> function __construct() {
> if ( empty($setup) ) {
> // do stuff
> }
> else {
> add_action( 'init', array(&$this, 'redirect'), 0);
> }
>
> public static function redirect() {
> wp_redirect( get_bloginfo('url').'/wp-admin/admin.php?
> page=setup.php', 301 );
> }
> }
> }
>
You need to always call exit; or die; after wp_redirect(). Otherwise, the
script continues and headers may not be sent.
More information about the wp-hackers
mailing list