Support » Plugin: WordPress Portfolio Plugin (WP Portfolio) » constructor method for WP_Widget in WPPortfolioWidget is deprecated

  • Resolved tolland

    (@tolland)


    Hi,
    If debug is enabled, I get the following message in the site;

    Notice: The called constructor method for WP_Widget in WPPortfolioWidget is deprecated since version 4.3.0! Use
    __construct()
    instead. in /var/www/romfordmakerspace/wp-includes/functions.php on line 3767

    Obviously I can get rid of it by disabling debug messages into the site, but this patch seems to fix it;

    --- lib/widget.inc.php  2016-10-10 18:03:44.738470380 +0000
    +++ lib/widget.inc.php_bak      2016-10-10 18:01:07.340470441 +0000
    @@ -17,7 +17,7 @@
                    $control_ops = array( 'width' => 500, 'height' => 40, 'id_base' => 'wp-portfolio-widget' );
     
                    /* Create the widget. */
    -               parent::__construct( 'wp-portfolio-widget', 'WP Portfolio Widget', $widget_ops, $control_ops );
    +               $this->WP_Widget( 'wp-portfolio-widget', 'WP Portfolio Widget', $widget_ops, $control_ops );
            }
     
            /**
    @@ -180,4 +180,4 @@
     add_action('widgets_init', create_function('', 'return register_widget("WPPortfolioWidget");'));
     
     
    -?>
    +?>

    based on the comment here;
    https://wordpress.org/support/topic/notice-wp_widget-is-deprecated-since-version-430/?replies=27#post-7532119

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author puravida1976

    (@puravida1976)

    Hi Tolland,

    Thanks for the report. We did not encounter that error in any of our testing, which included debug updates and testing. Could you detail which version of PHP and WordPress you are using?

    I will pass this on to the developer currently working on WP-Portfolio to make the updates.

    Best regards,

    Brandon

    I am running 4.6.1–en_GB wordpress on centos with php-5.3.3-46.el6_7.1.x86_64

    I have define('WP_DEBUG', true); set in my wp-config.php, however there are also lots of messages in the log files;

    [Mon Oct 10 18:01:48 2016] [error] [client 91.207.21.11] PHP Notice: The called constructor method for WP_Widget in WPPortfolioWidget is <strong>deprecated</strong> since version 4.3.0! Use <pre>__construct()</pre> instead. in /var/www/WORDPRESSXTYX/wp-includes/functions.php on line 3767, referer: http://www.mysite.org/wp-admin/admin.php?page=wp-portfolio%2Fwp-portfolio.php

    • This reply was modified 3 years, 7 months ago by tolland.

    Actually that patch is the wrong way round…. it should be parent::__construct( rather than $this->WP_Widget(

    Plugin Author puravida1976

    (@puravida1976)

    Hi Tolland,

    Thank you for the details. Now it makes sense. I thought you meant the debug option in WP-Portfolio was throwing those errors; not the WP debug. Thanks for clearing that up. We did not test with WP debug on. I will ask my dev for this plugin to take a look with WP debug on and make sure we’re using the most up-to-date, recommended functions.

    Cheers,

    Brandon

    Plugin Author puravida1976

    (@puravida1976)

    We have released v1.40.1 which should address any deprecated functions and is tested up to the current 4.7.2 release of WordPress. It also has backwards compatibility all the way back to legacy PHP version 5.2 for those who are unable to upgrade PHP. Please reopen this thread, if you still see any issues with the newer version.

    And don’t forget to leave a stellar review for the plugin, if you LOVE it! πŸ™‚

    Cheers,

    Brandon

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘constructor method for WP_Widget in WPPortfolioWidget is deprecated’ is closed to new replies.