$caption
$url

____________EOS; } else{ if(function_exists('wp_redirect')){ @wp_redirect($url); } else @header("Location:$url\n"); } exit; } else{ return false; } } /** * Gets the appropriate WP post meta key to to retrieve the redirect url. * * @return string Custom or default field key name. * * @uses WPREDIRECT_CACHE_FLAG * @uses WPREDIRECT_DEFAULT_META * @uses WPREDIRECT_CACHE_TTL */ function wpRedirect_metaKey() { $cacheKey = WPREDIRECT_CACHE_FLAG.'Meta'; if (function_exists('wp_cache_get')) { $metaKey = wp_cache_get($cacheKey, WPREDIRECT_CACHE_FLAG); if ($metaKey) return $metaKey; } // Cache-get failed, move on $metaKey = get_option($cacheKey); if (!$metaKey) $metaKey = WPREDIRECT_DEFAULT_META; if (function_exists('wp_cache_set')) wp_cache_set($cacheKey, $metaKey, WPREDIRECT_CACHE_FLAG, WPREDIRECT_CACHE_TTL); return $metaKey; } /** * Gets, caches and returns the actual URL to be redirected to. * * @param integer $post_ID An existing WP post/page ID * @return boolean false | string URL to redirect to * * @uses WPREDIRECT_CACHE_FLAG * @uses WPREDIRECT_CACHE_TTL * @uses wpRedirect_metaKey */ function wpRedirect_getAndCache($post_ID) { $url = get_post_meta($post_ID, wpRedirect_metaKey(), true); if ($url && function_exists('wp_cache_set')){ wp_cache_set( WPREDIRECT_CACHE_FLAG.'Post'.$post_ID, $url, WPREDIRECT_CACHE_FLAG, WPREDIRECT_CACHE_TTL ); } return $url; } /** * wpRedirect wrapper for WordPress add_action(); checks if post is * single or page, tries to get content of `redirect_me` custom field, * then redirects if necessary. * * @return void * * @uses WPREDIRECT_CACHE_FLAG * @uses wpRedirect * @uses wpRedirect_getAndCache */ function wpRedirect_init() { if (!is_single() && !is_page()) return false; global $post; $cacheKey = WPREDIRECT_CACHE_FLAG.'Post'.$post->ID; if (function_exists('wp_cache_get')) wpRedirect( wp_cache_get($cacheKey, WPREDIRECT_CACHE_FLAG) ); // Cache-based redir failed, move on wpRedirect( wpRedirect_getAndCache($post->ID) ); } /** * wpRedirect plugin configuration panel. * Allows administrators to define their own WP custom field to scan for redirects. * * @return void * * @uses WPREDIRECT_CACHE_FLAG * @uses WPREDIRECT_CACHE_TTL * @uses wpRedirect_metaKey * @uses WPREDIRECT_DEFAULT_META */ function wpRedirect_optionsPanel() { if ($_POST['wpRedirectOptionsSave']) { $metaKey = strip_tags($_POST['wpRedirectMeta']); if($metaKey){ $cacheKey = WPREDIRECT_CACHE_FLAG.'Meta'; update_option($cacheKey, $metaKey); if (function_exists('wp_cache_set')) wp_cache_set($cacheKey, $metaKey, WPREDIRECT_CACHE_FLAG, WPREDIRECT_CACHE_TTL); echo '

Your new settings were saved successfully.

'; } } if (!$metaKey) $metaKey = wpRedirect_metaKey(); $defMeta = WPREDIRECT_DEFAULT_META; echo <<

Redirection Options



The custom field key to scan for when displaying a single post or page. Defaults to "$defMeta".
EG: Can be set to an existing custom field, such as the one set by the built-in Import feature.

Powered by wpRedirect.

DirAuthForm; } /** * Adds the Menu for Wordpress Admin Panel. * Used in add_action('admin_menu', 'wpDirAuth_addmenu'); * * @return void * * @uses wpRedirect_optionsPanel */ function wpRedirect_addMenu() { if (function_exists('add_options_page')){ add_options_page( 'Redirection Options', 'Redirection', 9, basename(__FILE__), 'wpRedirect_optionsPanel' ); } } /** * Add custom WordPress actions * * @uses wpRedirect_init * @uses wpRedirect_addMenu * @uses wpRedirect_getAndCache * @uses wpRedirect_getAndCache * */ if (function_exists('add_action')) { add_action('wp', 'wpRedirect_init', 1); add_action('admin_menu', 'wpRedirect_addMenu'); add_action('publish_post', 'wpRedirect_getAndCache'); add_action('publish_page', 'wpRedirect_getAndCache'); } ?>