- >
__( 'Secondary Menu', 'gp-premium' ), ) ); } } if ( ! function_exists( 'generate_secondary_nav_enqueue_scripts' ) ) { add_action( 'wp_enqueue_scripts', 'generate_secondary_nav_enqueue_scripts', 100 ); /** * Add our necessary scripts * @since 0.1 */ function generate_secondary_nav_enqueue_scripts() { // Bail if no Secondary menu is set if ( ! has_nav_menu( 'secondary' ) ) { return; } $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_style( 'generate-secondary-nav', plugin_dir_url( __FILE__ ) . "css/style{$suffix}.css", array(), GENERATE_SECONDARY_NAV_VERSION ); if ( ! defined( 'GENERATE_DISABLE_MOBILE' ) ) { wp_add_inline_script( 'generate-navigation', "jQuery( document ).ready( function($) { $( '.secondary-navigation .menu-toggle' ).on( 'click', function( e ) { e.preventDefault(); $( this ).closest( '.secondary-navigation' ).toggleClass( 'toggled' ); $( this ).closest( '.secondary-navigation' ).attr( 'aria-expanded', $( this ).closest( '.secondary-navigation' ).attr( 'aria-expanded' ) === 'true' ? 'false' : 'true' ); $( this ).toggleClass( 'toggled' ); $( this ).children( 'i' ).toggleClass( 'fa-bars' ).toggleClass( 'fa-close' ); $( this ).attr( 'aria-expanded', $( this ).attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); }); });" ); wp_enqueue_style( 'generate-secondary-nav-mobile', plugin_dir_url( __FILE__ ) . "css/mobile{$suffix}.css", array(), GENERATE_SECONDARY_NAV_VERSION, 'all' ); } } } if ( ! function_exists( 'generate_secondary_nav_enqueue_customizer_scripts' ) ) { add_action( 'customize_preview_init', 'generate_secondary_nav_enqueue_customizer_scripts' ); /** * Add our Customizer preview JS. * * @since 0.1 */ function generate_secondary_nav_enqueue_customizer_scripts() { wp_enqueue_script( 'generate-secondary-nav-customizer', plugin_dir_url( __FILE__ ) . 'js/customizer.js', array( 'jquery', 'customize-preview' ), GENERATE_SECONDARY_NAV_VERSION, true ); } } if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) { /** * Set default options. * * @since 0.1 */ function generate_secondary_nav_get_defaults( $filter = true ) { $generate_defaults = array( 'secondary_nav_mobile_label' => 'Menu', 'secondary_nav_layout_setting' => 'secondary-fluid-nav', 'secondary_nav_inner_width' => 'contained', 'secondary_nav_position_setting' => 'secondary-nav-above-header', 'secondary_nav_alignment' => 'right', 'secondary_nav_dropdown_direction' => 'right', 'navigation_background_color' => '#636363', 'navigation_text_color' => '#ffffff', 'navigation_background_hover_color' => '#303030', 'navigation_text_hover_color' => '#ffffff', 'navigation_background_current_color' => '#ffffff', 'navigation_text_current_color' => '#222222', 'subnavigation_background_color' => '#303030', 'subnavigation_text_color' => '#ffffff', 'subnavigation_background_hover_color' => '#474747', 'subnavigation_text_hover_color' => '#ffffff', 'subnavigation_background_current_color' => '#474747', 'subnavigation_text_current_color' => '#ffffff', 'secondary_menu_item' => '20', 'secondary_menu_item_height' => '40', 'secondary_sub_menu_item_height' => '10', 'font_secondary_navigation' => 'inherit', 'font_secondary_navigation_variants' => '', 'font_secondary_navigation_category' => '', 'secondary_navigation_font_weight' => 'normal', 'secondary_navigation_font_transform' => 'none', 'secondary_navigation_font_size' => '13', 'nav_image' => '', 'nav_repeat' => '', 'nav_item_image' => '', 'nav_item_repeat' => '', 'nav_item_hover_image' => '', 'nav_item_hover_repeat' => '', 'nav_item_current_image' => '', 'nav_item_current_repeat' => '', 'sub_nav_image' => '', 'sub_nav_repeat' => '', 'sub_nav_item_image' => '', 'sub_nav_item_repeat' => '', 'sub_nav_item_hover_image' => '', 'sub_nav_item_hover_repeat' => '', 'sub_nav_item_current_image' => '', 'sub_nav_item_current_repeat' => '', 'merge_top_bar' => false ); if ( $filter ) { return apply_filters( 'generate_secondary_nav_option_defaults', $generate_defaults ); } return $generate_defaults; } } if ( ! function_exists( 'generate_secondary_nav_customize_register' ) ) { add_action( 'customize_register', 'generate_secondary_nav_customize_register', 100 ); /** * Register our options. * * @since 0.1 */ function generate_secondary_nav_customize_register( $wp_customize ) { // Get our defaults $defaults = generate_secondary_nav_get_defaults(); // Controls require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php'; if ( method_exists( $wp_customize, 'register_control_type' ) ) { $wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' ); } // Use the Layout panel in the free theme if it exists if ( $wp_customize->get_panel( 'generate_layout_panel' ) ) { $layout_panel = 'generate_layout_panel'; } else { $layout_panel = 'secondary_navigation_panel'; } // Add our secondary navigation panel // This shouldn't be used anymore if the theme is up to date if ( class_exists( 'WP_Customize_Panel' ) ) { $wp_customize->add_panel( 'secondary_navigation_panel', array( 'priority' => 100, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __( 'Secondary Navigation', 'gp-premium' ), 'description' => '', ) ); } // Add secondary navigation section $wp_customize->add_section( 'secondary_nav_section', array( 'title' => __( 'Secondary Navigation', 'gp-premium' ), 'capability' => 'edit_theme_options', 'priority' => 31, 'panel' => $layout_panel ) ); $wp_customize->add_control( new GeneratePress_Section_Shortcut_Control( $wp_customize, 'generate_secondary_navigation_layout_shortcuts', array( 'section' => 'secondary_nav_section', 'element' => __( 'Secondary Navigation', 'gp-premium' ), 'shortcuts' => array( 'colors' => 'secondary_navigation_color_section', 'typography' => 'secondary_font_section', 'backgrounds' => 'secondary_bg_images_section', ), 'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname', 'priority' => 1, ) ) ); // Mobile menu label $wp_customize->add_setting( 'generate_secondary_nav_settings[secondary_nav_mobile_label]', array( 'default' => $defaults['secondary_nav_mobile_label'], 'type' => 'option', 'sanitize_callback' => 'wp_kses_post' ) ); $wp_customize->add_control( 'secondary_nav_mobile_label_control', array( 'label' => __( 'Mobile Menu Label', 'gp-premium' ), 'section' => 'secondary_nav_section', 'settings' => 'generate_secondary_nav_settings[secondary_nav_mobile_label]', 'priority' => 10 ) ); // Navigation width $wp_customize->add_setting( 'generate_secondary_nav_settings[secondary_nav_layout_setting]', array( 'default' => $defaults['secondary_nav_layout_setting'], 'type' => 'option', 'sanitize_callback' => 'generate_premium_sanitize_choices', 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'generate_secondary_nav_settings[secondary_nav_layout_setting]', array( 'type' => 'select', 'label' => __( 'Navigation Width', 'gp-premium' ), 'section' => 'secondary_nav_section', 'choices' => array( 'secondary-fluid-nav' => _x( 'Full', 'Width', 'gp-premium' ), 'secondary-contained-nav' => _x( 'Contained', 'Width', 'gp-premium' ) ), 'settings' => 'generate_secondary_nav_settings[secondary_nav_layout_setting]', 'priority' => 15 ) ); // Inner navigation width $wp_customize->add_setting( 'generate_secondary_nav_settings[secondary_nav_inner_width]', array( 'default' => $defaults['secondary_nav_inner_width'], 'type' => 'option', 'sanitize_callback' => 'generate_premium_sanitize_choices', 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'generate_secondary_nav_settings[secondary_nav_inner_width]', array( 'type' => 'select', 'label' => __( 'Inner Navigation Width', 'gp-premium' ), 'section' => 'secondary_nav_section', 'choices' => array( 'full-width' => _x( 'Full', 'Width', 'gp-premium' ), 'contained' => _x( 'Contained', 'Width', 'gp-premium' ) ), 'settings' => 'generate_secondary_nav_settings[secondary_nav_inner_width]', 'priority' => 15 ) ); // Navigation alignment $wp_customize->add_setting( 'generate_secondary_nav_settings[secondary_nav_alignment]', array( 'default' => $defaults['secondary_nav_alignment'], 'type' => 'option', 'sanitize_callback' => 'generate_premium_sanitize_choices', 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'generate_secondary_nav_settings[secondary_nav_alignment]', array( 'type' => 'select', 'label' => __( 'Navigation Alignment', 'gp-premium' ), 'section' => 'secondary_nav_section', 'choices' => array( 'left' => __( 'Left', 'gp-premium' ), 'center' => __( 'Center', 'gp-premium' ), 'right' => __( 'Right', 'gp-premium' ) ), 'settings' => 'generate_secondary_nav_settings[secondary_nav_alignment]', 'priority' => 20 ) ); // Navigation location $wp_customize->add_setting( 'generate_secondary_nav_settings[secondary_nav_position_setting]', array( 'default' => $defaults['secondary_nav_position_setting'], 'type' => 'option', 'sanitize_callback' => 'generate_premium_sanitize_choices', 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'generate_secondary_nav_settings[secondary_nav_position_setting]', array( 'type' => 'select', 'label' => __( 'Navigation Location', 'gp-premium' ), 'section' => 'secondary_nav_section', 'choices' => array( 'secondary-nav-below-header' => __( 'Below Header', 'gp-premium' ), 'secondary-nav-above-header' => __( 'Above Header', 'gp-premium' ), 'secondary-nav-float-right' => __( 'Float Right', 'gp-premium' ), 'secondary-nav-float-left' => __( 'Float Left', 'gp-premium' ), 'secondary-nav-left-sidebar' => __( 'Left Sidebar', 'gp-premium' ), 'secondary-nav-right-sidebar' => __( 'Right Sidebar', 'gp-premium' ), '' => __( 'No Navigation', 'gp-premium' ) ), 'settings' => 'generate_secondary_nav_settings[secondary_nav_position_setting]', 'priority' => 30 ) ); $wp_customize->add_setting( 'generate_secondary_nav_settings[secondary_nav_dropdown_direction]', array( 'default' => $defaults['secondary_nav_dropdown_direction'], 'type' => 'option', 'sanitize_callback' => 'generate_premium_sanitize_choices', ) ); $wp_customize->add_control( 'generate_secondary_nav_settings[secondary_nav_dropdown_direction]', array( 'type' => 'select', 'label' => __( 'Dropdown Direction', 'gp-premium' ), 'section' => 'secondary_nav_section', 'choices' => array( 'right' => __( 'Right', 'gp-premium' ), 'left' => __( 'Left', 'gp-premium' ), ), 'settings' => 'generate_secondary_nav_settings[secondary_nav_dropdown_direction]', 'priority' => 35 ) ); // Merge top bar $wp_customize->add_setting( 'generate_secondary_nav_settings[merge_top_bar]', array( 'default' => $defaults['merge_top_bar'], 'type' => 'option', 'sanitize_callback' => 'generate_premium_sanitize_checkbox' ) ); $wp_customize->add_control( 'generate_secondary_nav_settings[merge_top_bar]', array( 'type' => 'checkbox', 'label' => __( 'Merge with Secondary Navigation', 'gp-premium' ), 'section' => 'generate_top_bar', 'settings' => 'generate_secondary_nav_settings[merge_top_bar]', 'priority' => 100, 'active_callback' => 'generate_secondary_nav_show_merge_top_bar' ) ); } } if ( ! function_exists( 'generate_display_secondary_google_fonts' ) ) { add_filter( 'generate_typography_google_fonts', 'generate_display_secondary_google_fonts', 50 ); /** * Add Google Fonts to wp_head if needed. * * @since 0.1 */ function generate_display_secondary_google_fonts($google_fonts) { // Bail if no Secondary menu is set if ( ! has_nav_menu( 'secondary' ) ) { return $google_fonts; } $generate_secondary_nav_settings = wp_parse_args( get_option( 'generate_secondary_nav_settings', array() ), generate_secondary_nav_get_defaults() ); // List our non-Google fonts if ( function_exists( 'generate_typography_default_fonts' ) ) { $not_google = str_replace( ' ', '+', generate_typography_default_fonts() ); } else { $not_google = array( 'inherit', 'Arial,+Helvetica,+sans-serif', 'Century+Gothic', 'Comic+Sans+MS', 'Courier+New', 'Georgia,+Times+New+Roman,+Times,+serif', 'Helvetica', 'Impact', 'Lucida+Console', 'Lucida+Sans+Unicode', 'Palatino+Linotype', 'Tahoma,+Geneva,+sans-serif', 'Trebuchet+MS,+Helvetica,+sans-serif', 'Verdana,+Geneva,+sans-serif' ); } // Create our Google Fonts array $secondary_google_fonts = array(); if ( function_exists( 'generate_get_google_font_variants' ) ) { // If our value is still using the old format, fix it if ( strpos( $generate_secondary_nav_settings[ 'font_secondary_navigation' ], ':' ) !== false ) { $generate_secondary_nav_settings[ 'font_secondary_navigation' ] = current( explode( ':', $generate_secondary_nav_settings[ 'font_secondary_navigation' ] ) ); } // Grab the variants using the plain name $variants = generate_get_google_font_variants( $generate_secondary_nav_settings[ 'font_secondary_navigation' ], 'font_secondary_navigation', generate_secondary_nav_get_defaults() ); } else { $variants = ''; } // Replace the spaces in the names with a plus $value = str_replace( ' ', '+', $generate_secondary_nav_settings[ 'font_secondary_navigation' ] ); // If we have variants, add them to our value $value = ! empty( $variants ) ? $value . ':' . $variants : $value; // Add our value to the array $secondary_google_fonts[] = $value; // Ignore any non-Google fonts $secondary_google_fonts = array_diff($secondary_google_fonts, $not_google); // Separate each different font with a bar $secondary_google_fonts = implode('|', $secondary_google_fonts); if ( !empty( $secondary_google_fonts ) ) { $print_secondary_fonts = '|' . $secondary_google_fonts; } else { $print_secondary_fonts = ''; } // Remove any duplicates $return = $google_fonts . $print_secondary_fonts; $return = implode('|',array_unique(explode('|', $return))); return $return; } } if ( ! function_exists( 'generate_add_secondary_navigation_after_header' ) ) { add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 ); /** * Add the navigation after the header. * * @since 0.1 */ function generate_add_secondary_navigation_after_header() { $generate_settings = wp_parse_args( get_option( 'generate_secondary_nav_settings', array() ), generate_secondary_nav_get_defaults() ); if ( 'secondary-nav-below-header' == $generate_settings['secondary_nav_position_setting'] ) { generate_secondary_navigation_position(); } } } if ( ! function_exists( 'generate_add_secondary_navigation_before_header' ) ) { add_action( 'generate_before_header', 'generate_add_secondary_navigation_before_header', 7 ); /** * Add the navigation before the header. * * @since 0.1 */ function generate_add_secondary_navigation_before_header() { $generate_settings = wp_parse_args( get_option( 'generate_secondary_nav_settings', array() ), generate_secondary_nav_get_defaults() ); if ( 'secondary-nav-above-header' == $generate_settings['secondary_nav_position_setting'] ) { generate_secondary_navigation_position(); } } } if ( ! function_exists( 'generate_add_secondary_navigation_float_right' ) ) { add_action( 'generate_before_header_content', 'generate_add_secondary_navigation_float_right', 7 ); /** * Add the navigation inside the header so it can float right. * * @since 0.1 */ function generate_add_secondary_navigation_float_right() { $generate_settings = wp_parse_args( get_option( 'generate_secondary_nav_settings', array() ), generate_secondary_nav_get_defaults() ); if ( 'secondary-nav-float-right' == $generate_settings['secondary_nav_position_setting'] || 'secondary-nav-float-left' == $generate_settings['secondary_nav_position_setting'] ) { generate_secondary_navigation_position(); } } } if ( ! function_exists( 'generate_add_secondary_navigation_before_right_sidebar' ) ) { add_action( 'generate_before_right_sidebar_content', 'generate_add_secondary_navigation_before_right_sidebar', 7 ); /** * Add the navigation into the right sidebar. * * @since 0.1 */ function generate_add_secondary_navigation_before_right_sidebar() { $generate_settings = wp_parse_args( get_option( 'generate_secondary_nav_settings', array() ), generate_secondary_nav_get_defaults() ); if ( 'secondary-nav-right-sidebar' == $generate_settings['secondary_nav_position_setting'] ) { echo '
'; } } } if ( ! function_exists( 'generate_add_secondary_navigation_before_left_sidebar' ) ) { add_action( 'generate_before_left_sidebar_content', 'generate_add_secondary_navigation_before_left_sidebar', 7 ); /** * Add the navigation into the left sidebar. * * @since 0.1 */ function generate_add_secondary_navigation_before_left_sidebar() { $generate_settings = wp_parse_args( get_option( 'generate_secondary_nav_settings', array() ), generate_secondary_nav_get_defaults() ); if ( 'secondary-nav-left-sidebar' == $generate_settings['secondary_nav_position_setting'] ) { echo ' '; } } } if ( ! function_exists( 'generate_secondary_navigation_position' ) ) { /** * Build our secondary navigation. * Would like to change this function name. * * @since 0.1 */ function generate_secondary_navigation_position() { $generate_settings = wp_parse_args( get_option( 'generate_secondary_nav_settings', array() ), generate_secondary_nav_get_defaults() ); if ( has_nav_menu( 'secondary' ) ) : ?>