2020-04-07 13:03:04 +00:00
|
|
|
<?php
|
2020-08-13 14:53:39 +00:00
|
|
|
/**
|
|
|
|
* This file handles the secondary navigation spacing Customizer options.
|
|
|
|
*
|
|
|
|
* @package GP Premium
|
|
|
|
*/
|
|
|
|
|
2020-04-07 13:03:04 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
2020-08-13 14:53:39 +00:00
|
|
|
exit; // No direct access, please.
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! function_exists( 'generate_spacing_secondary_nav_customizer' ) ) {
|
|
|
|
add_action( 'customize_register', 'generate_spacing_secondary_nav_customizer', 1000 );
|
|
|
|
/**
|
|
|
|
* Adds our Secondary Nav spacing options
|
|
|
|
*
|
|
|
|
* These options are in their own function so we can hook it in late to
|
|
|
|
* make sure Secondary Nav is activated.
|
|
|
|
*
|
|
|
|
* 1000 priority is there to make sure Secondary Nav is registered (999)
|
|
|
|
* as we check to see if the layout control exists.
|
|
|
|
*
|
|
|
|
* Secondary Nav now uses 100 as a priority.
|
2020-08-13 14:53:39 +00:00
|
|
|
*
|
|
|
|
* @param object $wp_customize The Customizer object.
|
2020-04-07 13:03:04 +00:00
|
|
|
*/
|
|
|
|
function generate_spacing_secondary_nav_customizer( $wp_customize ) {
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Bail if we don't have our defaults.
|
2020-04-07 13:03:04 +00:00
|
|
|
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Make sure Secondary Nav is activated.
|
2020-04-07 13:03:04 +00:00
|
|
|
if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Get our controls.
|
2020-04-07 13:03:04 +00:00
|
|
|
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Get our defaults.
|
2020-04-07 13:03:04 +00:00
|
|
|
$defaults = generate_secondary_nav_get_defaults();
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Remove our old label control if it exists.
|
|
|
|
// It only would if the user is using an old Secondary Nav add-on version.
|
|
|
|
if ( $wp_customize->get_control( 'generate_secondary_navigation_spacing_title' ) ) {
|
|
|
|
$wp_customize->remove_control( 'generate_secondary_navigation_spacing_title' );
|
|
|
|
}
|
2020-04-07 13:03:04 +00:00
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Menu item width.
|
2020-04-07 13:03:04 +00:00
|
|
|
$wp_customize->add_setting(
|
2020-08-13 14:53:39 +00:00
|
|
|
'generate_secondary_nav_settings[secondary_menu_item]',
|
|
|
|
array(
|
2020-04-07 13:03:04 +00:00
|
|
|
'default' => $defaults['secondary_menu_item'],
|
|
|
|
'type' => 'option',
|
|
|
|
'capability' => 'edit_theme_options',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
new GeneratePress_Pro_Range_Slider_Control(
|
|
|
|
$wp_customize,
|
|
|
|
'generate_secondary_nav_settings[secondary_menu_item]',
|
|
|
|
array(
|
|
|
|
'label' => __( 'Menu Item Width', 'gp-premium' ),
|
|
|
|
'section' => 'secondary_nav_section',
|
|
|
|
'settings' => array(
|
|
|
|
'desktop' => 'generate_secondary_nav_settings[secondary_menu_item]',
|
|
|
|
),
|
|
|
|
'choices' => array(
|
|
|
|
'desktop' => array(
|
|
|
|
'min' => 0,
|
|
|
|
'max' => 100,
|
|
|
|
'step' => 1,
|
|
|
|
'edit' => true,
|
|
|
|
'unit' => 'px',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'priority' => 220,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Menu item height.
|
2020-04-07 13:03:04 +00:00
|
|
|
$wp_customize->add_setting(
|
2020-08-13 14:53:39 +00:00
|
|
|
'generate_secondary_nav_settings[secondary_menu_item_height]',
|
|
|
|
array(
|
2020-04-07 13:03:04 +00:00
|
|
|
'default' => $defaults['secondary_menu_item_height'],
|
|
|
|
'type' => 'option',
|
|
|
|
'capability' => 'edit_theme_options',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
new GeneratePress_Pro_Range_Slider_Control(
|
|
|
|
$wp_customize,
|
|
|
|
'generate_secondary_nav_settings[secondary_menu_item_height]',
|
|
|
|
array(
|
|
|
|
'label' => __( 'Menu Item Height', 'gp-premium' ),
|
|
|
|
'section' => 'secondary_nav_section',
|
|
|
|
'settings' => array(
|
|
|
|
'desktop' => 'generate_secondary_nav_settings[secondary_menu_item_height]',
|
|
|
|
),
|
|
|
|
'choices' => array(
|
|
|
|
'desktop' => array(
|
|
|
|
'min' => 20,
|
|
|
|
'max' => 150,
|
|
|
|
'step' => 1,
|
|
|
|
'edit' => true,
|
|
|
|
'unit' => 'px',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'priority' => 240,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Sub-menu height.
|
2020-04-07 13:03:04 +00:00
|
|
|
$wp_customize->add_setting(
|
2020-08-13 14:53:39 +00:00
|
|
|
'generate_secondary_nav_settings[secondary_sub_menu_item_height]',
|
|
|
|
array(
|
2020-04-07 13:03:04 +00:00
|
|
|
'default' => $defaults['secondary_sub_menu_item_height'],
|
|
|
|
'type' => 'option',
|
|
|
|
'capability' => 'edit_theme_options',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
new GeneratePress_Pro_Range_Slider_Control(
|
|
|
|
$wp_customize,
|
|
|
|
'generate_secondary_nav_settings[secondary_sub_menu_item_height]',
|
|
|
|
array(
|
|
|
|
'label' => __( 'Sub-Menu Item Height', 'gp-premium' ),
|
|
|
|
'section' => 'secondary_nav_section',
|
|
|
|
'settings' => array(
|
|
|
|
'desktop' => 'generate_secondary_nav_settings[secondary_sub_menu_item_height]',
|
|
|
|
),
|
|
|
|
'choices' => array(
|
|
|
|
'desktop' => array(
|
|
|
|
'min' => 0,
|
|
|
|
'max' => 50,
|
|
|
|
'step' => 1,
|
|
|
|
'edit' => true,
|
|
|
|
'unit' => 'px',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'priority' => 260,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|