Filters Available

Filter Default Value
text_blocks_post_type_args Array of register_post_type Arguments
text_blocks_widget_html $block_content
text_blocks_show_text_block_id $id
wpml_object_id $page->ID
text_blocks_template_location array

text_blocks_post_type_args
Default: Array of register_post_type Arguments

You can modify the custom post type that gets created by filtering on the arguments. See the codex.

function hg_text_blocks_post_type_args( $args )
{
  $args['public'] = true;
  return $args;
}
add_filter('text_blocks_post_type_args','hg_text_blocks_post_type_args');

text_blocks_widget_html
Default: $block_content

When using the widget to display the Text Block you can modify it’s contents before it is displayed.

function hg_text_blocks_widget_html( $content )
{
  return '<div class="bonus-wrapper">' . $content . '</div>';
}
add_filter('text_blocks_widget_html','hg_text_blocks_widget_html');

text_blocks_show_text_block_id
Default: $id

You can modify the ID that is passed to the Text Block. This can be helpful for translation plugins or just general madness when creating your block.

function hg_text_blocks_show_text_block_id( $id )
{
  if( $id == 5 ) return "get-5-whatever";
  return $id;
}
add_filter('text_blocks_show_text_block_id','hg_text_blocks_show_text_block_id');

wpml_object_id
Default: $page->ID

WPML has now stopped supporting the get_page_by_path() function and it has caused problems when two pages (or text blocks) in different languages have the same slug. See this ticket for more info.

function hg_wpml_object_id( $id )
{
  // MODIFY LOGIC HERE
  return $id;
}
add_filter('wpml_object_id','hg_wpml_object_id');

text_blocks_template_location
Default: array

By default starting in version 1.5.3, the plugin will look for custom templates in the main theme folder and for a folder called ‘text-blocks‘ in your main theme folder. You can use this filter to change where the WordPress function locate_template looks for the template.

The {$template} variable in “text-blocks-{$template}.php” can be set with an attribute of templete=”” if that attribute is not available, it will use the ID of the text block.

function hg_text_blocks_template_location( )
{
  return array( "my-custom-folder-name/text-blocks-{$template}.php", "my-custom-folder-name/text-blocks.php" );
}
add_filter('text_blocks_template_location','hg_text_blocks_template_location');