Last active
August 29, 2015 14:17
-
-
Save cgcardona/f68998b1d45c14321361 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait WP_Widget_Inputs { | |
public function form_input_text( array $args = array() ) { | |
if ( !empty ( $args ) ) { | |
$id = esc_attr( $args['id'] ); | |
printf( | |
'<p><label for="%s">%s</label><input type="text" class="widefat" name="%s" id="%s" value="%s" /></p>', | |
$id, | |
esc_attr( $args['label_text'] ), | |
esc_attr( $args['name'] ), | |
$id, | |
esc_attr( $args['value'] ) | |
); | |
} | |
} | |
public function form_input_textarea( array $args = array() ) { | |
if ( !empty( $args ) ) { | |
$id = esc_attr( $args['id'] ); | |
printf( | |
'<p><label for="%s">%s</label><textarea class="widefat" rows="%s" cols="%s" id="%s" name="%s">%s</textarea></p>', | |
$id, | |
esc_attr( $args['label_text'] ), | |
!empty( $args['rows'] ) ? esc_attr( absint( $args['rows'] ) ) : 16, | |
!empty( $args['cols'] ) ? esc_attr( absint( $args['cols'] ) ) : 20, | |
$id, | |
esc_attr( $args['name'] ), | |
esc_html( $args['value'] ) | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment