Plugin Directory

Changeset 3111901

Timestamp:
07/03/2024 07:19:28 PM (5 weeks ago)
Author:
nko
Message:

Update to version 0.2.4 from GitHub

Location:
redirect-txt
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • redirect-txt/tags/0.2.4/classes/class-redirects.php

    r3092667 r3111901  
    140140        if ( is_string( $rules ) && $rules ) {
    141141
    142             // Remove comments.
    143             $rules = preg_replace( '/#.*/', '', $rules );
     142            /**
     143             * Remove comments, but keep hashes in links.
     144             *
     145             * This regex does two things:
     146             *  1. ^[ \t]*#.*$: Removes lines that start with a hash (optionally preceded by whitespace).
     147             *  2. (?<=\s)#.*$: Removes inline comments that start with a hash preceded by whitespace.
     148             *
     149             * Explanation of the new part:
     150             *  • (?<=\s): Positive lookbehind, ensures the hash is preceded by whitespace
     151             *  • #.*$: Matches the hash and everything after it until the end of the line
     152             */
     153            $rules = preg_replace( '/^[ \t]*#.*$|(?<=\s)#.*$/m', '', $rules );
    144154
    145155            // Split string by lines.
     
    202212        return $redirects;
    203213    }
    204 
    205     /**
    206      * Get redirects from DB and prepare array.
    207      *
    208      * @param bool $allow_url_only_redirects - allow redirecting using URLs only.
    209      * @param bool $allow_post_from - allow redirecting from post IDs.
    210      *
    211      * @return array
    212      */
    213     public static function get_redirect_rules( $allow_url_only_redirects = true, $allow_post_from = false ) {
    214         $rules = get_option( 'redirect_txt_rules', '' );
    215 
    216         return self::parse_redirect_rules( $rules, $allow_url_only_redirects, $allow_post_from );
    217     }
    218 
    219214
    220215    /**
  • redirect-txt/tags/0.2.4/readme.txt

    r3092667 r3111901  
    55Tested up to: 6.5
    66Requires PHP: 7.2
    7 Stable tag: 0.2.3
     7Stable tag: 0.2.
    88License: GPL-2.0-or-later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8383== Changelog ==
    8484
     85
     86
     87
     88
    8589= 0.2.3 - May 26, 2024 =
    8690
  • redirect-txt/tags/0.2.4/redirect-txt.php

    r3092667 r3111901  
    55 * Requires at least: 6.2
    66 * Requires PHP:      7.2
    7  * Version:           0.2.3
     7 * Version:           0.2.
    88 * Author:            Redirect.txt Team
    99 * License:           GPLv2 or later
     
    1919
    2020if ( ! defined( 'REDIRECT_TXT_VERSION' ) ) {
    21     define( 'REDIRECT_TXT_VERSION', '0.2.3' );
     21    define( 'REDIRECT_TXT_VERSION', '0.2.' );
    2222}
    2323
  • redirect-txt/trunk/classes/class-redirects.php

    r3092667 r3111901  
    140140        if ( is_string( $rules ) && $rules ) {
    141141
    142             // Remove comments.
    143             $rules = preg_replace( '/#.*/', '', $rules );
     142            /**
     143             * Remove comments, but keep hashes in links.
     144             *
     145             * This regex does two things:
     146             *  1. ^[ \t]*#.*$: Removes lines that start with a hash (optionally preceded by whitespace).
     147             *  2. (?<=\s)#.*$: Removes inline comments that start with a hash preceded by whitespace.
     148             *
     149             * Explanation of the new part:
     150             *  • (?<=\s): Positive lookbehind, ensures the hash is preceded by whitespace
     151             *  • #.*$: Matches the hash and everything after it until the end of the line
     152             */
     153            $rules = preg_replace( '/^[ \t]*#.*$|(?<=\s)#.*$/m', '', $rules );
    144154
    145155            // Split string by lines.
     
    202212        return $redirects;
    203213    }
    204 
    205     /**
    206      * Get redirects from DB and prepare array.
    207      *
    208      * @param bool $allow_url_only_redirects - allow redirecting using URLs only.
    209      * @param bool $allow_post_from - allow redirecting from post IDs.
    210      *
    211      * @return array
    212      */
    213     public static function get_redirect_rules( $allow_url_only_redirects = true, $allow_post_from = false ) {
    214         $rules = get_option( 'redirect_txt_rules', '' );
    215 
    216         return self::parse_redirect_rules( $rules, $allow_url_only_redirects, $allow_post_from );
    217     }
    218 
    219214
    220215    /**
  • redirect-txt/trunk/readme.txt

    r3092667 r3111901  
    55Tested up to: 6.5
    66Requires PHP: 7.2
    7 Stable tag: 0.2.3
     7Stable tag: 0.2.
    88License: GPL-2.0-or-later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8383== Changelog ==
    8484
     85
     86
     87
     88
    8589= 0.2.3 - May 26, 2024 =
    8690
  • redirect-txt/trunk/redirect-txt.php

    r3092667 r3111901  
    55 * Requires at least: 6.2
    66 * Requires PHP:      7.2
    7  * Version:           0.2.3
     7 * Version:           0.2.
    88 * Author:            Redirect.txt Team
    99 * License:           GPLv2 or later
     
    1919
    2020if ( ! defined( 'REDIRECT_TXT_VERSION' ) ) {
    21     define( 'REDIRECT_TXT_VERSION', '0.2.3' );
     21    define( 'REDIRECT_TXT_VERSION', '0.2.' );
    2222}
    2323
Note: See TracChangeset for help on using the changeset viewer.