Plugin Directory

Changeset 3490343


Ignore:
Timestamp:
03/24/2026 08:18:09 PM (4 days ago)
Author:
janzeman
Message:

Release 2.0.3

Location:
janzeman-shared-albums-for-google-photos/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • janzeman-shared-albums-for-google-photos/trunk/includes/class-orchestrator.php

    r3489427 r3490343  
    1111 * - Tracks cache expiration separately in wp_options
    1212 * - Allows same album to be reused across multiple posts
    13  * - Invalidates cache if CACHE_DURATION constant changes
     13 * - Invalidates cache if cache-refresh interval changes
    1414 *
    1515 * @package JZSA_Shared_Albums
     
    2828
    2929    /**
    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.
    3132     *
    3233     * @var int
    3334     */
    34     const CACHE_DURATION = 86400;
     35    const DEFAULT_CACHE_REFRESH = 168;
    3536
    3637    /**
     
    270271
    271272        // 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 ) {
    280282            $should_refresh = true;
    281283        }
     
    314316                'is_deprecated' => $result['is_deprecated'],
    315317            ),
    316             self::CACHE_DURATION
     318            $cache_duration
    317319        );
    318320
    319321        // Store expiration duration for tracking
    320         update_option( $expiry_key, self::CACHE_DURATION, false );
     322        update_option( $expiry_key, $cache_duration, false );
    321323
    322324        // Prepare photos with dimensions and max count
     
    372374            'slideshow-inactivity-timeout' => intval( isset( $atts['slideshow-inactivity-timeout'] ) ? $atts['slideshow-inactivity-timeout'] : self::DEFAULT_SLIDESHOW_INACTIVITY_TIMEOUT ),
    373375
     376            // Cache refresh interval in minutes (default: 1440 = 24 hours)
     377            'cache-refresh' => $this->parse_cache_refresh( $atts ),
     378
    374379                // Display
    375380                'mode'                 => $this->parse_mode( $atts ),
     
    497502
    498503    /**
     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    /**
    499522     * Parse image fit mode.
    500523     *
     
    10241047
    10251048        // 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 );
    10271053        set_transient(
    10281054            $cache_key,
     
    10321058                'is_deprecated' => $result['is_deprecated'],
    10331059            ),
    1034             self::CACHE_DURATION
     1060            $cache_duration
    10351061        );
    10361062
  • janzeman-shared-albums-for-google-photos/trunk/includes/class-settings-page.php

    r3489427 r3490343  
    272272                <div class="jzsa-tool-row">
    273273                    <div class="jzsa-tool-info">
    274                         <strong><?php esc_html_e( 'Clear 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 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>
    276276                    </div>
    277277                    <div class="jzsa-tool-action">
     
    902902                                    <td>300</td>
    903903                                </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>
    904909                            <tr>
    905910                                <td><code>source-width</code></td>
  • janzeman-shared-albums-for-google-photos/trunk/janzeman-shared-albums-for-google-photos.php

    r3489427 r3490343  
    55 * Author URI: https://github.com/JanZeman
    66 * 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.2
     7 * Version: 2.0.3
    88 * Requires at least: 5.0
    99 * Requires PHP: 7.0
     
    2323
    2424// Define plugin constants
    25 define( 'JZSA_VERSION', '2.0.2' );
     25define( 'JZSA_VERSION', '2.0.3' );
    2626define( 'JZSA_PLUGIN_FILE', __FILE__ );
    2727define( 'JZSA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • janzeman-shared-albums-for-google-photos/trunk/readme.txt

    r3489427 r3490343  
    55Tested up to: 6.9
    66Requires PHP: 7.0
    7 Stable tag: 2.0.2
     7Stable tag: 2.0.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    198198== Changelog ==
    199199
     200= 2.0.3 =
     201* New parameter: "cache-refresh"
     202
    200203= 2.0.2 =
    201204* Clear Cache button added
Note: See TracChangeset for help on using the changeset viewer.