PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.75
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.75
1.2.76 1.2.75 1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 All 176 releases
userswp / vendor / ayecode / wp-ayecode-ui / includes / components / class-aui-component-dropdown.php

class-aui-component-dropdown.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.75, at vendor/ayecode/wp-ayecode-ui/includes/components/class-aui-component-dropdown.php

72 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 /**
8 * A component class for rendering a bootstrap dropdown.
9 *
10 * @since 1.0.0
11 */
12 class AUI_Component_Dropdown {
13
14 /**
15 * Build the component.
16 *
17 * @param array $args
18 *
19 * @return string The rendered component.
20 */
21 public static function get($args = array()){
22 $defaults = array(
23 'type' => 'button',
24 'href' => '#',
25 'class' => 'btn btn-primary dropdown-toggle',
26 'wrapper_class' => '',
27 'dropdown_menu_class' => '',
28 'id' => '',
29 'title' => '',
30 'value' => '',
31 'content' => '',
32 'icon' => '',
33 'hover_content' => '',
34 'hover_icon' => '',
35 'data-toggle' => 'dropdown',
36 'aria-haspopup' => 'true',
37 'aria-expanded' => 'false',
38 'dropdown_menu' => '', // unescaped html menu (non-preferred way)
39 'dropdown_items' => array(), // array of AUI calls
40
41 );
42
43 /**
44 * Parse incoming $args into an array and merge it with $defaults
45 */
46 $args = wp_parse_args( $args, $defaults );
47 $output = '';
48 if ( ! empty( $args['type'] ) ) {
49 // wrapper open
50 $output .= '<div class="dropdown '.AUI_Component_Helper::esc_classes($args['wrapper_class']).'">';
51
52 // button part
53 $output .= aui()->button($args);
54
55 // dropdown-menu
56 if(!empty($args['dropdown_menu'])){
57 $output .= $args['dropdown_menu'];
58 }elseif(!empty($args['dropdown_items'])){
59 $output .= '<div class="dropdown-menu '.AUI_Component_Helper::esc_classes($args['dropdown_menu_class']).'" aria-labelledby="'.sanitize_html_class($args['id']).'">';
60 $output .= aui()->render($args['dropdown_items']);
61 $output .= '</div>';
62 }
63
64 // wrapper close
65 $output .= '</div>';
66
67 }
68
69 return $output;
70 }
71
72 }