• If you have PHP 7, Simple Footnotes will throw a PHP notice of Deprecated:

    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; nacin_footnotes has a deprecated constructor in /path/to/wp-content/plugins/simple-footnotes/simple-footnotes.php on line 10

    The E_DEPRECATED is emitted for the reason explained in this page: https://www.php.net/manual/en/migration70.deprecated.php#migration70.deprecated.php4-constructors.

    Since the plugin has not been updated for 4 years, I edited it in this way:

    Line 15

    Change this line from this:

    function nacin_footnotes() {

    to this:

    function __construct() {

    Notice that __ is a double underscore.

    Line 26

    After line 26 (i.e., create a newline), add these lines:

    function nacin_footnotes() {
    	self::__construct();
    }

    Save the file and you should not receive notices anymore.

    To be clear, here you can find the diff between the original file and the modified: https://gist.github.com/aldolat/9642e5614449753f9408bd256136b4da/revisions

Viewing 2 replies - 1 through 2 (of 2 total)
  • I installed the patch and it kinda worked. Many, many thanks.

    In re-running the PHP compatibility checker (vis-a-vis PHP 7.1}, it is unhappy with the new line 15:

    FILE: /homepages/37/d146050845/htdocs/gf-wp/wp-content/plugins/simple-footnotes/x.php
    ———————————————————————————————
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ———————————————————————————————
    15 | WARNING | Use of deprecated PHP4 style class constructor is not supported since PHP 7.
    ———————————————————————————————

    Since this plugin appears to not be supported by the original maintainer, I wonder what the process is to fork it with you fix?

    Thread Starter Aldo Latino

    (@aldolat)

    I installed the patch and it kinda worked. Many, many thanks.

    You’re welcome.

    In re-running the PHP compatibility checker (vis-a-vis PHP 7.1}, it is unhappy with the new line 15

    Are you sure your script is the same as this? I tested it with PHP compatibility checker (7.0, 7.1, and 7.2) without errors or warnings.

    Since this plugin appears to not be supported by the original maintainer, I wonder what the process is to fork it with you fix?

    For this particular case I would suggest you to contact the administrators of the plugin repository via Slack, in order to best guide you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to resolve the notice of Deprecated with PHP 7’ is closed to new replies.