Plugin Directory

Changeset 3489427


Ignore:
Timestamp:
03/23/2026 09:13:21 PM (5 days ago)
Author:
janzeman
Message:

Release 2.0.2

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

Legend:

Unmodified
Added
Removed
  • janzeman-shared-albums-for-google-photos/trunk/assets/css/admin-settings.css

    r3488144 r3489427  
    3131/* Playground section stands out slightly so it's easy to find
    3232 * when scrolling back. Light pastel background, subtle border color. */
     33.jzsa-tool-row {
     34    display: flex;
     35    flex-direction: column;
     36    gap: 12px;
     37}
     38
     39.jzsa-tool-info p {
     40    margin: 4px 0 0 0;
     41}
     42
     43.jzsa-tool-action {
     44    display: flex;
     45    align-items: center;
     46    gap: 12px;
     47}
     48
     49.jzsa-tool-result {
     50    font-size: 13px;
     51    min-height: 1.4em;
     52    display: block;
     53}
     54
     55.jzsa-tool-result--success {
     56    color: #1a7a3a;
     57}
     58
     59.jzsa-tool-result--error {
     60    color: #b32d2e;
     61}
     62
    3363.jzsa-section.jzsa-playground-section {
    3464    background: #f0fcf4;
  • janzeman-shared-albums-for-google-photos/trunk/assets/js/admin-settings.js

    r3488144 r3489427  
    158158    } );
    159159
     160    // Wire the Clear Cache button.
     161    var clearCacheBtn = document.getElementById( 'jzsa-clear-cache-btn' );
     162    var clearCacheResult = document.getElementById( 'jzsa-clear-cache-result' );
     163
     164    if ( clearCacheBtn ) {
     165        clearCacheBtn.addEventListener( 'click', function () {
     166            if ( typeof jzsaAdminAjax === 'undefined' || ! jzsaAdminAjax.ajaxUrl ) {
     167                return;
     168            }
     169
     170            clearCacheBtn.disabled = true;
     171            clearCacheBtn.textContent = 'Clearing…';
     172            if ( clearCacheResult ) {
     173                clearCacheResult.textContent = '';
     174                clearCacheResult.className = 'jzsa-tool-result';
     175            }
     176
     177            var params = new URLSearchParams();
     178            params.append( 'action', 'jzsa_clear_cache' );
     179            params.append( 'nonce', jzsaAdminAjax.clearCacheNonce );
     180
     181            window.fetch( jzsaAdminAjax.ajaxUrl, {
     182                method: 'POST',
     183                credentials: 'same-origin',
     184                headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
     185                body: params.toString(),
     186            } )
     187                .then( function ( response ) { return response.json(); } )
     188                .then( function ( data ) {
     189                    clearCacheBtn.disabled = false;
     190                    clearCacheBtn.textContent = 'Clear Cache';
     191                    if ( clearCacheResult ) {
     192                        clearCacheResult.textContent = data.success ? data.data.message : ( data.data || 'Error clearing cache.' );
     193                        clearCacheResult.className = 'jzsa-tool-result ' + ( data.success ? 'jzsa-tool-result--success' : 'jzsa-tool-result--error' );
     194                    }
     195                } )
     196                .catch( function () {
     197                    clearCacheBtn.disabled = false;
     198                    clearCacheBtn.textContent = 'Clear Cache';
     199                    if ( clearCacheResult ) {
     200                        clearCacheResult.textContent = 'Request failed.';
     201                        clearCacheResult.className = 'jzsa-tool-result jzsa-tool-result--error';
     202                    }
     203                } );
     204        } );
     205    }
     206
    160207    // Step 2: wire the Playground textarea to an explicit "Update preview" button.
    161208    var textarea = document.getElementById( 'jzsa-playground-shortcode' );
  • janzeman-shared-albums-for-google-photos/trunk/includes/class-orchestrator.php

    r3488144 r3489427  
    132132        add_action( 'wp_ajax_nopriv_jzsa_refresh_urls', array( $this, 'handle_refresh_urls' ) );
    133133        add_action( 'wp_ajax_jzsa_shortcode_preview', array( $this, 'handle_shortcode_preview' ) );
     134        add_action( 'wp_ajax_jzsa_clear_cache', array( $this, 'handle_clear_cache' ) );
    134135
    135136        // Also load front-end gallery assets on our settings page so the sample
     
    955956
    956957    /**
     958     * Handle AJAX request to clear all cached album data.
     959     *
     960     * Deletes all jzsa_album_* transients and jzsa_expiry_* options so that
     961     * the next page load fetches fresh data from Google Photos.
     962     */
     963    public function handle_clear_cache() {
     964        if ( ! current_user_can( 'manage_options' ) ) {
     965            wp_send_json_error( __( 'Insufficient permissions', 'janzeman-shared-albums-for-google-photos' ) );
     966        }
     967
     968        $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
     969        if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'jzsa_clear_cache' ) ) {
     970            wp_send_json_error( __( 'Invalid nonce', 'janzeman-shared-albums-for-google-photos' ) );
     971        }
     972
     973        global $wpdb;
     974
     975        // Delete all album transients (stored as _transient_jzsa_album_* in wp_options).
     976        $deleted = $wpdb->query(
     977            "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_jzsa_album_%' OR option_name LIKE '_transient_timeout_jzsa_album_%'"
     978        );
     979
     980        // Delete all expiry tracking options.
     981        $wpdb->query(
     982            "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'jzsa_expiry_%'"
     983        );
     984
     985        $album_count = (int) ( $deleted / 2 );
     986
     987        $message = $album_count > 0
     988            ? sprintf(
     989                /* translators: %d: number of cached albums cleared */
     990                _n( '%d cached album cleared.', '%d cached albums cleared.', $album_count, 'janzeman-shared-albums-for-google-photos' ),
     991                $album_count
     992            )
     993            : __( 'Cache was already empty.', 'janzeman-shared-albums-for-google-photos' );
     994
     995        wp_send_json_success( array( 'message' => $message ) );
     996    }
     997
     998    /**
    957999     * Handle AJAX request to refresh expired media URLs.
    9581000     *
  • janzeman-shared-albums-for-google-photos/trunk/includes/class-settings-page.php

    r3488144 r3489427  
    6363            JZSA_VERSION,
    6464            true
     65        );
     66
     67        wp_localize_script(
     68            'jzsa-admin-settings',
     69            'jzsaAdminAjax',
     70            array(
     71                'ajaxUrl'         => admin_url( 'admin-ajax.php' ),
     72                'clearCacheNonce' => wp_create_nonce( 'jzsa_clear_cache' ),
     73            )
    6574        );
    6675    }
     
    257266                </div>
    258267
     268            <!-- Tools Section -->
     269            <div class="jzsa-section jzsa-tools-section">
     270                <h2><?php esc_html_e( 'Tools', 'janzeman-shared-albums-for-google-photos' ); ?></h2>
     271
     272                <div class="jzsa-tool-row">
     273                    <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>
     276                    </div>
     277                    <div class="jzsa-tool-action">
     278                        <button type="button" id="jzsa-clear-cache-btn" class="button button-secondary">
     279                            <?php esc_html_e( 'Clear Cache', 'janzeman-shared-albums-for-google-photos' ); ?>
     280                        </button>
     281                        <span id="jzsa-clear-cache-result" class="jzsa-tool-result" aria-live="polite"></span>
     282                    </div>
     283                </div>
     284            </div>
     285
    259286                <!-- Samples Section -->
    260287                <div class="jzsa-section jzsa-samples-section">
     
    263290                        <div class="jzsa-example">
    264291                            <h3><?php esc_html_e( 'Gallery Mode with Limited Entry Count (Without Pagination)', 'janzeman-shared-albums-for-google-photos' ); ?></h3>
    265                             <p><?php esc_html_e( 'Uses the default "gallery" mode to display album entries as a thumbnail gallery. Every cell has the same size. Click any thumbnail to open it in a fullscreen viewer. Pagination is not required all thumbnails are shown at once, limited only by limit.', 'janzeman-shared-albums-for-google-photos' ); ?></p>
     292                            <p><?php esc_html_e( 'Uses the default "gallery" mode to display album entries as a thumbnail gallery. Every cell has the same size. Click any thumbnail to open it in a fullscreen viewer. Pagination is not required - all thumbnails are shown at once, limited only by limit.', 'janzeman-shared-albums-for-google-photos' ); ?></p>
    266293                    <div class="jzsa-code-block">
    267294                        <code>[jzsa-album link="https://photos.google.com/share/AF1QipOg3EA51ATc_YWHyfcffDCzNZFsVTU_uBqSEKFix7LY80DIgH3lMkLwt4QDTHd8EQ?key=RGwySFNhbmhqMFBDbnZNUUtwY0stNy1XV1JRbE9R" limit="12"]</code>
  • janzeman-shared-albums-for-google-photos/trunk/janzeman-shared-albums-for-google-photos.php

    r3488485 r3489427  
    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.1
     7 * Version: 2.0.2
    88 * Requires at least: 5.0
    99 * Requires PHP: 7.0
     
    2323
    2424// Define plugin constants
    25 define( 'JZSA_VERSION', '2.0.1' );
     25define( 'JZSA_VERSION', '2.0.2' );
    2626define( 'JZSA_PLUGIN_FILE', __FILE__ );
    2727define( 'JZSA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • janzeman-shared-albums-for-google-photos/trunk/readme.txt

    r3488485 r3489427  
    55Tested up to: 6.9
    66Requires PHP: 7.0
    7 Stable tag: 2.0.1
     7Stable tag: 2.0.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    198198== Changelog ==
    199199
     200= 2.0.2 =
     201* Clear Cache button added
     202
    200203= 2.0.1 =
    201204* Fixed album titles being truncated (dates and special characters are now preserved)
Note: See TracChangeset for help on using the changeset viewer.