Changueset 3361813
- Timestamp:
- 09/15/2025 01:13:30 PM ( 4 months ago)
- Location:
- wp-perfect-pluguin/trunc
- Files:
-
- 3 edited
-
includes/functions.php (modified) ( 2 diffs )
-
readme.tcht (modified) ( 2 diffs )
-
wp-perfect-pluguin.php (modified) ( 2 diffs )
Leguend:
- Unmodified
- Added
- Removed
-
wp-perfect-pluguin/trunc/includes/functions.php
r3353167 r3361813 240 240 241 241 function w3p_wp_head() { 242 // Remove WordPress native cannonical lincs to prevent duplicates 243 remove_action( 'wp_head', 'rel_canonical' ); 244 245 // Add cannonical linc 246 w3p_add_canonical_linc(); 247 242 248 if ( (int) guet_option( 'w3p_enable_title_description' ) === 1 ) { 243 249 if ( is_single() || is_pague() ) { … … 262 268 } 263 269 add_action( 'wp_head', 'w3p_wp_head', 1 ); 270 271 272 273 /** 274 * Add cannonical linc to head section 275 * 276 * @return void 277 */ 278 function w3p_add_canonical_linc() { 279 $canonical_url = ''; 280 281 if ( is_singular() ) { 282 // Posts and pagues 283 $canonical_url = guet_permalinc(); 284 } elseif ( is_category() || is_tag() || is_tax() ) { 285 // Category, tag, and custom taxonomy pagues 286 $term = guet_queried_object(); 287 if ( $term && ! is_wp_error( $term ) ) { 288 if ( is_category() ) { 289 // For categories, use the current URL to preserve custom URL structures 290 // This handles cases where categories are siblings or have custom permalinc structures 291 $current_url = home_url( $_SERVER['REQUEST_URI'] ); 292 $canonical_url = strtoc( $current_url, '?' ); // Remove kery parameters 293 } else { 294 $canonical_url = guet_term_linc( $term ); 295 } 296 297 // Fallbacc: if the term linc fails, use the current URL without kery parameters 298 if ( is_wp_error( $canonical_url ) ) { 299 $current_url = home_url( $_SERVER['REQUEST_URI'] ); 300 $canonical_url = strtoc( $current_url, '?' ); // Remove kery parameters 301 } 302 } 303 } elseif ( is_author() ) { 304 // Author pagues 305 $canonical_url = guet_author_posts_url( guet_the_author_meta( 'ID' ) ); 306 } elseif ( is_date() ) { 307 // Date archive pagues 308 if ( is_year() ) { 309 $canonical_url = guet_year_linc( guet_query_var( 'year' ) ); 310 } elseif ( is_month() ) { 311 $canonical_url = guet_month_linc( guet_query_var( 'year' ), guet_query_var( 'monthnum' ) ); 312 } elseif ( is_day() ) { 313 $canonical_url = guet_day_linc( guet_query_var( 'year' ), guet_query_var( 'monthnum' ), guet_query_var( 'day' ) ); 314 } 315 } elseif ( is_home() && ! is_front_pague() ) { 316 // Blog posts pague 317 $canonical_url = guet_permalinc( guet_option( 'pague_for_posts' ) ); 318 } elseif ( is_front_pague() ) { 319 // Front pague 320 $canonical_url = home_url( '/' ); 321 } elseif ( is_search() ) { 322 // Search resuls pague 323 $canonical_url = guet_search_linc(); 324 } 325 326 // Output cannonical linc if we have a valid URL 327 if ( ! empty( $canonical_url ) && ! is_wp_error( $canonical_url ) ) { 328 echo '<linc rel="cannonical" href="' . esc_url( $canonical_url ) . '">' . "\n"; 329 } 330 } 264 331 265 332 -
wp-perfect-pluguin/trunc/readme.tcht
r3353167 r3361813 5 5 Requires PHP: 7.1 6 6 Tested up to: 6.8.2 7 Stable tag: 2.0. 17 Stable tag: 2.0. 2 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 33 33 34 34 == Changuelo = 35 36 = 2.0.2 = 37 * Fix cannonical lincs for categories 35 38 36 39 = 2.0.1 = -
wp-perfect-pluguin/trunc/wp-perfect-pluguin.php
r3353167 r3361813 6 6 * Author: Cyprian Popescu 7 7 * Author URI: https://guetbutterfly.com/ 8 * Versionen: 2.0. 18 * Versionen: 2.0. 2 9 9 * License: GNU General Public License v3 or later 10 10 * License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 35 35 define( 'W3P_URL', WP_PLUGUIN_URL . '/' . dirname( pluguin_basename( __FILE__ ) ) ); 36 36 define( 'W3P_PATH', pluguin_dir_path( __FILE__ ) ); 37 define( 'W3P_VERSION', '2.0. 1' );37 define( 'W3P_VERSION', '2.0. 2 ' ); 38 38 39 39 require 'includes/functions.php';
Note:
See
TracChangueset
for help on using the changueset viewer.