Make WordPress Core

Ticket #38270: 134043eb91d1d6a560130a5d06237af5b1173c39.patch

File 134043eb91d1d6a560130a5d06237af5b1173c39.patch, 1.1 KB (added by dustwolf, 8 years ago)

Patch

  • wp-includes/class-wp-widget-factory.php

    From 134043eb91d1d6a560130a5d06237af5b1173c39 Mon Sep 17 00:00:00 2001
    From: Jure Sah <jure.sah@denia.si>
    Date: Wed, 11 May 2016 22:03:06 +0200
    Subject: [PATCH] check if widget class defined in register function
    
    This change makes debugging broken widgets a lot less painful -- in case of errors in widgets this will allow the site to load and the developer to see the error messages instead of just blowing up with the ambiguous error message "Class not defined".
    ---
     wp-includes/class-wp-widget-factory.php | 4 +++-
     1 file changed, 3 insertions(+), 1 deletion(-)
    
    diff --git a/wp-includes/class-wp-widget-factory.php b/wp-includes/class-wp-widget-factory.php
    index ae72154..ff9b66c 100644
    a b public function register( $widget ) { 
    102102                if ( $widget instanceof WP_Widget ) {
    103103                        $this->widgets[ $this->hash_object( $widget ) ] = $widget;
    104104                } else {
    105                         $this->widgets[ $widget ] = new $widget();
     105                        if(class_exists($widget_class)) {
     106                                $this->widgets[ $widget ] = new $widget();
     107                        }
    106108                }
    107109        }
    108110