Plugin Directory

Changeset 3465464


Ignore:
Timestamp:
02/20/2026 01:39:14 AM (6 weeks ago)
Author:
kasuga16
Message:

Fix a minor bug

Location:
stick-copy-button-codeblock
Files:
13 added
2 edited

Legend:

Unmodified
Added
Removed
  • stick-copy-button-codeblock/trunk/readme.txt

    r3464250 r3465464  
    165165
    166166== Changelog ==
     167= 1.5.1 =
     168* Minor fix to the conditional script loading logic introduced in 1.5.0.
     169
    167170= 1.5.0 =
    168171* Load scripts only when code blocks are detected.
  • stick-copy-button-codeblock/trunk/stick-copy-button-codeblock.php

    r3464250 r3465464  
    33 * Plugin Name: Sticky Copy Button for Code Blocks
    44 * Description: This plugin adds a convenient copy button to every code block on your blog posts. Customize the button's position, labels, size, and colors from a dedicated settings page to match your site's design. Optional line numbers can be displayed.
    5  * Version: 1.5.0
     5 * Version: 1.5.1
    66 * Author: Kasuga
    77 * License: GPLv2 or later
     
    235235 */
    236236function kasuga_scbc_enqueue_assets() {
     237    if ( is_admin() || is_feed() ) {
     238        return;
     239    }
     240
    237241    if ( ! is_singular() ) {
    238242        return;
     
    244248    }
    245249
    246     if ( ! has_block( 'core/code', $post ) && strpos( $post->post_content, '<pre' ) === false ) {
     250    $should_enqueue = false;
     251
     252    if ( has_block( 'core/code', $post ) || has_block( 'core/preformatted', $post ) ) {
     253        $should_enqueue = true;
     254    }
     255
     256    $content = $post->post_content;
     257    if ( ! $should_enqueue && ( strpos( $content, '<pre' ) !== false || strpos( $content, '<code' ) !== false ) ) {
     258        $should_enqueue = true;
     259    }
     260
     261    if ( ! $should_enqueue && has_block( 'core/block', $post ) ) {
     262        $should_enqueue = true;
     263    }
     264
     265    if ( ! $should_enqueue ) {
    247266        return;
    248267    }
Note: See TracChangeset for help on using the changeset viewer.