Re: [PHP] Wordpress Theme Switcher plugin redirect modification



On Mon, July 30, 2007 4:48 am, Erik Gyepes wrote:
I would like to modify the Theme Switcher Plugin for Wordpress
(http://dev.wp-plugins.org/wiki/ThemeSwitcher). When I currently
request
the page to switch the theme (for example:
mydomain.com/?wptheme=My+Theme) I'm redirected to the index.php, but
instead I would like to redirect back to the page where I was before
(for example: mydomain.com/?p=15)

Here is the code which is redirecting the page:

function ts_set_theme_cookie() { $expire = time
<http://www.php.net/time>() + 30000000; if (!empty
<http://www.php.net/empty>($_GET["wptheme"])) { setcookie
<http://www.php.net/setcookie>("wptheme" . COOKIEHASH,
stripslashes
<http://www.php.net/stripslashes>($_GET["wptheme"]),
$expire, COOKIEPATH
); $redirect = get_settings('home').'/';
if
(function_exists <http://www.php.net/function_exists>('wp_redirect'))
wp_redirect($redirect); else header
<http://www.php.net/header>("Location: ". $redirect); exit
<http://www.php.net/exit>; } }

I don't know what added all those links, but it made this pretty
unreadable...

That said, the call to stripslashes is a dead giveaway that something
is very messed up in the code indeed...

This is awfully WordPress specific...

I've tried to change the $redirect variable to $_SERVER['REQUEST_URI']
but it doesn't worked.

REQUEST_URI is the page you are on right now.

Re-directing there is pretty much an infinite loop.

Then I realized that I should save the current
page URL in the cookies, so I've set a cookie and then I tried
redirect
the page to the URL in that cookie. It worked, but not as intended,
there are some situations when it is redirecting in a loop.

Put it in $_SESSION maybe, but not a Cookie.

Any recommendations how to do it properly?

Rewrite WordPress from scratch? :-v

Ask the WordPress guys is probably the real answer.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
.



Relevant Pages

  • RE: A little problem with Forms authentication :-(
    ... I'm using forms authentication and the user is getting authenticated no ... should be redirected to the login page. ... I've set the time out for the cookie to the test value of 1 ... redirect from login bit because as I understand it, ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Forms Authentication - Sudden Redirect Failure on Login
    ... HttpCookie cookie = new HttpCookie ... Yields the problem on ALL platforms, the redirect does not happen. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: why browser cache setting affects program behavior? Fix?
    ... if you use server.treansfer, you don't need a cookie, get the data you ... > post xml data, and then redirects the request to an appropriate page. ... > successful redirect to another page on the servers. ... Otherwise if the cache setting is set to check for every ...
    (microsoft.public.dotnet.framework.aspnet)
  • javascript cookie redirect (with various options) - help needed
    ... I'm a bit stuck with this redirect and javascript in general. ... They choose their city, a pop up asks them if they want their browser ... If they opted for their choice to be remembered (ie/ a cookie to be ... set) then they would never see the list of cities again (or until the ...
    (comp.lang.javascript)
  • Re: What is it called ???
    ... But the point is its cool its gonna redirect you if you type the adress i ... But if you click on the button "Forum" it should redirect you ... browser to the main page, but if you push the forum button on the main page ... fall-back method (or only a cookie, ...
    (alt.php)