code-block-pro icon indicating copy to clipboard operation
code-block-pro copied to clipboard

Copy button does not work

Open Kami958 opened this issue 1 year ago • 10 comments

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 avatar Apr 12 '24 12:04 Kami958

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

Kami958 avatar Apr 12 '24 12:04 Kami958

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

KevinBatdorf avatar Apr 12 '24 13:04 KevinBatdorf

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.

Kami958 avatar Apr 12 '24 13:04 Kami958

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.

KevinBatdorf avatar Apr 12 '24 18:04 KevinBatdorf

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

Kami958 avatar Apr 13 '24 03:04 Kami958

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 avatar Apr 18 '24 04:04 TCBW-KOD

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 avatar Apr 18 '24 05:04 TCBW-KOD

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 avatar Apr 18 '24 06:04 TCBW-KOD

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

TCBW-KOD avatar Apr 18 '24 06:04 TCBW-KOD

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.

KevinBatdorf avatar Apr 18 '24 13:04 KevinBatdorf