Created
January 23, 2021 09:36
-
-
Save gvgvgvijayan/4e4eb793d3d4d65b919562508daca379 to your computer and use it in GitHub Desktop.
This gist is used in the tutorial https://www.vijayan.in/how-to-create-custom-table-list-in-wordpress-admin-page
This file contains 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 | |
... | |
/** | |
* Navigation dropdown HTML generator | |
* | |
* @param array $args Argument array to generate dropdown. | |
* | |
* @return void | |
*/ | |
private function html_dropdown( $args ) { | |
?> | |
<div class="<?php echo( esc_attr( $args['container']['class'] ) ); ?>"> | |
<label | |
for="<?php echo( esc_attr( $args['select']['id'] ) ); ?>" | |
class="<?php echo( esc_attr( $args['label']['class'] ) ); ?>"> | |
</label> | |
<select | |
name="<?php echo( esc_attr( $args['select']['name'] ) ); ?>" | |
id="<?php echo( esc_attr( $args['select']['id'] ) ); ?>"> | |
<?php | |
foreach ( $args['options'] as $id => $title ) { | |
?> | |
<option | |
<?php if ( $args['select']['selected'] === $id ) { ?> | |
selected="selected" | |
<?php } ?> | |
value="<?php echo( esc_attr( $id ) ); ?>"> | |
<?php echo esc_html( \ucwords( $title ) ); ?> | |
</option> | |
<?php | |
} | |
?> | |
</select> | |
</div> | |
<?php | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment