Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Reusable Text Blocks plugin #203

Closed
strarsis opened this issue Mar 5, 2018 · 10 comments
Closed

Support for Reusable Text Blocks plugin #203

strarsis opened this issue Mar 5, 2018 · 10 comments
Labels

Comments

@strarsis
Copy link

strarsis commented Mar 5, 2018

Issue Overview

Content inserted by Reusable Text Block plugin is not filtered by wp-typography (hyphenations missing).

Steps to Reproduce (for bugs)

  1. Install and enable Reusable Text Block plugin.
  2. Install and enable wp-typography plugin.
  3. Create a new Text block.
  4. Insert this Textblock on a page and save/publish that page.
  5. View the page, inspect the content inserted by Textblock, there are no hyphenations.

Expected Behavior

Inserted Text block content is filtered and hyphenations inserted.

Current Behavior

Inserted Text block is not filtered, no hyphenations inserted.

Possible Solution

Add wp-typography as filter of Text block content to insert?
Should the author of Reusable Text Blocks use a more generic filter for the inserted Text block content?

Related Issues

https://wordpress.org/support/topic/content-filter-wp-typography/

Edit:
Apparently the_content filter is applied by Resuable Text Block plugin – should this suffice?:
https://plugins.trac.wordpress.org/browser/reusable-text-blocks/trunk/text-blocks.php#L302

@mundschenk-at
Copy link
Owner

The filter is not applied for all code paths, so if it's a plain text widget, nothing is done. This really is an issue with the Resuable Text Block plugin (and can easily be fixed by adding the filter to one of their hooks in your functions.php).

@strarsis
Copy link
Author

strarsis commented Mar 5, 2018

@mundschenk-at: Thanks! I tried

add_filter( 'text_blocks_shortcode_html', array( 'WP_Typography', 'filter' ) );

but this filter doesn't seem to be used in this use-case.

@mundschenk-at
Copy link
Owner

mundschenk-at commented Mar 6, 2018

Try writing a small wrapper function that logs the input and output to see if it gets ever called, something like this:

function my_filter( $content ) {
    error_log( "In: $content" );
    $result = WP_Typography::filter( $content );
    error_log( "Out: $result" );
    return $result;
}
add_filter( 'text_blocks_shortcode_html', 'my_filter' );

@mundschenk-at
Copy link
Owner

@strarsis Have you had any luck with the proposed my_filter function?

@strarsis
Copy link
Author

strarsis commented Mar 13, 2018

@mundschenk-at: Thanks for the code. But nothing is logged from inside the filter function.
I tested the logging outside the filter and logging works.

@mundschenk-at
Copy link
Owner

mundschenk-at commented Mar 13, 2018

Then for some reason the plugin does not use that filter hook in your case. You are using a shortcode?

@strarsis
Copy link
Author

strarsis commented Mar 13, 2018

@mundschenk-at: I am using it as widget ('Text Blocks Widget') in a sidebar.

@mundschenk-at
Copy link
Owner

mundschenk-at commented Mar 13, 2018

I think there is a separate hook for the widgets. @strarsis, try replacing text_blocks_shortcode_html with text_blocks_widget_html.

@mundschenk-at
Copy link
Owner

@strarsis Have you tried the widgets hook?

@strarsis
Copy link
Author

strarsis commented Mar 22, 2018

@mundschenk-at: Yes, it works now. 👍

// Reusable Text Blocks plugin
// Workaround for
//   https://wordpress.org/support/topic/content-filter-wp-typography/
//   https://github.com/mundschenk-at/wp-typography/issues/203
add_filter( 'text_blocks_widget_html',    array( 'WP_Typography', 'filter' ) );
add_filter( 'text_blocks_shortcode_html', array( 'WP_Typography', 'filter' ) );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants