KevinBatdorf / code-block-pro

A Gutenberg code block with syntax highlighting powered by VS Code
https://code-block-pro.com
132 stars 10 forks source link

Copy button does not work #315

Open Kami958 opened 7 months ago

Kami958 commented 7 months ago

I have set up a copy button, which displays normally on the editing interface, but the copy button is not displayed on the publishing interface. Is this related to my topic? Or am I missing any plugins? image image

Kami958 commented 7 months ago

Okay, I have identified the issue, which is due to the theme

KevinBatdorf commented 7 months ago

Hey thanks for reporting (even if it's the theme). Could you provide details on the fix? Maybe I could account for it in the plugin, or if you still need help fixing it let me know

Kami958 commented 7 months ago

Hey thanks for reporting (even if it's the theme). Could you provide details on the fix? Maybe I could account for it in the plugin, or if you still need help fixing it let me know

No, I only know that this is related to the theme. I resolved this issue after changing the theme. But since I haven't studied any relevant programming languages, I don't know the cause of the problem, and I'm sorry.

KevinBatdorf commented 7 months ago

Ah ok. What's the theme name? I can take a look.

Or if you want to enable the other theme just send me a url to your site and I'll check it.

Or if you're happy with the new theme that's fine too.

Kami958 commented 7 months ago

Ah ok. What's the theme name? I can take a look.

Or if you want to enable the other theme just send me a url to your site and I'll check it.

Or if you're happy with the new theme that's fine too.

This is the theme of not working properly : https://github.com/kannafay/iEmo

TCBW-KOD commented 7 months ago

I experienced the same issue and resolved it by changing the theme. Here is the link to the non-functioning theme: https://github.com/justid/InlineAMP.

TCBW-KOD commented 7 months ago

I managed to display the code correctly by removing remove_all_actions('wp_head') and add_filter('use_block_editor_for_post', '__return_false', 10) in the original theme's functions.php. However, the copy button isn't functioning properly. Strangely, everything works as expected in Gutenberg's preview and editor interfaces, but not in the visitor interface.

TCBW-KOD commented 7 months ago

I discovered the issue: the theme uses wp_footer() exclusively under conditions such as being in customize preview or when a user is logged in, as shown below:

<?php 
    if (is_customize_preview() || is_user_logged_in()) {
        wp_footer(); 
    }
?>

I removed this conditional restriction, and now everything functions as expected.

TCBW-KOD commented 7 months ago

By the way, great plugin—I really love the theme options!

KevinBatdorf commented 7 months ago

Hey thanks for checking back in. If you want to remove wp_footer() you could load the JS script manually, but you probably want that loaded anyway as it's loading some important stuff there.