[wp-hackers] 2 Questions: $_REQUEST equivalent and using GET
in mod_rewrite
Alex Günsche
ag.ml2007 at zirona.com
Tue Aug 28 16:43:14 GMT 2007
On Tue, 2007-08-28 at 16:01 +0100, Alex Andrews wrote:
> I have developed the plugin so far as an external PHP application,
> albeit one that require(s) all the appropriate Wordpress includes. Now
> I wish to intergrate it into Wordpress. At the moment, I use $_REQUEST
> to parse user input and return things. Looking at the Codex, it seems
> that Wordpress has a more advanced way of doing this that santises the
> data. Can someone walk me through it?
Absolutely. When you create a plugin, you will have to use the API hooks
and filters of WordPress. You also don't need to require() anything.
Very good documentation on using the API as well as lists of hooks and
filters are found at http://codex.wordpress.org/Plugin_API and the pages
linked there.
> More importantly, I want to use mod_rewrite to map onto this plugin. I
> know Wordpress can do this, but I am not sure how. Here is the schema
> I imagine, artists.php being replaced by the correct wordpress plugin
> hookup (some suggestion here might be helpful two)
One of my plugins uses the following:
function myRewrite($rules)
{ $rules['foo'] = 'index.php?pagename=foo'; return $rules; }
add_filter('rewrite_rules_array', 'myRewrite');
When the plugin is activated, you must visit
wp-admin/options-permalinks.php (once is sufficient) to add your slug to
WP's ruleset.
Then, every request that calls /foo/* in this example, will be handled
by the plugin. However, this solution also requires to have a page with
the slug "foo". Maybe there's a better solution, but this one works for
me.
HTH
Regards,
Alex
--
Alex Günsche, Zirona OpenSource-Consulting
Blogs: http://www.zirona.com/ | http://www.regularimpressions.net
PubKey for this address: http://www.zirona.com/misc/ag.ml2007.asc
More information about the wp-hackers
mailing list