简体   繁体   中英

Having Issue Applying WordPress Theme

I am relatively new to WordPress (and this site) and was wondering if someone could help me out. I usually just muck about with HTML and CSS front-end, but I'm trying to apply this theme to WordPress on my localhost and this happens:

Notice: The called constructor method for WP_Widget is deprecated since version 4.3.0! Use

 __construct()  
instead. in C:\\wamp\\www\\project_name\\wp-includes\\functions.php on line 3457

And this comes after it:

Call Stack
#   Time    Memory  Function    Location
1   0.0002  250512  {main}( )   ..\index.php:0
2   0.0003  253616  require( 'C:\wamp\www\project_name\wp-blog-header.php' )    ..\index.php:17
3   0.0005  271976  require_once( 'C:\wamp\www\project_name\wp-load.php' )  ..\wp-blog-header.php:12
4   0.0007  283080  require_once( 'C:\wamp\www\project_name\wp-config.php' )    ..\wp-load.php:37
5   0.0011  381920  require_once( 'C:\wamp\www\project_name\wp-settings.php' )  ..\wp-config.php:91
6   0.2640  36262904    do_action( )    ..\wp-settings.php:353
7   0.3925  36334448    call_user_func_array:{C:\wamp\www\project_name\wp-includes\plugin.php:503} ( )  ..\plugin.php:503
8   0.3925  36334624    wp_widgets_init( )  ..\plugin.php:503
9   0.3934  36375496    do_action( )    ..\default-widgets.php:1649
10  0.3934  36377800    call_user_func_array:{C:\wamp\www\project_name\wp-includes\plugin.php:503} ( )  ..\plugin.php:503
11  0.3934  36377864    __lambda_func( )    ..\plugin.php:503
12  0.3934  36377952    register_widget( )  ..\widget-woo-adspace.php(207) : runtime-created function:1
13  0.3934  36378000    WP_Widget_Factory->register( )  ..\widgets.php:720
14  0.3934  36378552    Woo_Widget_AdSpace->Woo_Widget_AdSpace( )   ..\widgets.php:591
15  0.3934  36380000    WP_Widget->WP_Widget( ) ..\widget-woo-adspace.php:42
16  0.3935  36380248    _deprecated_constructor( )  ..\widgets.php:176
17  0.3935  36380760    trigger_error ( )   ..\functions.php:3457

Could someone please help me make sense of all this?

Thank you for your time and have a blessed day.

The key here is on line 14:

14  0.3934  36378552    Woo_Widget_AdSpace->Woo_Widget_AdSpace( )   ..\widgets.php:591

As someone else had mentioned, this is an old PHP4 style constructor that is deprecated. It's likely that it's coming from your theme. A quick search yielded this result when searching for that specific Widget, which means it's a problem with your theme.

If you want to continue to use that particular theme as a base, but get rid of the errors altogether, you'll need to read up on creating a child theme , and then override the widget from within.

Once you successfully extend the theme, you can override it with something like this in your child theme's functions.php file:

add_action('after_setup_theme', 'my_theme_overrides');
function my_theme_overrides(){
    unregister_widget('Woo_AdWidget');
    register_widget('My_Woo_AdWidget');
}
class My_Woo_AdWidget extends Woo_AdWidget{
    public function __construct(){
        $widget_ops = array('description' => 'Use this widget to add any type of Ad as a widget.' );
        WP_Widget::__construct(false, __('Woo - Adspace Widget', 'woothemes'),$widget_ops);
    }
}

This is untested, but it should help circumvent the deprecation error while retaining the main logic of your theme's classes. I would highly recommend choosing a different theme, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM