Plugin Directory

Changeset 3390622


Ignore:
Timestamp:
11/05/2025 05:28:39 PM (5 months ago)
Author:
grocerslist
Message:

v1.10.0 - Ad removal optimizations for paying customers.

Location:
grocerslist
Files:
205 added
5 edited

Legend:

Unmodified
Added
Removed
  • grocerslist/trunk/README.md

    r3386046 r3390622  
    44Author: Grocers List, Engineering
    55Tested up to: 6.8
    6 Stable tag: 1.9.0
     6Stable tag: 1.10.0
    77Requires PHP: 7.0
    88License: GPLv3
     
    6666#### - 10/28/2025 - 1.9.0 - Feature: ability to gate posts by category, ability to apply gating defaults to categories that get inherited by posts
    6767
     68#### - 11/5/2025 - 1.10.0 - Ad removal optimizations for paying customers.
     69
    6870### Resources:
    6971
  • grocerslist/trunk/client-ui/dist/bundle.js

    r3379735 r3390622  
    1 
     1(()=>{const e=()=>{setTimeout(()=>{document.body.classList.add("grocers-list-ads-processed")},1e4)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()})();
  • grocerslist/trunk/grocerslist.php

    r3386046 r3390622  
    77Requires PHP: 7.0
    88Tested up to: 6.8
    9 Version: 1.9.0
    10 Stable tag: 1.9.0
     9Version: 1.10.0
     10Stable tag: 1.10.0
    1111Author: Grocers List Engineering
    1212License: GPLv3
     
    1818if (!defined('ABSPATH')) exit;
    1919
    20 define('GROCERS_LIST_VERSION', '1.9.0');
     20define('GROCERS_LIST_VERSION', '1.10.0');
    2121define('GROCERS_LIST_PLUGIN_FILE', __FILE__);
    2222define('GROCERS_LIST_PLUGIN_DIR', __DIR__);
  • grocerslist/trunk/includes/Frontend/ClientScripts.php

    r3386046 r3390622  
    5151    }
    5252
    53     public function enqueueScripts(): void
    54     {
     53    /**
     54     * Create a stylesheet that ensures ads are hidden on page load.
     55     *
     56     * In practice this looks like the following:
     57     * - We inject a stylesheet that has dynamically generated classes
     58     *   based on the adSelectors defined for the account.
     59     * - These classes take the following shape:
     60     *   body:not(.grocers-list-ads-processed) .my_ad_selector { display: none !important; }
     61     * - This is done for every adSelector that's defined
     62     * - These classes are applied immediately on page load to ensure that no ads are shown
     63     * - Once we determine the authentication state of the user, we then do the following:
     64     *   -- Immediately show the ads for unauthenticated users
     65     *   -- Remove the ads and then apply the class (this is so there is no brief flash of content)
     66     *
     67     * @return void
     68     **/
     69    public function createAdselectorStylesheet($creatorSettings): void {
     70        $STYLESHEET_IDENTIFIER= 'grocers-list-ad-selectors';
     71
     72        $adSelectors = $creatorSettings->adSelectors;
     73        if ($adSelectors && count($adSelectors) > 0) {
     74            wp_register_style($STYLESHEET_IDENTIFIER, false);
     75            wp_enqueue_style($STYLESHEET_IDENTIFIER);
     76
     77            $prefixedAdSelectors = array_map(static function ($className): string {
     78                return 'body:not(.grocers-list-ads-processed) ' . $className;
     79            }, $adSelectors);
     80
     81            // Add stylesheet with each ad selector prefixed with 'body:not(.grocers-list-ads-processed) '
     82            // e.g.,: body:not(.grocers-list-ads-processed) .foo, body:not(.grocers-list-ads-processed) .bar { display: none !important; }
     83            wp_add_inline_style(
     84                $STYLESHEET_IDENTIFIER,
     85                implode(',', $prefixedAdSelectors) . ' { display: none !important; } }'
     86            );
     87        }
     88    }
     89
     90    public function enqueueScripts(): void {
    5591        // Set comprehensive no-cache headers to prevent any caching
    5692        $this->setNoCacheHeaders();
    5793
    5894        $assetBase = plugin_dir_url(__FILE__) . '../../client-ui/dist/';
    59        
    6095        wp_enqueue_script('grocers-list-client', $assetBase . 'bundle.js', [], $this->get_cache_busting_string(), true);
    6196
     
    76111            'settings' => $creatorSettings->settings ?? null,
    77112            'provisioning' => $creatorSettings->provisioning ?? null,
     113            'adSelectors' => $creatorSettings->adSelectors ?? null
    78114        ];
    79115
     
    97133
    98134        if ($membershipsFullyEnabled && !empty($externalJsUrl)) {
     135            $this->createAdselectorStylesheet($creatorSettings);
    99136            wp_enqueue_script('grocers-list-external', $externalJsUrl, [], $this->get_cache_busting_string(), array('strategy' => 'async', 'in_footer' => false));
    100137        }
  • grocerslist/trunk/vendor/composer/installed.php

    r3386046 r3390622  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => 'bc6322799543d31464f03219df5a207404cc7251',
     6        'reference' => 'ea26b9abab4fe3f55391dd53d36785a2da76ea87',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-master',
    1515            'version' => 'dev-master',
    16             'reference' => 'bc6322799543d31464f03219df5a207404cc7251',
     16            'reference' => 'ea26b9abab4fe3f55391dd53d36785a2da76ea87',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.