codesnippetspro/code-snippets

WordPress Core issue affecting Code-snippets CodeMirror options?

Closed this issue · 2 comments

I'm not sure when it happened, but I lost a key feature, line numbering in the code-snippets editor. Features in the gutter like lineNumbers and code-folding no longer displayed. Interestingly, toggling the lineNumbers feature in settings would momentarily work in the preview, but after saving would no longer display.

After exhausting/testing code-snippets handling of CodeMirror, I focused on the WP core function, wp_enqueue_code_editor:

function wp_enqueue_code_editor( $args ) {
if ( is_user_logged_in() && 'false' === wp_get_current_user()->syntax_highlighting ) {
return false;
}

The very first thing it does is check if the user is logged in and is allowing syntax highlighting, but rather than load up CodeMirror with its options it returns false.

Inverting the condition makes much more sense to me and actually solved my problem. And so, on my system, the condition now reads:

    if ( ! is_user_logged_in() ||  'true' === wp_get_current_user()->syntax_highlighting ) { //<-note that syntax highlighting means  disable syntax highlighting
            return false;
    }

I bring this to your attention, Shea, in the hope that it is helpful. I would have cross-posted this to WordPress, but couldn't find their "issues" and didn't pursue it further. Also, I have butted heads with them already over code changes that despite being syntactically correct (their standard of excellence) completely changed the usefulness.

Congratulations on the new company!

WordPress: 6.1.1
Code-snippets: 3.2.2

Mike

Hi Mike,

Thank you for raising this issue. I'm a little confused however – wouldn't this be solved by just enabling syntax highlighting in your user settings? It sounds like you have it turned off, which is why inverting the condition made things work again.

You can find the setting on the wp-admin/profile.php page of your site:

image

Closing this for now as it seems like it might be down to a misconfiguration on your site user profile. Feel free to follow this up further if you have additional questions or concerns.