Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlaizumibamford/85e789d9d8560b4ecefc93dcc654596c to your computer and use it in GitHub Desktop.
Save carlaizumibamford/85e789d9d8560b4ecefc93dcc654596c to your computer and use it in GitHub Desktop.
Creating A Custom Wordpress Widget Plugin Vol 6
public function widget( $args, $instance ) {
extract( $args );
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$text = isset( $instance['text'] ) ? $instance['text'] : '';
$textarea = isset( $instance['textarea'] ) ?$instance['textarea'] : '';
$select = isset( $instance['select'] ) ? $instance['select'] : '';
$checkbox = ! empty( $instance['checkbox'] ) ? $instance['checkbox'] : false;
echo $before_widget;
echo '<div class="widget-text wp_widget_plugin_box">';
if ( $title ) {
echo $before_title . $title . $after_title;
}
if ( $text ) {
echo '<p>' . $text . '</p>';
}
if ( $textarea ) {
echo '<p>' . $textarea . '</p>';
}
if ( $select ) {
echo '<p>' . $select . '</p>';
}
if ( $checkbox ) {
echo '<p>Something awesome</p>';
}
echo '</div>';
echo $after_widget;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment