Better AMP technically known as “Better AMP – WordPress Complete AMP” is one of the free-premium WordPress plugin that comes with almost very themes designed and developed by the Better Studio one of the leading WordPress theme designing company on the themeforest. Better AMP is also an alternative to the AMP Plugin developed by the Automattic better known “the company that has developed the WordPress”
On 24th April 2017, Better Studio released the Better AMP version 1.3.1 with improvements, but unlike every software the Better AMP has some bug which could not be discovered until you are not using W3 Total Cache to supercharge your website or blog’s performance.
On updating Better AMP and activating the W3 Total Cache I discovered that my server’s error log was filled with following error:
[24-Apr-2017 19:15:08 UTC] PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Better_AMP' does not have a method '_return_false' in /wp-includes/class-wp-hook.php on line 298
It was a bit scary for me since I’d recently moved my whole website from sub-directory to the root and the most of the hits I was getting was mostly from “301 Permanently Moved Redirect” and I was worried to lose the Google ranking.
For a moment I thought there is some problem with wp-hook.php since the WordPress has modified wp-hook.php file in their last update and error log included the name of wp-hook.php file, but this could not be possible as they test it out several times before releasing to the public. So, to resolve the issue quickly I decided to create a ticket on the official website of the Better AMP developer i.e. the Better Studio, but unfortunately there was huge difference between the time-zone and I could not wait for the next 12 hours to get the issue resolved which further could not guarantee me 100% to resolve the issue on time.
So, finally decided to take the help from wordpress.stackexchange.com community and I posted the question and within fraction of minutes I received the answer too.
So, the solution to the PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘Better_AMP’ does not have a method’ I found is manually modifying the better-amp.php
To resolve the issue :
- Go to the plugins folders
- Go to the better-amp (the default plugin directory for the Better AMP)
- Locate and open better-amp.php file and replace the line number 1197 and 1198
add_filter( 'w3tc_minify_js_enable', array( $this, '_return_false' ) ); add_filter( 'w3tc_minify_css_enable', array( $this, '_return_false' ) );
add_filter( 'w3tc_minify_js_enable', '__return_false' ); add_filter( 'w3tc_minify_css_enable', '__return_false' );
Well, this worked for me! Your comments and suggestions will be appreciated in the comment