| @@ -32,9 +32,8 @@ | ||
| 32 | 32 | public function init_cache() { |
| 33 | 33 | // Only for front view |
| 34 | 34 | if ( ! is_admin() ) { |
| 35 | 35 | add_action( 'wp_head', array( $this, 'start_cache' ) ); |
| 36 | - add_action( 'wp_footer', array( $this, 'modify_html' ), 99999 ); | |
| 37 | 36 | } |
| 38 | 37 | } |
| 39 | 38 | /** |
| 40 | 39 | * Start cache for outputing |
| @@ -39,9 +38,9 @@ | ||
| 39 | 38 | /** |
| 40 | 39 | * Start cache for outputing |
| 41 | 40 | */ |
| 42 | 41 | public function start_cache() { |
| 43 | - ob_start(); | |
| 42 | + ob_start( array( $this, 'modify_html' ) ); | |
| 44 | 43 | } |
| 45 | 44 | /** |
| 46 | 45 | * Will be called when flush cache |
| 47 | 46 | * |
| @@ -47,14 +46,13 @@ | ||
| 47 | 46 | * |
| 48 | 47 | * @param string cached string |
| 49 | 48 | * @return string modified cached string |
| 50 | 49 | */ |
| 51 | - public function modify_html() { | |
| 52 | - $html = ob_get_clean(); | |
| 50 | + public function modify_html( $html ) { | |
| 53 | 51 | if ( $this->site_header_loaded && $this->site_footer_loaded ) { |
| 54 | - echo apply_filters( 'loftloader_modify_html', $html ); | |
| 52 | + return apply_filters( 'loftloader_modify_html', $html ); | |
| 55 | 53 | } else { |
| 56 | - echo $html; | |
| 54 | + return $html; | |
| 57 | 55 | } |
| 58 | 56 | } |
| 59 | 57 | /** |
| 60 | 58 | * @description get the plugin settings |