| Conditions | 4 |
| Paths | 4 |
| Total Lines | 49 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 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 | } |
||
| 72 | } |