[wp-hackers] some problem with understanding wp_rewrite

Konrad Karpieszuk kkarpieszuk at gmail.com
Thu Oct 13 16:08:43 UTC 2011


so i understand that when i will use add_rewrite_endpoint to add
endpoint, there will be conflict with plugins which also use this
method?

if yes: is there any other way to append something to url?

why i still dont want to give aup and just add ?partner=1234 at the
end? i want to make it as much easy for affiliate partners as i can.
it is more easy to describe for partners "just put /partner/{your id}
at and of url and thats all" than "put ?partner={your id} at end, if
in url you see already question mark, you should add &partner={your
id}" :)

On Thu, Oct 13, 2011 at 5:46 PM, Dagan Henderson
<Dagan.Henderson at epyllion.com> wrote:
> Given that the path is used to build the WordPress query, the partner ID has nothing to do with the query, and you can't predict how other plugins will interact with and interpret the path, wouldn't it be "more correct" to exclude non-query-related information from the path? Adding extra data to the path could break another plugin inadvertently.
>
> I recently struggled through this myself while building a theme that supports mobile devices. I wanted to prepend the path with /m/ to signify a mobile device, but it really became far more hassle than it was worth, and I ultimately decided, at least for me, that that was the wrong way to go.
>
> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Konrad Karpieszuk
> Sent: Thursday, October 13, 2011 8:34 AM
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] some problem with understanding wp_rewrite
>
> Hi :)
>
> because i want to learn proper way how everybody should do it in wordpress :)
>
> On Thu, Oct 13, 2011 at 5:32 PM, Dagan Henderson <Dagan.Henderson at epyllion.com> wrote:
>> Why not add the query vars via the GET/POST request itself? For example, http://example.com/post/hellow-world/something/?partner=1234.
>>
>> That would make the partner ID accessible via $_REQUEST['partner'] without impacting the WP query.
>>
>> -----Original Message-----
>> From: wp-hackers-bounces at lists.automattic.com
>> [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Konrad
>> Karpieszuk
>> Sent: Thursday, October 13, 2011 6:01 AM
>> To: wp-hackers at lists.automattic.com
>> Subject: Re: [wp-hackers] some problem with understanding wp_rewrite
>>
>> thank you :) it looks like something what i need :)
>>
>> and more question: what if i have some plugin which also use add_rewrite_endpoint to add for example endpoint 'something'?
>>
>> urls like
>> example.com/post/hello-world/something/smth-from-plugin/partner/1234
>> and
>> example.com/post/hello-world/partner/1234/something/smth-from-plugin
>>
>> still will work? both of them?
>>
>> On Thu, Oct 13, 2011 at 2:18 PM, Ozh <ozh at ozh.org> wrote:
>>> I think what you need is a nice illustration of custom endpoints See
>>> http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint
>>>
>>> That would be something like:
>>>
>>> // Add the endpoint rewrite rules
>>> add_filter( 'init', 'ozh_ep_add_rules' ); function ozh_ep_add_rules()
>>> {
>>>    add_rewrite_endpoint( 'partner', EP_ALL ); // add endpoint on all
>>> pages }
>>>
>>> // Add permalink structure and flush on plugin activation
>>> register_activation_hook( __FILE__, 'ozh_ep_activate' ); function
>>> ozh_ep_activate() {
>>>    ozh_ep_add_rules();
>>>    flush_rewrite_rules();
>>> }
>>>
>>> // Handle the partner id early
>>> add_filter( 'template_redirect', 'ozh_ep_template_redirect' );
>>> function ozh_ep_template_redirect() {
>>>    $partner = get_query_var( 'partner' );
>>>    // do something with $partner
>>>    // ...
>>> }
>>>
>>> HTH
>>>
>>> Ozh
>>>
>>> --
>>> http://ozh.org/ - @ozh on Twitter
>>> WordPress plugins? I wrote a book! http://amzn.to/plugindevbook
>>>
>>>> hello
>>>>
>>>> I spent all last night reading codex and tutorials but i still don't
>>>> understand how to do this.
>>>>
>>>> I run online shop on wordpress and now i want to create affiliate
>>>> program. I will tell to affiliate partners that if someone of them
>>>> want to publish referral link on their website, then they have to
>>>> take any link from my shops' website and add /partner/1234 at the
>>>> and, where '1234' is id of partner
>>>>
>>>> OK, but how to manage this in wordpress? How to register this
>>>> rewrite rule that 'any webpage which has "/partner/(.*?)" at end
>>>> should be redirected to  version without this (or even it can stay)
>>>> and to query_vars[] will be added 'partner''?
>>>>
>>>> "Any" means that partner can publish somewhere links like:
>>>> example.com/partner/1234
>>>> example.com/blog/hello-world/partner/1234
>>>> example.com/archive/january/partner/1234
>>>> example.com/static-page/partner/1234
>>>>
>>>> and any other variations which i cant even imagine right now :)
>>>>
>>>> --
>>>> (en) regards / (pl) pozdrawiam
>>>> Konrad Karpieszuk
>>>> http://tradematik.pl wtyczka do WordPressa do tworzenia sklepów dla
>>>> klientów z Polski _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>
>>
>>
>> --
>> (en) regards / (pl) pozdrawiam
>> Konrad Karpieszuk
>> http://tradematik.pl wtyczka do WordPressa do tworzenia sklepów dla
>> klientów z Polski _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> (en) regards / (pl) pozdrawiam
> Konrad Karpieszuk
> http://tradematik.pl wtyczka do WordPressa do tworzenia sklepów dla klientów z Polski _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



-- 
(en) regards / (pl) pozdrawiam
Konrad Karpieszuk
http://tradematik.pl wtyczka do WordPressa do tworzenia sklepów dla
klientów z Polski


More information about the wp-hackers mailing list