Plugin Directory


Ignore:
Timestamp:
09/23/2022 03:04:29 PM (4 years ago)
Author:
stracker.phil
Message:

1.0.3

Location:
gdpr-cache-scripts-styles
Files:
25 added
7 edited

Legend:

Unmodified
Added
Removed
  • gdpr-cache-scripts-styles/trunk/constants.php

    r2788227 r2789381  
    1717 */
    1818define( 'GDPR_CACHE_PATH', plugin_dir_path( GDPR_CACHE_PLUGIN_FILE ) );
     19
     20/**
     21 * Absolute URL to the current plugins base folder, with trailing slash. Used
     22 * to enqueue scripts that are shipped with this plugin.
     23 *
     24 * @var string
     25 */
     26define( 'GDPR_CACHE_PLUGIN_URL', plugin_dir_url( GDPR_CACHE_PLUGIN_FILE ) );
    1927
    2028/**
     
    5159     * in TTF fonts being used.
    5260     *
    53      * @see https://developers.google.com/fonts/docs/technical_considerations
     61     * @see   https://developers.google.com/fonts/docs/technical_considerations
    5462     *
    5563     * @since 1.0.1
  • gdpr-cache-scripts-styles/trunk/includes/admin/options.php

    r2788227 r2789381  
    7777 */
    7878function render_admin_page() {
     79    // Flush plugin cache when the Options Page is opened.
     80    wp_cache_delete( 'data', 'gdpr-cache' );
     81
    7982    require GDPR_CACHE_PATH . 'templates/admin-options.php';
    8083}
  • gdpr-cache-scripts-styles/trunk/includes/libs/cache.php

    r2788227 r2789381  
    217217        'expires' => time() + $expiration,
    218218        'file'    => $file,
     219        'type'    => get_url_type( $url ),
    219220    ];
    220221
  • gdpr-cache-scripts-styles/trunk/plugin.php

    r2789331 r2789381  
    1212 * Plugin URI:  https://github.com/divimode/gdpr-cache-script-styles
    1313 * Description: Caches external scripts and styles and serves them from your local website to make it more compliant with GDPR regulations
    14  * Version:     1.0.2
     14 * Version:     1.0.3
    1515 * Author:      Divimode
    1616 * Author URI:  https://divimode.com/
     
    4646 * @var string
    4747 */
    48 const GDPR_CACHE_VERSION = '1.0.2';
     48const GDPR_CACHE_VERSION = '1.0.3';
    4949
    5050/**
  • gdpr-cache-scripts-styles/trunk/readme.txt

    r2789366 r2789381  
    44Tested up to: 6.0.2
    55Requires PHP: 7.2
    6 Stable tag: 1.0.2
     6Stable tag: 1.0.3
    77License: GPL v2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    121121== Changelog ==
    122122
     123= 1.0.3 =
     124
     125* New: Display file-type of cached assets in the plugin's option page.
     126* New: Also in the plugin's option page - allow sorting of the "Cached Assets" list.
     127* Improve: Flush the plugins internal cache when opening the options page.
     128
    123129= 1.0.2 =
    124130
  • gdpr-cache-scripts-styles/trunk/templates/admin-options.php

    r2788227 r2789381  
    1010// Exit if accessed directly.
    1111defined( 'ABSPATH' ) || exit;
     12
     13wp_enqueue_script( 'gdpr-sortable', GDPR_CACHE_PLUGIN_URL . 'scripts/sortable.js' );
     14wp_enqueue_style( 'gdpr-sortable', GDPR_CACHE_PLUGIN_URL . 'styles/admin.css' );
    1215
    1316$assets = get_cached_data();
     
    3336foreach ( $assets as $url => $item ) {
    3437    $status_label = '';
     38    $local_url    = '';
    3539    $item_status  = get_asset_status( $url );
     40    $item_type    = isset( $item['type'] ) ? $item['type'] : '';
     41
     42    if ( ! $item_type ) {
     43        $item_type = get_url_type( $url );
     44    }
    3645
    3746    if ( 'valid' !== $item_status ) {
     
    4453        $status_label = $status_labels[ $item_status ];
    4554    }
     55    if ( in_array( $item_status, [ 'valid', 'expired' ] ) ) {
     56        $local_url = build_cache_file_url( $item['file'] );
     57    }
    4658    $counts['all'] ++;
    4759    $counts[ $item_status ] ++;
     
    5163        'status'       => $item_status,
    5264        'status_label' => $status_label,
     65        'type'         => $item_type,
     66        'local_url'    => $local_url,
    5367        'created'      => gmdate( 'Y-m-d H:i', $item['created'] ),
    5468        'expires'      => gmdate( 'Y-m-d H:i', $item['expires'] ),
     
    6175    }
    6276
     77    $item_type   = get_url_type( $url );
    6378    $item_status = 'enqueued';
    6479    $counts['all'] ++;
     
    6984        'status'       => $item_status,
    7085        'status_label' => $status_labels[ $item_status ],
     86        'type'         => $item_type,
     87        'local_url'    => '',
    7188        'created'      => '',
    7289        'expires'      => '',
     
    84101
    85102?>
    86 <div class="wrap">
     103<div class="wrap" id="gdpr-cache">
    87104    <h1><?php esc_html_e( 'GDPR Cache Options', 'gdpr-cache' ); ?></h1>
    88105
     
    131148        </p>
    132149    <?php else : ?>
    133         <table class="wp-list-table widefat fixed striped table-view-list">
     150        <table class="wp-list-table widefat fixed striped table-view-list sortable">
    134151            <thead>
    135152            <tr>
    136                 <th class="asset-url"><?php esc_html_e( 'URL', 'gdpr-cache' ); ?></th>
    137                 <th
    138                         class="asset-status" style="width:100px"
    139                 ><?php esc_html_e( 'Status', 'gdpr-cache' ); ?></th>
    140                 <th
    141                         class="asset-created" style="width:125px"
    142                 ><?php esc_html_e( 'Created', 'gdpr-cache' ); ?></th>
    143                 <th
    144                         class="asset-expires" style="width:125px"
    145                 ><?php esc_html_e( 'Expires', 'gdpr-cache' ); ?></th>
     153                <th class="asset-url">
     154                    <?php esc_html_e( 'URL', 'gdpr-cache' ); ?>
     155                </th>
     156                <th class="asset-type">
     157                    <?php esc_html_e( 'Type', 'gdpr-cache' ); ?>
     158                </th>
     159                <th class="asset-status">
     160                    <?php esc_html_e( 'Status', 'gdpr-cache' ); ?>
     161                </th>
     162                <th class="asset-created">
     163                    <?php esc_html_e( 'Created', 'gdpr-cache' ); ?>
     164
     165                </th>
     166                <th class="asset-expires">
     167                    <?php esc_html_e( 'Expires', 'gdpr-cache' ); ?>
     168                </th>
    146169            </tr>
    147170            </thead>
     
    149172                <tr class="status-<?php echo esc_attr( $item['status'] ); ?>">
    150173                    <td class="asset-url"><?php echo esc_html( $item['url'] ); ?></td>
     174                    <td class="asset-type"><?php echo esc_html( $item['type'] ); ?></td>
    151175                    <td class="asset-status">
    152                         <?php echo esc_html( $item['status_label'] ); ?>
     176                        <?php if ( $item['local_url'] ): ?>
     177                            <a
     178                                    href="<?php echo esc_url( $item['local_url'] ); ?>"
     179                                    title="<?php esc_attr_e( 'Open the cached file in a new window', 'gdpr-cache' ); ?>"
     180                                    target="_blank"
     181                            >
     182                                <?php echo esc_html( $item['status_label'] ); ?>
     183                            </a>
     184                        <?php else: ?>
     185                            <?php echo esc_html( $item['status_label'] ); ?>
     186                        <?php endif; ?>
    153187                    </td>
    154188                    <td class="asset-created"><?php echo esc_html( $item['created'] ); ?></td>
     
    159193    <?php endif; ?>
    160194</div>
    161 
    162 <style>
    163     .subsubsub {
    164         margin-bottom: 12px
    165     }
    166 
    167     .subsubsub li + li:before {
    168         content: '|';
    169         padding: 0 2px;
    170     }
    171 
    172     .subsubsub .count-all .status {
    173         font-weight: bold;
    174     }
    175 
    176     .widefat .asset-status {
    177         vertical-align: middle;
    178         text-align: center;
    179     }
    180 
    181     .status-valid .asset-status {
    182         background: #c8e6c940;
    183         color: #005005;
    184     }
    185 
    186     .status-expired .asset-status {
    187         background: #ffecb340;
    188         color: #c56000;
    189     }
    190 
    191     .status-missing .asset-status {
    192         background: #ffccbc40;
    193         color: #9f0000;
    194     }
    195 
    196     .status-enqueued .asset-status {
    197         background: #e1bee740;
    198         color: #38006b;
    199     }
    200 </style>
Note: See TracChangeset for help on using the changeset viewer.