Support » Plugin: TW Recent Posts Widget » Notice: WP_Widget is deprecated since version 4.3.0

  • Resolved ssssteve

    (@ssssteve)


    Upgrading to 4.3.0 gives an error:

    ( ! ) Notice: The called constructor method for WP_Widget is <strong>deprecated</strong> since version 4.3.0! Use <pre>__construct()</pre> instead. in [...]\wp-includes\functions.php on line 3457

    Changing tw-recent-posts-widget.php line 48 from:

    $this->WP_Widget('tw-recent-posts', __('TW Recent Posts ', $this->localization_domain), $widget_ops);

    to

    parent::__construct('tw-recent-posts', __('TW Recent Posts ', $this->localization_domain), $widget_ops);

    appears to fix it.

    https://wordpress.org/plugins/tw-recent-posts-widget/

Viewing 15 replies - 1 through 15 (of 35 total)
  • I do not have this plugin installed – no “TW Recent Posts” Widget in my Plugins folder… is there somewhere else i can find this file and make the change.

    A client’s site is pretty messed up since I updated to this Version of WordPress… Help?

    abandoned

    (@thedirector227)

    Since the update, it’s most likely every Plug-in and theme you have installed.

    I searched my local computer’s WordPress folders for “WP_Widget” and just about every WordPress file appeared. Including Aksmet.

    Lines 1-5

    <?php
    /**
     * @package Akismet
     */
    class Akismet_Widget extends WP_Widget {

    Will most likely have to wait for updates.

    Akismet is fine. The phrase “WP_Widget” isn’t what causes the issue.

    The issue is the use of deprecated PHP 4 style constructors for widgets:
    {object}->WP_Widget(), WP_Widget::WP_Widget(), and parent::WP_Widget().

    At this time there are approximately 3,500 plugins who still need to update their plugins, something core team and others have been warning people about on make.wordpress.org/core, twitter and via Post Status/WPTavern about for several months now. They also received an email about it, and several emails telling them to test against 4.3 during betas/rcs, which would have showed the issue.

    Thankfully the fix takes only a few seconds to do. So expect many of your plugin authors who didn’t update their plugins to be doing so shortly.

    We’re keeping a list of the plugins affected here and steps for the plugin authors to fix the issue here: https://gist.github.com/chriscct7/d7d077afb01011b1839d

    Beaucoup de sites sont impactés par ce message d’erreur :

    Notice: La méthode constructor appelée pour WP_Widget est obsolète depuis la version 4.3.0 ! Veuillez utiliser
    __construct()
    à la place. in /var/www/vhosts/mode-et-fantaisie.com/httpdocs/wp-includes/functions.php on line 3457

    Le pourquoi est expliqué dans les autres posts, pour s’en sortir :

    • déjà ce message n’apparait que si WP_DEBUG est à true dans wp_config, laissez à true pour chercher et corriger vos erreurs mais passez le à false en dehors de ce temps de développement pour éviter de le retrouver comme description de votre site dans Google
    • téléchargez en local votre répertoire plugins puis avec un éditeur utilisez la fonction rechercher dans ce répertoire pour trouver tous les appels de WP_Widget et comparer les différentes syntaxes.

    Ci-dessous un exemple trouvé dans le plugin “google-adsense-plug-and-play” :

    Mauvaise syntaxe :

    class GoogleAdsensePlugAndPlayWidget extends WP_Widget
    {
      function GoogleAdsensePlugAndPlayWidget()
      {
        $widget_ops = array('classname' => 'GoogleAdsensePlugAndPlayWidget', 'description' => 'Adsense Plug & Play - Sidebar add' );
        $this->WP_Widget('GoogleAdsensePlugAndPlayWidget', 'Adsense Plug & Play - Sidebar add', $widget_ops);
      }
     // ...........
    }

    Bonne syntaxe une fois corrigée :

    class GoogleAdsensePlugAndPlayWidget extends WP_Widget
    {
      function __construct()
      {
        $widget_ops = array('classname' => 'GoogleAdsensePlugAndPlayWidget', 'description' => 'Adsense Plug & Play - Sidebar add' );
        parent::__construct('GoogleAdsensePlugAndPlayWidget', 'Adsense Plug & Play - Sidebar add', $widget_ops);
      }
     // ...........
    }

    Avec un exemple c’est toujours + concret

    Please delete ” Theme My Login” or any login plugin via cPanel.

    Cheer’s !!

    Until you figure out which plugin is causing the issue, turn your site debug off. Place/edit this in wp-config.php:

    define('WP_DEBUG', false);

    You can hide this kind of error by adding in your functions.php the following line:

    add_filter('deprecated_constructor_trigger_error', '__return_false');

    I hope it helps 🙂

    Thanks @lordgiotto.

    This solution worked for me.

    Merci @comkapi ça bien fonctionner pour moi.

    Thanks!

    You can turn off debug or you can force the function to return false. I prefer the latter as it still allows you to have the debug on when in Dev.

    > This is actually a bug in the core of wordpress in the class WP_Widget (widgets.php)

    That is not a bug in WordPress. That is an intentionally thrown deprecation error, designed to warn people that they are using a plugin that contains a widget using an old PHP 4 style constructor, which itself is deprecated and scheduled for permanent, backwards-compatibility breaking removal by PHP core. There are several posts on make.wordpress.org/core/ that can help authors update their plugins to use modern PHP constructors.

    Hello, same issues for me.
    after I added the code: add_filter(‘deprecated_constructor_trigger_error’, ‘__return_false’);
    Fatal error: Call to undefined function add_filter() in F:\wamp\www\alonelion\wp-includes\functions.php on line 4999
    thank you everybody

    Re: Post #12– I believe there IS a bug, in that the line reported as being in error is NOT the offending line but rather the line in the filter that reports the situation.

    I don’t dispute that the deprecation warning is needed. However it needs to correctly identify that location of the deprecated function being called.

    Incidentally, I’m not a plugin developer, but rather am simply building a few sites using WP, and found that adding the suggested “add_filter” line to the functions.php file of my child themes removed the warning and made it possible for me to use WP_DEBUG without cluttering up my log with hundreds of lines of meaningless (to me) information.

    Hi guys

    I have a similar error. But it’s not even letting me load the login page under /wp-admin

    I get this displayed in my browser when I try to load login page.

    Notice: The called constructor method for WP_Widget is deprecated since version 4.3.0! Use
    __construct()
    instead. in /home2/bananali/public_html/wp-includes/functions.php on line 3457

    Is there a way to fix this beside trying to login and deactivate plugins?

    My domain is bananalife.com.au

    I’m not a coder just a theme user but have a little bit of FTP experience.

    Thanks

    Andy

    for plugin ” Theme My Login”
    ( ! ) Notice: The called constructor method for WP_Widget is deprecated since version 4.3.0! Use

    __construct()

    instead. in […]\wp-includes\functions.php on line 3457
    Changing class-theme-my-login-widget.php line 26 from:
    $this->WP_Widget( ‘theme-my-login’, __( ‘Theme My Login’, ‘theme-my-login’ ), $widget_options );

    to

    parent::__construct( ‘theme-my-login’, __( ‘Theme My Login’, ‘theme-my-login’ ), $widget_options );

    to fix it.

Viewing 15 replies - 1 through 15 (of 35 total)
  • The topic ‘Notice: WP_Widget is deprecated since version 4.3.0’ is closed to new replies.