Changeset 3757750
- Timestamp:
- 10/21/2026 05:47:18 AM (3 weeks ago)
- Location:
- glossary-tooltip/trunk
- Files:
-
- 1 deleted
- 6 edited
-
frontend/class-frontend.php (modified) (2 diffs)
-
frontend/class-highlighter.php (modified) (1 diff)
-
functions.php (modified) (1 diff)
-
glossary-tooltip.php (modified) (2 diffs)
-
gtt-main.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
-
uninstall.php (deleted)
Legend:
- Unmodified
- Added
- Removed
-
glossary-tooltip/trunk/frontend/class-frontend.php
r3747234 r3757750 139 139 140 140 $extract = trim( (string) ( is_array( $json ) ? ( $json['extract'] ?? '' ) : '' ) ); 141 $url = is_array( $json ) && isset( $json['content_urls']['desktop']['page'] ) 142 ? $json['content_urls']['desktop']['page'] 143 : sprintf( 'https://%1$s.wikipedia.org/wiki/%2$s', rawurlencode( $lang ), rawurlencode( str_replace( ' ', '_', $term ) ) ); 141 142 $fallback = sprintf( 'https://%1$s.wikipedia.org/wiki/%2$s', rawurlencode( $lang ), rawurlencode( str_replace( ' ', '_', $term ) ) ); 143 144 // Serve only trusted http(s) Wikipedia URLs; anything else uses the fallback. 145 $page = is_array( $json ) ? trim( (string) ( $json['content_urls']['desktop']['page'] ?? '' ) ) : ''; 146 $scheme = strtolower( (string) wp_parse_url( $page, PHP_URL_SCHEME ) ); 147 $url = ( '' !== $page && in_array( $scheme, [ 'http', 'https' ], true ) ) ? esc_url_raw( $page ) : $fallback; 144 148 145 149 $payload = array( … … 178 182 179 183 if ( ! empty( $this->options['single_only'] ) ) { 180 if ( ! is_singular() || is_front_page() || is_home() || is_archive() ) { 184 // A static front page is a singular page, so it highlights too; only 185 // listings (blog home, archives) are excluded. 186 if ( ! is_singular() || is_home() || is_archive() ) { 181 187 return $content; 182 188 } -
glossary-tooltip/trunk/frontend/class-highlighter.php
r3747234 r3757750 74 74 // the normalized lookup key, which is lowercased in case-insensitive mode 75 75 // and must never be shown to the reader. 76 if ( ! empty( $this->options['enable_title_attribute'] ) ) {77 $attributes['title'] = $text;78 }79 80 76 $tooltip_enabled = gtt_is_amp_request() ? false : ( null === $tooltip_enabled 81 77 ? ! empty( $this->options['enable_tooltip'] ) 82 78 : (bool) $tooltip_enabled ); 79 80 // The custom tooltip already shows the term on hover, so the native title 81 // attribute is only added when no tooltip renders (avoids a double tooltip). 82 if ( ! empty( $this->options['enable_title_attribute'] ) && ! $tooltip_enabled ) { 83 $attributes['title'] = $text; 84 } 83 85 84 86 if ( $tooltip_enabled ) { -
glossary-tooltip/trunk/functions.php
r3747234 r3757750 545 545 } 546 546 547 $fs = gtt_premium_fs(); 548 549 if ( ! $fs->can_use_premium_code__premium_only() ) { 550 return false; 551 } 552 553 return $fs->is_plan( $plan ); 547 return gtt_premium_fs()->is_plan__premium_only( $plan ); 554 548 } 555 549 -
glossary-tooltip/trunk/glossary-tooltip.php
r3747234 r3757750 4 4 * Plugin URI: https://glossarytooltip.com 5 5 * Description: Automatically highlight glossary terms and display tooltips with definitions. 6 * Version: 3.0. 56 * Version: 3.0.6 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 21 21 } 22 22 23 define( 'GTT_VERSION', '3.0. 5' );23 define( 'GTT_VERSION', '3.0.6' ); 24 24 define( 'GTT_NAME', 'Glossary Tooltip' ); 25 25 -
glossary-tooltip/trunk/gtt-main.php
r3747234 r3757750 11 11 if ( ! defined( 'ABSPATH' ) ) { 12 12 exit; 13 } 14 15 if ( version_compare( PHP_VERSION, '7.4', '<' ) ) { 16 add_action( 17 'admin_notices', 18 function () { 19 echo '<div class="notice notice-error"><p>' . esc_html__( 'Glossary Tooltip requires PHP 7.4 or higher.', 'glossary-tooltip' ) . '</p></div>'; 20 } 21 ); 22 return; 13 23 } 14 24 … … 76 86 // Signal that SDK was initiated. 77 87 do_action( 'gtt_fs_loaded' ); 88 89 // Freemius guideline: no uninstall.php (it would swallow the uninstall 90 // event + feedback). Clean up on its after_uninstall action instead. 91 gtt_fs()->add_action( 'after_uninstall', 'gtt_uninstall_cleanup' ); 78 92 } 79 93 … … 132 146 } 133 147 ); 148 149 /** 150 * Removes every option, transient and leftover post meta for one site, but 151 * only if the user opted in via the "Delete data on uninstall" setting. 152 * 153 * @return void 154 */ 155 function gtt_uninstall_site() { 156 157 $glossary_options = get_option( 'glossary_options' ); 158 159 if ( empty( $glossary_options['delete_data_on_uninstall'] ) ) { 160 return; 161 } 162 163 global $wpdb; 164 165 $options = [ 166 'glossary_options', 167 'gtt_welcome_completed', 168 'gtt_cache_salt', 169 'gtt_flush_rewrites', 170 'gtt_feedback_state', 171 'gtt_multisite_upgrade_notice', 172 'widget_gtt_search_widget', 173 'widget_gtt_latest_terms_widget', 174 'widget_gtt_categories_widget', 175 ]; 176 177 foreach ( $options as $option ) { 178 delete_option( $option ); 179 } 180 181 $transients = [ 182 'gtt_terms_cache_cs_v3', 183 'gtt_terms_cache_ci_v3', 184 'gtt_terms_cache_cs_v5', 185 'gtt_terms_cache_ci_v5', 186 'gtt_terms_cache_cs_v6', 187 'gtt_terms_cache_ci_v6', 188 'gtt_welcome_message', 189 ]; 190 191 foreach ( $transients as $transient ) { 192 delete_transient( $transient ); 193 } 194 195 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- one-off cleanup, no cache applies. 196 $wpdb->query( 197 $wpdb->prepare( 198 "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", 199 $wpdb->esc_like( '_transient_gtt_parsed_' ) . '%', 200 $wpdb->esc_like( '_transient_timeout_gtt_parsed_' ) . '%' 201 ) 202 ); 203 204 // The post type/taxonomies may not be registered during uninstall -- 205 // register them just enough for wp_delete_term()/wp_delete_post() to work. 206 register_taxonomy( 'glossary-cat', 'glossary' ); 207 register_taxonomy( 'glossary-tag', 'glossary' ); 208 209 foreach ( [ 'glossary-cat', 'glossary-tag' ] as $taxonomy ) { 210 $term_ids = get_terms( 211 [ 212 'taxonomy' => $taxonomy, 213 'fields' => 'ids', 214 'hide_empty' => false, 215 ] 216 ); 217 218 foreach ( $term_ids as $term_id ) { 219 wp_delete_term( $term_id, $taxonomy ); 220 } 221 } 222 223 $glossary_post_ids = get_posts( 224 [ 225 'post_type' => 'glossary', 226 'post_status' => 'any', 227 'posts_per_page' => -1, 228 'fields' => 'ids', 229 ] 230 ); 231 232 foreach ( $glossary_post_ids as $post_id ) { 233 wp_delete_post( $post_id, true ); 234 } 235 236 // Per-post overrides live on regular posts and pages, so deleting the 237 // glossary post type is not enough to clean them up. 238 $meta_keys = [ 239 'glossary_highlight_override', 240 'glossary_tooltip_override', 241 'glossary_disable_highlight', 242 'glossary_highlighting', 243 'glossary_index', 244 'glossary_synonyms', 245 'glossary_abbreviation', 246 'glossary_custom_url', 247 ]; 248 249 foreach ( $meta_keys as $meta_key ) { 250 delete_post_meta_by_key( $meta_key ); 251 } 252 253 wp_cache_flush(); 254 } 255 256 /** 257 * Freemius after_uninstall handler: runs gtt_uninstall_site() across every 258 * site on a network, mirroring what the removed uninstall.php did. 259 * 260 * @return void 261 */ 262 function gtt_uninstall_cleanup() { 263 if ( is_multisite() ) { 264 $site_ids = get_sites( 265 [ 266 'fields' => 'ids', 267 'number' => 0, 268 'update_site_meta_cache' => false, 269 ] 270 ); 271 272 foreach ( $site_ids as $site_id ) { 273 switch_to_blog( $site_id ); 274 gtt_uninstall_site(); 275 restore_current_blog(); 276 } 277 } else { 278 gtt_uninstall_site(); 279 } 280 } -
glossary-tooltip/trunk/readme.txt
r3747234 r3757750 6 6 Requires PHP: 7.4 7 7 Tested up to: 7.1 8 Stable tag: 3.0. 58 Stable tag: 3.0.6 9 9 License: GPLv3 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.txt … … 214 214 == Upgrade Notice == 215 215 216 = 3.0.6 = 217 218 * Fixes static front pages not highlighting terms. 219 * Removes the double tooltip when the title attribute is enabled. 220 * Validates double-click Wikipedia links to http/https only. 221 216 222 = 3.0.5 = 217 223 … … 239 245 240 246 == Changelog == 247 248 = 3.0.6 = 249 250 * Fixed: glossary terms now highlight on a static front page. 251 * Fixed: native title attribute no longer adds a second tooltip. 252 * Fixed: double-click Wikipedia URLs are restricted to http/https. 241 253 242 254 = 3.0.5 =
Note:
See TracChangeset
for help on using the changeset viewer.