Support » Plugin: Reusable Text Blocks » Feature: Update filter

  • Resolved defunct

    (@defunctlife)


    I am trying to filter the content to add a direct edit link to users who can edit the text block (similar to how tablepress does it) but there isn’t a proper hook that includes the id.

    I updated your function to include an updated filter so it would now be possible. It would be awesome if you added it to the core.

    // SHOW TEXT BLOCK
    function show_text_block($id, $plain = false)
    {
    	// 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;
    
    	if($plain)
    	{
    		return apply_filters( 'text_blocks_shortcode_html', get_post_field('post_content', $id), $id);
    	}
    
    	$content = apply_filters( 'the_content', get_post_field('post_content', $id) );
    	return apply_filters( 'text_blocks_shortcode_html', $content, $id);
    }

    https://wordpress.org/plugins/reusable-text-blocks/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Hal Gatewood

    (@halgatewood)

    I will do so soon. Thanks for the idea!

    Plugin Author Hal Gatewood

    (@halgatewood)

    Can you post your version? This looks like the one that is currently there. Unless I just don’t see what you did.

    Hi,

    Sorry for the REALLY late reply!

    The update would be to line 299 in the current version of the plugin:

    From: return apply_filters( 'text_blocks_shortcode_html', $content, $atts );

    To: return apply_filters( 'text_blocks_shortcode_html', $content, $atts, $id);

    Adding $id to the filter allows me to create an edit post link based on the post id of the text block.

    Thanks!

    Plugin Author Hal Gatewood

    (@halgatewood)

    Great addition. Just got it added to 1.4.7.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Feature: Update filter’ is closed to new replies.