Changeset 3482248
- Timestamp:
- 03/13/2026 08:00:12 PM (2 weeks ago)
- Location:
- dropinblog/trunk
- Files:
-
- 3 edited
-
classes/rendering.php (modified) (3 diffs)
-
dropinblog.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dropinblog/trunk/classes/rendering.php
r3481598 r3482248 34 34 35 35 $request_uri = isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : ''; 36 if (strpos($request_uri, '/' . $this->assigned_page->post_name) === false) { 36 $request_path = wp_parse_url($request_uri, PHP_URL_PATH); 37 $base_slug = '/' . $this->assigned_page->post_name; 38 39 if (strpos($request_path, $base_slug) !== 0) { 40 return; 41 } 42 43 // Reject wrong trailing slash on the base URL (let WordPress redirect) 44 $remainder = substr($request_path, strlen($base_slug)); 45 $uses_trailing_slashes = substr(get_option('permalink_structure'), -1) === '/'; 46 $correct_base = $uses_trailing_slashes ? $base_slug . '/' : $base_slug; 47 if (($remainder === '' || $remainder === '/') && $request_path !== $correct_base) { 37 48 return; 38 49 } … … 114 125 public function render_redirect() 115 126 { 127 // Redirect wrong trailing slash on sub-paths (not real WP posts, so WP won't handle) 128 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'GET') { 129 $request_uri = isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : ''; 130 $path = wp_parse_url($request_uri, PHP_URL_PATH); 131 if ($path && !str_contains(basename($path), '.')) { 132 $correct_path = user_trailingslashit($path); 133 if ($path !== $correct_path) { 134 $query_string = wp_parse_url($request_uri, PHP_URL_QUERY); 135 wp_redirect($correct_path . ($query_string ? '?' . $query_string : ''), 301); 136 exit; 137 } 138 } 139 } 140 116 141 if ($this->is_full_type) { 117 142 if ($this->is_full_type === 'sitemap') { … … 363 388 public function get_url_subsegments($base_slug = '') 364 389 { 365 // Safely get REQUEST_URI366 390 $request_uri = isset($_SERVER['REQUEST_URI']) 367 391 ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) 368 392 : ''; 369 393 370 // Strip base path 371 $path = str_replace($base_slug, '', wp_parse_url($request_uri, PHP_URL_PATH)); 372 373 // Build parts 374 $path_parts = explode('/', $path); 375 if (end($path_parts) === '') { 376 array_pop($path_parts); 377 } 378 379 return $path_parts; 394 $path = wp_parse_url($request_uri, PHP_URL_PATH); 395 396 // Strip base path (handle with or without trailing slash) 397 $base_no_slash = rtrim($base_slug, '/'); 398 if (strpos($path, $base_no_slash) === 0) { 399 $path = substr($path, strlen($base_no_slash)); 400 } 401 402 // Build parts from remaining path 403 $path = trim($path, '/'); 404 if ($path === '' || $path === false) { 405 return []; 406 } 407 408 return explode('/', $path); 380 409 } 381 410 -
dropinblog/trunk/dropinblog.php
r3481598 r3482248 4 4 Plugin URI: https://dropinblog.com 5 5 Description: Embed and display your DropInBlog seamlessly within WordPress with full SEO support. 6 Version: 1.0. 36 Version: 1.0.4 7 7 License: GPL v2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
dropinblog/trunk/readme.txt
r3481598 r3482248 4 4 Tested up to: 6.9 5 5 Requires at least PHP: 8.0 6 Stable tag: 1.0. 36 Stable tag: 1.0.4 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 43 43 == Changelog == 44 44 45 = 1.0.4 = 46 * Fixed trailing slash handling for blog sub-paths to match WordPress permalink settings 47 45 48 = 1.0.3 = 46 49 * Enqueue external scripts via wp_enqueue_script for better compatibility with caching and optimization plugins … … 56 59 57 60 == Upgrade Notice == 61 62 = 1.0.4 = 63 Fixes trailing slash redirects on blog post URLs to match your WordPress permalink settings. 58 64 59 65 = 1.0.3 =
Note: See TracChangeset
for help on using the changeset viewer.