get_settings(); // Check if sidebar is enabled if ( ! $settings['enable'] ) { return; } // Don't render if current page is excluded if ( $settings_instance->is_current_page_excluded() ) { return; } /** * Filter: aha_mobile_menu_pre_render * Allows developers to prevent sidebar rendering * * @since 1.0.0 * * @param bool $render Whether to render the sidebar. */ if ( ! apply_filters( 'aha_mobile_menu_pre_render', true ) ) { return; } $this->render_markup( $settings ); } /** * Render sidebar markup * * @param array $settings Settings array. */ private function render_markup( $settings ) { // Prepare template variables $position = in_array( $settings['position'], array( 'left', 'right' ), true ) ? $settings['position'] : 'left'; $logo_id = $settings['logo']; $menu_id = $settings['menu']; $enable_search = $settings['enable_search']; $mobile_only = $settings['mobile_only']; $animation = $this->get_animation_class( $settings['animation'] ); $social_links = $settings['social_links']; // Include template include AHA_MOBILE_MENU_PATH . 'templates/sidebar.php'; } /** * Get animation CSS class * * @param string $animation Animation type. * @return string */ private function get_animation_class( $animation ) { $animations = array( 'slide' => 'aha-mobile-menu__sidebar--slide', 'fade' => 'aha-mobile-menu__sidebar--fade', ); /** * Filter: aha_mobile_menu_animations * Allows developers to add custom animations * * @since 1.0.0 * * @param array $animations Available animations. */ $animations = apply_filters( 'aha_mobile_menu_animations', $animations ); return isset( $animations[ $animation ] ) ? $animations[ $animation ] : $animations['slide']; } /** * Get custom trigger classes * * @return array */ public function get_trigger_classes() { $settings = AHA_Mobile_Menu_Settings::get_instance()->get_settings(); $classes = array( 'aha-open-sidebar' ); if ( ! empty( $settings['trigger_classes'] ) ) { // Handle both array and string formats if ( is_array( $settings['trigger_classes'] ) ) { $custom_classes = array_map( 'trim', $settings['trigger_classes'] ); } else { $custom_classes = array_map( 'trim', explode( "\n", $settings['trigger_classes'] ) ); } $custom_classes = array_filter( $custom_classes ); $classes = array_merge( $classes, $custom_classes ); } /** * Filter: aha_mobile_menu_trigger_classes * Allows developers to add or modify trigger classes * * @since 1.0.0 * * @param array $classes Trigger classes. */ return apply_filters( 'aha_mobile_menu_trigger_classes', $classes ); } /** * Render menu items * * @param int $menu_id Menu ID. * @return void */ public function render_menu( $menu_id ) { if ( ! $menu_id ) { return; } // Free plugin supports nested menu items (submenus). $menu_depth = 3; /** * Filter: aha_mobile_menu_menu_args * Allows developers to modify menu arguments * * @since 1.0.0 * * @param array $args Menu arguments. */ $args = apply_filters( 'aha_mobile_menu_menu_args', array( 'menu' => $menu_id, 'container' => 'nav', 'container_class' => 'aha-mobile-menu__nav', 'menu_class' => 'aha-mobile-menu__menu', 'depth' => $menu_depth, 'fallback_cb' => false, ) ); wp_nav_menu( $args ); } /** * Render search form * * @return void */ public function render_search_form() { ?>
%s', esc_url( $url ), esc_attr( $network ), esc_attr( $label ), esc_attr( $label ), $icon_svg ); // Allowed HTML for social links including SVG $allowed_html = array( 'a' => array( 'href' => true, 'class' => true, 'title' => true, 'target' => true, 'rel' => true, 'aria-label' => true, ), 'svg' => array( 'xmlns' => true, 'viewbox' => true, 'viewBox' => true, 'fill' => true, 'width' => true, 'height' => true, 'class' => true, ), 'path' => array( 'd' => true, 'fill' => true, ), ); echo wp_kses( apply_filters( 'aha_mobile_menu_social_link', $html, $link ), $allowed_html ); } ?>
get_settings(); $icon_1 = isset( $settings['action_button_1_icon'] ) ? $settings['action_button_1_icon'] : ''; $pos_1 = isset( $settings['action_button_1_icon_position'] ) ? $settings['action_button_1_icon_position'] : 'before'; $icon_2 = isset( $settings['action_button_2_icon'] ) ? $settings['action_button_2_icon'] : ''; $pos_2 = isset( $settings['action_button_2_icon_position'] ) ? $settings['action_button_2_icon_position'] : 'before'; ?>
get_action_button_content( $button_1_text, $icon_1, $pos_1 ); ?> get_action_button_content( $button_2_text, $icon_2, $pos_2 ); ?>
' . $icon_svg . '' : ''; $text_html = '' . esc_html( $text ) . ''; if ( 'after' === $position && $icon_html ) { return $text_html . $icon_html; } if ( $icon_html ) { return $icon_html . $text_html; } return $text_html; } /** * Get sidebar HTML attributes * * @param array $settings Settings array. * @return string */ public function get_sidebar_attributes( $settings ) { $position = in_array( $settings['position'], array( 'left', 'right' ), true ) ? $settings['position'] : 'left'; $classes = array( 'aha-mobile-menu__sidebar', 'aha-mobile-menu__sidebar--' . $position, $this->get_animation_class( $settings['animation'] ), 'aha-mobile-menu__animate-pane', // Required class for animation to work 'aha-mobile-menu__fadepane-out', // Initial state (hidden) ); if ( $settings['mobile_only'] ) { $classes[] = 'aha-mobile-menu__sidebar--mobile-only'; } /** * Filter: aha_mobile_menu_sidebar_classes * Allows developers to add custom sidebar classes * * @since 1.0.0 * * @param array $classes Sidebar classes. */ $classes = apply_filters( 'aha_mobile_menu_sidebar_classes', $classes ); $style = sprintf( 'background-color: %s; color: %s;', esc_attr( $settings['bg_color'] ), esc_attr( $settings['text_color'] ) ); /** * Filter: aha_mobile_menu_sidebar_style * Allows developers to modify sidebar inline styles * * @since 1.0.0 * * @param string $style Inline styles. * @param array $settings Settings array. */ $style = apply_filters( 'aha_mobile_menu_sidebar_style', $style, $settings ); return sprintf( 'id="aha-mobile-menu-sidebar" class="%s" style="%s" role="navigation" aria-label="%s"', esc_attr( implode( ' ', $classes ) ), $style, esc_attr__( 'Mobile Navigation', 'aha-mobile-menu' ) ); } }