Plugin Directory

Changeset 2186955


Ignore:
Timestamp:
11/06/2019 01:19:55 PM (6 years ago)
Author:
lightplugins
Message:

1.0.2

Location:
simple-www-redirect/trunk
Files:
23 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • simple-www-redirect/trunk/css/admin.css

    r2177006 r2186955  
    8181    display:none;
    8282}
     83
     84.light-plugins-link{
     85    font-weight:600;
     86}
  • simple-www-redirect/trunk/index.php

    r2185777 r2186955  
    66Author: LightPlugins
    77Author URI: https://lightplugins.com/
    8 Version: 1.0.1
     8Version: 1.0.2
    99Text Domain: swr
    1010*/
     
    9494    $parsed_url2 = wp_parse_url($home);
    9595
     96    // htaccess
     97    $htaccess_file = ABSPATH . ".htaccess";
     98
    9699    // the IP address doesn't support www.
    97100    if(filter_var($siteurl, FILTER_VALIDATE_IP)) {
     
    125128    // force www
    126129    if($type == "www"){
     130
     131        // redirect rules
     132        $rules = "RewriteEngine On
     133RewriteCond %{HTTP_HOST} !^www\. [NC]
     134RewriteRule ^(.*)$ ".$protocol."www.%{HTTP_HOST}/$1 [R=301,L]";
    127135       
    128136        // add www to siteurl
     
    139147    }else if($type == "non-www"){
    140148
     149        // redirect rules
     150        $rules = "RewriteEngine On
     151RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
     152RewriteRule ^(.*)$ ".$protocol."%1/$1 [R=301,L]";
     153
    141154        // remove www from siteurl and home
    142155        update_option("siteurl", str_replace("://www.", "://", $siteurl));
     
    145158    }
    146159
    147 }
     160    // checks if htaccess file is exists
     161    if (file_exists($htaccess_file)){
     162
     163        // remove insert
     164        if($method == "deactivate"){
     165            insert_with_markers($htaccess_file, "Simple www Redirect", array());
     166
     167        // insert
     168        }else if(strlen($rules) > 0){
     169            insert_with_markers($htaccess_file, "Simple www Redirect", explode("\n", $rules));
     170        }
     171
     172    }
     173
     174}
     175
     176
     177// the plugin deactivate hook
     178function swr_deactivate_hook(){
     179
     180    // delete redirect lines from htaccess file when deactivated
     181    swr_update_url(null, "deactivate");
     182
     183}
     184
     185register_deactivation_hook( __FILE__, 'swr_deactivate_hook' );
    148186
    149187
     
    243281    <div id="swr-settings"<?php echo $error_class; ?>>
    244282
    245         <p id="swr-information"><?php _e('The plugin specifies whether your domain will include www. The plugin basically creates redirect rule and adds to the .url file. Choose Your Style!', 'swr'); ?></p>
     283        <p id="swr-information"><?php _e('The plugin specifies whether your domain will include www. The plugin basically creates redirect rule and adds to the .htaccess file. Choose Your Style!', 'swr'); ?></p>
    246284
    247285        <p class="swr-errors"><?php echo $errors; ?></p>
     
    259297    </div>
    260298
     299    <p class="light-plugins-link">This plugin total is just 6KB.<br />Do you like lightweight plugins? Check <a href="https://www.lightplugins.com/?ref=simple-www-redirect" target="_blank">lightplugins.com</a></p>
     300
    261301</form>
    262302</div>
  • simple-www-redirect/trunk/js/admin.js

    r2157673 r2186955  
    11;(function($) {
    22
     3
     4
    35    // after document ready
     6
    47    $(document).ready(function(){
    58
     9
     10
    611        // the radio change event
     12
    713        $("[name='swr_force_type']").on("change", function() {
     14
    815            $(".swr-radio").removeClass("checked");
     16
    917            $("[name='swr_force_type']:checked").parents(".swr-radio").addClass("checked");
     18
    1019        });
    1120
     21
     22
    1223        // radio division click updating the radio value
     24
    1325        $(".swr-radio").on("click", function() {
     26
    1427            $(this).find("input").prop("checked", true);
     28
    1529            $(".swr-radio").removeClass("checked");
     30
    1631            $("[name='swr_force_type']:checked").parents(".swr-radio").addClass("checked");
     32
    1733        });
     34
     35
    1836
    1937    });
    2038
     39
     40
    2141}(jQuery));
  • simple-www-redirect/trunk/readme.txt

    r2185404 r2186955  
    22Tags: disable, www, non-www, redirect, world wide web
    33Requires at least: 4.0
    4 Tested up to: 5.2
    5 Stable tag: 5.2
     4Tested up to: 5.3
     5Stable tag: 5.3
    66Contributors: LightPlugins
    77License: GPLv2 or later
     
    1414
    1515= Key Features =
    16 * Add www to your domain, redirect non-www links to www
     16* Redirect non-www links to www
    1717* Or redirect www links to non-www
    1818* A simple lightweight plugin
     
    3535
    3636== Changelog ==
     37= 1.0.2 =
     38* Fixed a confict on Linux servers about htaccess file
     39
    3740= 1.0.1 =
    3841* A Redirect bug fixed
Note: See TracChangeset for help on using the changeset viewer.