Title: PHP7 Compatibility EASY FIX use __construct()
Last modified: September 1, 2016

---

# PHP7 Compatibility EASY FIX use __construct()

 *  Resolved [Jer Clarke](https://wordpress.org/support/users/jeremyclarke/)
 * (@jeremyclarke)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/php7-compatibility-easy-fix-use-_construct/)
 * PHP7 has a new deprecation warning that forces us to define classes slightly 
   differently. Rather than being able to use the class name as the label for the
   constructor method, the constructor method must be called `__construct()`. PHP7
   is about to explode in popularity because it is terrifically faster than PHP5
   and the new Ubuntu LTS version featuring PHP7 is about to see final release.
 * Here’s the type of error I get from Google Analyticator running on PHP7:
 * > ( ! ) Deprecated: Methods with the same name as their class will not be constructors
   > in a future version of PHP; GoogleAnalyticsStats has a deprecated constructor
   > in /[…]/wp-content/plugins/google-analyticator/class.analytics.stats.php on
   > line 8
 * They happen all over the site when WP_DEBUG is enabled because just loading that
   code into memory triggers it, so it’s extremely important that the warnings be
   removed, as it will fill up the server logs of anyone who uses the plugin.
 * The solution is super simple, and just requires you to match the code style to
   what the rest of WP has already done (in `class.analytics.stats.php`):
 *     ```
       /**
       	 * HOTFIX: Replace class name as constructor with __construct()
       	 */
       //	function GoogleAnalyticsStats()
       	function __construct()
       ```
   
 * Here are the places in your plugin that need updating:
 * google-analytics-summary-widget.php:
 *     ```
       //function GoogleAnalyticsSummary($shortcode = FALSE)
           function __construct($shortcode = FALSE)
       ```
   
 * google-analytics-stats-widget.php:
 *     ```
       //function GoogleStatsWidget($shortcode = FALSE) {
       	function __construct($shortcode = FALSE) {
       ```
   
 * and the class.analytics.stats.php example above.
 * Thank you for fixing this if you can. Please review the other tickets about notices/
   deprecation in your plugin as there are several other EASY fixes that would mean
   I could start using the vanilla version of your plugin again.
 * [https://wordpress.org/plugins/google-analyticator/](https://wordpress.org/plugins/google-analyticator/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Joe Hana](https://wordpress.org/support/users/joehana/)
 * (@joehana)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/php7-compatibility-easy-fix-use-_construct/#post-7589870)
 * +1 and thumbs up. Was just about to post the same since I ran into the same issue.
   Luckily got it easily fixed.
 *  [Gwyneth Llewelyn](https://wordpress.org/support/users/gwynethllewelyn/)
 * (@gwynethllewelyn)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/php7-compatibility-easy-fix-use-_construct/#post-8407328)
 * Thanks, I keep forgetting about this when temporarily setting PHP7 to be very
   strict… and then I get always surprised at the sheer amount of notices I get!
 * Google Analyticator is not really among the worst plugins out there… it’s easy
   enough to fix.
 *  Thread Starter [Jer Clarke](https://wordpress.org/support/users/jeremyclarke/)
 * (@jeremyclarke)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/php7-compatibility-easy-fix-use-_construct/#post-8411226)
 * Easy to fix but that applies to both us and the developer. Fixing it upstream
   would mean users who don’t and shouldn’t edit PHP are able to keep using the 
   plugin.
 * Also because this plugin uses external API it MUST be updated, so users can’t
   avoid updating to new versions to maintain their hacks. Really a bad situation.
 * Hoping the devs can integrate these fixes soon.
 *  Plugin Author [Garrett Grimm](https://wordpress.org/support/users/grimmdude/)
 * (@grimmdude)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/php7-compatibility-easy-fix-use-_construct/#post-8726760)
 * Hi There,
 * Thanks for the ticket, this has been fixed in 6.5.1.
 * -Garrett

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP7 Compatibility EASY FIX use __construct()’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/google-analyticator_fefefe.svg)
 * [Analyticator](https://wordpress.org/plugins/google-analyticator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analyticator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analyticator/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analyticator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analyticator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analyticator/reviews/)

## Tags

 * [errors](https://wordpress.org/support/topic-tag/errors/)
 * [Logs](https://wordpress.org/support/topic-tag/logs/)
 * [PHP7](https://wordpress.org/support/topic-tag/php7/)
 * [warnings](https://wordpress.org/support/topic-tag/warnings/)

 * 4 replies
 * 4 participants
 * Last reply from: [Garrett Grimm](https://wordpress.org/support/users/grimmdude/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/php7-compatibility-easy-fix-use-_construct/#post-8726760)
 * Status: resolved