Compatibility issue with OMGF
-
Hi!
We have a mutual client who is experiencing a compatibility issue between your plugin and OMGF (my plugin).
The issue lies in the usage of output buffering. Speed Optimizer and OMGF both start output buffers with a callback, but since Speed Optimizer flushes all output buffers, OMGF’s callback never runs.
A fix I found would be to add a filter to your output HTML, e.g. at the end of
SiteGround_Optimizer\Parser\Parser::run():/**
* Run the parser.
*
* @since 5.5.2
*
* @param string $html The page html.
*
* @return string $html The modified html.
*/
public function run( $html ) {
if ( ! preg_match( '/<\/html>/i', $html ) ) {
return $html;
}
// Replace unsecure links if the option is enabled.
if ( Options::is_enabled( 'siteground_optimizer_fix_insecure_content' ) ) {
$html = Ssl::get_instance()->replace_insecure_links( $html );
}
// Do not run optimizations if amp is active, the page is an xml or feed.
if (
$this->is_amp_enabled( $html ) ||
Helper::is_xml( $html ) ||
is_feed()
) {
return $html;
}
// If the user is logged in and the filebased caching is disabled.
if ( is_user_logged_in() ) {
// Return the original html if the filebased caching is disabled.
if ( ! Options::is_enabled( 'siteground_optimizer_file_caching' ) ) {
return $html;
}
// Return the original html if loggedin filebased caching is disabled.
if ( ! Options::is_enabled( 'siteground_optimizer_logged_in_cache' ) ) {
return $html;
}
}
$optimized_html = $this->optimize_for_visitors( $html );
if ( Options::is_enabled( 'siteground_optimizer_file_caching' ) ) {
File_Cacher::get_instance()->process( $optimized_html );
}
return apply_filters( 'sgo_optimized_html', $optimized_html );
}With this filter in place, OMGF would hook into that, so it could still apply its optimizations, e.g.:
if ( defined( 'SiteGround_Optimizer\PLUGIN_SLUG' ) ) {
remove_filter( 'omgf_buffer_output', [ $this, 'process' ] );
add_filter( 'sgo_optimized_html', [ $this, 'process' ] );
}Hopefully you’d be willing to add this filter short term to help out our mutual client.
Looking forward to your reply!
Kind regards,
Daan van den Bergh (developer of OMGF)
The page I need help with: [log in to see the link]
You must be logged in to reply to this topic.