Support » Plugin: WP Native Dashboard » PHP 7 deprecated constructors

  • Hello,

    First, I want to congratulate for this great plugin.

    Just to inform you that I just upgraded to PHP 7, and I get:

    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; wp_native_dashboard has a deprecated constructor in /wp-content/plugins/wp-native-dashboard/wp-native-dashboard.php on line 103

    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; wp_native_dashboard_automattic has a deprecated constructor in /wp-content/plugins/wp-native-dashboard/automattic.php on line 15

    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; wp_native_dashboard_langswitcher has a deprecated constructor in /wp-content/plugins/wp-native-dashboard/langswitcher.php on line 9

    Carry on the great work.

    https://wordpress.org/plugins/wp-native-dashboard/

Viewing 4 replies - 1 through 4 (of 4 total)
  • +1 this is a real problem with an easy fix!

    PHP7 is going to explode in popularity now that the new Ubuntu LTS version supports it, so being compatible is important.

    All you need to do to fix this is change the constructor method for classes to use __construct() instead of the class name, e.g.:

    wp-native-dashboard.php line 103:

    class wp_native_dashboard {
    //	function wp_native_dashboard() {
    	function __construct() {

    automattic.php line 15:

    class wp_native_dashboard_automattic {
    //	function wp_native_dashboard_automattic($tagged, $root_tagged) {
    	function __construct($tagged, $root_tagged) {

    langswitcher.php line 9:

    class wp_native_dashboard_langswitcher {
    //	function wp_native_dashboard_langswitcher($plugin_url, $as_head, $as_admin_bar) {
    	function _construct($plugin_url, $as_head, $as_admin_bar) {

    This has long been the best way to declare classes, but PHP7 now makes it a requirement to silence warnings in the logs.

    Thanks to the author if you can patch this! If not hope others find my patches useful!

    Found another one in loginselector.php:

    class wp_native_dashboard_loginselector {
    //	function wp_native_dashboard_loginselector($permit_template_tags) {
    	function __construct($permit_template_tags) {

    Somebody just forked this plugin and made sure it works on PHP7.

    https://github.com/redandbluefi/wp-native-dashboard

    Man I wish someone could update this upstream from the fork.

    I emailed the author directly to point to this thread and ask for an update 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP 7 deprecated constructors’ is closed to new replies.