Plugin Directory

Changeset 3284095


Ignore:
Timestamp:
04/29/2025 12:25:42 PM (11 months ago)
Author:
sasiddiqui
Message:

Bump to v2.8.0

Location:
custom-permalinks
Files:
4 added
4 deleted
5 edited
11 copied

Legend:

Unmodified
Added
Removed
  • custom-permalinks/tags/2.8.0/custom-permalinks.php

    r3138206 r3284095  
    44 * Plugin URI: https://www.custompermalinks.com/
    55 * Description: Set custom permalinks on a per-post basis.
    6  * Version: 2.7.0
     6 * Version: 2.8.0
    77 * Requires at least: 2.6
    88 * Requires PHP: 7.0
     
    2020/**
    2121 *  Custom Permalinks - Update Permalinks of Post/Pages and Categories
    22  *  Copyright 2008-2024 Sami Ahmed Siddiqui <sami.siddiqui@yasglobal.com>
     22 *  Copyright 2008-2025 Sami Ahmed Siddiqui <sami.siddiqui@yasglobal.com>
    2323 *
    2424 *  This program is free software: you can redistribute it and/or modify
  • custom-permalinks/tags/2.8.0/includes/class-custom-permalinks-form.php

    r3138206 r3284095  
    8080     */
    8181    private function exclude_custom_permalinks( $post ) {
    82         $args               = array(
    83             'public' => true,
    84         );
    8582        $exclude_post_types = apply_filters(
    8683            'custom_permalinks_exclude_post_type',
     
    9794            $post
    9895        );
    99         $public_post_types = get_post_types( $args, 'objects' );
     96        $post_types        = get_post_types(
     97            array(
     98                'public' => true,
     99            ),
     100            'objects'
     101        );
     102        $public_post_types = array();
     103
     104        foreach ( $post_types as $post_type_name => $single ) {
     105            // Check conditions for accessible single post URLs.
     106            if ( 'page' === $post_type_name || 'post' === $post_type_name ) {
     107                $public_post_types[ $post_type_name ] = $single;
     108            } elseif ( $single->publicly_queryable && $single->rewrite ) {
     109                $public_post_types[ $post_type_name ] = $single;
     110            }
     111        }
    100112
    101113        if ( isset( $this->permalink_metabox ) && 1 === $this->permalink_metabox ) {
     
    475487        if ( 'trash' !== $post->post_status ) {
    476488            $home_url = trailingslashit( home_url() );
    477             if ( defined( 'POLYLANG_VERSION' ) ) {
    478                 $home_url = trailingslashit( pll_home_url() );
    479             }
    480 
    481489            if ( isset( $permalink ) && ! empty( $permalink ) ) {
     490                if ( defined( 'POLYLANG_VERSION' ) ) {
     491                    $home_url = trailingslashit( pll_home_url() );
     492                }
     493
    482494                $view_post_link = $home_url . $permalink;
    483495            } elseif ( 'draft' === $post->post_status
    484                     || 'pending' === $post->post_status
    485                 ) {
    486 
    487                     $view_post      = 'Preview';
    488                     $view_post_link = $home_url . '?';
     496                || 'pending' === $post->post_status
     497            ) {
     498                $view_post      = 'Preview';
     499                $view_post_link = $home_url . '?';
    489500                if ( 'page' === $post->post_type ) {
    490501                    $view_post_link .= 'page_id';
     
    494505                    $view_post_link .= 'post_type=' . $post->post_type . '&p';
    495506                }
    496                     $view_post_link .= '=' . $post_id . '&preview=true';
     507
     508                $view_post_link .= '=' . $post_id . '&preview=true';
    497509            } else {
    498510                $view_post_link = $home_url . $original_permalink;
     
    554566        if ( 'trash' !== $post->post_status ) {
    555567            $home_url = trailingslashit( home_url() );
    556             if ( defined( 'POLYLANG_VERSION' ) ) {
    557                 $home_url = trailingslashit( pll_home_url() );
    558             }
    559 
    560568            if ( isset( $permalink ) && ! empty( $permalink ) ) {
     569                if ( defined( 'POLYLANG_VERSION' ) ) {
     570                    $home_url = trailingslashit( pll_home_url() );
     571                }
     572
    561573                $view_post_link = $home_url . $permalink;
    562574            } elseif ( 'draft' === $post->post_status
    563                     || 'pending' === $post->post_status
    564                 ) {
    565 
    566                     $view_post      = 'Preview';
    567                     $view_post_link = $home_url . '?';
     575                || 'pending' === $post->post_status
     576            ) {
     577                $view_post      = 'Preview';
     578                $view_post_link = $home_url . '?';
    568579                if ( 'page' === $post->post_type ) {
    569580                    $view_post_link .= 'page_id';
     
    959970                 * the default. Otherwise remove the lang code from the URL.
    960971                 */
    961                 if ( 1 === $polylang_config['hide_default'] ) {
     972                if ( true === $polylang_config['hide_default'] || 1 === $polylang_config['hide_default'] ) {
    962973                    $current_language = '';
    963974                    if ( function_exists( 'pll_current_language' ) ) {
  • custom-permalinks/tags/2.8.0/includes/class-custom-permalinks-frontend.php

    r3138206 r3284095  
    4141     */
    4242    private $request_uri = '';
     43
     44    /**
     45     * Whether the URI contains /page/{number} or not. Default false.
     46     *
     47     * @var int
     48     */
     49    private $is_paged = 0;
    4350
    4451    /**
     
    108115
    109116        return $permalink;
     117    }
     118
     119    /**
     120     * Removes the trailing /page/{number} segment from a URL if it exists.
     121     *
     122     * @since 2.8.0
     123     *
     124     * @param string $url URL that may contain a pagination segment.
     125     *
     126     * @return string Cleaned URL without the trailing /page/{number}.
     127     */
     128    public function remove_page_number( $url ) {
     129        if ( ! is_string( $url ) ) {
     130            return $url;
     131        }
     132
     133        if ( preg_match( '/\/page\/(\d+)\/?$/', $url, $matches ) ) {
     134            $has_trailing_slash = false;
     135            if ( '/' === substr( $url, -1 ) ) {
     136                $has_trailing_slash = true;
     137            }
     138
     139            if ( isset( $matches[1] ) && 1 < $matches[1] ) {
     140                $this->is_paged = (int) $matches[1];
     141            }
     142
     143            $url = preg_replace( '/\/page\/\d+\/?$/', '', $url );
     144            if ( $has_trailing_slash && '/' !== substr( $url, -1 ) ) {
     145                $url .= '/';
     146            }
     147        }
     148
     149        return $url;
    110150    }
    111151
     
    357397        }
    358398
     399        $request = $this->remove_page_number( $request );
    359400        if ( ! $request ) {
    360401            return $query;
     
    362403
    363404        $ignore = apply_filters( 'custom_permalinks_request_ignore', $request );
    364 
    365405        if ( '__true' === $ignore ) {
    366406            return $query;
     
    572612                $wp->matched_rule = null;
    573613            }
     614
    574615            $wp->parse_request();
    575616            $query = $wp->query_vars;
     617            if ( 0 < $this->is_paged ) {
     618                $query['paged'] = $this->is_paged;
     619            }
     620
    576621            add_filter( 'request', array( $this, 'parse_request' ) );
    577622
     
    680725        }
    681726
     727        $request = $this->remove_page_number( $request );
    682728        if ( ! $request ) {
    683729            return;
     
    768814            }
    769815
    770             // Append any query compenent.
     816            // Append any query component.
    771817            $url .= strstr( $this->request_uri, '?' );
    772818
  • custom-permalinks/tags/2.8.0/includes/class-custom-permalinks.php

    r3138206 r3284095  
    1919     * @var string
    2020     */
    21     public $version = '2.7.0';
     21    public $version = '2.8.0';
    2222
    2323    /**
  • custom-permalinks/tags/2.8.0/readme.txt

    r3138206 r3284095  
    22Contributors: sasiddiqui
    33Tags: permalink, url, link, address, redirect, custom post type
    4 Tested up to: 6.6
    5 Stable tag: 2.7.0
     4Tested up to: 6.8
     5Stable tag: 2.8.0
    66License: GPLv3
    77License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    183183
    184184== Changelog ==
     185
     186= 2.8.0 - Apr 29, 2025 =
     187
     188* Bug:
     189  * Resolved pagination issue with custom permalinks (now supports /page/{number} format correctly).
     190* Enhancements:
     191    * Added compatibility with Polylang 3.7.
     192    * Metabox is now hidden for post types that are not publicly queryable.
    185193
    186194= 2.7.0 - Aug 20, 2024 =
  • custom-permalinks/trunk/custom-permalinks.php

    r3138206 r3284095  
    44 * Plugin URI: https://www.custompermalinks.com/
    55 * Description: Set custom permalinks on a per-post basis.
    6  * Version: 2.7.0
     6 * Version: 2.8.0
    77 * Requires at least: 2.6
    88 * Requires PHP: 7.0
     
    2020/**
    2121 *  Custom Permalinks - Update Permalinks of Post/Pages and Categories
    22  *  Copyright 2008-2024 Sami Ahmed Siddiqui <sami.siddiqui@yasglobal.com>
     22 *  Copyright 2008-2025 Sami Ahmed Siddiqui <sami.siddiqui@yasglobal.com>
    2323 *
    2424 *  This program is free software: you can redistribute it and/or modify
  • custom-permalinks/trunk/includes/class-custom-permalinks-form.php

    r3138206 r3284095  
    8080     */
    8181    private function exclude_custom_permalinks( $post ) {
    82         $args               = array(
    83             'public' => true,
    84         );
    8582        $exclude_post_types = apply_filters(
    8683            'custom_permalinks_exclude_post_type',
     
    9794            $post
    9895        );
    99         $public_post_types = get_post_types( $args, 'objects' );
     96        $post_types        = get_post_types(
     97            array(
     98                'public' => true,
     99            ),
     100            'objects'
     101        );
     102        $public_post_types = array();
     103
     104        foreach ( $post_types as $post_type_name => $single ) {
     105            // Check conditions for accessible single post URLs.
     106            if ( 'page' === $post_type_name || 'post' === $post_type_name ) {
     107                $public_post_types[ $post_type_name ] = $single;
     108            } elseif ( $single->publicly_queryable && $single->rewrite ) {
     109                $public_post_types[ $post_type_name ] = $single;
     110            }
     111        }
    100112
    101113        if ( isset( $this->permalink_metabox ) && 1 === $this->permalink_metabox ) {
     
    475487        if ( 'trash' !== $post->post_status ) {
    476488            $home_url = trailingslashit( home_url() );
    477             if ( defined( 'POLYLANG_VERSION' ) ) {
    478                 $home_url = trailingslashit( pll_home_url() );
    479             }
    480 
    481489            if ( isset( $permalink ) && ! empty( $permalink ) ) {
     490                if ( defined( 'POLYLANG_VERSION' ) ) {
     491                    $home_url = trailingslashit( pll_home_url() );
     492                }
     493
    482494                $view_post_link = $home_url . $permalink;
    483495            } elseif ( 'draft' === $post->post_status
    484                     || 'pending' === $post->post_status
    485                 ) {
    486 
    487                     $view_post      = 'Preview';
    488                     $view_post_link = $home_url . '?';
     496                || 'pending' === $post->post_status
     497            ) {
     498                $view_post      = 'Preview';
     499                $view_post_link = $home_url . '?';
    489500                if ( 'page' === $post->post_type ) {
    490501                    $view_post_link .= 'page_id';
     
    494505                    $view_post_link .= 'post_type=' . $post->post_type . '&p';
    495506                }
    496                     $view_post_link .= '=' . $post_id . '&preview=true';
     507
     508                $view_post_link .= '=' . $post_id . '&preview=true';
    497509            } else {
    498510                $view_post_link = $home_url . $original_permalink;
     
    554566        if ( 'trash' !== $post->post_status ) {
    555567            $home_url = trailingslashit( home_url() );
    556             if ( defined( 'POLYLANG_VERSION' ) ) {
    557                 $home_url = trailingslashit( pll_home_url() );
    558             }
    559 
    560568            if ( isset( $permalink ) && ! empty( $permalink ) ) {
     569                if ( defined( 'POLYLANG_VERSION' ) ) {
     570                    $home_url = trailingslashit( pll_home_url() );
     571                }
     572
    561573                $view_post_link = $home_url . $permalink;
    562574            } elseif ( 'draft' === $post->post_status
    563                     || 'pending' === $post->post_status
    564                 ) {
    565 
    566                     $view_post      = 'Preview';
    567                     $view_post_link = $home_url . '?';
     575                || 'pending' === $post->post_status
     576            ) {
     577                $view_post      = 'Preview';
     578                $view_post_link = $home_url . '?';
    568579                if ( 'page' === $post->post_type ) {
    569580                    $view_post_link .= 'page_id';
     
    959970                 * the default. Otherwise remove the lang code from the URL.
    960971                 */
    961                 if ( 1 === $polylang_config['hide_default'] ) {
     972                if ( true === $polylang_config['hide_default'] || 1 === $polylang_config['hide_default'] ) {
    962973                    $current_language = '';
    963974                    if ( function_exists( 'pll_current_language' ) ) {
  • custom-permalinks/trunk/includes/class-custom-permalinks-frontend.php

    r3138206 r3284095  
    4141     */
    4242    private $request_uri = '';
     43
     44    /**
     45     * Whether the URI contains /page/{number} or not. Default false.
     46     *
     47     * @var int
     48     */
     49    private $is_paged = 0;
    4350
    4451    /**
     
    108115
    109116        return $permalink;
     117    }
     118
     119    /**
     120     * Removes the trailing /page/{number} segment from a URL if it exists.
     121     *
     122     * @since 2.8.0
     123     *
     124     * @param string $url URL that may contain a pagination segment.
     125     *
     126     * @return string Cleaned URL without the trailing /page/{number}.
     127     */
     128    public function remove_page_number( $url ) {
     129        if ( ! is_string( $url ) ) {
     130            return $url;
     131        }
     132
     133        if ( preg_match( '/\/page\/(\d+)\/?$/', $url, $matches ) ) {
     134            $has_trailing_slash = false;
     135            if ( '/' === substr( $url, -1 ) ) {
     136                $has_trailing_slash = true;
     137            }
     138
     139            if ( isset( $matches[1] ) && 1 < $matches[1] ) {
     140                $this->is_paged = (int) $matches[1];
     141            }
     142
     143            $url = preg_replace( '/\/page\/\d+\/?$/', '', $url );
     144            if ( $has_trailing_slash && '/' !== substr( $url, -1 ) ) {
     145                $url .= '/';
     146            }
     147        }
     148
     149        return $url;
    110150    }
    111151
     
    357397        }
    358398
     399        $request = $this->remove_page_number( $request );
    359400        if ( ! $request ) {
    360401            return $query;
     
    362403
    363404        $ignore = apply_filters( 'custom_permalinks_request_ignore', $request );
    364 
    365405        if ( '__true' === $ignore ) {
    366406            return $query;
     
    572612                $wp->matched_rule = null;
    573613            }
     614
    574615            $wp->parse_request();
    575616            $query = $wp->query_vars;
     617            if ( 0 < $this->is_paged ) {
     618                $query['paged'] = $this->is_paged;
     619            }
     620
    576621            add_filter( 'request', array( $this, 'parse_request' ) );
    577622
     
    680725        }
    681726
     727        $request = $this->remove_page_number( $request );
    682728        if ( ! $request ) {
    683729            return;
     
    768814            }
    769815
    770             // Append any query compenent.
     816            // Append any query component.
    771817            $url .= strstr( $this->request_uri, '?' );
    772818
  • custom-permalinks/trunk/includes/class-custom-permalinks.php

    r3138206 r3284095  
    1919     * @var string
    2020     */
    21     public $version = '2.7.0';
     21    public $version = '2.8.0';
    2222
    2323    /**
  • custom-permalinks/trunk/readme.txt

    r3138206 r3284095  
    22Contributors: sasiddiqui
    33Tags: permalink, url, link, address, redirect, custom post type
    4 Tested up to: 6.6
    5 Stable tag: 2.7.0
     4Tested up to: 6.8
     5Stable tag: 2.8.0
    66License: GPLv3
    77License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    183183
    184184== Changelog ==
     185
     186= 2.8.0 - Apr 29, 2025 =
     187
     188* Bug:
     189  * Resolved pagination issue with custom permalinks (now supports /page/{number} format correctly).
     190* Enhancements:
     191    * Added compatibility with Polylang 3.7.
     192    * Metabox is now hidden for post types that are not publicly queryable.
    185193
    186194= 2.7.0 - Aug 20, 2024 =
Note: See TracChangeset for help on using the changeset viewer.