<?php
// ini_set('display_errors',0);
// error_reporting(E_ALL|E_STRICT);
class chimp_footer_menu extends WP_Widget {
function construct() {
//Create Widget
parent::__construct() {
'footer_menu_widget',
__('The Footer menu Widget','text_domain'),
array( 'description' => __('A Footer Menu Widget', 'text_domain' ))
}
}
// Front End display
public function widget($args, $instance) {}
// Backend Form
public function form() {}
// Update Widget Values
public function update() {}
}
add_action('widgets_init', function(){
register_widget('chimp_footer_menu');
});
?>
Normally I believe that some '(' or ')' is incomplete and then such things happen, but I have counted them and everything seems to be ok.
additionally, chimp_footer_menu::construct() must be called explicitly, at which point the parent constructor was already called (and thus likely caused an error).
// Front End display
public function widget($args, $instance) {}
// Backend Form
public function form($instance) {}
// Update Widget Values
public function update($new_instance, $old_instance) {}
I have never seen a parent constructor used Iike that before. I’ve always thought an object call requires arguments to be passed within the parentheses. Not a curly brace after the parentheses. Also, isn’t a function call like that only in Javascript?
Actually the problem is fixed.
First thing that I did is I deleted the {} from parent::__construct
Second thing I did is parent::__construct() was like this and the entire arguments was outside this. I put the entire argument into that.
Final version that is not generating the error →
function construct() {
//Create Widget
parent::__construct(
'footer_menu_widget',
__('The Footer menu Widget','text_domain'),
array( 'description' => __('A Footer Menu Widget', 'text_domain' ))
);
}
You mean localization, Right? I mean the language translations.
Can you please guide me over this since I have just started learning and know only a little bit of PHP. May be if there is some suggested link to read. Thanks!