soflyy / oxygen-bugs-and-features

Bug Reports & Feature Requests for Oxygen
https://oxygenbuilder.com/
314 stars 29 forks source link

Add an equivalent to filter the_content #1652

Open swinggraphics opened 4 years ago

swinggraphics commented 4 years ago

Describe the feature you'd like to see included in Oxygen. Because Oxygen doesn't run the_content filters on pages built in it, it would be helpful if Oxygen would (really, should) run a similar filter after doing its shortcodes. While we can filter do_shortcode_tag, that will get run many times on a page, and that can lead to very complex coding or filters being run too many times.

In addition to a filter in the code, it might be neat to be able to tell parts of a template to run specific filters on its output. For example, I would want to set an Inner Content to apply the_content filters.

What are the use cases for this feature? Our own filters for special characters, language needs, easier integration with plugins, etc.

Rados51 commented 4 years ago

+1

swinggraphics commented 4 years ago

For anyone who finds this looking for a solution, this is what I'm currently using for a specific case:

/* Superscript TM and R */
function my_sup_tm_r( $content ) {
    $content = preg_replace( '%(™|&trade;|&#8482;|&#x2122;)(?!</sup>)%', '<sup>$1</sup>', $content );
    $content = preg_replace( '%(®|&reg;|&#174;|&#x00AE;)(?!</sup>)%', '<sup>$1</sup>', $content );
    return $content;
}
add_filter( 'the_content', 'my_sup_tm_r', 20 );
add_filter( 'do_shortcode_tag', 'my_sup_tm_r', 20 );
yankiara commented 3 years ago

+1

wala0003 commented 2 years ago

+1 need something like this to do URL modification to support an image CDN. It would also be good to be able to filter the oxy generated CSS for these URLs as well.

dubpir8 commented 2 years ago

Many membership plugins that restrict access to pages appear to use "the_content" filter. Is there an easy way to add this filter to the "Inner Content" element in templates so that this can work with Oxygen Builder?

swinggraphics commented 2 years ago

Many membership plugins that restrict access to pages appear to use "the_content" filter. Is there an easy way to add this filter to the "Inner Content" element in templates so that this can work with Oxygen Builder?

The inner content module uses the_content(), so the filters should be applied. For example, this works:

function filter_test( $content ) {
    return $content . '<!-- FILTER TEST -->';
}
add_filter( 'the_content', 'filter_test' );
oliver-groth commented 2 years ago

Where do I add this code? In a oxygen code block at "Inner Content"? I can't get it working.