August 2017
Beginner
412 pages
10h 30m
English
The third main function in your widget class is the one that is called by the sidebar when it's time to actually show the widget to people visiting the website. It needs to retrieve any relevant saved user data and print out information for the website visitor. In this case, our final print function looks like this:
public function widget($args, $instance) { extract($args); $current_taxonomy = $this->_get_current_taxonomy($instance); if(!empty($instance['title'])) { $title = $instance['title']; } else { if('post_tag' == $current_taxonomy) { $title = 'Tags'; } else { $tax = get_taxonomy($current_taxonomy); $title = $tax->labels->name; } } $title = apply_filters('widget_title', $title, $instance, $this- >id_base); ...Read now
Unlock full access