Filter content in show_text_block()
-
I want suggest this modify for the method show_text_block function:
This method is used in version 1.4.8
// SHOW TEXT BLOCK function show_text_block($id, $plain = false, $atts = false) { $id = apply_filters( 'text_blocks_show_text_block_id', $id ); // IF ID IS NOT NUMERIC CHECK FOR SLUG if(!is_numeric($id)) { $page = get_page_by_path( $id, null, 'text-blocks' ); $id = $page->ID; } if( !$id ) return false; // LOOK FOR TEMPLATE IN THEME $template = isset($atts['template']) ? $atts['template'] : $id; $template = locate_template( array( "text-blocks-{$template}.php" ) ); // Daniele: This filter is used from template to translate content for multilanguage $content = apply_filters('text_blocks_content', get_post_field( 'post_content', $id ), $id, $plain, $atts); // LOAD TEMPLATE IF FOUND if( $template ) { ob_start(); include( $template ); $output = ob_get_contents(); ob_end_clean(); return $output; } // LOAD PLAIN CONTENT if($plain) { return apply_filters( 'text_blocks_shortcode_html', $content, $atts ); } // APPLY 'the_content' FILTER TO BLEND WITH EVERYTHING ELSE $content = apply_filters( 'the_content', $content, $atts ); return apply_filters( 'text_blocks_shortcode_html', $content, $atts, $id ); }
I’ve added this line
$content = apply_filters('text_blocks_content', get_post_field( 'post_content', $id ), $id, $plain, $atts);
For me it’s really helpful to increase performance when this plugin load content of multilanguage; For example: I use qTranslateX, the content page split language content like is [:en]En content[:it]IT content[:]
Adding my suggested filter I can filter loaded content in my template to return only the content with current language (and other minor fix related to qTranslateX).
Best regards,
Daniele
- The topic ‘Filter content in show_text_block()’ is closed to new replies.