Skip to content

Instantly share code, notes, and snippets.

@tenman
Last active April 21, 2016 07:54
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 tenman/3a2e2b31610936405d2c3db29833f211 to your computer and use it in GitHub Desktop.
Save tenman/3a2e2b31610936405d2c3db29833f211 to your computer and use it in GitHub Desktop.
example loop
public function form( $instance ) {
$values = array(
'name' => array(
'gaiyou' => $instance[ 'gaiyou1' ],
'gaiyou_name' => $this->get_field_name( 'gaiyou1' ),
'gaiyou_id' => $this->get_field_id( 'gaiyou1' ),
),
'url' => array(
'gaiyou' => $instance[ 'gaiyou2' ],
'gaiyou_name' => $this->get_field_name( 'gaiyou2' ),
'gaiyou_id' => $this->get_field_id( 'gaiyou2' ),
),
'address' => array(
'gaiyou' => $instance[ 'gaiyou3' ],
'gaiyou_name' => $this->get_field_name( 'gaiyou3' ),
'gaiyou_id' => $this->get_field_id( 'gaiyou3' ),
),
'tel' => array(
'gaiyou' => $instance[ 'gaiyou4' ],
'gaiyou_name' => $this->get_field_name( 'gaiyou4' ),
'gaiyou_id' => $this->get_field_id( 'gaiyou4' ),
),
);
$html = '<p><label for="%2$s">商号:</label><input class="widefat" id="%2$s" name="%3$s" type="text" value="%1$s"></p>';
foreach ( $values as $key => $val ) {
printf( $html, esc_attr( $val['gaiyou'] ), esc_attr( $val['gaiyou_id'] ), esc_attr( $val['gaiyou_name'] ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment