EnlighterJS / Plugin.WordPress

:package: Official WordPress Plugin of EnlighterJS
http://wordpress.org/plugins/enlighter/
GNU General Public License v2.0
118 stars 17 forks source link

It doesn't work in custom post types #122

Closed rafaelcmgt closed 6 years ago

rafaelcmgt commented 6 years ago

Hi,

I am trying to use this plugin in my custom post types, but it doesn't work whatsoever. Is there a way to do it?

AndiDittrich commented 6 years ago

Hi @rafaelcmgt ,

is this issue related to TinyMCE or Gutenberg editor ?

could you please post a minimal example code snippet how you've created the post types ?

best regards, Andi

rafaelcmgt commented 6 years ago

Hi, Thank you for the quick response.

AndiDittrich commented 6 years ago

i've created a minimal example code to add a custom post-type and everything works as expected: Enlighter Toolbar buttons are available and the EnlighterJS/Plugin.TinyMCE has been successful initialized.

currently i believe it is an issue with your toolset plugin - maybe they override the editor plugins/buttons. you should contact their support for further further assistance.... because it is a payed plugin and i have no possibility to test/debug it. sorry!

you should also send them a link to this issue.

in the past there were a lot of issues related to 3rd party plugin - most of the commercial providers/vendors fixed the issues related to the editor


Code

<?php

add_action('init', function(){

    register_post_type(
        'courses',
        array(
            'label' => __('Courses'),
            'public' => true,
            'show_ui' => true,
            'supports' => array(
                'title',
                'editor',
                'post-thumbnails',
                'thumbnail',
                'revisions')
        )
    );

    register_taxonomy('coursetype', 'courses',
        array(
            'hierarchical' => true,
            'label' => __('Course Types'),
            'query_var' => 'coursetype',
            'rewrite' => array('slug' => 'coursetype' )
        )
    );
});

Result enlighter_posttype_test

rafaelcmgt commented 6 years ago

Sorry, I forgot to mention that the plugin works ok in the back-end. The problem is that it doesn't work in the front-end. Here is an example:

The back-end: back-end

The front-end front-end

I think that it might be this plugin. Other syntax hightlighter plugin works properly in my custom post type.

AndiDittrich commented 6 years ago

oh ok...it is not related to the editor...

and it works on standard posts/pages ?

edit: i've tested it with the custom post type above and everything works as expected.

do you use any kind of optimization/minification plugins ? try to disable them

AndiDittrich commented 6 years ago

btw. can you post a link to the frontend ? i will take a look on it - maybe some resources are missing

rafaelcmgt commented 6 years ago

It works perfect on standard post. This web is not on production yet. This is why i am not using any optimization/minification plugins. I was using a different syntax highlighting plugin. I have deactivated it, I have activated enlighter plugin and I have just created a post in my custom post type for you to see it. This is the link:

https://www.rafaelmartinweb.com/snippet/enlighter-plugin-test/

Just in case, here you have all my activated plugins:

plugins rafaelmartinweb wordpress

"Funciones" plugin is my own function plugin.

AndiDittrich commented 6 years ago

i've identified the issue: your frontend-builder css is overriding the EnlighterJS styles - therefore you didn't see any highlighted code (the engine itself and the plugin is working fine...)

by disabling the weak css rules everything works as expected..

enlighter_error_frontendbuilder

rafaelcmgt commented 6 years ago

Hi,

You are right. In the custom post type I am using a frontend builder.

To solve my problem, I am thinking in queueing the EnlighterJS.min.css with higher priority. I don't know if this are going to work, but I will try. However, I am unable to find the part of the code where this plugin queue EnlighterJS.min.css (I need to know it in order to unqueue it). Where is it?

AndiDittrich commented 6 years ago

https://github.com/EnlighterJS/Plugin.WordPress/blob/master/class/ResourceLoader.php#L253

rafaelcmgt commented 6 years ago

Thank you.

Unfortunately, it didn't work. I have decided to stop using the frontend builder for this custom post type. Now the Enlighter plugin is working properly.

Nice plugin and good support. I am going to post a good review in the wordpress repository.