[wp-hackers] wp_redirect() fails on Linux
AJ Chen
canovaj at gmail.com
Wed Aug 23 06:28:15 GMT 2006
add_action('admin_menu', 'w2x_add_pages');
function w2x_add_pages() {
// Add submenu under Write:
add_submenu_page('post.php', 'Write Project Post', '[project]', 8,
'prj', 'w2x_show_prj_post');
}
function w2x_show_prj_post() {
wp_redirect(get_settings('siteurl') . "/wp-admin/post.php?w2x=prj");
}
wp_redirect() is called from the function for a new submenu item under Write
menu. Is there any potential problem for such use of wp_redirect()?
The above approach may not be the best one. Any better idea for launching
the post editor from the newly added submenu [project]?
The submenu item [project] is actually a link similar to "Write Post"
submenu item, as seen in html source:
<li><a href='http://localhost/publish/wp-admin/post.php'>Write Post</a></li>
<li><a href='http://localhost/publish/wp-admin/page-new.php'>Write
Page</a></li>
<li><a href='http://localhost/publish/wp-admin/post.php?page=prj'
class="current">[project]</a></li>
This means clicking on [project] should launch post editor
without a need to call wp_redirect(), but it does not. Is this a bug?
thanks,
AJ
On 8/22/06, Mark Jaquith <mark.wordpress at txfx.net> wrote:
>
> On Aug 23, 2006, at 1:39 AM, AJ Chen wrote:
>
> > There must be something printed before header() is called when
> > wordpress is
> > running on Linux. Has anybody seen this before? Any idea what
> > might be
> > printed before line 272 header() is executed? It could be a bug.
>
> What hook is your plugin using when it calls wp_redirect() ? You
> should be able to safely use the "init" hook, or "plugins_loaded"
>
> If you're hooking in with the "wp_head" hook, or any template-level
> hook, that'd cause the problem you're seeing.
>
> --
> Mark Jaquith
> http://txfx.net/
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list