what is instance in WordPress widget function? -
i beginner @ theme development , want build custom widget scratch can't understand purpose of instance parameter , there inside it?
public function widget( $args, $instance ) { echo $args['before_widget']; if ( ! empty( $instance['title'] ) ) { echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; } echo '<div class="textwidget">'; echo esc_html__( $instance['text'], 'text_domain' ); echo '</div>'; echo $args['after_widget']; }
$instance
variable repeatedly used within wp_widget class (and hence in child classes). array settings incarnation of wordpress widget. array() gets saved db , retrieved again able save settings different widgets.
Comments
Post a Comment