[wp-hackers] SSL for a single page

Otto otto at ottodestruct.com
Thu Oct 16 20:34:30 GMT 2008


On Thu, Oct 16, 2008 at 1:43 PM, Rich Pedley <elflop at googlemail.com> wrote:
> So rather than have the link be something like this:
> https://ssl.sharedserver.co.uk/~elfden/wp-content/plugins/eshop/googlecheckout.php
> i.e. not directly via wordpress - where I would have to try and
> include WP scripts correctly
> I would prefer the url to be something like:
> https://ssl.sharedserver.co.uk/~elfden/googlecheckout/
> ie via the wordpress installation
>
> I may also end up adding  a variable like ?checkoutgoogle to the url as well.
>
> So far as I am aware this isn't currently possible.

Sure it is. Add a query variable, then hook to template_redirect with
a priority 1.

add_filter('query_vars', 'add_my_var');
function add_my_var($public_query_vars) {
	$public_query_vars[] = 'googlecheckoutnotification';
	return $public_query_vars;
}

Now, you need to check for that identifier and act on it:

add_action('template_redirect', 'my_var_output', 1);
function my_var_output() {
	$myvalue=get_query_var('googlecheckoutnotification');
	if ($myvalue) {
		// do whatever you like here
		// WordPress is loaded up fully at this point
		// you can even use $myvalue to see what the request is for

		exit; // this stops WordPress dead in its tracks, no further
processing is done
	}
}

When you hit https://whatever/yourblog?googlecheckoutnotification=1,
then your plugin takes over, does whatever, and then stops WordPress
before anything happens like a redirect or something.


More information about the wp-hackers mailing list