function p404_redirect()
{
    if (is_404()) {
        $options = get_my_options();
        $link = get_current_URL();
        if ($link == $options['p404_redirect_to']) {
            echo "<b>All 404 Redirect to Homepage</b> has detected that the target URL is invalid, this will cause an infinite loop redirection, please go to the plugin settings and correct the traget link! ";
            exit;
        }
        if ($options['p404_status'] == '1' & $options['p404_redirect_to'] != '') {
            header('HTTP/1.1 301 Moved Permanently');
            header("Location: " . $options['p404_redirect_to']);
            exit;
        }
    }
}
Exemple #2
0
<?php

include_once "cf_dropdown.php";
global $wpdb, $table_prefix;
if (array_key_exists('redirect_to', $_POST) && $_POST['redirect_to'] != '') {
    $newoptions['p404_redirect_to'] = $_POST['redirect_to'];
    $newoptions['p404_status'] = $_POST['p404_status'];
    update_my_options($newoptions);
    option_msg('Options Saved!');
}
$options = get_my_options();
?>

<?php 
if (there_is_cache() != '') {
    info_option_msg("You have a cache plugin installed <b>'" . there_is_cache() . "'</b>, you have to clear cache after any changes to get the changes reflected immediately! ");
}
?>

<div class="wrap">
<div class='procontainer'><div class='inner'>
<h2>All 404 Redirect to Homepage</h2>
<form method="POST">
	
	<br/><br/>
	404 Redirection Status: 
	<?php 
$drop = new dropdown('p404_status');
$drop->add('Enabled', '1');
$drop->add('Disabled', '2');
$drop->dropdown_print();