WordPress.org

Plugin Directory

Changeset 624845


Ignore:
Timestamp:
11/13/12 20:56:02 (5 years ago)
Author:
ecolosites
Message:

EELV Redirection v0.3

Location:
eelv-redirection/trunk
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • eelv-redirection/trunk/eelv_redirection.php

    r614726 r624845  
    11<?php 
    22/* 
    3 Plugin Name: EELV - Redirection 
    4 Description: Simply redirect all pages off your blogs to a specified URL 
     3Plugin Name: EELV Redirection 
     4Description: Simply redirect all pages to a specified URL 
     5Plugin URI: http://ecolosites.eelv.fr/redirection/ 
     6Version: 0.3 
     7Author: bastho, ecolosites, EELV 
    58Author URI: http://ecolosites.eelv.fr/ 
    6 Plugin URI: http://ecolosites.eelv.fr/redirection/ 
    7 Version: 0.2 
    8 Author: Bastien Ho, ecolosites, EELV 
    99License: Creative commons CC BY-NC 3.0 
    1010*/ 
    1111 
    1212add_action('init', 'eelv_mk_redirect'); 
    13 add_action('wp_head', 'eelv_mk_redirecthtml'); 
     13add_action('wp_head', 'eelv_mk_redirecthtml'); // We never know... 
    1414add_action('admin_menu', 'ajout_page_admin_redirect'); 
     15load_plugin_textdomain( 'eelv-redirection', false, 'eelv-redirection/languages' ); 
     16 
    1517function ajout_page_admin_redirect() { 
    16     add_menu_page('Redirection','redirection', 'manage_options', 'eelv_option_redirect', 'eelv_option_redirect' );   
     18    //add_menu_page('Redirection','redirection', 'manage_options', 'eelv_option_redirect', 'eelv_option_redirect' );     
     19    add_submenu_page('options-general.php', __('Redirection', 'eelv-redirection' ), __('Redirection', 'eelv-redirection' ), 'manage_options', 'eelv_option_redirect', 'eelv_option_redirect');   
    1720} 
    1821function eelv_mk_redirect() { 
    1922    $dir=basename(realpath('.')); 
    20     if($dir!='wp-admin' && $dir!='network'){ 
     23    if($dir!='wp-admin' && $dir!='network' && $_SERVER['SCRIPT_NAME']!='/wp-login.php'){ 
    2124    if(get_option("eelv_url_redirect")!='') { 
    22         header("location: ".get_option("eelv_url_redirect"),true,get_option("eelv_code_redirect")); 
    23         header("location: ".get_option("eelv_url_redirect")); 
     25        $eelv_when_redirect = abs(get_option( "eelv_when_redirect" )); 
     26        if($eelv_when_redirect==0 || ($eelv_when_redirect==1 && !is_user_logged_in())){ 
     27            header("location: ".get_option("eelv_url_redirect"),true,get_option("eelv_code_redirect")); 
     28            header("location: ".get_option("eelv_url_redirect")); 
     29            exit(); 
     30        } 
    2431    } 
    2532  } 
     
    2734function eelv_mk_redirecthtml() { 
    2835    $dir=basename(realpath('.')); 
    29     if($dir!='wp-admin' && $dir!='network'){ 
    30     if(get_option("eelv_url_redirect")!='') { ?> 
    31 <!-- redirection -->  
    32 <link rel="canonical" href="<?=get_option("eelv_url_redirect")?>" /> 
    33 <SCRIPT LANGUAGE="JavaScript"> 
    34  document.location.href="<?=get_option("eelv_url_redirect")?>" 
    35 </SCRIPT>  
    36 <?  } 
     36    if($dir!='wp-admin' && $dir!='network' && $_SERVER['SCRIPT_NAME']!='/wp-login.php'){ // only on front 
     37    if(get_option("eelv_url_redirect")!='') {  
     38    $eelv_when_redirect = abs(get_option( "eelv_when_redirect" )); 
     39    if($eelv_when_redirect==0 || ($eelv_when_redirect==1 && !is_user_logged_in())){ ?> 
     40    <!-- redirection -->  
     41 <?php if(get_option("eelv_code_redirect")=='301') : ?> 
     42    <meta http-equiv="refresh" content="0; url=<?=get_option("eelv_url_redirect")?>"/> 
     43 <?php else: ?> 
     44    <link rel="canonical" href="<?=get_option("eelv_url_redirect")?>" /> 
     45<?php endif; ?> 
     46    <script language="JavaScript"> 
     47     document.location.href="<?=get_option("eelv_url_redirect")?>" 
     48    </script>  
     49    <?  } 
     50    } 
    3751  } 
    3852} 
     
    4761        update_option( "eelv_url_redirect", $_POST[ 'eelv_url_redirect' ]); 
    4862        update_option( "eelv_code_redirect", $_POST[ 'eelv_code_redirect' ]); 
     63        update_option( "eelv_when_redirect", $_POST[ 'eelv_when_redirect' ]); 
    4964?> 
    50 <div class="updated"><p><strong>Option saved</strong></p></div> 
     65<div class="updated"><p><strong><?php _e('Option saved','eelv-redirection')?></strong></p></div> 
    5166<?php 
    5267 
     
    5469$eelv_url_redirect = get_option( "eelv_url_redirect" ); 
    5570$eelv_code_redirect = get_option( "eelv_code_redirect" ); 
     71$eelv_when_redirect = abs(get_option( "eelv_when_redirect" )); 
    5672    // Now display the options editing screen 
    5773 
     
    6581     
    6682    ?> 
    67  
    6883<form name="form1" method="post" action=""> 
    69 <select name="eelv_code_redirect"> 
    70     <option value="301" <?php if($eelv_code_redirect=='301'){ echo'selected';} ?>>301 Moved Permanently</option> 
    71     <option value="302" <?php if($eelv_code_redirect=='302'){ echo'selected';} ?>>302 Moved Temporarily</option> 
     84<p> 
     85<label for="eelv_when_redirect"><?php _e('When :','eelv-redirection')?></label> 
     86<select name="eelv_when_redirect" id="eelv_when_redirect"> 
     87    <option value="0" <?php if($eelv_when_redirect=='0'){ echo'selected';} ?>><?php _e('Always','eelv-redirection')?></option> 
     88    <option value="1" <?php if($eelv_when_redirect=='1'){ echo'selected';} ?>><?php _e('Only non-logged-in users','eelv-redirection')?></option> 
    7289</select> 
    73 to : 
    74 <input type="text" name="eelv_url_redirect" value="<?=$eelv_url_redirect?>" size="50" placeholder="http://"> 
    75  
     90</form> 
     91<p> 
     92<label id="eelv_code_redirect"><?php _e('How :','eelv-redirection')?></label> 
     93<select name="eelv_code_redirect" id="eelv_code_redirect"> 
     94    <option value="301" <?php if($eelv_code_redirect=='301'){ echo'selected';} ?>><?php _e('301 : Moved Permanently','eelv-redirection')?></option> 
     95    <option value="302" <?php if($eelv_code_redirect=='302'){ echo'selected';} ?>><?php _e('302 : Moved Temporarily','eelv-redirection')?></option> 
     96</select> 
     97</p> 
     98<p> 
     99<label id="eelv_url_redirect"><?php _e('Where :','eelv-redirection')?></label> 
     100<input type="text" name="eelv_url_redirect" id="eelv_url_redirect" value="<?=$eelv_url_redirect?>" size="50" placeholder="http://"> 
     101</p> 
    76102<p class="submit"> 
    77 <input type="submit" name="Submit" value="ok" /> 
     103<input type="submit" name="Submit" value="<?php _e('Save','eelv-redirection')?>" /> 
    78104</p> 
    79105 
  • eelv-redirection/trunk/readme.txt

    r614726 r624845  
    1 === EELV redirection  === 
    2 Contributors: 8457, ecolosites 
     1=== EELV Redirection  === 
     2Contributors: bastho, ecolosites 
    33Donate link:  
    44Tags: redirection 
     
    1313== Description == 
    1414 
    15 Simply redirect all pages off your blogs to a specified URL, can be used for temporary or permanently redirect 
     15Simply redirect all pages to a specified URL, can be used for temporary or permanently redirect 
    1616 
    1717== Installation == 
    1818 
    19191. Upload `eelv_redirection.php` to the `/wp-content/plugins/` directory 
    20 1. Activate the plugin through the 'Plugins' menu in WordPress admin 
     202. Activate the plugin through the 'Plugins' menu in WordPress admin 
     213. Go to the configuration page to configure your redirection 
    2122 
    2223== Frequently asked questions == 
     
    3233== Changelog == 
    3334 
     35v 0.3 
     36Add : Option for logged-in users 
     37Add : French translation 
     38Fix : 301 and 302 redirections nhanced 
     39 
    3440v 0.2 
    35 Add 301 and 302 headers 
     41Add : 301 and 302 headers 
    3642 
    3743v 0.1 
Note: See TracChangeset for help on using the changeset viewer.