Plugin Directory

Changeset 480939


Ignore:
Timestamp:
12/27/2011 05:58:32 AM (14 years ago)
Author:
suhas93
Message:

Bug fix

Location:
seo-blogger-to-wordpress-301-redirector/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • seo-blogger-to-wordpress-301-redirector/trunk/readme.txt

    r480827 r480939  
    55Requires at least: 2.6
    66Tested up to: 3.3
    7 Stable tag: 0.3.5
     7Stable tag: 0.3.6
    88
    99This plugin will 301 redirect all incoming traffic from your Blogger account to your newly setup Wordpress account. Move from Blogger to wordpress with great ease.
     
    6868== Upgrade Notice ==
    6969
    70 = 0.3.5 =
    71 Redirects for Archive and Label Pages
     70= 0.3.6 =
     71Bug Fix from last night's update.
  • seo-blogger-to-wordpress-301-redirector/trunk/seo-blogger-to-wordpress.php

    r480827 r480939  
    44 Plugin URI: http://suhastech.com/seo-blogger-to-wordpress
    55 Description: This plugin will 301 redirect all incoming traffic from your Blogger account to your newly setup Wordpress account. Please read the documentation at suhastech.com/seo-blogger-to-wordpress before you continue.
    6  Version: 0.3.5
     6 Version: 0.3.6
    77 Author: Suhas Sharma
    88 Author URI: http://suhastech.com
     
    388388function suhas_blogger() {
    389389    global $wpdb;
    390     if ( !is_404() && !preg_match("/blogspot.com/i",$_SERVER['HTTP_REFERER']))
     390    if ( !is_404() )
    391391    return;
    392     $subdirectory = explode ("/", get_home_url());
    393     $req_uri = str_replace("/".end($subdirectory), "", $_SERVER['REQUEST_URI']);
     392
     393    $req_uri = $_SERVER['REQUEST_URI'];
    394394    $url = explode("?", $req_uri);
    395395    $res = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'blogger_permalink' AND meta_value = '$url[0]'");
     
    398398        wp_redirect(get_permalink($res[0]->post_id), 301 );
    399399    }
    400     else if (preg_match("/blogspot.com/i",$_SERVER['HTTP_REFERER'])) {
    401 
    402         $process = explode("blogspot.com", $_SERVER['HTTP_REFERER']);
    403         $exp = explode("/",$process[1]);
    404 
    405         if (preg_match("/archive.html/i",$exp[1]))
    406         {
    407             $archive = explode("_",$exp[1]);
    408             ?>
     400    else
     401    {
     402        return;
     403    }
     404    exit();
     405}
     406
     407function suhas_blogspot() {
     408    global $wpdb;
     409    $old_url = $_GET['blogger'];
     410
     411    if ($old_url != "") {
     412
     413        $permalink = explode("blogspot.com", $old_url);
     414        $url = explode("?", $permalink[1]);
     415        $res = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'blogger_permalink' AND meta_value = '$url[0]'");
     416        if(isset($res[0]->post_id))
     417        {
     418            wp_redirect(get_permalink($res[0]->post_id), 301 );
     419        }
     420        else {
     421            return;
     422        }
     423
     424    }
     425    exit();
     426}
     427
     428function suhas_blogspot_archive() {
     429    if ( !is_home())
     430    return;
     431    $process = explode("blogspot.com", $_SERVER['HTTP_REFERER']);
     432    $exp = explode("/",$process[1]);
     433
     434    if (preg_match("/archive.html/i",$exp[1]))
     435    {
     436        $archive = explode("_",$exp[1]);
     437        ?>
    409438<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    410439<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
     
    423452</body>
    424453</html>
    425             <?php
    426             // Yup, this is supposed to be SEO unfriendly, else your homepage will be redirected to archive pages and will not be indexed.
    427             // This is just for real vistors.
    428 
    429         }
    430         else if (substr($exp[1], 0, 6) == "search")
    431         {
    432             if(!($exp[3] == ""))
    433             {
    434                
    435                 ?>
     454        <?php
     455        // Yup, this is supposed to be SEO unfriendly, else your homepage will be redirected to archive pages and will not be indexed.
     456        // This is just for real vistors.
     457
     458    }
     459    else if (substr($exp[1], 0, 6) == "search")
     460    {
     461        if(!($exp[3] == ""))
     462        {
     463
     464            ?>
    436465<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    437466<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
     
    450479</body>
    451480</html>
    452                 <?php
    453                
    454             }
    455 
    456         } else { return; }
    457 
    458 
    459 
    460     }
     481            <?php
     482
     483        }
     484
     485    } else { return; }
     486
    461487    exit();
    462 }
    463 
    464 function suhas_blogspot() {
    465     global $wpdb;
    466     $old_url = $_GET['blogger'];
    467 
    468     if ($old_url != "") {
    469 
    470         $permalink = explode("blogspot.com", $old_url);
    471         $url = explode("?", $permalink[1]);
    472         $res = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'blogger_permalink' AND meta_value = '$url[0]'");
    473         if(isset($res[0]->post_id))
    474         {
    475             wp_redirect(get_permalink($res[0]->post_id), 301 );
    476         }
    477         else {
    478             return;
    479         }
    480 
    481     }
    482     exit();
     488
     489
    483490}
    484491
     
    487494if ( isset( $_GET['blogger'] ) )
    488495add_action( 'template_redirect', 'suhas_blogspot' );
     496if (preg_match("/blogspot.com/i",$_SERVER['HTTP_REFERER']))
     497add_action( 'template_redirect', 'suhas_blogspot_archive' );
    489498?>
     499
Note: See TracChangeset for help on using the changeset viewer.