JohnTendik / jtrt-tables

A Wordpress plugin to help users create responsive tables without having to read or write code.
GNU General Public License v2.0
22 stars 6 forks source link

Tables Don't Display on Excerpts Shown to Logged Out Users #90

Open Seamate opened 5 years ago

Seamate commented 5 years ago

Hello John,

I experienced an issue with your plugin when I used it in an excerpt on a page which requires log in to have access. The page shows an excerpt to logged out users, but tables are not parsed. It only shows the shortcode.

It might be a conflict with the Sensei LMS since it was in lessons I used the tables in an excerpt.

I will be expecting a response from you, and possibly a fix.

Thank you

JohnTendik commented 5 years ago

Hey @Seamate ,

I'm not really sure what could be going on, can you email me an example, like a page where the issue is happening?

I could make wild assumptions about Sensei LMS plugin handling content output and blame them but lets try a few things first :)

Can you try adding this to your functions.php file

// Allow Shortcodes in the Excerpt field
 add_filter('the_excerpt', 'do_shortcode');
add_filter('get_the_excerpt', 'do_shortcode');

Thinking about this some more, this could be a bigger problem than it seems though... The excerpt has a maximum content length, the table plugin will generate a lot of text which could exceed the limits of excerpt text length. If the except cuts off the table content text that is generated, the table would never be able to work because it would be incomplete and broken.. Im not sure.. I will investigate.

Seamate commented 5 years ago

I added the filter to functions.php and it seemed to work, but it also shows two boxes above the actual table. The first box contains the raw code that displays the table I guess. I have sent you the page via email. Thank you

Seamate commented 5 years ago

Any update, John?

JohnTendik commented 5 years ago

Im still looking into this, sorry for the delay.

Seamate commented 5 years ago

Okay bro. Thanks

JohnTendik commented 5 years ago

Hey, so after looking at this a few times, I've started to thing its not a problem with my JTRT plugin. The snippets I gave you:

add_filter('the_excerpt', 'do_shortcode'); add_filter('get_the_excerpt', 'do_shortcode');

adding these two to my functions.php in my theme seemed to fix the issue for me.. However, I'm not using that same Sensei LMS plugin... Thinking that its a plugin designed specifically to hide content, I think they probably have some sort of hooks to hide content within the except.

Have you tried creating a bug ticket for Sensei LMS?

JohnTendik commented 5 years ago

Also, looking through the code of Sensei,

// @since 1.9.0
// lesson custom excerpts
add_filter( 'get_the_excerpt', array( 'Sensei_Lesson', 'alter_the_lesson_excerpt' ) );
public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
        $html = '';
        if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
            $excerpt = $lesson->post_excerpt;
            // if $add_p_tags true wrap with <p> else return the excerpt as is
            $html = $add_p_tags ? wp_kses_post( wpautop( $excerpt ) ) : esc_html( $excerpt );
        }
        return apply_filters( 'sensei_lesson_excerpt', $html );
    } // End lesson_excerpt()

so try this

add_filter('sensei_lesson_excerpt', 'do_shortcode');

Let me know if that helps. If not, I think the best thing to do would be to contact Sensei support and see what they think..

P.S make sure add_p_tags is false (im not sure if its a setting you can set) because having <table>inside of <p> is invalid.

Seamate commented 5 years ago

I tried the code in my functions.php file but it didn't work. Thanks for taking the time to look into this.