'widget_meta', 'description' => __( 'Login, RSS, & WordPress.org links.', 'benjamin' ), 'customize_selective_refresh' => true, ); parent::__construct( 'meta', __( 'Meta','benjamin' ), $widget_ops ); } private function menuStyleArgs($style = 'side_nav'){ if($style == 'side_nav'): $class = 'usa-sidenav-list'; elseif($style == 'nav_list'): $class = 'usa-unstyled-list'; else: $class = ''; endif; return $class; } public function dropdown_js($dropdown_id) { ob_start(); ?> menuStyleArgs($style); $class = $style_args ? 'class="'.esc_attr($style_args).'"' : ''; echo ''; } /** * Outputs the content for the current Meta widget instance. * * @since 2.8.0 * @access public * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Meta widget instance. */ public function widget( $args, $instance ) { /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta', 'benjamin' ) : $instance['title'], $instance, $this->id_base ); $style = ! empty( $instance['menu_style'] ) ? $instance['menu_style'] : 'side_nav'; echo $args['before_widget']; // WPCS: xss ok. if ( $title ) { echo $args['before_title'] . esc_html($title) . $args['after_title']; // WPCS: xss ok. } if($style == 'dropdown') { $this->dropdown(); } else { $this->menu($style ); } echo $args['after_widget']; // WPCS: xss ok. } /** * Handles updating settings for the current Meta widget instance. * * @since 2.8.0 * @access public * * @param array $new_instance New settings for this instance as input by the user via * WP_Widget::form(). * @param array $old_instance Old settings for this instance. * @return array Updated settings to save. */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = sanitize_text_field( $new_instance['title'] ); if ( ! empty( $new_instance['menu_style'] ) ) { $instance['menu_style'] = sanitize_text_field($new_instance['menu_style']); } return $instance; } /** * Outputs the settings form for the Meta widget. * * @since 2.8.0 * @access public * * @param array $instance Current settings. */ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); $title = sanitize_text_field( $instance['title'] ); $saved_style = isset( $instance['menu_style'] ) ? $instance['menu_style'] : ''; ?>