Changeset 3490343
- Timestamp:
- 03/24/2026 08:18:09 PM (4 days ago)
- Location:
- janzeman-shared-albums-for-google-photos/trunk
- Files:
-
- 4 edited
-
includes/class-orchestrator.php (modified) (8 diffs)
-
includes/class-settings-page.php (modified) (2 diffs)
-
janzeman-shared-albums-for-google-photos.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
janzeman-shared-albums-for-google-photos/trunk/includes/class-orchestrator.php
r3489427 r3490343 11 11 * - Tracks cache expiration separately in wp_options 12 12 * - Allows same album to be reused across multiple posts 13 * - Invalidates cache if CACHE_DURATION constantchanges13 * - Invalidates cache if cache-refresh interval changes 14 14 * 15 15 * @package JZSA_Shared_Albums … … 28 28 29 29 /** 30 * Cache duration in seconds (24 hours) 30 * Default cache refresh interval in hours (7 days). 31 * Can be overridden per shortcode via the cache-refresh attribute. 31 32 * 32 33 * @var int 33 34 */ 34 const CACHE_DURATION = 86400;35 const DEFAULT_CACHE_REFRESH = 168; 35 36 36 37 /** … … 270 271 271 272 // Smart caching: Check cache and expiration tracking 272 $cache_key = $this->get_cache_key( $album_url ); 273 $expiry_key = $this->get_expiration_key( $album_url ); 274 $cached_data = get_transient( $cache_key ); 275 $stored_expiry = get_option( $expiry_key, 0 ); 276 $should_refresh = false; 277 278 // Refresh if no cache OR if cache duration setting changed 279 if ( false === $cached_data || (int) $stored_expiry !== self::CACHE_DURATION ) { 273 $cache_key = $this->get_cache_key( $album_url ); 274 $expiry_key = $this->get_expiration_key( $album_url ); 275 $cached_data = get_transient( $cache_key ); 276 $stored_expiry = get_option( $expiry_key, 0 ); 277 $cache_duration = $config['cache-refresh'] * 3600; // convert hours to seconds 278 $should_refresh = false; 279 280 // Refresh if no cache OR if cache-refresh interval changed 281 if ( false === $cached_data || (int) $stored_expiry !== $cache_duration ) { 280 282 $should_refresh = true; 281 283 } … … 314 316 'is_deprecated' => $result['is_deprecated'], 315 317 ), 316 self::CACHE_DURATION318 $cache_duration 317 319 ); 318 320 319 321 // Store expiration duration for tracking 320 update_option( $expiry_key, self::CACHE_DURATION, false );322 update_option( $expiry_key, $cache_duration, false ); 321 323 322 324 // Prepare photos with dimensions and max count … … 372 374 'slideshow-inactivity-timeout' => intval( isset( $atts['slideshow-inactivity-timeout'] ) ? $atts['slideshow-inactivity-timeout'] : self::DEFAULT_SLIDESHOW_INACTIVITY_TIMEOUT ), 373 375 376 // Cache refresh interval in minutes (default: 1440 = 24 hours) 377 'cache-refresh' => $this->parse_cache_refresh( $atts ), 378 374 379 // Display 375 380 'mode' => $this->parse_mode( $atts ), … … 497 502 498 503 /** 504 * Parse cache-refresh attribute. 505 * Returns the number of hours before the album data is re-fetched from Google Photos. 506 * Defaults to DEFAULT_CACHE_REFRESH (168 hours = 7 days). 507 * 508 * @param array $atts Shortcode attributes. 509 * @return int Hours between cache refreshes. 510 */ 511 private function parse_cache_refresh( $atts ) { 512 if ( isset( $atts['cache-refresh'] ) ) { 513 $value = intval( $atts['cache-refresh'] ); 514 if ( $value >= 1 ) { 515 return $value; 516 } 517 } 518 return self::DEFAULT_CACHE_REFRESH; 519 } 520 521 /** 499 522 * Parse image fit mode. 500 523 * … … 1024 1047 1025 1048 // Update the transient cache with fresh URLs. 1026 $cache_key = $this->get_cache_key( $album_url ); 1049 // Use the stored expiry duration for this album so we respect its cache-refresh setting. 1050 $cache_key = $this->get_cache_key( $album_url ); 1051 $expiry_key = $this->get_expiration_key( $album_url ); 1052 $cache_duration = (int) get_option( $expiry_key, self::DEFAULT_CACHE_REFRESH * 3600 ); 1027 1053 set_transient( 1028 1054 $cache_key, … … 1032 1058 'is_deprecated' => $result['is_deprecated'], 1033 1059 ), 1034 self::CACHE_DURATION1060 $cache_duration 1035 1061 ); 1036 1062 -
janzeman-shared-albums-for-google-photos/trunk/includes/class-settings-page.php
r3489427 r3490343 272 272 <div class="jzsa-tool-row"> 273 273 <div class="jzsa-tool-info"> 274 <strong><?php esc_html_e( ' ClearAlbum Cache', 'janzeman-shared-albums-for-google-photos' ); ?></strong>275 <p class="jzsa-help-text"><?php esc_html_e( 'Album data is cached for 24 hours to reduce server load. If you have modified any of your Google Photos albums and need to see the changes immediately, simply click this button.', 'janzeman-shared-albums-for-google-photos' ); ?></p>274 <strong><?php esc_html_e( 'Album Cache', 'janzeman-shared-albums-for-google-photos' ); ?></strong> 275 <p class="jzsa-help-text"><?php esc_html_e( 'Album data is cached for 24 hours on your web server to reduce load. If you have modified any of your Google Photos albums and need to see the changes immediately, simply click the button below. For albums that are updated frequently (e.g. live events), use the cache-refresh shortcode parameter to automatically reduce the cache duration.', 'janzeman-shared-albums-for-google-photos' ); ?><br><span style="display:block;margin-top:6px"></span><em><?php esc_html_e( 'This clears the cached album data - not your browser or page cache. If you use a page caching plugin (WP Fastest Cache, WP Super Cache, etc.), consider excluding the pages with albums from page caching, or clear that cache separately.', 'janzeman-shared-albums-for-google-photos' ); ?></em></p> 276 276 </div> 277 277 <div class="jzsa-tool-action"> … … 902 902 <td>300</td> 903 903 </tr> 904 <tr> 905 <td><code>cache-refresh</code></td> 906 <td>How often the album data is re-fetched from Google Photos, in hours. Useful for albums that are updated frequently (e.g. live event albums). Example: cache-refresh="1" to refresh every hour.</td> 907 <td>168 (7 days)</td> 908 </tr> 904 909 <tr> 905 910 <td><code>source-width</code></td> -
janzeman-shared-albums-for-google-photos/trunk/janzeman-shared-albums-for-google-photos.php
r3489427 r3490343 5 5 * Author URI: https://github.com/JanZeman 6 6 * Description: Display publicly shared Google Photos albums with a modern Swiper-based gallery viewer. Not affiliated with or endorsed by Google LLC. 7 * Version: 2.0. 27 * Version: 2.0.3 8 8 * Requires at least: 5.0 9 9 * Requires PHP: 7.0 … … 23 23 24 24 // Define plugin constants 25 define( 'JZSA_VERSION', '2.0. 2' );25 define( 'JZSA_VERSION', '2.0.3' ); 26 26 define( 'JZSA_PLUGIN_FILE', __FILE__ ); 27 27 define( 'JZSA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
janzeman-shared-albums-for-google-photos/trunk/readme.txt
r3489427 r3490343 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.0 7 Stable tag: 2.0. 27 Stable tag: 2.0.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 198 198 == Changelog == 199 199 200 = 2.0.3 = 201 * New parameter: "cache-refresh" 202 200 203 = 2.0.2 = 201 204 * Clear Cache button added
Note: See TracChangeset
for help on using the changeset viewer.