How are these PHP function applied to a specific page in WordPress? -
i'm new php , trying understand practical ways.
i'm getting of what's going on in following code, of http://www.php.net , http://codex.wordpress.org/function_reference/.
in current situation, 1 page on site triggers popup form if no cookie set. functionality specified within code?
here's functions:
if (isset($_post['confirm']) && isset($_post['location'])) { setcookie("location", $_post['location'], time()+3600); } elseif (!isset($_cookie["location"])) { setcookie("location", "", 1); } elseif (isset($_post['deny'])) { setcookie("location", "", 1); } // popup confirmation function show_popup($content) { global $post; $location = get_post_meta($post->id, 'location', true); if (strtolower($l) == strtolower($location) || strlen($location) == 0 || (isset($_cookie["location"]) && strtolower($_cookie["location"]) == strtolower($location))) { return $content; } else { ?> <div id="popup"> <p>foo.</p> <p>yes/no?</p> <form action="<?php echo $php_self ?>" method="post"> <input type="hidden" name="location" value="<?php echo $location; ?>" /> <input type="submit" name="confirm" value="yes" /> <input type="submit" name="deny" value="no" /> </form> </div> <?php } } add_filter('the_content', 'show_popup'); // adds content <head> tag function add_meta_content() { if(isset($_post['deny'])) { ?> <meta http-equiv="refresh" content="0;url=<?php bloginfo ('wpurl') ?>"> <?php } if(isset($_post['confirm'])) { ?> <meta http-equiv="refresh" content="0;url=<?php echo $php_self; ?>"> <?php } } add_action('wp_head', 'add_meta_content');
it's if statement in show_popup function.
it either returns $content (ie. nothing) or outputs form.
if current post has meta field called location that's not 0 characters long, , there's not cookie matching location, output form.
Comments
Post a Comment