Plugin Directory

Changeset 3818248


Ignore:
Timestamp:
11/23/2026 12:29:06 PM (2 days ago)
Author:
clicknote
Message:

Update to version 1.0.1 from GitHub

Location:
clicknote
Files:
4 added
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • clicknote/tags/1.0.1/clicknote.php

    r3818086 r3818248  
    44 * Plugin URI:        https://clicknote.io/docs/wordpress
    55 * Description:       Adds your ClickNote project's snippet to this site, so your clients can click directly on elements of a page and leave a note. Ordinary visitors are not affected.
    6  * Version:           1.0.0
     6 * Version:           1.0.1
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
    … …  
    1818defined( 'ABSPATH' ) || exit;
    1919
    20 define( 'CLICKNOTE_VERSION', '1.0.0' );
     20define( 'CLICKNOTE_VERSION', '1.0.1' );
    2121define( 'CLICKNOTE_OPTION', 'clicknote_settings' );
    2222define( 'CLICKNOTE_HANDLE', 'clicknote-loader' );
     23
     24// Caching and optimisation plugins: clearing their caches, and keeping the loader out of their way.
     25require_once __DIR__ . '/includes/other-plugins.php';
    2326
    2427/**
    … …  
    138141
    139142        if ( ! empty( $input['disconnect'] ) ) {
    140                 add_settings_error( CLICKNOTE_OPTION, 'clicknote_disconnected', __( 'Disconnected. The snippet is no longer added to this site.', 'clicknote' ), 'success' );
    141                 return array(
    142                         'script_url' => '',
    143                         'project_id' => '',
     143                return clicknote_saving(
     144                        array(
     145                                'script_url' => '',
     146                                'project_id' => '',
     147                        ),
     148                        $current,
     149                        'clicknote_disconnected',
     150                        __( 'Disconnected. The snippet is no longer added to this site.', 'clicknote' )
    144151                );
    145152        }
    … …  
    152159
    153160        $replaced = clicknote_is_connected() && $parsed !== $current;
    154         add_settings_error(
    155                 CLICKNOTE_OPTION,
     161        return clicknote_saving(
     162                $parsed,
     163                $current,
    156164                'clicknote_connected',
    157165                $replaced
    158                         ? __( 'Snippet replaced. The new one is now on every public page of this site. If you use a caching plugin, clear its cache.', 'clicknote' )
    159                         : __( 'Connected. The snippet is now on every public page of this site. If you use a caching plugin, clear its cache.', 'clicknote' ),
    160                 'success'
    161         );
    162         return $parsed;
    163 }
     166                        ? __( 'Snippet replaced. The new one is now on every public page of this site.', 'clicknote' )
     167                        : __( 'Connected. The snippet is now on every public page of this site.', 'clicknote' )
     168        );
     169}
     170
     171/**
     172 * A form save that will change what pages show: clear the page caches once the new value is
     173 * stored, then say what happened and which caches were cleared.
     174 *
     175 * Clearing has to wait until the value is in the database, or a page rebuilt in between would be
     176 * cached with the old one. WordPress says so with the add_option_ and update_option_ actions below.
     177 * When the value is the one already stored (the same snippet pasted again), it writes nothing and
     178 * fires neither, so then it is done straight away.
     179 *
     180 * @param array  $value   What will be stored.
     181 * @param array  $current What is stored now.
     182 * @param string $code    The notice's code.
     183 * @param string $message The notice, without the sentence about caches.
     184 * @return array The value, unchanged.
     185 */
     186function clicknote_saving( $value, $current, $code, $message ) {
     187        if ( $value === $current ) {
     188                clicknote_saved_notice( $code, $message );
     189        } else {
     190                $GLOBALS['clicknote_pending_notice'] = array( $code, $message );
     191        }
     192        return $value;
     193}
     194
     195/**
     196 * The setting has been stored: clear the caches and give the notice that was waiting for it.
     197 */
     198function clicknote_settings_stored() {
     199        if ( empty( $GLOBALS['clicknote_pending_notice'] ) ) {
     200                return;
     201        }
     202        list( $code, $message ) = $GLOBALS['clicknote_pending_notice'];
     203        unset( $GLOBALS['clicknote_pending_notice'] );
     204        clicknote_saved_notice( $code, $message );
     205}
     206add_action( 'add_option_' . CLICKNOTE_OPTION, 'clicknote_settings_stored' );
     207add_action( 'update_option_' . CLICKNOTE_OPTION, 'clicknote_settings_stored' );
     208
     209/**
     210 * Clear the page caches and give one notice: what happened, then which caches were cleared or, if
     211 * no caching plugin was found, the advice to clear its cache.
     212 *
     213 * @param string $code    The notice's code.
     214 * @param string $message The notice, without the sentence about caches.
     215 */
     216function clicknote_saved_notice( $code, $message ) {
     217        $cleared = clicknote_clear_page_caches();
     218        add_settings_error( CLICKNOTE_OPTION, $code, $message . ' ' . clicknote_cache_sentence( $cleared ), 'success' );
     219}
     220
     221/**
     222 * When the plugin is deactivated the snippet stops being added, so cached pages that still have it
     223 * are cleared too.
     224 */
     225function clicknote_deactivate() {
     226        if ( clicknote_is_connected() ) {
     227                clicknote_clear_page_caches();
     228        }
     229}
     230register_deactivation_hook( __FILE__, 'clicknote_deactivate' );
    164231
    165232/**
    … …  
    274341                        <h1><?php esc_html_e( 'ClickNote', 'clicknote' ); ?></h1>
    275342                </div>
    276                 <p class="clicknote-lead"><?php esc_html_e( 'Website feedback your clients give by clicking. They open their own site, click the thing they mean and write a note. You get the page, the element, a screenshot and the device.', 'clicknote' ); ?></p>
     343                <p class="clicknote-lead"><?php esc_html_e( 'Website feedback your clients give by clicking. They open their own site, click directly on elements of the page and write a note. You get the page, the element, a screenshot and the device.', 'clicknote' ); ?></p>
    277344
    278345                <?php if ( $connected ) : ?>
    … …  
    379446
    380447/**
    381  * Give the loader's tag the project's id, and make sure it is async on every WordPress version.
     448 * Give the loader's tag the project's id, make sure it is async on every WordPress version, and
     449 * add the attributes that tell optimisation tools to leave it as it is (see includes/other-plugins.php).
    382450 *
    383451 * @param string $tag    The script tag.
    … …  
    396464        if ( ! preg_match( '/\sasync(\s|=|>)/', $tag ) ) {
    397465                $attributes .= ' async';
     466        }
     467        foreach ( clicknote_leave_alone_attributes() as $name => $value ) {
     468                if ( ! preg_match( '/\s' . preg_quote( $name, '/' ) . '(\s|=|>)/', $tag ) ) {
     469                        $attributes .= ' ' . $name . ( '' === $value ? '' : '="' . esc_attr( $value ) . '"' );
     470                }
    398471        }
    399472        if ( '' === $attributes ) {
  • clicknote/tags/1.0.1/readme.txt

    r3818086 r3818248  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    2121* Adds one small script tag before the closing body tag of every public page.
    2222* Keeps working when the theme is changed or updated.
     23* Clears the page cache of popular caching plugins when you connect, replace or disconnect the snippet, and keeps its script out of script delaying and combining.
    2324* Removes its setting when the plugin is deleted.
    2425
    … …  
    48492. In ClickNote, open your project, go to "Install and settings" and copy the snippet.
    49503. In WordPress, go to Settings, ClickNote, paste the snippet and press Connect.
    50 4. If the site uses a caching plugin, clear its cache so pages are rebuilt with the snippet.
     514. The plugin clears the page cache of popular caching plugins itself, and says which. If the site uses another, clear its cache so pages are rebuilt with the snippet.
    51525. Open your project's review link to check that the review tools appear.
    5253
    … …  
    6768= Does it work with caching and optimisation plugins? =
    6869
    69 Yes. Clear the page cache after connecting. If a plugin combines, delays or inlines scripts, leave this one out of that: it must stay a separate script tag to work.
     70Yes. When you connect, replace or disconnect the snippet, and when you deactivate the plugin, it clears the page cache of WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super Cache, WP Fastest Cache, Speed Optimizer, Hummingbird, Breeze, Cache Enabler, WP-Optimize, Nginx Helper and Super Page Cache, whichever are active. The settings page says which caches it cleared. With any other caching plugin, clear its cache yourself.
     71
     72The script has to run as soon as a page loads, so the review tools appear the moment a client opens a review link. So the plugin also asks WP Rocket, LiteSpeed Cache, Autoptimize, Perfmatters, Speed Optimizer, Hummingbird, Jetpack Boost, W3 Total Cache, WP-Optimize and Breeze not to delay, defer, combine or minify it, using each plugin's own exclusion settings, and marks its script tag so that Cloudflare's Rocket Loader leaves it alone too. If another plugin delays, combines or inlines scripts, leave this one out of that: it must stay a separate script tag to work.
    7073
    7174= Does it work with page builders? =
    … …  
    98101== Changelog ==
    99102
     103= 1.0.1 =
     104* Clears the page cache of popular caching plugins, among them WP Rocket, LiteSpeed Cache, W3 Total Cache and WP Super Cache, when the snippet is connected, replaced or disconnected and when the plugin is deactivated. The settings page says which caches were cleared.
     105* Asks popular optimisation plugins, among them WP Rocket, LiteSpeed Cache, Autoptimize and Perfmatters, not to delay, defer, combine or minify its script, so the review tools still appear as soon as a review link is opened.
     106* The settings page describes ClickNote in the same words as the plugin's description.
     107
    100108= 1.0.0 =
    101109* First release.
    … …  
    103111== Upgrade Notice ==
    104112
     113= 1.0.1 =
     114Works with popular caching and optimisation plugins: clears their page cache when the snippet changes, and keeps its script out of delaying and combining. Also a wording change on the settings page.
     115
    105116= 1.0.0 =
    106117First release.
  • clicknote/trunk/clicknote.php

    r3818086 r3818248  
    44 * Plugin URI:        https://clicknote.io/docs/wordpress
    55 * Description:       Adds your ClickNote project's snippet to this site, so your clients can click directly on elements of a page and leave a note. Ordinary visitors are not affected.
    6  * Version:           1.0.0
     6 * Version:           1.0.1
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
    … …  
    1818defined( 'ABSPATH' ) || exit;
    1919
    20 define( 'CLICKNOTE_VERSION', '1.0.0' );
     20define( 'CLICKNOTE_VERSION', '1.0.1' );
    2121define( 'CLICKNOTE_OPTION', 'clicknote_settings' );
    2222define( 'CLICKNOTE_HANDLE', 'clicknote-loader' );
     23
     24// Caching and optimisation plugins: clearing their caches, and keeping the loader out of their way.
     25require_once __DIR__ . '/includes/other-plugins.php';
    2326
    2427/**
    … …  
    138141
    139142        if ( ! empty( $input['disconnect'] ) ) {
    140                 add_settings_error( CLICKNOTE_OPTION, 'clicknote_disconnected', __( 'Disconnected. The snippet is no longer added to this site.', 'clicknote' ), 'success' );
    141                 return array(
    142                         'script_url' => '',
    143                         'project_id' => '',
     143                return clicknote_saving(
     144                        array(
     145                                'script_url' => '',
     146                                'project_id' => '',
     147                        ),
     148                        $current,
     149                        'clicknote_disconnected',
     150                        __( 'Disconnected. The snippet is no longer added to this site.', 'clicknote' )
    144151                );
    145152        }
    … …  
    152159
    153160        $replaced = clicknote_is_connected() && $parsed !== $current;
    154         add_settings_error(
    155                 CLICKNOTE_OPTION,
     161        return clicknote_saving(
     162                $parsed,
     163                $current,
    156164                'clicknote_connected',
    157165                $replaced
    158                         ? __( 'Snippet replaced. The new one is now on every public page of this site. If you use a caching plugin, clear its cache.', 'clicknote' )
    159                         : __( 'Connected. The snippet is now on every public page of this site. If you use a caching plugin, clear its cache.', 'clicknote' ),
    160                 'success'
    161         );
    162         return $parsed;
    163 }
     166                        ? __( 'Snippet replaced. The new one is now on every public page of this site.', 'clicknote' )
     167                        : __( 'Connected. The snippet is now on every public page of this site.', 'clicknote' )
     168        );
     169}
     170
     171/**
     172 * A form save that will change what pages show: clear the page caches once the new value is
     173 * stored, then say what happened and which caches were cleared.
     174 *
     175 * Clearing has to wait until the value is in the database, or a page rebuilt in between would be
     176 * cached with the old one. WordPress says so with the add_option_ and update_option_ actions below.
     177 * When the value is the one already stored (the same snippet pasted again), it writes nothing and
     178 * fires neither, so then it is done straight away.
     179 *
     180 * @param array  $value   What will be stored.
     181 * @param array  $current What is stored now.
     182 * @param string $code    The notice's code.
     183 * @param string $message The notice, without the sentence about caches.
     184 * @return array The value, unchanged.
     185 */
     186function clicknote_saving( $value, $current, $code, $message ) {
     187        if ( $value === $current ) {
     188                clicknote_saved_notice( $code, $message );
     189        } else {
     190                $GLOBALS['clicknote_pending_notice'] = array( $code, $message );
     191        }
     192        return $value;
     193}
     194
     195/**
     196 * The setting has been stored: clear the caches and give the notice that was waiting for it.
     197 */
     198function clicknote_settings_stored() {
     199        if ( empty( $GLOBALS['clicknote_pending_notice'] ) ) {
     200                return;
     201        }
     202        list( $code, $message ) = $GLOBALS['clicknote_pending_notice'];
     203        unset( $GLOBALS['clicknote_pending_notice'] );
     204        clicknote_saved_notice( $code, $message );
     205}
     206add_action( 'add_option_' . CLICKNOTE_OPTION, 'clicknote_settings_stored' );
     207add_action( 'update_option_' . CLICKNOTE_OPTION, 'clicknote_settings_stored' );
     208
     209/**
     210 * Clear the page caches and give one notice: what happened, then which caches were cleared or, if
     211 * no caching plugin was found, the advice to clear its cache.
     212 *
     213 * @param string $code    The notice's code.
     214 * @param string $message The notice, without the sentence about caches.
     215 */
     216function clicknote_saved_notice( $code, $message ) {
     217        $cleared = clicknote_clear_page_caches();
     218        add_settings_error( CLICKNOTE_OPTION, $code, $message . ' ' . clicknote_cache_sentence( $cleared ), 'success' );
     219}
     220
     221/**
     222 * When the plugin is deactivated the snippet stops being added, so cached pages that still have it
     223 * are cleared too.
     224 */
     225function clicknote_deactivate() {
     226        if ( clicknote_is_connected() ) {
     227                clicknote_clear_page_caches();
     228        }
     229}
     230register_deactivation_hook( __FILE__, 'clicknote_deactivate' );
    164231
    165232/**
    … …  
    274341                        <h1><?php esc_html_e( 'ClickNote', 'clicknote' ); ?></h1>
    275342                </div>
    276                 <p class="clicknote-lead"><?php esc_html_e( 'Website feedback your clients give by clicking. They open their own site, click the thing they mean and write a note. You get the page, the element, a screenshot and the device.', 'clicknote' ); ?></p>
     343                <p class="clicknote-lead"><?php esc_html_e( 'Website feedback your clients give by clicking. They open their own site, click directly on elements of the page and write a note. You get the page, the element, a screenshot and the device.', 'clicknote' ); ?></p>
    277344
    278345                <?php if ( $connected ) : ?>
    … …  
    379446
    380447/**
    381  * Give the loader's tag the project's id, and make sure it is async on every WordPress version.
     448 * Give the loader's tag the project's id, make sure it is async on every WordPress version, and
     449 * add the attributes that tell optimisation tools to leave it as it is (see includes/other-plugins.php).
    382450 *
    383451 * @param string $tag    The script tag.
    … …  
    396464        if ( ! preg_match( '/\sasync(\s|=|>)/', $tag ) ) {
    397465                $attributes .= ' async';
     466        }
     467        foreach ( clicknote_leave_alone_attributes() as $name => $value ) {
     468                if ( ! preg_match( '/\s' . preg_quote( $name, '/' ) . '(\s|=|>)/', $tag ) ) {
     469                        $attributes .= ' ' . $name . ( '' === $value ? '' : '="' . esc_attr( $value ) . '"' );
     470                }
    398471        }
    399472        if ( '' === $attributes ) {
  • clicknote/trunk/readme.txt

    r3818086 r3818248  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    2121* Adds one small script tag before the closing body tag of every public page.
    2222* Keeps working when the theme is changed or updated.
     23* Clears the page cache of popular caching plugins when you connect, replace or disconnect the snippet, and keeps its script out of script delaying and combining.
    2324* Removes its setting when the plugin is deleted.
    2425
    … …  
    48492. In ClickNote, open your project, go to "Install and settings" and copy the snippet.
    49503. In WordPress, go to Settings, ClickNote, paste the snippet and press Connect.
    50 4. If the site uses a caching plugin, clear its cache so pages are rebuilt with the snippet.
     514. The plugin clears the page cache of popular caching plugins itself, and says which. If the site uses another, clear its cache so pages are rebuilt with the snippet.
    51525. Open your project's review link to check that the review tools appear.
    5253
    … …  
    6768= Does it work with caching and optimisation plugins? =
    6869
    69 Yes. Clear the page cache after connecting. If a plugin combines, delays or inlines scripts, leave this one out of that: it must stay a separate script tag to work.
     70Yes. When you connect, replace or disconnect the snippet, and when you deactivate the plugin, it clears the page cache of WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super Cache, WP Fastest Cache, Speed Optimizer, Hummingbird, Breeze, Cache Enabler, WP-Optimize, Nginx Helper and Super Page Cache, whichever are active. The settings page says which caches it cleared. With any other caching plugin, clear its cache yourself.
     71
     72The script has to run as soon as a page loads, so the review tools appear the moment a client opens a review link. So the plugin also asks WP Rocket, LiteSpeed Cache, Autoptimize, Perfmatters, Speed Optimizer, Hummingbird, Jetpack Boost, W3 Total Cache, WP-Optimize and Breeze not to delay, defer, combine or minify it, using each plugin's own exclusion settings, and marks its script tag so that Cloudflare's Rocket Loader leaves it alone too. If another plugin delays, combines or inlines scripts, leave this one out of that: it must stay a separate script tag to work.
    7073
    7174= Does it work with page builders? =
    … …  
    98101== Changelog ==
    99102
     103= 1.0.1 =
     104* Clears the page cache of popular caching plugins, among them WP Rocket, LiteSpeed Cache, W3 Total Cache and WP Super Cache, when the snippet is connected, replaced or disconnected and when the plugin is deactivated. The settings page says which caches were cleared.
     105* Asks popular optimisation plugins, among them WP Rocket, LiteSpeed Cache, Autoptimize and Perfmatters, not to delay, defer, combine or minify its script, so the review tools still appear as soon as a review link is opened.
     106* The settings page describes ClickNote in the same words as the plugin's description.
     107
    100108= 1.0.0 =
    101109* First release.
    … …  
    103111== Upgrade Notice ==
    104112
     113= 1.0.1 =
     114Works with popular caching and optimisation plugins: clears their page cache when the snippet changes, and keeps its script out of delaying and combining. Also a wording change on the settings page.
     115
    105116= 1.0.0 =
    106117First release.
Note: See TracChangeset for help on using the changeset viewer.