• Resolved tonytj

    (@tonytj)


    This piece of code is from an example about Widget in a book called professional WordPress Design and Development.

    I just wonder what does the call to extract($args)?

    function widget($args, $instance)
    {
    extract($args);
    echo $before_widget;
    $title = apply_filters(‘widget_title’, $instance[‘title’] );
    $name = (empty($instance[‘name’] ) ) ? ‘ ‘ : $instance[‘name’];
    $bio = (empty($instance[‘bio’] ) ) ? ‘ ‘ : $instance[‘bio’];

    if ( !empty( $title ) )
    {
    echo $before_title. esc_html($title). $after_title;
    }

    echo ‘<p>Name: ‘ . esc_html( $name ) . ‘</p>’;
    echo ‘<p>Bio: ‘ . esc_html( $bio ) . ‘</p>’;
    echo $after_widget;
    }

    //Tony

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Don't understand function extract in this piece of code’ is closed to new replies.