jtrt-tables icon indicating copy to clipboard operation
jtrt-tables copied to clipboard

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

Open Seamate opened this issue 5 years ago • 8 comments

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

Seamate avatar Jul 31 '19 12:07 Seamate

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.

JohnTendik avatar Jul 31 '19 23:07 JohnTendik

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 avatar Aug 01 '19 03:08 Seamate

Any update, John?

Seamate avatar Aug 04 '19 01:08 Seamate

Im still looking into this, sorry for the delay.

JohnTendik avatar Aug 10 '19 16:08 JohnTendik

Okay bro. Thanks

Seamate avatar Aug 17 '19 15:08 Seamate

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 avatar Sep 04 '19 23:09 JohnTendik

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.

JohnTendik avatar Sep 04 '19 23:09 JohnTendik

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

Seamate avatar Sep 07 '19 05:09 Seamate