Plugin Directory

Changeset 2761725


Ignore:
Timestamp:
07/26/2022 11:13:15 AM (4 years ago)
Author:
ClearcodeHQ
Message:

Version 1.1.0

Location:
cc-redirects
Files:
67 added
4 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • cc-redirects/trunk/.htaccess

    r1849203 r2761725  
    88</IfModule>
    99
    10 <FilesMatch "^(style\.css)$">
     10<FilesMatch "^(script\.js|style\.css)$">
    1111    <IfModule !mod_authz_core.c>
    1212        Allow from all
  • cc-redirects/trunk/AUTHORS.txt

    r1849203 r2761725  
    11This file contains the list of people involved in the development of CC-Redirects plugin along its history.
    22
    3 Piotr Niewiadomski <http://piotr.press>
     3Piotr Niewiadomski <https://piotr.press>
    44
    55Great thanks to Clearcode <https://clearcode.cc> for allowing releasing CC-Redirects plugin as free software!
  • cc-redirects/trunk/README.txt

    r2437597 r2761725  
    22Contributors: ClearcodeHQ, PiotrPress
    33Tags: 301, redirect, redirects, seo, url, request, destination, 302, csv, clearcode, piotrpress
    4 Requires PHP: 7.0
     4Requires PHP: 7.4
    55Requires at least: 4.9.4
    6 Tested up to: 5.6
     6Tested up to: 6.0.1
    77Stable tag: trunk
    88License: GPLv3
     
    5757== Changelog ==
    5858
     59= 1.1.0 =
     60*Release date: 26.07.2022*
     61
     62* Added `comparison` method setting
     63* Added `parameters` forward setting
     64
    5965= 1.0.3 =
    6066*Release date: 11.12.2020*
  • cc-redirects/trunk/assets/css/style.css

    r2437597 r2761725  
    66    width: 100%;
    77}
     8.cc-redirects .column-comparison {
     9    width: 150px;
     10}
     11.cc-redirects .column-parameters {
     12    width: 90px;
     13}
    814.cc-redirects .column-code {
    915    width: 70px;
  • cc-redirects/trunk/includes/Redirects.php

    r2437597 r2761725  
    22
    33/*
    4     Copyright (C) 2020 by Clearcode <https://clearcode.cc>
     4    Copyright (C) 2022 by Clearcode <https://clearcode.cc>
    55    and associates (see AUTHORS.txt file).
    66
     
    2424namespace Clearcode;
    2525
    26 use Clearcode\Framework\v3\Plugin;
     26use Clearcode\Redirects\Vendor\Clearcode\Framework\v3\Plugin;
    2727use Clearcode\Redirects\Settings;
    2828
     
    6060        public function search( $request ) {
    6161            $redirects = Settings::instance()->redirects;
     62            if ( empty( $redirects ) ) return false;
    6263
    63             if ( empty( $redirects ) ) return false;
     64            parse_str( parse_url( $request, PHP_URL_QUERY ), $parameters );
    6465
    6566            foreach ( $redirects as $id => $redirect ) {
    6667                $redirect['id'] = $id;
    6768
     69                if ( (bool)($redirect['parameters'] ?? true ) )
     70                    $redirect['to'] = add_query_arg( $parameters, $redirect['to'] );
     71
     72                $from = ( $redirect['comparison'] ?? 'path' ) === 'path' ? strtok( $request, '?' ) : $request;
     73
    6874                if ( false !== strpos( $redirect['from'], '*' ) ) {
    6975                    $redirect['from'] = str_replace( '*', '(.*)', $redirect['from'] );
    70                     $pattern          = '/^' . str_replace( '/', '\/', rtrim( $redirect['from'], '/' ) ) . '/';
     76                    $pattern          = '/^' . str_replace( '/', '\/', $redirect['from'] ) . '/';
    7177                    $redirect['to']   = str_replace( '*', '$1', $redirect['to'] );
    72                     $redirect['to']   = preg_replace( $pattern, $redirect['to'], $request );
     78                    $redirect['to']   = preg_replace( $pattern, $redirect['to'], $from );
    7379
    74                     if ( $redirect['to'] !== $request ) return $redirect;
     80                    if ( $redirect['to'] !== $from ) return $redirect;
    7581
    76                 } elseif ( urldecode( $request ) == rtrim( $redirect['from'], '/' ) ) return $redirect;
     82                } elseif ( urldecode( $from ) === $redirect['from'] ) return $redirect;
    7783            }
    7884
    79             return false;
     85            return false;
    8086        }
    8187
  • cc-redirects/trunk/includes/Settings.php

    r2437597 r2761725  
    22
    33/*
    4     Copyright (C) 2020 by Clearcode <https://clearcode.cc>
     4    Copyright (C) 2022 by Clearcode <https://clearcode.cc>
    55    and associates (see AUTHORS.txt file).
    66
     
    2525use Clearcode\Redirects;
    2626
    27 use Clearcode\Framework\v3\Singleton;
    28 use Clearcode\Framework\v3\Filterer;
     27use Clearcode\Redirects\Vendor\Clearcode\Framework\v3\Singleton;
     28use Clearcode\Redirects\Vendor\Clearcode\Framework\v3\Filterer;
    2929
    3030if ( ! defined( 'ABSPATH' ) ) exit;
     
    8080
    8181            add_action( "load-$hook", function() {
    82                 add_screen_option( 'per_page', [
     82                add_screen_option( 'per_page', [
    8383                    'label'   => Redirects::__( 'Redirects per page' ),
    8484                    'default' => 100,
    8585                    'option'  => 'redirects_per_page'
    8686                ] );
     87
     88                get_current_screen()->add_help_tab( [
     89                    'id' => 'redirects',
     90                    'title' => Redirects::__( 'Redirects' ),
     91                    'content' => Redirects::render( 'paragraph', [ 'content' =>
     92                        sprintf(
     93                            Redirects::__( 'The %s field should be relative to your website root.' ),
     94                            Redirects::render( 'code', [ 'content' => Redirects::__( 'From' ) ] )
     95                        ) . '</br>' .
     96                        sprintf(
     97                            Redirects::__( 'The %s field can be either a full URL to any page on the web, or relative to your website root.' ),
     98                            Redirects::render( 'code', [ 'content' => Redirects::__( 'To'   ) ] )
     99                        ) . '</br>' .
     100                        Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-page/'                   ] ) . ' '     .
     101                        Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => '/new-page/'                   ] ) . '<br/>' .
     102                        Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-page/'                   ] ) . ' '     .
     103                        Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => 'http://example.com/new-page/' ] ) . '<br/>' .
     104                        '</br>' .
     105                        sprintf(
     106                            Redirects::__( 'To use wildcards, put an asterisk %s after the folder name you want to redirect.' ),
     107                            Redirects::render( 'code', [ 'content' => '*' ] )
     108                        ) . '</br>' .
     109                        Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-folder/*'              ] ) . ' '     .
     110                        Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => '/redirect-everything-here/' ] ) . '<br/>' .
     111                        '</br>' .
     112                        sprintf(
     113                            Redirects::__( 'You can also use the asterisk %s in the %s field to replace whatever it matches in the %s field.' ),
     114                            Redirects::render( 'code', [ 'content' => '*'                       ] ),
     115                            Redirects::render( 'code', [ 'content' => Redirects::__( 'To'     ) ] ),
     116                            Redirects::render( 'code', [ 'content' => Redirects::__( 'From'   ) ] )
     117                        ) . '<br/>' .
     118                        Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-folder/*'          ] ) . ' '     .
     119                        Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => '/some/other/folder/*'   ] ) . '<br/>' .
     120                        Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-folder/*/content/' ] ) . ' '     .
     121                        Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => '/some/other/folder/*'   ] ) . '<br/>'
     122                    ] )
     123                ] );
     124
     125                get_current_screen()->add_help_tab( [
     126                    'id' => 'import',
     127                    'title' => Redirects::__( 'Import' ),
     128                    'content' => Redirects::render( 'paragraph', [ 'content' =>
     129                        sprintf(
     130                            Redirects::__( 'Format: %s' ),
     131                            Redirects::render( 'code', [ 'content' => '"from","to"[,"path|query"][,0|1][,301|302]' ] )
     132                        ) . '</br>' . '</br>' .
     133                        sprintf(
     134                            Redirects::__( 'Field delimiter character: %s' ),
     135                            Redirects::render( 'code', [ 'content' => ',' ] )
     136                        ) . '</br>' .
     137                        sprintf(
     138                            Redirects::__( 'Field enclosure character: %s' ),
     139                            Redirects::render( 'code', [ 'content' => '"' ] )
     140                        ) . '</br>' .
     141                        sprintf(
     142                            Redirects::__( 'Escape character: %s' ),
     143                            Redirects::render( 'code', [ 'content' => '\\' ] )
     144                        ) . '</br>'
     145                    ] )
     146                ] );
    87147            } );
    88148        }
     
    94154        public function action_admin_enqueue_scripts( $page ) {
    95155            if ( $this->page !== $page ) return;
     156
    96157            wp_register_style( Redirects::get( 'slug' ), Redirects::get( 'url' ) . 'assets/css/style.css', [], Redirects::get( 'version' ) );
    97158            wp_enqueue_style(  Redirects::get( 'slug' ) );
     159
     160            wp_register_script( Redirects::get( 'slug' ), Redirects::get( 'url' ) . 'assets/js/script.js', [], Redirects::get( 'version' ) );
     161            wp_enqueue_script(  Redirects::get( 'slug' ) );
    98162        }
    99163
     
    108172            $redirects = false !== $id ? [ $id => $this->redirects[$id] ] : $this->redirects;
    109173
    110             if ( 'search' !== $this->get_action() and false === $id ) $redirects[] = [ 'from' => '', 'to' => '', 'code' => '301' ];
     174            if ( 'search' !== $this->get_action() and false === $id ) $redirects[] = [ 'from' => '', 'to' => '', 'comparison' => 'path', 'parameters' => '1', 'code' => '301' ];
    111175
    112176            $table = new Table( $redirects );
     
    133197                'tabs'   => $this->get_tabs(),
    134198                'tab'    => $this->get_tab(),
    135                 'desc'   => sprintf(
    136                                 Redirects::__( 'Redirects format is similar to the one that Apache uses. The %s field should be relative to your website root. The %s field can be either a full URL to any page on the web, or relative to your website root.' ),
    137                                 Redirects::render( 'code', [ 'content' => Redirects::__( 'From' ) ] ),
    138                                 Redirects::render( 'code', [ 'content' => Redirects::__( 'To'   ) ] )
    139                             ) . '</br>' .
    140                             Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-page/'                   ] ) . ' '     .
    141                             Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => '/new-page/'                   ] ) . '<br/>' .
    142                             Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-page/'                   ] ) . ' '     .
    143                             Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => 'http://example.com/new-page/' ] ) . '<br/>' .
    144                             '</br>' .
    145                             sprintf(
    146                                 Redirects::__( 'To use wildcards, put an asterisk %s after the folder name you want to redirect.' ),
    147                                 Redirects::render( 'code', [ 'content' => '*' ] )
    148                             ) . '</br>' .
    149                             Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-folder/*'              ] ) . ' '     .
    150                             Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => '/redirect-everything-here/' ] ) . '<br/>' .
    151                             '</br>' .
    152                             sprintf(
    153                                 Redirects::__( 'You can also use the asterisk %s in the %s field to replace whatever it matches in the %s field.' ),
    154                                 Redirects::render( 'code', [ 'content' => '*'                       ] ),
    155                                 Redirects::render( 'code', [ 'content' => Redirects::__( 'To'     ) ] ),
    156                                 Redirects::render( 'code', [ 'content' => Redirects::__( 'From'   ) ] )
    157                             ) . '<br/>' .
    158                             Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-folder/*'          ] ) . ' '     .
    159                             Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => '/some/other/folder/*'   ] ) . '<br/>' .
    160                             Redirects::__( 'From' ) . ': ' . Redirects::render( 'code', [ 'content' => '/old-folder/*/content/' ] ) . ' '     .
    161                             Redirects::__( 'To'   ) . ': ' . Redirects::render( 'code', [ 'content' => '/some/other/folder/*'   ] ) . '<br/>'
     199                'desc'   => Redirects::render( 'button', [
     200                    'type' => 'button',
     201                    'id' => Redirects::get( 'slug' ) . '-help-button',
     202                    'class' => 'button',
     203                    'content' => Redirects::__( 'Help' )
     204                ] )
    162205            ] );
    163206        }
     
    180223                'tabs'   => $this->get_tabs(),
    181224                'tab'    => $this->get_tab(),
    182                 'desc'   => sprintf(
    183                     Redirects::__( 'Parse CSV formatted string to redirects.'     ) . ' ' .
    184                     Redirects::__( 'Format: %s (optional 3rd argument).'          ) . ' ' .
    185                     Redirects::__( 'Field delimiter character: %s'                ) . ' ' .
    186                     Redirects::__( 'Field enclosure character: %s'                ) . ' ' .
    187                     Redirects::__( 'Escape character: %s'                         ),
    188                     Redirects::render( 'code', [ 'content' => '"from","to",301' ] ),
    189                     Redirects::render( 'code', [ 'content' => ','               ] ),
    190                     Redirects::render( 'code', [ 'content' => '"'               ] ),
    191                     Redirects::render( 'code', [ 'content' => '\\'              ] )
    192                 )
     225                'desc'   => Redirects::__( 'Parse CSV formatted string to redirects.' )
    193226            ] );
    194227        }
     
    197230            $export = '';
    198231            foreach ( $this->redirects as $redirect )
    199                 $export .= sprintf( '"%s","%s",%s', $redirect['from'], $redirect['to'], $redirect['code'] ) . "\n";
    200 
     232                $export .= sprintf(
     233                    '"%s","%s","%s",%d,%d',
     234                    $redirect['from'],
     235                    $redirect['to'],
     236                    self::sanitize_comparison( $redirect['comparison'] ?? 'path' ),
     237                    (int)self::sanitize_parameters( $redirect['parameters'] ?? true ),
     238                    (int)self::sanitize_code( $redirect['code'] ?? 301 )
     239                ) . "\n";
    201240
    202241            echo Redirects::render( 'export', [
     
    207246                'tab'    => $this->get_tab(),
    208247                'export' => $export,
    209                 'desc'   => sprintf(
    210                     Redirects::__( 'Exported CSV formatted string of redirects.'  ) . ' ' .
    211                     Redirects::__( 'Format: %s (optional 3rd argument).'          ) . ' ' .
    212                     Redirects::__( 'Field delimiter character: %s'                ) . ' ' .
    213                     Redirects::__( 'Field enclosure character: %s'                ) . ' ' .
    214                     Redirects::__( 'Escape character: %s'                         ),
    215                     Redirects::render( 'code', [ 'content' => '"from","to",301' ] ),
    216                     Redirects::render( 'code', [ 'content' => ','               ] ),
    217                     Redirects::render( 'code', [ 'content' => '"'               ] ),
    218                     Redirects::render( 'code', [ 'content' => '\\'              ] )
    219                 )
     248                'desc'   => Redirects::__( 'Exported CSV formatted string of redirects.' )
    220249            ] );
    221250        }
     
    276305        }
    277306
     307        static public function sanitize_url( $url ) {
     308            $url = sanitize_text_field( (string)$url );
     309            if ( '/' !== $url ) rtrim( $url, '/' );
     310            if ( ! empty( $url ) and ! preg_match( '/^https?:\/\//i', $url ) ) $url = ( '/' . ltrim( $url, '/' ) );
     311            return $url;
     312        }
     313
     314        static public function sanitize_comparison( $comparison ) {
     315            return 'query' === $comparison ? 'query' : 'path';
     316        }
     317
     318        static public function sanitize_parameters( $parameters ) {
     319            return (bool)$parameters;
     320        }
     321
     322        static public function sanitize_code( $code ) {
     323           return 302 === (int)$code ? 302 : 301;
     324        }
     325
    278326        protected function save() {
    279327            if ( empty( $_POST[Redirects::get( 'slug' )] ) or
     
    286334                $id = (int)$id;
    287335
    288                 $from = sanitize_text_field( (string)$redirect['from'] );
    289                 $to   = sanitize_text_field( (string)$redirect['to'  ] );
    290 
    291                 $code = (int)$redirect['code'];
    292                 if ( $code !== 302 ) $code = 301;
    293 
    294                 if ( empty( $from ) or empty( $to ) ) continue;
     336                foreach ( [ 'from', 'to' ] as $url )
     337                    $redirect[$url] = self::sanitize_url( $redirect[$url] );
     338
     339                if ( empty( $redirect['from'] ) or empty( $redirect['to'] ) ) continue;
    295340                $this->redirects[$id] = [
    296                     'from' => $from,
    297                     'to'   => $to,
    298                     'code' => $code
     341                    'from'       => $redirect['from'],
     342                    'to'         => $redirect['to'],
     343                    'comparison' => self::sanitize_comparison( $redirect['comparison'] ?? 'path' ),
     344                    'parameters' => self::sanitize_parameters( $redirect['parameters'] ?? true ),
     345                    'code'       => self::sanitize_code( $redirect['code'] ?? 301 )
    299346                ];
    300347            }
     
    302349            $this->redirects = array_values( $this->redirects );
    303350            if ( update_option( Redirects::get( 'slug' ), $this->redirects ) )
    304                 self::notice( Redirects::__(  'Redirects saved successfully.', 'updated' ) );
     351                self::notice( Redirects::__(  'Redirects saved successfully.' ), 'updated' );
    305352            else self::notice( Redirects::__( 'Error while saving redirects occurred.' ) );
    306353        }
     
    316363            $this->redirects = array_values( $this->redirects );
    317364            if ( update_option( Redirects::get( 'slug' ), $this->redirects ) ) {
    318                 self::notice( Redirects::__( 'Redirect removed successfully.', 'updated' ) );
     365                self::notice( Redirects::__( 'Redirect removed successfully.' ), 'updated' );
    319366                self::redirect();
    320367            } else self::notice( Redirects::__( 'Error while removing redirect occurred.' ) );
     
    354401
    355402                $redirects[] = [
    356                     'from' => $redirect[0],
    357                     'to'   => $redirect[1],
    358                     'code' => ( isset( $redirect[2] ) and 302 == $redirect[2] ) ? 302 : 301
     403                    'from'       => rtrim( $redirect[0], '/' ),
     404                    'to'         => rtrim( $redirect[1], '/' ),
     405                    'comparison' => self::sanitize_comparison( $redirect[2] ?? 'path' ),
     406                    'parameters' => self::sanitize_parameters( $redirect[3] ?? true ),
     407                    'code'       => self::sanitize_code( $redirect[4] ?? 301 )
    359408                ];
    360409            }
     
    362411            $this->redirects = array_merge( $this->redirects, $redirects );
    363412            if ( update_option( Redirects::get( 'slug' ), $this->redirects ) )
    364                 self::notice( Redirects::__( 'Redirects imported successfully.', 'updated' ) );
     413                self::notice( Redirects::__( 'Redirects imported successfully.' ), 'updated' );
    365414            else self::notice( Redirects::__( 'Error while importing redirects occurred.' ) );
    366415        }
     
    369418            if ( delete_option( Redirects::get( 'slug' ) ) ) {
    370419                $this->redirects = [];
    371                 self::notice( Redirects::__( 'Redirects removed successfully.', 'updated' ) );
     420                self::notice( Redirects::__( 'Redirects removed successfully.' ), 'updated' );
    372421                self::redirect();
    373422            } else self::notice( Redirects::__( 'Error while removing redirects occurred.' ) );
  • cc-redirects/trunk/includes/Table.php

    r2437597 r2761725  
    22
    33/*
    4     Copyright (C) 2020 by Clearcode <https://clearcode.cc>
     4    Copyright (C) 2022 by Clearcode <https://clearcode.cc>
    55    and associates (see AUTHORS.txt file).
    66
     
    4949        public function get_columns() {
    5050            return [
    51                 'id'     => Redirects::__( '#'      ),
    52                 'from'   => Redirects::__( 'From'   ),
    53                 'to'     => Redirects::__( 'To'     ),
    54                 'code'   => Redirects::__( 'Code'   ),
    55                 'action' => Redirects::__( 'Action' )
     51                'id'         => Redirects::__( '#'          ),
     52                'from'       => Redirects::__( 'From'       ),
     53                'to'         => Redirects::__( 'To'         ),
     54                'comparison' => Redirects::__( 'Comparison' ),
     55                'parameters' => Redirects::__( 'Parameters' ),
     56                'code'       => Redirects::__( 'Code'       )
    5657            ];
    5758        }
     
    5960        public function column_default( $item, $column_name ) {
    6061            switch ( $column_name ) {
    61                 case 'id'   : return ++$item['id'];
     62                case 'id' : return ++$item['id'];
    6263                case 'from' :
    63                 case 'to'   :
     64                    $actions['edit'] = Redirects::render( 'button', [
     65                        'type'  => 'submit',
     66                        'class' => 'button-link',
     67                        'content' => Redirects::__( 'Save' )
     68                    ] );
     69                    if ( count( $this->redirects ) !== $item['id'] + 1 )
     70                        $actions['delete'] = Redirects::render( 'link', [
     71                            'link'  => Redirects::__( 'Remove' ),
     72                            'class' => '',
     73                            'url'   => wp_nonce_url( add_query_arg( [
     74                                'action' => 'remove',
     75                                'id'     => $item['id'],
     76                            ], admin_url( sprintf( Settings::URL, Redirects::get( 'slug' ) ) ) ), 'remove' )
     77                        ] );
     78                case 'to' :
    6479                    return Settings::input( [
    6580                        'type'  => 'text',
    6681                        'name'  => Redirects::get( 'slug' ) . '[' . $item['id'] . '][' . $column_name . ']',
    67                         'value' => $item[$column_name],
    68                     ] );
     82                        'value' => Settings::sanitize_url( $item[$column_name] ),
     83                    ] ) . $this->row_actions( $actions ?? [] );
     84                case 'comparison' :
     85                    return Settings::select( [
     86                        'name'     => Redirects::get( 'slug' ) . '[' . $item['id'] . '][comparison]',
     87                        'selected' => Settings::sanitize_comparison( $item['comparison'] ?? 'path' ),
     88                        'options'  => [
     89                            'path'  => Redirects::__( 'Ignore parameters' ),
     90                            'query' => Redirects::__( 'Precise address'   )
     91                        ]
     92                    ] );
     93                case 'parameters' :
     94                    return Settings::select( [
     95                        'name'     => Redirects::get( 'slug' ) . '[' . $item['id'] . '][parameters]',
     96                        'selected' => (int)Settings::sanitize_parameters( $item['parameters'] ?? true ),
     97                        'options'  => [
     98                            1 => Redirects::__( 'Forward' ),
     99                            0 => Redirects::__( 'Remove'  )
     100                        ]
     101                    ] );
    69102                case 'code' :
    70                     $code = in_array( (int)$item['code'], [ 301, 302 ] ) ? $item['code'] : 301;
    71103                    return Settings::select( [
    72104                        'name'     => Redirects::get( 'slug' ) . '[' . $item['id'] . '][code]',
    73                         'selected' => $code,
     105                        'selected' => Settings::sanitize_code( $item['code'] ?? 301 ),
    74106                        'options'  => [
    75107                            301  => '301',
    76108                            302  => '302'
    77109                        ]
    78                     ] );
    79                 case 'action' :
    80                     return Redirects::render( 'link', [
    81                         'link'  => Redirects::__( 'Remove' ),
    82                         'class' => 'button button-secondary',
    83                         'url'   => wp_nonce_url( add_query_arg( [
    84                             'action' => 'remove',
    85                             'id'     => $item['id'],
    86                         ], admin_url( sprintf( Settings::URL, Redirects::get( 'slug' ) ) ) ), 'remove' )
    87110                    ] );
    88111                default : return print_r( $item, true );
  • cc-redirects/trunk/languages/cc-redirects-pl_PL.po

    r2437597 r2761725  
    22msgstr ""
    33"Project-Id-Version: cc-redirects\n"
    4 "POT-Creation-Date: 2020-12-11 17:07+0100\n"
    5 "PO-Revision-Date: 2020-12-11 17:22+0100\n"
     4"POT-Creation-Date: 2022-07-11 17:56+0200\n"
     5"PO-Revision-Date: 2022-07-11 18:09+0200\n"
    66"Last-Translator: Piotr Niewiadomski <p.niewiadomski@clearcode.cc>\n"
    77"Language-Team: Clearcode | Piotr Niewiadomski <p.niewiadomski@clearcode.cc>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.4.2\n"
    13 "X-Poedit-Basepath: ..\n"
    1412"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
    1513"|| n%100>=20) ? 1 : 2);\n"
     14"X-Generator: Poedit 3.1.1\n"
     15"X-Poedit-Basepath: ..\n"
    1616"X-Poedit-SourceCharset: UTF-8\n"
    1717"X-Poedit-KeywordsList: __;_e\n"
    1818"X-Poedit-SearchPath-0: .\n"
    1919
    20 #: includes/Redirects.php:88
     20#: includes/Redirects.php:95
    2121msgid "Settings"
    2222msgstr "Ustawienia"
    2323
    24 #: includes/Redirects.php:98
     24#: includes/Redirects.php:105
    2525msgid "Author"
    2626msgstr "Autor"
    2727
    28 #: includes/Redirects.php:121
     28#: includes/Redirects.php:128
    2929#, php-format
    3030msgid "This post is redirected from: %s to: %s with code: %s."
    3131msgstr "Ten wpis jest przekierowany z: %s do: %s z kodem: %s."
    3232
    33 #: includes/Redirects.php:127
     33#: includes/Redirects.php:134
    3434msgid "Edit"
    3535msgstr "Edytuj"
    3636
    37 #: includes/Settings.php:74 includes/Settings.php:123 includes/Settings.php:174
    38 #: includes/Settings.php:203 includes/Settings.php:232
    39 #: includes/Settings.php:250
     37#: includes/Settings.php:74 includes/Settings.php:90 includes/Settings.php:187
     38#: includes/Settings.php:217 includes/Settings.php:242
     39#: includes/Settings.php:261 includes/Settings.php:279
    4040msgid "Redirects"
    4141msgstr "Przekierowania"
     
    4545msgstr "Ilość przekierowań na stronę"
    4646
    47 #: includes/Settings.php:101 includes/Settings.php:263
     47#: includes/Settings.php:93
     48#, php-format
     49msgid "The %s field should be relative to your website root."
     50msgstr "Pole %s powinno być adresem względnym do Twojej strony głównej."
     51
     52#: includes/Settings.php:94 includes/Settings.php:100 includes/Settings.php:102
     53#: includes/Settings.php:109 includes/Settings.php:116
     54#: includes/Settings.php:118 includes/Settings.php:120 includes/Table.php:52
     55msgid "From"
     56msgstr "Z"
     57
     58#: includes/Settings.php:97
     59#, php-format
     60msgid ""
     61"The %s field can be either a full URL to any page on the web, or relative to "
     62"your website root."
     63msgstr ""
     64"Pole %s może być albo pełnym adresem URL do dowolnej strony w sieci, lub "
     65"względne do Twojej strony głównej."
     66
     67#: includes/Settings.php:98 includes/Settings.php:101 includes/Settings.php:103
     68#: includes/Settings.php:110 includes/Settings.php:115
     69#: includes/Settings.php:119 includes/Settings.php:121 includes/Table.php:53
     70msgid "To"
     71msgstr "Do"
     72
     73#: includes/Settings.php:106
     74#, php-format
     75msgid ""
     76"To use wildcards, put an asterisk %s after the folder name you want to "
     77"redirect."
     78msgstr ""
     79"Aby użyć symbolu wieloznacznego, umieść znak gwiazdki %s za folderem, który "
     80"chcesz przekierować."
     81
     82#: includes/Settings.php:113
     83#, php-format
     84msgid ""
     85"You can also use the asterisk %s in the %s field to replace whatever it "
     86"matches in the %s field."
     87msgstr ""
     88"Możesz także użyć znaku gwiazdki %s w polu %s żeby zamienić spasowany "
     89"element adresu z pola %s."
     90
     91#: includes/Settings.php:127 includes/Settings.php:280
     92msgid "Import"
     93msgstr "Import"
     94
     95#: includes/Settings.php:130
     96#, php-format
     97msgid "Format: %s"
     98msgstr "Format: %s"
     99
     100#: includes/Settings.php:134
     101#, php-format
     102msgid "Field delimiter character: %s"
     103msgstr "Znak rozdzielający pole: %s"
     104
     105#: includes/Settings.php:138
     106#, php-format
     107msgid "Field enclosure character: %s"
     108msgstr "Znak okalający pole: %s"
     109
     110#: includes/Settings.php:142
     111#, php-format
     112msgid "Escape character: %s"
     113msgstr "Znak ucieczki: %s"
     114
     115#: includes/Settings.php:165 includes/Settings.php:292
    48116#: vendor/clearcode/wordpress-framework/src/v3/Singleton.php:31
    49 #: vendor/clearcode/wordpress-framework/src/v3/Singleton.php:34
    50 #: vendor/clearcode/wordpress-framework/src/v3/Singleton.php:38
    51117msgid "Cheatin&#8217; uh?"
    52118msgstr "Oszukujemy&#8217; co?"
    53119
    54 #: includes/Settings.php:129 includes/Settings.php:179
     120#: includes/Settings.php:193 includes/Settings.php:222 includes/Table.php:67
    55121msgid "Save"
    56122msgstr "Zapisz"
    57123
    58 #: includes/Settings.php:130
     124#: includes/Settings.php:194
    59125msgid "Search"
    60126msgstr "Szukaj"
    61127
    62 #: includes/Settings.php:132
     128#: includes/Settings.php:196
    63129msgid "Search results for"
    64130msgstr "Wyniki wyszukiwania dla"
    65131
    66 #: includes/Settings.php:136
    67 #, php-format
    68 msgid ""
    69 "Redirects format is similar to the one that Apache uses. The %s field should "
    70 "be relative to your website root. The %s field can be either a full URL to "
    71 "any page on the web, or relative to your website root."
    72 msgstr ""
    73 "Format przekierowań jest podobny do tego wykorzystywanego przez Apache. Pole "
    74 "%s powinno być względne do Twojej strony głównej. Pole %s może być albo "
    75 "pełnym adresem URL do dowolnej strony w sieci, lub względne do Twojej strony "
    76 "głównej."
    77 
    78 #: includes/Settings.php:137 includes/Settings.php:140
    79 #: includes/Settings.php:142 includes/Settings.php:149
    80 #: includes/Settings.php:156 includes/Settings.php:158
    81 #: includes/Settings.php:160 includes/Table.php:52
    82 msgid "From"
    83 msgstr "Z"
    84 
    85 #: includes/Settings.php:138 includes/Settings.php:141
    86 #: includes/Settings.php:143 includes/Settings.php:150
    87 #: includes/Settings.php:155 includes/Settings.php:159
    88 #: includes/Settings.php:161 includes/Table.php:53
    89 msgid "To"
    90 msgstr "Do"
    91 
    92 #: includes/Settings.php:146
    93 #, php-format
    94 msgid ""
    95 "To use wildcards, put an asterisk %s after the folder name you want to "
    96 "redirect."
    97 msgstr ""
    98 "Aby użyć symbolu wieloznacznego, umieść znak gwiazdki %s za folderem, który "
    99 "chcesz przekierować."
    100 
    101 #: includes/Settings.php:153
    102 #, php-format
    103 msgid ""
    104 "You can also use the asterisk %s in the %s field to replace whatever it "
    105 "matches in the %s field."
    106 msgstr ""
    107 "Możesz także użyć znaku gwiazdki %s w polu %s żeby zamienić spasowany "
    108 "element adresu z pola %s."
    109 
    110 #: includes/Settings.php:183
     132#: includes/Settings.php:203
     133msgid "Help"
     134msgstr "Pomoc"
     135
     136#: includes/Settings.php:225
    111137msgid "Parse CSV formatted string to redirects."
    112138msgstr "Zaimportuj przekierowania z formatu CSV."
    113139
    114 #: includes/Settings.php:184 includes/Settings.php:211
    115 #, php-format
    116 msgid "Format: %s (optional 3rd argument)."
    117 msgstr "Format: %s (opcjonalny trzeci argument)."
    118 
    119 #: includes/Settings.php:185 includes/Settings.php:212
    120 #, php-format
    121 msgid "Field delimiter character: %s"
    122 msgstr "Znak rozdzielający pole: %s"
    123 
    124 #: includes/Settings.php:186 includes/Settings.php:213
    125 #, php-format
    126 msgid "Field enclosure character: %s"
    127 msgstr "Znak okalający pole: %s"
    128 
    129 #: includes/Settings.php:187 includes/Settings.php:214
    130 #, php-format
    131 msgid "Escape character: %s"
    132 msgstr "Znak ucieczki: %s"
    133 
    134 #: includes/Settings.php:210
     140#: includes/Settings.php:248
    135141msgid "Exported CSV formatted string of redirects."
    136142msgstr "Przekierowania wyeksportowane do formatu CSV."
    137143
    138 #: includes/Settings.php:237 includes/Settings.php:253
     144#: includes/Settings.php:266 includes/Settings.php:282
    139145msgid "Reset"
    140146msgstr "Resetuj"
    141147
    142 #: includes/Settings.php:240
     148#: includes/Settings.php:269
    143149msgid "Remove all redirects."
    144150msgstr "Usuń wszystkie przekierowania."
    145151
    146 #: includes/Settings.php:251
    147 msgid "Import"
    148 msgstr "Import"
    149 
    150 #: includes/Settings.php:252
     152#: includes/Settings.php:281
    151153msgid "Export"
    152154msgstr "Eksport"
    153155
    154 #: includes/Settings.php:281 includes/Settings.php:305
     156#: includes/Settings.php:329 includes/Settings.php:352
    155157msgid "Error while saving redirects occurred."
    156158msgstr "Wystąpił błąd podczas zapisywania przekierowań."
    157159
    158 #: includes/Settings.php:304
     160#: includes/Settings.php:351
    159161msgid "Redirects saved successfully."
    160162msgstr "Przekierowania zostały zapisane."
    161163
    162 #: includes/Settings.php:311 includes/Settings.php:320
     164#: includes/Settings.php:358 includes/Settings.php:367
    163165msgid "Error while removing redirect occurred."
    164166msgstr "Wystąpił błąd podczas usuwania przekierowania."
    165167
    166 #: includes/Settings.php:318
     168#: includes/Settings.php:365
    167169msgid "Redirect removed successfully."
    168170msgstr "Przekierowanie zostało usunięte."
    169171
    170 #: includes/Settings.php:342 includes/Settings.php:365
     172#: includes/Settings.php:389 includes/Settings.php:414
    171173msgid "Error while importing redirects occurred."
    172174msgstr "Wystąpił błąd podczas importu przekierowań."
    173175
    174 #: includes/Settings.php:364
     176#: includes/Settings.php:413
    175177msgid "Redirects imported successfully."
    176178msgstr "Przekierowania zostały zaimportowane."
    177179
    178 #: includes/Settings.php:371
     180#: includes/Settings.php:420
    179181msgid "Redirects removed successfully."
    180182msgstr "Przekierowania zostały usunięte."
    181183
    182 #: includes/Settings.php:373
     184#: includes/Settings.php:422
    183185msgid "Error while removing redirects occurred."
    184186msgstr "Wystąpił błąd podczas usuwania przekierowań."
     
    189191
    190192#: includes/Table.php:54
     193msgid "Comparison"
     194msgstr "Porównanie"
     195
     196#: includes/Table.php:55
     197msgid "Parameters"
     198msgstr "Parametry"
     199
     200#: includes/Table.php:56
    191201msgid "Code"
    192202msgstr "Kod"
    193203
    194 #: includes/Table.php:55
    195 msgid "Action"
    196 msgstr "Akcja"
    197 
    198 #: includes/Table.php:81
     204#: includes/Table.php:71 includes/Table.php:99
    199205msgid "Remove"
    200206msgstr "Usuń"
    201207
    202 #: includes/Table.php:93
     208#: includes/Table.php:89
     209msgid "Ignore parameters"
     210msgstr "Ignoruj parametry"
     211
     212#: includes/Table.php:90
     213msgid "Precise address"
     214msgstr "Dokładny adres"
     215
     216#: includes/Table.php:98
     217msgid "Forward"
     218msgstr "Przekaż"
     219
     220#: includes/Table.php:116
    203221msgid "No redirects available."
    204222msgstr "Brak przekierowań do wyświetlenia."
    205223
     224#, php-format
    206225#~ msgid ""
    207 #~ "Redirects work similar to the format that Apache uses. The %s field "
     226#~ "Redirects format is similar to the one that Apache uses. The %s field "
    208227#~ "should be relative to your website root. The %s field can be either a "
    209228#~ "full URL to any page on the web, or relative to your website root."
    210 #~ msgstr "Przekierowania działają podobnie do "
     229#~ msgstr ""
     230#~ "Format przekierowań jest podobny do tego wykorzystywanego przez Apache. "
     231#~ "Pole %s powinno być względne do Twojej strony głównej. Pole %s może być "
     232#~ "albo pełnym adresem URL do dowolnej strony w sieci, lub względne do "
     233#~ "Twojej strony głównej."
     234
     235#, php-format
     236#~ msgid "Format: %s (optional 3rd argument)."
     237#~ msgstr "Format: %s (opcjonalny trzeci argument)."
     238
     239#~ msgid "Action"
     240#~ msgstr "Akcja"
    211241
    212242#~ msgid ""
  • cc-redirects/trunk/plugin.php

    r2437597 r2761725  
    22
    33/**
    4  * CC-Redirects
    5  *
    6  * @package     CC-Redirects
    7  * @author      PiotrPress
    8  * @copyright   2020 Clearcode
    9  * @license     GPL-3.0+
    10  *
    11  * @wordpress-plugin
    124 * Plugin Name: CC-Redirects
    135 * Plugin URI:  https://wordpress.org/plugins/cc-redirects
    146 * Description: This plugin allows you to create simple redirect requests to another page on your site or elsewhere on the web.
    15  * Version:     1.0.3
     7 * Version:     1.1.0
    168 * Author:      Clearcode
    179 * Author URI:  https://clearcode.cc
     
    2113 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
    2214
    23    Copyright (C) 2020 by Clearcode <https://clearcode.cc>
     15   Copyright (C) 2022 by Clearcode <https://clearcode.cc>
    2416   and associates (see AUTHORS.txt file).
    2517
     
    4335namespace Clearcode\Redirects;
    4436use Clearcode\Redirects;
    45 
    46 use Clearcode\Framework\v3\Autoloader;
    4737use Exception;
    4838
    4939defined( 'ABSPATH' ) or exit;
    5040
     41require __DIR__ . '/vendor/autoload.php';
     42
    5143try {
    52     require __DIR__ . '/vendor/autoload.php';
    53     new Autoloader( [ __NAMESPACE__  . '\\' => __DIR__ . '/includes' ] );
    54 
    55     foreach( [ 'Redirects' ] as $file )
    56         require_once( __DIR__ . "/includes/$file.php" );
    57 
    5844    Redirects::instance( __FILE__ );
    5945} catch ( Exception $exception ) {
  • cc-redirects/trunk/templates/input.php

    r1849203 r2761725  
    11<?php defined( 'ABSPATH' ) or exit; ?>
    2 <label>
     2<?php if ( ! empty( $before ) or ! empty( $after ) ) : ?><label><?php endif; ?>
    33    <?php if ( ! empty( $before ) ) : ?><?= $before; ?><?php endif; ?>
    44    <input <?php if ( ! empty( $atts ) ) : ?><?= $atts; ?><?php endif; ?><?php if ( ! empty( $checked ) ) : ?> <?= $checked; ?><?php endif; ?>/>
    55    <?php if ( ! empty( $after ) ) : ?><?= $after; ?><?php endif; ?>
    6 </label>
     6<?php if ( ! empty( $before ) or ! empty( $after ) ) : ?></label><?php endif; ?>
    77<?php if ( ! empty( $desc ) ) : ?>
    88    <p class="description">
  • cc-redirects/trunk/templates/redirects.php

    r1849203 r2761725  
    1313            <?php endforeach; ?>
    1414        </h2>
    15         <p><?= $desc; ?></p>
    1615        <div id="poststuff">
    1716            <div id="post-body" class="metabox-holder">
     17                <?= $desc; ?>
    1818                <?php $table->search_box( $search, $id ); ?>
    1919                <div id="post-body-content">
  • cc-redirects/trunk/templates/select.php

    r1849203 r2761725  
    33<select<?php if ( ! empty( $name ) ) : ?> name="<?= $name; ?>"<?php endif; ?>>
    44    <?php if ( $options ) foreach( $options as $value => $name ) : ?>
    5         <option <?php  if ( ! empty( $value ) ) : ?>value="<?= $value; ?>"<?php endif; ?><?php if ( ! empty( $selected ) and $selected == $value ) : ?> selected="selected"<?php endif; ?>><?php if ( ! empty( $name ) ) : ?><?= $name; ?><?php endif; ?></option>
     5        <option <?php  if ( '' !== $value ) : ?>value="<?= $value; ?>"<?php endif; ?><?php if ( $selected === $value ) : ?> selected="selected"<?php endif; ?>><?php if ( ! empty( $name ) ) : ?><?= $name; ?><?php endif; ?></option>
    66    <?php endforeach; ?>
    77</select>
  • cc-redirects/trunk/uninstall.php

    r2437597 r2761725  
    22
    33/*
    4     Copyright (C) 2020 by Clearcode <https://clearcode.cc>
     4    Copyright (C) 2022 by Clearcode <https://clearcode.cc>
    55    and associates (see AUTHORS.txt file).
    66
  • cc-redirects/trunk/vendor/autoload.php

    r1849203 r2761725  
    1 <?php
    2 
    3 // autoload.php @generated by Composer
    4 
    5 require_once __DIR__ . '/composer/autoload_real.php';
    6 
    7 return ComposerAutoloaderInit9bc91c4f337f84d06d294051e80dd290::getLoader();
     1<?php return spl_autoload_register( function( string $class ) {
     2    $map = require __DIR__ . '/classmap.php';
     3    if ( isset( $map[ $class ] ) ) require dirname( __DIR__ ) . $map[ $class ];
     4} );
  • cc-redirects/trunk/vendor/clearcode/wordpress-framework/src/v3/Filterer.php

    r2437597 r2761725  
    22
    33/*
    4     Copyright (C) 2020 by Clearcode <https://clearcode.cc>
     4    Copyright (C) 2022 by Clearcode <https://clearcode.cc>
    55    and associates (see AUTHORS.txt file).
    66
     
    2222 */
    2323
    24 namespace Clearcode\Framework\v3;
     24namespace Clearcode\Redirects\Vendor\Clearcode\Framework\v3;
    2525
    2626use ReflectionClass;
  • cc-redirects/trunk/vendor/clearcode/wordpress-framework/src/v3/Plugin.php

    r2437597 r2761725  
    22
    33/*
    4     Copyright (C) 2020 by Clearcode <https://clearcode.cc>
     4    Copyright (C) 2022 by Clearcode <https://clearcode.cc>
    55    and associates (see AUTHORS.txt file).
    66
     
    2222 */
    2323
    24 namespace Clearcode\Framework\v3;
     24namespace Clearcode\Redirects\Vendor\Clearcode\Framework\v3;
    2525
    2626defined( 'ABSPATH' ) or exit;
     
    142142
    143143        public function action_init_0(){
    144             load_plugin_textdomain( static::get( 'text_domain' ), false, static::get( 'dir' ) . static::get( 'domain_path' ) );
     144            load_plugin_textdomain( static::get( 'text_domain' ), false, static::get( 'slug' ) . static::get( 'domain_path' ) );
    145145        }
    146146
  • cc-redirects/trunk/vendor/clearcode/wordpress-framework/src/v3/Singleton.php

    r2437597 r2761725  
    22
    33/*
    4     Copyright (C) 2020 by Clearcode <https://clearcode.cc>
     4    Copyright (C) 2022 by Clearcode <https://clearcode.cc>
    55    and associates (see AUTHORS.txt file).
    66
     
    2222 */
    2323
    24 namespace Clearcode\Framework\v3;
     24namespace Clearcode\Redirects\Vendor\Clearcode\Framework\v3;
    2525
    2626defined( 'ABSPATH' ) or exit;
     
    2828if ( ! trait_exists( __NAMESPACE__ . '\Singleton' ) ) {
    2929    trait Singleton {
    30         final private function __clone() {
    31             _doing_it_wrong( __METHOD__, __( 'Cheatin&#8217; uh?' ), '' );
    32         }
    33         final private function __wakeup() {
    34             _doing_it_wrong( __METHOD__, __( 'Cheatin&#8217; uh?' ), '' );
    35         }
    36        
    3730        protected function __construct() {
    3831            _doing_it_wrong( __METHOD__, __( 'Cheatin&#8217; uh?' ), '' );
Note: See TracChangeset for help on using the changeset viewer.