Changeset 3284095
- Timestamp:
- 04/29/2025 12:25:42 PM (11 months ago)
- Location:
- custom-permalinks
- Files:
-
- 4 added
- 4 deleted
- 5 edited
- 11 copied
-
tags/2.8.0 (copied) (copied from custom-permalinks/trunk)
-
tags/2.8.0/admin/class-custom-permalinks-about.php (copied) (copied from custom-permalinks/trunk/admin/class-custom-permalinks-about.php)
-
tags/2.8.0/admin/class-custom-permalinks-admin.php (copied) (copied from custom-permalinks/trunk/admin/class-custom-permalinks-admin.php)
-
tags/2.8.0/admin/class-custom-permalinks-post-types-table.php (copied) (copied from custom-permalinks/trunk/admin/class-custom-permalinks-post-types-table.php)
-
tags/2.8.0/admin/class-custom-permalinks-post-types.php (copied) (copied from custom-permalinks/trunk/admin/class-custom-permalinks-post-types.php)
-
tags/2.8.0/admin/class-custom-permalinks-taxonomies-table.php (copied) (copied from custom-permalinks/trunk/admin/class-custom-permalinks-taxonomies-table.php)
-
tags/2.8.0/assets/css/about-plugins-2.5.1.min.css (deleted)
-
tags/2.8.0/assets/css/about-plugins-2.8.0.min.css (added)
-
tags/2.8.0/assets/js/script-form-2.5.1.min.js (deleted)
-
tags/2.8.0/assets/js/script-form-2.8.0.min.js (added)
-
tags/2.8.0/custom-permalinks.php (copied) (copied from custom-permalinks/trunk/custom-permalinks.php) (2 diffs)
-
tags/2.8.0/includes/class-custom-permalinks-form.php (copied) (copied from custom-permalinks/trunk/includes/class-custom-permalinks-form.php) (6 diffs)
-
tags/2.8.0/includes/class-custom-permalinks-frontend.php (copied) (copied from custom-permalinks/trunk/includes/class-custom-permalinks-frontend.php) (7 diffs)
-
tags/2.8.0/includes/class-custom-permalinks.php (copied) (copied from custom-permalinks/trunk/includes/class-custom-permalinks.php) (1 diff)
-
tags/2.8.0/readme.txt (copied) (copied from custom-permalinks/trunk/readme.txt) (2 diffs)
-
trunk/assets/css/about-plugins-2.7.0.min.css (deleted)
-
trunk/assets/css/about-plugins-2.8.0.min.css (added)
-
trunk/assets/js/script-form-2.7.0.min.js (deleted)
-
trunk/assets/js/script-form-2.8.0.min.js (added)
-
trunk/custom-permalinks.php (modified) (2 diffs)
-
trunk/includes/class-custom-permalinks-form.php (modified) (6 diffs)
-
trunk/includes/class-custom-permalinks-frontend.php (modified) (7 diffs)
-
trunk/includes/class-custom-permalinks.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
custom-permalinks/tags/2.8.0/custom-permalinks.php
r3138206 r3284095 4 4 * Plugin URI: https://www.custompermalinks.com/ 5 5 * Description: Set custom permalinks on a per-post basis. 6 * Version: 2. 7.06 * Version: 2.8.0 7 7 * Requires at least: 2.6 8 8 * Requires PHP: 7.0 … … 20 20 /** 21 21 * Custom Permalinks - Update Permalinks of Post/Pages and Categories 22 * Copyright 2008-202 4Sami Ahmed Siddiqui <sami.siddiqui@yasglobal.com>22 * Copyright 2008-2025 Sami Ahmed Siddiqui <sami.siddiqui@yasglobal.com> 23 23 * 24 24 * 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 80 80 */ 81 81 private function exclude_custom_permalinks( $post ) { 82 $args = array(83 'public' => true,84 );85 82 $exclude_post_types = apply_filters( 86 83 'custom_permalinks_exclude_post_type', … … 97 94 $post 98 95 ); 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 } 100 112 101 113 if ( isset( $this->permalink_metabox ) && 1 === $this->permalink_metabox ) { … … 475 487 if ( 'trash' !== $post->post_status ) { 476 488 $home_url = trailingslashit( home_url() ); 477 if ( defined( 'POLYLANG_VERSION' ) ) {478 $home_url = trailingslashit( pll_home_url() );479 }480 481 489 if ( isset( $permalink ) && ! empty( $permalink ) ) { 490 if ( defined( 'POLYLANG_VERSION' ) ) { 491 $home_url = trailingslashit( pll_home_url() ); 492 } 493 482 494 $view_post_link = $home_url . $permalink; 483 495 } 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 . '?'; 489 500 if ( 'page' === $post->post_type ) { 490 501 $view_post_link .= 'page_id'; … … 494 505 $view_post_link .= 'post_type=' . $post->post_type . '&p'; 495 506 } 496 $view_post_link .= '=' . $post_id . '&preview=true'; 507 508 $view_post_link .= '=' . $post_id . '&preview=true'; 497 509 } else { 498 510 $view_post_link = $home_url . $original_permalink; … … 554 566 if ( 'trash' !== $post->post_status ) { 555 567 $home_url = trailingslashit( home_url() ); 556 if ( defined( 'POLYLANG_VERSION' ) ) {557 $home_url = trailingslashit( pll_home_url() );558 }559 560 568 if ( isset( $permalink ) && ! empty( $permalink ) ) { 569 if ( defined( 'POLYLANG_VERSION' ) ) { 570 $home_url = trailingslashit( pll_home_url() ); 571 } 572 561 573 $view_post_link = $home_url . $permalink; 562 574 } 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 . '?'; 568 579 if ( 'page' === $post->post_type ) { 569 580 $view_post_link .= 'page_id'; … … 959 970 * the default. Otherwise remove the lang code from the URL. 960 971 */ 961 if ( 1 === $polylang_config['hide_default'] ) {972 if ( true === $polylang_config['hide_default'] || 1 === $polylang_config['hide_default'] ) { 962 973 $current_language = ''; 963 974 if ( function_exists( 'pll_current_language' ) ) { -
custom-permalinks/tags/2.8.0/includes/class-custom-permalinks-frontend.php
r3138206 r3284095 41 41 */ 42 42 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; 43 50 44 51 /** … … 108 115 109 116 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; 110 150 } 111 151 … … 357 397 } 358 398 399 $request = $this->remove_page_number( $request ); 359 400 if ( ! $request ) { 360 401 return $query; … … 362 403 363 404 $ignore = apply_filters( 'custom_permalinks_request_ignore', $request ); 364 365 405 if ( '__true' === $ignore ) { 366 406 return $query; … … 572 612 $wp->matched_rule = null; 573 613 } 614 574 615 $wp->parse_request(); 575 616 $query = $wp->query_vars; 617 if ( 0 < $this->is_paged ) { 618 $query['paged'] = $this->is_paged; 619 } 620 576 621 add_filter( 'request', array( $this, 'parse_request' ) ); 577 622 … … 680 725 } 681 726 727 $request = $this->remove_page_number( $request ); 682 728 if ( ! $request ) { 683 729 return; … … 768 814 } 769 815 770 // Append any query comp enent.816 // Append any query component. 771 817 $url .= strstr( $this->request_uri, '?' ); 772 818 -
custom-permalinks/tags/2.8.0/includes/class-custom-permalinks.php
r3138206 r3284095 19 19 * @var string 20 20 */ 21 public $version = '2. 7.0';21 public $version = '2.8.0'; 22 22 23 23 /** -
custom-permalinks/tags/2.8.0/readme.txt
r3138206 r3284095 2 2 Contributors: sasiddiqui 3 3 Tags: permalink, url, link, address, redirect, custom post type 4 Tested up to: 6. 65 Stable tag: 2. 7.04 Tested up to: 6.8 5 Stable tag: 2.8.0 6 6 License: GPLv3 7 7 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 183 183 184 184 == 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. 185 193 186 194 = 2.7.0 - Aug 20, 2024 = -
custom-permalinks/trunk/custom-permalinks.php
r3138206 r3284095 4 4 * Plugin URI: https://www.custompermalinks.com/ 5 5 * Description: Set custom permalinks on a per-post basis. 6 * Version: 2. 7.06 * Version: 2.8.0 7 7 * Requires at least: 2.6 8 8 * Requires PHP: 7.0 … … 20 20 /** 21 21 * Custom Permalinks - Update Permalinks of Post/Pages and Categories 22 * Copyright 2008-202 4Sami Ahmed Siddiqui <sami.siddiqui@yasglobal.com>22 * Copyright 2008-2025 Sami Ahmed Siddiqui <sami.siddiqui@yasglobal.com> 23 23 * 24 24 * This program is free software: you can redistribute it and/or modify -
custom-permalinks/trunk/includes/class-custom-permalinks-form.php
r3138206 r3284095 80 80 */ 81 81 private function exclude_custom_permalinks( $post ) { 82 $args = array(83 'public' => true,84 );85 82 $exclude_post_types = apply_filters( 86 83 'custom_permalinks_exclude_post_type', … … 97 94 $post 98 95 ); 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 } 100 112 101 113 if ( isset( $this->permalink_metabox ) && 1 === $this->permalink_metabox ) { … … 475 487 if ( 'trash' !== $post->post_status ) { 476 488 $home_url = trailingslashit( home_url() ); 477 if ( defined( 'POLYLANG_VERSION' ) ) {478 $home_url = trailingslashit( pll_home_url() );479 }480 481 489 if ( isset( $permalink ) && ! empty( $permalink ) ) { 490 if ( defined( 'POLYLANG_VERSION' ) ) { 491 $home_url = trailingslashit( pll_home_url() ); 492 } 493 482 494 $view_post_link = $home_url . $permalink; 483 495 } 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 . '?'; 489 500 if ( 'page' === $post->post_type ) { 490 501 $view_post_link .= 'page_id'; … … 494 505 $view_post_link .= 'post_type=' . $post->post_type . '&p'; 495 506 } 496 $view_post_link .= '=' . $post_id . '&preview=true'; 507 508 $view_post_link .= '=' . $post_id . '&preview=true'; 497 509 } else { 498 510 $view_post_link = $home_url . $original_permalink; … … 554 566 if ( 'trash' !== $post->post_status ) { 555 567 $home_url = trailingslashit( home_url() ); 556 if ( defined( 'POLYLANG_VERSION' ) ) {557 $home_url = trailingslashit( pll_home_url() );558 }559 560 568 if ( isset( $permalink ) && ! empty( $permalink ) ) { 569 if ( defined( 'POLYLANG_VERSION' ) ) { 570 $home_url = trailingslashit( pll_home_url() ); 571 } 572 561 573 $view_post_link = $home_url . $permalink; 562 574 } 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 . '?'; 568 579 if ( 'page' === $post->post_type ) { 569 580 $view_post_link .= 'page_id'; … … 959 970 * the default. Otherwise remove the lang code from the URL. 960 971 */ 961 if ( 1 === $polylang_config['hide_default'] ) {972 if ( true === $polylang_config['hide_default'] || 1 === $polylang_config['hide_default'] ) { 962 973 $current_language = ''; 963 974 if ( function_exists( 'pll_current_language' ) ) { -
custom-permalinks/trunk/includes/class-custom-permalinks-frontend.php
r3138206 r3284095 41 41 */ 42 42 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; 43 50 44 51 /** … … 108 115 109 116 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; 110 150 } 111 151 … … 357 397 } 358 398 399 $request = $this->remove_page_number( $request ); 359 400 if ( ! $request ) { 360 401 return $query; … … 362 403 363 404 $ignore = apply_filters( 'custom_permalinks_request_ignore', $request ); 364 365 405 if ( '__true' === $ignore ) { 366 406 return $query; … … 572 612 $wp->matched_rule = null; 573 613 } 614 574 615 $wp->parse_request(); 575 616 $query = $wp->query_vars; 617 if ( 0 < $this->is_paged ) { 618 $query['paged'] = $this->is_paged; 619 } 620 576 621 add_filter( 'request', array( $this, 'parse_request' ) ); 577 622 … … 680 725 } 681 726 727 $request = $this->remove_page_number( $request ); 682 728 if ( ! $request ) { 683 729 return; … … 768 814 } 769 815 770 // Append any query comp enent.816 // Append any query component. 771 817 $url .= strstr( $this->request_uri, '?' ); 772 818 -
custom-permalinks/trunk/includes/class-custom-permalinks.php
r3138206 r3284095 19 19 * @var string 20 20 */ 21 public $version = '2. 7.0';21 public $version = '2.8.0'; 22 22 23 23 /** -
custom-permalinks/trunk/readme.txt
r3138206 r3284095 2 2 Contributors: sasiddiqui 3 3 Tags: permalink, url, link, address, redirect, custom post type 4 Tested up to: 6. 65 Stable tag: 2. 7.04 Tested up to: 6.8 5 Stable tag: 2.8.0 6 6 License: GPLv3 7 7 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 183 183 184 184 == 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. 185 193 186 194 = 2.7.0 - Aug 20, 2024 =
Note: See TracChangeset
for help on using the changeset viewer.