From d6c6b42e977c2101ba1e500bc5fb2a4ba6ccd288 Mon Sep 17 00:00:00 2001 From: "Rafasashi\\Raphael" Date: Mon, 22 Apr 2024 11:41:41 +0200 Subject: [PATCH] admin api updated --- ...ss-wordpress-plugin-template-admin-api.php | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/includes/lib/class-wordpress-plugin-template-admin-api.php b/includes/lib/class-wordpress-plugin-template-admin-api.php index 301c8c8..55a9705 100644 --- a/includes/lib/class-wordpress-plugin-template-admin-api.php +++ b/includes/lib/class-wordpress-plugin-template-admin-api.php @@ -58,7 +58,7 @@ public function display_field( $data = array(), $post = null, $echo = true ) { // Get saved field data. - $data = get_post_meta( $post->ID, $field['id'], true ); + $data = get_post_meta( $post->ID, $option_name, true ); } else { @@ -78,6 +78,18 @@ public function display_field( $data = array(), $post = null, $echo = true ) { $data = ''; } + // get attributes + + $style = ( !empty($field['style']) ? ' style="'.$field['style'].'"' : '' ); + + $disabled = ( ( isset($field['disabled']) && $field['disabled'] === true ) ? ' disabled="disabled"' : '' ); + + $required = ( ( isset($field['required']) && $field['required'] === true ) ? ' required="true"' : '' ); + + $placeholder = ( isset($field['placeholder']) ? esc_attr($field['placeholder']) : '' ); + + // get html + $html = ''; switch ( $field['type'] ) { @@ -86,7 +98,7 @@ public function display_field( $data = array(), $post = null, $echo = true ) { case 'url': case 'color': case 'email': - $html .= '' . "\n"; + $html .= '' . "\n"; break; case 'password': @@ -101,15 +113,15 @@ public function display_field( $data = array(), $post = null, $echo = true ) { if ( isset( $field['max'] ) ) { $max = ' max="' . esc_attr( $field['max'] ) . '"'; } - $html .= '' . "\n"; + $html .= '' . "\n"; break; case 'text_secret': - $html .= '' . "\n"; + $html .= '' . "\n"; break; case 'textarea': - $html .= '
' . "\n"; + $html .= '
' . "\n"; break; case 'checkbox': @@ -136,13 +148,13 @@ public function display_field( $data = array(), $post = null, $echo = true ) { if ( $k === $data ) { $checked = true; } - $html .= ' '; + $html .= ' '; } break; case 'select': - $html .= ''; foreach ( $field['options'] as $k => $v ) { @@ -165,7 +177,7 @@ public function display_field( $data = array(), $post = null, $echo = true ) { break; case 'select_multi': - $html .= ''; foreach ( $field['options'] as $k => $v ) { $selected = false; if ( in_array( $k, (array) $data, true ) ) {