芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/shortcoder/admin/form.php
'; foreach( $rows as $row ){ $html .= '
'; $html .= '
' . ( isset( $row[0] ) ? $row[0] : '' ) . '
'; $html .= '
' . ( isset( $row[1] ) ? $row[1] : '' ) . '
'; $html .= '
'; } $html .= ''; if( $print ){ echo $html; }else{ return $html; } } public static function field( $field_type, $params = array() ){ $fields = array( 'text', 'select', 'checkbox', 'textarea' ); $default_props = array( 'id' => '', 'name' => '', 'class' => '', 'value' => '', 'list' => array(), 'type' => 'text', 'required' => '', 'placeholder' => '', 'rows' => '', 'cols' => '', 'helper' => '', 'tooltip' => '', 'before_text' => '', 'after_text' => '', 'custom' => '' ); if( !in_array( $field_type, $fields ) ){ return ''; } $params = Shortcoder::set_defaults( $params, $default_props ); $params = self::clean_attr( $params ); $field_html = ''; extract( $params, EXTR_SKIP ); $id_attr = empty( $id ) ? '' : 'id="' . $id . '"'; switch( $field_type ){ case 'text': $field_html = "
"; break; case 'select': $field_html .= "
"; foreach( $list as $k => $v ){ $field_html .= "
$v
"; } $field_html .= "
"; break; case 'textarea': $field_html .= "
$value</textarea>"; break; case 'checkbox': $field_html .= '
'; foreach( $list as $k => $v ){ $checked = in_array( $k, $value ) ? ' checked="checked"' : ''; $field_html .= "
$v
"; } $field_html .= '
'; break; } if( !empty( $tooltip ) ){ $field_html .= "
$tooltip
"; } if( !empty( $helper ) ){ $field_html .= "
$helper
"; } return $field_html; } public static function clean_attr( $a ){ foreach( $a as $k=>$v ){ if( is_array( $v ) ){ $a[ $k ] = self::clean_attr( $v ); }else{ if( in_array( $k, array( 'custom', 'tooltip', 'helper', 'before_text', 'after_text' ) ) ){ $a[ $k ] = wp_kses_post( $v ); }else{ $a[ $k ] = esc_attr( $v ); } } } return $a; } } ?>