Changeset 3818248
- Timestamp:
- 11/23/2026 12:29:06 PM (2 days ago)
- Location:
- clicknote
- Files:
-
- 4 added
- 4 edited
- 1 copied
-
tags/1.0.1 (copied) (copied from clicknote/trunk )
-
tags/1.0.1/clicknote.php (modified) (7 diffs)
-
tags/1.0.1/includes (added)
-
tags/1.0.1/includes/other-plugins.php (added)
-
tags/1.0.1/readme.txt (modified) (6 diffs)
-
trunk/clicknote.php (modified) (7 diffs)
-
trunk/includes (added)
-
trunk/includes/other-plugins.php (added)
-
trunk/readme.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
clicknote/tags/1.0.1/clicknote.php
r3818086 r3818248 4 4 * Plugin URI: https://clicknote.io/docs/wordpress 5 5 * 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. 06 * Version: 1.0.1 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 18 18 defined( 'ABSPATH' ) || exit; 19 19 20 define( 'CLICKNOTE_VERSION', '1.0. 0' );20 define( 'CLICKNOTE_VERSION', '1.0.1' ); 21 21 define( 'CLICKNOTE_OPTION', 'clicknote_settings' ); 22 22 define( 'CLICKNOTE_HANDLE', 'clicknote-loader' ); 23 24 // Caching and optimisation plugins: clearing their caches, and keeping the loader out of their way. 25 require_once __DIR__ . '/includes/other-plugins.php'; 23 26 24 27 /** … … 138 141 139 142 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' ) 144 151 ); 145 152 } … … 152 159 153 160 $replaced = clicknote_is_connected() && $parsed !== $current; 154 add_settings_error( 155 CLICKNOTE_OPTION, 161 return clicknote_saving( 162 $parsed, 163 $current, 156 164 'clicknote_connected', 157 165 $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 */ 186 function 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 */ 198 function 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 } 206 add_action( 'add_option_' . CLICKNOTE_OPTION, 'clicknote_settings_stored' ); 207 add_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 */ 216 function 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 */ 225 function clicknote_deactivate() { 226 if ( clicknote_is_connected() ) { 227 clicknote_clear_page_caches(); 228 } 229 } 230 register_deactivation_hook( __FILE__, 'clicknote_deactivate' ); 164 231 165 232 /** … … 274 341 <h1><?php esc_html_e( 'ClickNote', 'clicknote' ); ?></h1> 275 342 </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 meanand 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> 277 344 278 345 <?php if ( $connected ) : ?> … … 379 446 380 447 /** 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). 382 450 * 383 451 * @param string $tag The script tag. … … 396 464 if ( ! preg_match( '/\sasync(\s|=|>)/', $tag ) ) { 397 465 $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 } 398 471 } 399 472 if ( '' === $attributes ) { -
clicknote/tags/1.0.1/readme.txt
r3818086 r3818248 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 21 21 * Adds one small script tag before the closing body tag of every public page. 22 22 * 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. 23 24 * Removes its setting when the plugin is deleted. 24 25 … … 48 49 2. In ClickNote, open your project, go to "Install and settings" and copy the snippet. 49 50 3. 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.51 4. 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. 51 52 5. Open your project's review link to check that the review tools appear. 52 53 … … 67 68 = Does it work with caching and optimisation plugins? = 68 69 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. 70 Yes. 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 72 The 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. 70 73 71 74 = Does it work with page builders? = … … 98 101 == Changelog == 99 102 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 100 108 = 1.0.0 = 101 109 * First release. … … 103 111 == Upgrade Notice == 104 112 113 = 1.0.1 = 114 Works 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 105 116 = 1.0.0 = 106 117 First release. -
clicknote/trunk/clicknote.php
r3818086 r3818248 4 4 * Plugin URI: https://clicknote.io/docs/wordpress 5 5 * 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. 06 * Version: 1.0.1 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 18 18 defined( 'ABSPATH' ) || exit; 19 19 20 define( 'CLICKNOTE_VERSION', '1.0. 0' );20 define( 'CLICKNOTE_VERSION', '1.0.1' ); 21 21 define( 'CLICKNOTE_OPTION', 'clicknote_settings' ); 22 22 define( 'CLICKNOTE_HANDLE', 'clicknote-loader' ); 23 24 // Caching and optimisation plugins: clearing their caches, and keeping the loader out of their way. 25 require_once __DIR__ . '/includes/other-plugins.php'; 23 26 24 27 /** … … 138 141 139 142 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' ) 144 151 ); 145 152 } … … 152 159 153 160 $replaced = clicknote_is_connected() && $parsed !== $current; 154 add_settings_error( 155 CLICKNOTE_OPTION, 161 return clicknote_saving( 162 $parsed, 163 $current, 156 164 'clicknote_connected', 157 165 $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 */ 186 function 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 */ 198 function 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 } 206 add_action( 'add_option_' . CLICKNOTE_OPTION, 'clicknote_settings_stored' ); 207 add_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 */ 216 function 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 */ 225 function clicknote_deactivate() { 226 if ( clicknote_is_connected() ) { 227 clicknote_clear_page_caches(); 228 } 229 } 230 register_deactivation_hook( __FILE__, 'clicknote_deactivate' ); 164 231 165 232 /** … … 274 341 <h1><?php esc_html_e( 'ClickNote', 'clicknote' ); ?></h1> 275 342 </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 meanand 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> 277 344 278 345 <?php if ( $connected ) : ?> … … 379 446 380 447 /** 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). 382 450 * 383 451 * @param string $tag The script tag. … … 396 464 if ( ! preg_match( '/\sasync(\s|=|>)/', $tag ) ) { 397 465 $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 } 398 471 } 399 472 if ( '' === $attributes ) { -
clicknote/trunk/readme.txt
r3818086 r3818248 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 21 21 * Adds one small script tag before the closing body tag of every public page. 22 22 * 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. 23 24 * Removes its setting when the plugin is deleted. 24 25 … … 48 49 2. In ClickNote, open your project, go to "Install and settings" and copy the snippet. 49 50 3. 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.51 4. 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. 51 52 5. Open your project's review link to check that the review tools appear. 52 53 … … 67 68 = Does it work with caching and optimisation plugins? = 68 69 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. 70 Yes. 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 72 The 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. 70 73 71 74 = Does it work with page builders? = … … 98 101 == Changelog == 99 102 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 100 108 = 1.0.0 = 101 109 * First release. … … 103 111 == Upgrade Notice == 104 112 113 = 1.0.1 = 114 Works 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 105 116 = 1.0.0 = 106 117 First release.
Note:
See TracChangeset
for help on using the changeset viewer.