[wp-pro] internal redirects

capsx capsx at team.lv
Tue Apr 27 16:44:43 UTC 2010


I apologize ...
wrong list ...
:S

On Tue, 27 Apr 2010 12:50:01 -0400
  Mike Schinkel <mikeschinkel at newclarity.net> wrote:
> This list is reserved for hiring people.  
> 
> To ask questions, go here:  
> 
> 	http://wordpress.org/support/
> 	http://tech.groups.yahoo.com/group/wpgarage/
> 	http://www.wptavern.com/forum/
> 	http://www.linkedin.com/groups?gid=154024
> 
> -Mike
> 
> 
> On Apr 27, 2010, at 12:15 PM, capsx wrote:
> 
>> Hello all!
>> 
>> I'm quite new to WP, especially to wordpress plugins.
>> I'm writing plugin which validate posted form 
>>(frontpage).
>> 
>> My style that i did that task previous is:
>> 
>> 1. after user submit the form, i check posted variables
>> 2. if there are errors i redirect user back to the same 
>>page, before that i set in session in which there are 
>>errors
>> 3. code cheks if there are errors or something else to 
>>show, and if is, it's shows
>> 
>> the problem starts with headers.
>> in the example above i used technique with ob_start(); 
>>and ob_end_clean(); in index file, to prevent 'headers 
>>already sent' error is displaying
>> 
>> but in wordpress it's a bit different ...
>> 
>> at first time my way to complete the task was:
>> 
>> add_shortcode('shortcode', 'asd');
>> then make function asd() which calls class and class is 
>>displaying needed information
>> and in that case i can't use header('location: xxx), 
>>cause headers are already sent ...
>> 
>> so i made all that in a different way:
>> 
>> my code get slug from wp options and compare it with 
>>requested page slug
>> if both are equal - function is called to show my plugin
>> 
>> --
>> 
>> $plugin_call_slug = get_option('_slug');
>> $requested_uri = base_server('REQUEST_URI'); // == 
>>$_SERVER['REQUEST_URI']
>> $requested_page = get_page_by_path( $requested_uri );
>> 
>> $requested_page = $requested_page->post_name;
>> 
>> if($requested_page == $plugin_call_slug)
>> {
>>    _function();
>> }
>> 
>> --
>> 
>> and _function calls class, and that class make all what 
>>it must do
>> and all output is stored in variable $return and that 
>>variable is stored in session variable $ss
>> 
>> and then we call the same function
>> add_shortcode('shortcode', 'asd');
>> only now function() is displaying only that variable 
>>from session variable $ss which hold all output from 
>>class execution
>> 
>> function asd()
>> {
>>    $a = base_session('return');
>>    echo $a;
>> }
>> 
>> ---
>> 
>> THE QUESTION IS - IS THIS A +/- CORRECT WAY HOW TO MAKE 
>>INTERNAL REDIRECTS, OR THERE IS OTHER LESS PAINFUL WAYS 
>>TO MAKE THOSE REDIRECTS AND OUTPUT NEEDED CONTENT... ???
>> 
>> ---
>> 
>> thx :)
>> _______________________________________________
>> wp-pro mailing list
>> wp-pro at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-pro
> 

-nonse response-


More information about the wp-pro mailing list