Refactor taxonomy widget

Adds new widget form class, which all three widgets can share.
This commit is contained in:
Robin Cornett
2017-05-18 16:36:27 -04:00
parent 338fc6e41d
commit 4ef7e552da
8 changed files with 317 additions and 127 deletions
+8
View File
@@ -0,0 +1,8 @@
<?php
$value = isset( $instance[ $args['id'] ] ) ? $instance[ $args['id'] ] : $this->parent->defaults[ $args['id'] ];
echo '<p>';
printf( '<input type="hidden" name="%s" value="0" />', esc_attr( $this->parent->get_field_name( $args['id'] ) ) );
printf( '<input id="%s" type="checkbox" name="%s" value="1" %s/>', esc_attr( $this->parent->get_field_id( $args['id'] ) ), esc_attr( $this->parent->get_field_name( $args['id'] ) ), checked( 1, esc_attr( $value ), false ) );
printf( '<label for="%s">%s</label>', esc_attr( $this->parent->get_field_id( $args['id'] ) ), esc_attr( $args['label'] ) );
echo '</p>';