2020-04-07 13:03:04 +00:00
|
|
|
<?php
|
2020-08-13 14:53:39 +00:00
|
|
|
/**
|
|
|
|
* This file handles the sidebar 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
|
|
|
}
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Add our old Sidebars section.
|
|
|
|
// This section is no longer used but is kept around for back compat.
|
2020-04-07 13:03:04 +00:00
|
|
|
$wp_customize->add_section(
|
|
|
|
'generate_spacing_sidebar',
|
|
|
|
array(
|
|
|
|
'title' => __( 'Sidebars', 'gp-premium' ),
|
|
|
|
'capability' => 'edit_theme_options',
|
|
|
|
'priority' => 15,
|
2020-08-13 14:53:39 +00:00
|
|
|
'panel' => 'generate_spacing_panel',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Add our controls to the Layout panel if it exists.
|
|
|
|
// If not, use the old section.
|
2020-04-07 13:03:04 +00:00
|
|
|
$widget_section = ( $wp_customize->get_panel( 'generate_layout_panel' ) ) ? 'generate_layout_sidebars' : 'generate_spacing_sidebar';
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Widget padding top.
|
|
|
|
$wp_customize->add_setting(
|
|
|
|
'generate_spacing_settings[widget_top]',
|
2020-04-07 13:03:04 +00:00
|
|
|
array(
|
|
|
|
'default' => $defaults['widget_top'],
|
|
|
|
'type' => 'option',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Widget padding right.
|
|
|
|
$wp_customize->add_setting(
|
|
|
|
'generate_spacing_settings[widget_right]',
|
2020-04-07 13:03:04 +00:00
|
|
|
array(
|
|
|
|
'default' => $defaults['widget_right'],
|
|
|
|
'type' => 'option',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Widget padding bottom.
|
|
|
|
$wp_customize->add_setting(
|
|
|
|
'generate_spacing_settings[widget_bottom]',
|
2020-04-07 13:03:04 +00:00
|
|
|
array(
|
|
|
|
'default' => $defaults['widget_bottom'],
|
|
|
|
'type' => 'option',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Widget padding left.
|
|
|
|
$wp_customize->add_setting(
|
|
|
|
'generate_spacing_settings[widget_left]',
|
2020-04-07 13:03:04 +00:00
|
|
|
array(
|
|
|
|
'default' => $defaults['widget_left'],
|
|
|
|
'type' => 'option',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Widget padding top.
|
|
|
|
$wp_customize->add_setting(
|
|
|
|
'generate_spacing_settings[mobile_widget_top]',
|
2020-04-07 13:03:04 +00:00
|
|
|
array(
|
|
|
|
'default' => $defaults['mobile_widget_top'],
|
|
|
|
'type' => 'option',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Widget padding right.
|
|
|
|
$wp_customize->add_setting(
|
|
|
|
'generate_spacing_settings[mobile_widget_right]',
|
2020-04-07 13:03:04 +00:00
|
|
|
array(
|
|
|
|
'default' => $defaults['mobile_widget_right'],
|
|
|
|
'type' => 'option',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Widget padding bottom.
|
|
|
|
$wp_customize->add_setting(
|
|
|
|
'generate_spacing_settings[mobile_widget_bottom]',
|
2020-04-07 13:03:04 +00:00
|
|
|
array(
|
|
|
|
'default' => $defaults['mobile_widget_bottom'],
|
|
|
|
'type' => 'option',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Widget padding left.
|
|
|
|
$wp_customize->add_setting(
|
|
|
|
'generate_spacing_settings[mobile_widget_left]',
|
2020-04-07 13:03:04 +00:00
|
|
|
array(
|
|
|
|
'default' => $defaults['mobile_widget_left'],
|
|
|
|
'type' => 'option',
|
|
|
|
'sanitize_callback' => 'absint',
|
2020-08-13 14:53:39 +00:00
|
|
|
'transport' => 'postMessage',
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Make use of the widget padding settings.
|
2020-04-07 13:03:04 +00:00
|
|
|
$wp_customize->add_control(
|
|
|
|
new GeneratePress_Spacing_Control(
|
|
|
|
$wp_customize,
|
|
|
|
'widget_spacing',
|
|
|
|
array(
|
2020-08-13 14:53:39 +00:00
|
|
|
'type' => 'generatepress-spacing',
|
|
|
|
'label' => esc_html__( 'Widget Padding', 'gp-premium' ),
|
|
|
|
'section' => $widget_section,
|
|
|
|
'settings' => array(
|
2020-04-07 13:03:04 +00:00
|
|
|
'desktop_top' => 'generate_spacing_settings[widget_top]',
|
|
|
|
'desktop_right' => 'generate_spacing_settings[widget_right]',
|
|
|
|
'desktop_bottom' => 'generate_spacing_settings[widget_bottom]',
|
|
|
|
'desktop_left' => 'generate_spacing_settings[widget_left]',
|
|
|
|
'mobile_top' => 'generate_spacing_settings[mobile_widget_top]',
|
|
|
|
'mobile_right' => 'generate_spacing_settings[mobile_widget_right]',
|
|
|
|
'mobile_bottom' => 'generate_spacing_settings[mobile_widget_bottom]',
|
2020-08-13 14:53:39 +00:00
|
|
|
'mobile_left' => 'generate_spacing_settings[mobile_widget_left]',
|
2020-04-07 13:03:04 +00:00
|
|
|
),
|
2020-08-13 14:53:39 +00:00
|
|
|
'element' => 'widget',
|
|
|
|
'priority' => 99,
|
2020-04-07 13:03:04 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Left sidebar width.
|
2020-04-07 13:03:04 +00:00
|
|
|
$wp_customize->add_setting(
|
2020-08-13 14:53:39 +00:00
|
|
|
'generate_spacing_settings[left_sidebar_width]',
|
|
|
|
array(
|
2020-04-07 13:03:04 +00:00
|
|
|
'default' => $defaults['left_sidebar_width'],
|
|
|
|
'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_spacing_settings[left_sidebar_width]',
|
|
|
|
array(
|
|
|
|
'label' => esc_html__( 'Left Sidebar Width', 'gp-premium' ),
|
|
|
|
'section' => $widget_section,
|
|
|
|
'settings' => array(
|
|
|
|
'desktop' => 'generate_spacing_settings[left_sidebar_width]',
|
|
|
|
),
|
|
|
|
'choices' => array(
|
|
|
|
'desktop' => array(
|
|
|
|
'min' => 15,
|
|
|
|
'max' => 50,
|
|
|
|
'step' => 5,
|
|
|
|
'edit' => false,
|
|
|
|
'unit' => '%',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'priority' => 125,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-08-13 14:53:39 +00:00
|
|
|
// Right sidebar width.
|
2020-04-07 13:03:04 +00:00
|
|
|
$wp_customize->add_setting(
|
2020-08-13 14:53:39 +00:00
|
|
|
'generate_spacing_settings[right_sidebar_width]',
|
|
|
|
array(
|
2020-04-07 13:03:04 +00:00
|
|
|
'default' => $defaults['right_sidebar_width'],
|
|
|
|
'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_spacing_settings[right_sidebar_width]',
|
|
|
|
array(
|
|
|
|
'label' => esc_html__( 'Right Sidebar Width', 'gp-premium' ),
|
|
|
|
'section' => $widget_section,
|
|
|
|
'settings' => array(
|
|
|
|
'desktop' => 'generate_spacing_settings[right_sidebar_width]',
|
|
|
|
),
|
|
|
|
'choices' => array(
|
|
|
|
'desktop' => array(
|
|
|
|
'min' => 15,
|
|
|
|
'max' => 50,
|
|
|
|
'step' => 5,
|
|
|
|
'edit' => false,
|
|
|
|
'unit' => '%',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'priority' => 125,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|