Changeset 3458320
- Timestamp:
- 02/10/2026 06:01:59 PM (7 weeks ago)
- Location:
- wp-perfect-plugin/trunk
- Files:
-
- 3 edited
-
includes/functions.php (modified) (9 diffs)
-
readme.txt (modified) (2 diffs)
-
wp-perfect-plugin.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-perfect-plugin/trunk/includes/functions.php
r3441000 r3458320 167 167 168 168 // Cache function_exists() results to avoid repeated checks 169 static $has_edd = null;170 static $has_wc = null;169 static $has_edd = null; 170 static $has_wc = null; 171 171 static $has_mepr = null; 172 172 … … 279 279 280 280 // Fallback: Generate excerpt from content (only if excerpt is empty) 281 // Use wp_trim_words() directly on post_content for better performance 282 $content = $post->post_content; 283 $content = strip_shortcodes( $content ); 284 $content = wp_strip_all_tags( $content ); 285 $excerpt = wp_trim_words( $content, 55, '...' ); 281 // Use character limit (155) instead of word count for SEO meta descriptions 282 $content = strip_shortcodes( $post->post_content ); 283 $content = sanitize_text_field( $content ); 284 $content = str_replace( [ ' ', "\xC2\xA0" ], ' ', $content ); // Remove entities and UTF-8 non-breaking spaces 285 286 // Trim to 155 characters (recommended meta description length) 287 if ( mb_strlen( $content ) > 155 ) { 288 $excerpt = mb_substr( $content, 0, 155 ) . '...'; 289 } else { 290 $excerpt = $content; 291 } 286 292 287 293 return esc_attr( $excerpt ); … … 349 355 // For categories, use the current URL to preserve custom URL structures 350 356 // This handles cases where categories are siblings or have custom permalink structures 351 $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '';352 $current_url = home_url( $request_uri );357 $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : ''; 358 $current_url = home_url( $request_uri ); 353 359 $canonical_url = strtok( $current_url, '?' ); // Remove query parameters 354 360 } else { … … 358 364 // Fallback: if the term link fails, use the current URL without query parameters 359 365 if ( is_wp_error( $canonical_url ) ) { 360 $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '';361 $current_url = home_url( $request_uri );366 $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : ''; 367 $current_url = home_url( $request_uri ); 362 368 $canonical_url = strtok( $current_url, '?' ); // Remove query parameters 363 369 } … … 375 381 $canonical_url = get_year_link( $year ); 376 382 } elseif ( is_month() ) { 377 $monthnum = get_query_var( 'monthnum' );383 $monthnum = get_query_var( 'monthnum' ); 378 384 $canonical_url = get_month_link( $year, $monthnum ); 379 385 } elseif ( is_day() ) { 380 $monthnum = get_query_var( 'monthnum' );381 $day = get_query_var( 'day' );386 $monthnum = get_query_var( 'monthnum' ); 387 $day = get_query_var( 'day' ); 382 388 $canonical_url = get_day_link( $year, $monthnum, $day ); 383 389 } … … 435 441 if ( $w3p_kg_logo ) { 436 442 // Transient key based on logo URL hash 437 $transient_key = 'w3p_kg_logo_dimensions_' . md5( $w3p_kg_logo );443 $transient_key = 'w3p_kg_logo_dimensions_' . md5( $w3p_kg_logo ); 438 444 $cached_dimensions = get_transient( $transient_key ); 439 445 440 446 if ( false !== $cached_dimensions ) { 441 447 // Use cached dimensions … … 445 451 // Try to get attachment ID from URL (expensive query - cache the result) 446 452 $attachment_id_transient_key = 'w3p_kg_logo_attachment_id_' . md5( $w3p_kg_logo ); 447 $attachment_id = get_transient( $attachment_id_transient_key );448 453 $attachment_id = get_transient( $attachment_id_transient_key ); 454 449 455 if ( false === $attachment_id ) { 450 456 // Only call attachment_url_to_postid if not in transient (expensive query) … … 453 459 set_transient( $attachment_id_transient_key, $attachment_id, WEEK_IN_SECONDS ); 454 460 } 455 461 456 462 if ( $attachment_id ) { 457 463 // Get dimensions from attachment metadata (stored in database) … … 462 468 } 463 469 } 464 470 465 471 // Cache dimensions for 7 days 466 set_transient( $transient_key, [ 467 'width' => $w3p_kg_logo_width, 468 'height' => $w3p_kg_logo_height, 469 ], WEEK_IN_SECONDS ); 472 set_transient( 473 $transient_key, 474 [ 475 'width' => $w3p_kg_logo_width, 476 'height' => $w3p_kg_logo_height, 477 ], 478 WEEK_IN_SECONDS 479 ); 470 480 } 471 481 } -
wp-perfect-plugin/trunk/readme.txt
r3441000 r3458320 4 4 Requires at least: 5.7 5 5 Requires PHP: 7.1 6 Tested up to: 6.9 7 Stable tag: 2.1. 16 Tested up to: 6.9.1 7 Stable tag: 2.1.2 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 33 33 34 34 == Changelog = 35 36 = 2.1.2 = 37 * FIX: Change excerpt generation from 55 words to 155 characters for proper SEO meta description length 38 * FIX: Add sanitization and removal of non-breaking spaces ( ) from meta descriptions 35 39 36 40 = 2.1.1 = -
wp-perfect-plugin/trunk/wp-perfect-plugin.php
r3441000 r3458320 6 6 * Author: Ciprian Popescu 7 7 * Author URI: https://getbutterfly.com/ 8 * Version: 2.1. 18 * Version: 2.1.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_PLUGIN_URL . '/' . dirname( plugin_basename( __FILE__ ) ) ); 36 36 define( 'W3P_PATH', plugin_dir_path( __FILE__ ) ); 37 define( 'W3P_VERSION', '2.1. 1' );37 define( 'W3P_VERSION', '2.1.2' ); 38 38 39 39 require 'includes/functions.php';
Note: See TracChangeset
for help on using the changeset viewer.