WordPress.org

Forums

Reusable Text Blocks
[resolved] Feature: Update filter (5 posts)

  1. defunctlife
    Member
    Posted 1 year ago #

    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/

  2. Hal Gatewood
    Member
    Plugin Author

    Posted 1 year ago #

    I will do so soon. Thanks for the idea!

  3. Hal Gatewood
    Member
    Plugin Author

    Posted 1 year ago #

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

  4. defunctlife
    Member
    Posted 2 months ago #

    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!

  5. Hal Gatewood
    Member
    Plugin Author

    Posted 2 months ago #

    Great addition. Just got it added to 1.4.7.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Reusable Text Blocks
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.