Plugin Directory

Changeset 3085800


Ignore:
Timestamp:
05/13/2024 12:24:53 PM (23 months ago)
Author:
camthor
Message:

version 0.24.0

Location:
redirect-url-to-post
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • redirect-url-to-post/tags/0.24.0/readme.txt

    r3048291 r3085800  
    44Tags: redirect, random, recent, random post, filter
    55Requires at least: 4.9
    6 Tested up to: 6.4.3
    7 Stable tag: 0.23.0
     6Tested up to: 6.5.3
     7Stable tag: 0.24.0
    88Requires PHP: 7.4
    99License: GPLv3
     
    136136== Changelog ==
    137137
     138### 0.24.0 ###
     139
     140= Features =
     141
     142* New query parameters to search for custom fields (post meta): `meta_key`, `meta_value`, `meta_value_num` and `meta_compare`
     143* New parameter `loop=1` in connection with `redirect_to=prev` or `redirect_to=next` to loop back to the last or first post at the end
     144
    138145### 0.23.0 ###
    139146
  • redirect-url-to-post/tags/0.24.0/redirect-url-to-post.php

    r2962112 r3085800  
    66Author: Christoph Amthor
    77Author URI: https://chattymango.com/
    8 Version: 0.23.0
     8Version: 0.24.0
    99License: GNU GENERAL PUBLIC LICENSE, Version 3
    1010Text Domain: redirect-url-to-post
     
    158158   */
    159159  private $each_once;
     160
     161
     162  /**
     163   * For prev and next, return to the beginning when done
     164   *
     165   * @var boolean
     166   */
     167  private $loop;
    160168
    161169  /**
     
    502510     * Construct the 'date_query' array for redirecting to previous or next
    503511     */
    504 
    505512    if ( ! empty( $date_query_items ) ) {
    506513
     
    563570      'include',
    564571      'minute',
     572      'meta_key',
     573      'meta_value',
     574      'meta_value_num',
     575      'meta_compare',
    565576      'monthnum',
    566577      'order',
     
    772783     * Special processing for comment count
    773784     */
    774 
    775785    if ( isset( $_GET['comment_count'] ) ) {
    776786
     
    801811     * Parameters that set properties
    802812     */
    803 
    804813    if ( isset( $_GET['each_once'] ) ) {
    805814
     
    811820
    812821      $this->each_once = false;
     822
     823    }
     824
     825    if ( isset( $_GET['loop'] ) && ( 'prev' === $this->redirect_to || 'next' === $this->redirect_to ) ) {
     826
     827      $this->loop = (bool) $_GET['loop'];
     828
     829      $this->maybe_add_debug_message( __( 'Looping back to the start when done.', 'redirect-url-to-post' ) );
     830
     831    } else {
     832
     833      $this->loop = false;
    813834
    814835    }
     
    10681089      }
    10691090
     1091    } elseif ($this->loop) {
     1092
     1093      if ('prev' === $this->redirect_to) {
     1094
     1095        if ( $this->debug_mode ) {
     1096       
     1097          $this->add_debug_message( __( 'We are looping back to the last post.', 'redirect-url-to-post' ) );
     1098
     1099          $this->output_debug_messages();
     1100
     1101          exit;
     1102
     1103        }
     1104
     1105        $this->redirection_target = add_query_arg( array( 'redirect_to' => 'last' ) );
     1106
     1107        header( 'Cache-Control: no-cache, must-revalidate' );
     1108        header( 'Location: ' . $this->redirection_target, true, 307 );
     1109       
     1110        exit;
     1111
     1112      } elseif ('next' === $this->redirect_to) {
     1113
     1114        if ( $this->debug_mode ) {
     1115
     1116          $this->add_debug_message( __( 'We are looping back to the first post.', 'redirect-url-to-post' ) );
     1117
     1118          $this->output_debug_messages();
     1119
     1120          exit;
     1121
     1122        }
     1123
     1124        $this->redirection_target = add_query_arg( array('redirect_to' => 'first') );
     1125
     1126        header( 'Cache-Control: no-cache, must-revalidate' );
     1127        header( 'Location: ' . $this->redirection_target, true, 307 );
     1128
     1129        exit;
     1130
     1131      }
    10701132    }
    10711133
  • redirect-url-to-post/trunk/readme.txt

    r3048291 r3085800  
    44Tags: redirect, random, recent, random post, filter
    55Requires at least: 4.9
    6 Tested up to: 6.4.3
    7 Stable tag: 0.23.0
     6Tested up to: 6.5.3
     7Stable tag: 0.24.0
    88Requires PHP: 7.4
    99License: GPLv3
     
    136136== Changelog ==
    137137
     138### 0.24.0 ###
     139
     140= Features =
     141
     142* New query parameters to search for custom fields (post meta): `meta_key`, `meta_value`, `meta_value_num` and `meta_compare`
     143* New parameter `loop=1` in connection with `redirect_to=prev` or `redirect_to=next` to loop back to the last or first post at the end
     144
    138145### 0.23.0 ###
    139146
  • redirect-url-to-post/trunk/redirect-url-to-post.php

    r2962112 r3085800  
    66Author: Christoph Amthor
    77Author URI: https://chattymango.com/
    8 Version: 0.23.0
     8Version: 0.24.0
    99License: GNU GENERAL PUBLIC LICENSE, Version 3
    1010Text Domain: redirect-url-to-post
     
    158158   */
    159159  private $each_once;
     160
     161
     162  /**
     163   * For prev and next, return to the beginning when done
     164   *
     165   * @var boolean
     166   */
     167  private $loop;
    160168
    161169  /**
     
    502510     * Construct the 'date_query' array for redirecting to previous or next
    503511     */
    504 
    505512    if ( ! empty( $date_query_items ) ) {
    506513
     
    563570      'include',
    564571      'minute',
     572      'meta_key',
     573      'meta_value',
     574      'meta_value_num',
     575      'meta_compare',
    565576      'monthnum',
    566577      'order',
     
    772783     * Special processing for comment count
    773784     */
    774 
    775785    if ( isset( $_GET['comment_count'] ) ) {
    776786
     
    801811     * Parameters that set properties
    802812     */
    803 
    804813    if ( isset( $_GET['each_once'] ) ) {
    805814
     
    811820
    812821      $this->each_once = false;
     822
     823    }
     824
     825    if ( isset( $_GET['loop'] ) && ( 'prev' === $this->redirect_to || 'next' === $this->redirect_to ) ) {
     826
     827      $this->loop = (bool) $_GET['loop'];
     828
     829      $this->maybe_add_debug_message( __( 'Looping back to the start when done.', 'redirect-url-to-post' ) );
     830
     831    } else {
     832
     833      $this->loop = false;
    813834
    814835    }
     
    10681089      }
    10691090
     1091    } elseif ($this->loop) {
     1092
     1093      if ('prev' === $this->redirect_to) {
     1094
     1095        if ( $this->debug_mode ) {
     1096       
     1097          $this->add_debug_message( __( 'We are looping back to the last post.', 'redirect-url-to-post' ) );
     1098
     1099          $this->output_debug_messages();
     1100
     1101          exit;
     1102
     1103        }
     1104
     1105        $this->redirection_target = add_query_arg( array( 'redirect_to' => 'last' ) );
     1106
     1107        header( 'Cache-Control: no-cache, must-revalidate' );
     1108        header( 'Location: ' . $this->redirection_target, true, 307 );
     1109       
     1110        exit;
     1111
     1112      } elseif ('next' === $this->redirect_to) {
     1113
     1114        if ( $this->debug_mode ) {
     1115
     1116          $this->add_debug_message( __( 'We are looping back to the first post.', 'redirect-url-to-post' ) );
     1117
     1118          $this->output_debug_messages();
     1119
     1120          exit;
     1121
     1122        }
     1123
     1124        $this->redirection_target = add_query_arg( array('redirect_to' => 'first') );
     1125
     1126        header( 'Cache-Control: no-cache, must-revalidate' );
     1127        header( 'Location: ' . $this->redirection_target, true, 307 );
     1128
     1129        exit;
     1130
     1131      }
    10701132    }
    10711133
Note: See TracChangeset for help on using the changeset viewer.