Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

in the book professional wordpress, they use something like

$options = array(
    'classname' => 'pp_widget',
    'description' => '...'
);
$this->WP_Widget('pp_widget', ..., $options);

but in most tutorials

$this->WP_Widget(false, ...

is used. i wonder is there a reason to specify the $id_base param? i see that if i dont, an id will be generated. also, is there any need to specify the classname option?

on a side note, i asked a related question on stack overflow: PHP: parent::somefunction or $this->somefunction if someone got an answer let me know :)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The reason is simply customization (these values end up in widget's HTML markup). If someone needs to change this stuff (for example to be compatible with some script without adding wrapper layers) the option is there.

As for methods calling - parent:: explicitly calls method from parent class, $this-> calls method from current class. Since widgets do not redefine WP_Widget method there is no practical difference.

share|improve this answer
    
thanks for clearing things up. –  Jiew Meng Sep 13 '10 at 7:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.