• Resolved Chad Hayton

    (@chadhayton)


    We are running PHP 7.1 and are getting the following warning when running the Simple Preview plugin:

    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Simple_Preview has a deprecated constructor in /app01/html/aaa_ncnu/wp-content/plugins/simple-preview/simple-preview.php on line 45

    Can you please update the class constructor in the plugin so it uses the PHP 7-valid __construct() method instead of the old-style constructor method that uses the class name as the constructor?

    Instead of constructing the class like this:

    // Plugin startup
    function Simple_Preview() {
    	if ( ! is_admin() ) {
    		add_action('init', array(&$this, 'show_preview'));
    	} else {
    		register_activation_hook(__FILE__, array(&$this, 'init'));
    		add_action('admin_menu', array(&$this, 'meta_box'));
    		add_action('save_post', array(&$this, 'save_post'));
    	}
    }

    We’d construct it like this:

    // Plugin startup
    function __construct() {
    	if ( ! is_admin() ) {
    		add_action('init', array(&$this, 'show_preview'));
    	} else {
    		register_activation_hook(__FILE__, array(&$this, 'init'));
    		add_action('admin_menu', array(&$this, 'meta_box'));
    		add_action('save_post', array(&$this, 'save_post'));
    	}
    }
    • This topic was modified 7 years, 7 months ago by Chad Hayton.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Not PHP 7 Compliant’ is closed to new replies.