laipower/wp-content/plugins/gp-premium/spacing/functions/customizer/content-spacing.php

245 lines
6.2 KiB
PHP
Raw Permalink Normal View History

2020-04-07 13:03:04 +00:00
<?php
/**
* This file handles the content spacing Customizer options.
*
* @package GP Premium
*/
2020-04-07 13:03:04 +00:00
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
2020-04-07 13:03:04 +00:00
}
// Add our old Spacing section.
2020-04-07 13:03:04 +00:00
$wp_customize->add_section(
'generate_spacing_content',
array(
'title' => __( 'Content', 'gp-premium' ),
'capability' => 'edit_theme_options',
'priority' => 10,
'panel' => 'generate_spacing_panel',
2020-04-07 13:03:04 +00:00
)
);
// If we don't have a layout panel, use our old spacing section.
2020-04-07 13:03:04 +00:00
if ( $wp_customize->get_panel( 'generate_layout_panel' ) ) {
$content_section = 'generate_layout_container';
} else {
$content_section = 'generate_spacing_content';
}
// Take control of the container width control.
// This control is handled by the free theme, but we take control of it here for consistency between control styles.
2020-04-07 13:03:04 +00:00
$wp_customize->add_control(
new GeneratePress_Pro_Range_Slider_Control(
$wp_customize,
'generate_settings[container_width]',
array(
'label' => __( 'Container Width', 'gp-premium' ),
2020-04-07 13:03:04 +00:00
'section' => 'generate_layout_container',
'settings' => array(
'desktop' => 'generate_settings[container_width]',
),
'choices' => array(
'desktop' => array(
'min' => 700,
'max' => 2000,
'step' => 5,
'edit' => true,
'unit' => 'px',
),
),
'priority' => 0,
)
)
);
// Separating space.
2020-04-07 13:03:04 +00:00
$wp_customize->add_setting(
'generate_spacing_settings[separator]',
array(
2020-04-07 13:03:04 +00:00
'default' => $defaults['separator'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'absint',
'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[separator]',
array(
'label' => __( 'Separating Space', 'gp-premium' ),
'section' => $content_section,
'settings' => array(
'desktop' => 'generate_spacing_settings[separator]',
),
'choices' => array(
'desktop' => array(
'min' => 0,
'max' => 100,
'step' => 1,
'edit' => true,
'unit' => 'px',
),
),
)
)
);
// Content padding top.
$wp_customize->add_setting(
'generate_spacing_settings[content_top]',
2020-04-07 13:03:04 +00:00
array(
'default' => $defaults['content_top'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
2020-04-07 13:03:04 +00:00
)
);
// Content padding right.
$wp_customize->add_setting(
'generate_spacing_settings[content_right]',
2020-04-07 13:03:04 +00:00
array(
'default' => $defaults['content_right'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
2020-04-07 13:03:04 +00:00
)
);
// Content padding bottom.
$wp_customize->add_setting(
'generate_spacing_settings[content_bottom]',
2020-04-07 13:03:04 +00:00
array(
'default' => $defaults['content_bottom'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
2020-04-07 13:03:04 +00:00
)
);
// Content padding left.
$wp_customize->add_setting(
'generate_spacing_settings[content_left]',
2020-04-07 13:03:04 +00:00
array(
'default' => $defaults['content_left'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
2020-04-07 13:03:04 +00:00
)
);
$content_padding_settings = array(
'desktop_top' => 'generate_spacing_settings[content_top]',
'desktop_right' => 'generate_spacing_settings[content_right]',
'desktop_bottom' => 'generate_spacing_settings[content_bottom]',
'desktop_left' => 'generate_spacing_settings[content_left]',
);
// If mobile_content_top is set, the rest of them are too.
// We have to check as these defaults are set in the theme.
if ( isset( $defaults['mobile_content_top'] ) ) {
2020-04-07 13:03:04 +00:00
$content_padding_settings['mobile_top'] = 'generate_spacing_settings[mobile_content_top]';
$content_padding_settings['mobile_right'] = 'generate_spacing_settings[mobile_content_right]';
$content_padding_settings['mobile_bottom'] = 'generate_spacing_settings[mobile_content_bottom]';
$content_padding_settings['mobile_left'] = 'generate_spacing_settings[mobile_content_left]';
2020-04-07 13:03:04 +00:00
// Mobile content padding top.
$wp_customize->add_setting(
'generate_spacing_settings[mobile_content_top]',
2020-04-07 13:03:04 +00:00
array(
'default' => $defaults['mobile_content_top'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
2020-04-07 13:03:04 +00:00
)
);
// Content padding right.
$wp_customize->add_setting(
'generate_spacing_settings[mobile_content_right]',
2020-04-07 13:03:04 +00:00
array(
'default' => $defaults['mobile_content_right'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
2020-04-07 13:03:04 +00:00
)
);
// Content padding bottom.
$wp_customize->add_setting(
'generate_spacing_settings[mobile_content_bottom]',
2020-04-07 13:03:04 +00:00
array(
'default' => $defaults['mobile_content_bottom'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
2020-04-07 13:03:04 +00:00
)
);
// Content padding left.
$wp_customize->add_setting(
'generate_spacing_settings[mobile_content_left]',
2020-04-07 13:03:04 +00:00
array(
'default' => $defaults['mobile_content_left'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
2020-04-07 13:03:04 +00:00
)
);
}
// Make use of the content padding settings.
2020-04-07 13:03:04 +00:00
$wp_customize->add_control(
new GeneratePress_Spacing_Control(
$wp_customize,
'content_spacing',
array(
'type' => 'generatepress-spacing',
'label' => esc_html__( 'Content Padding', 'gp-premium' ),
'section' => $content_section,
'settings' => $content_padding_settings,
'element' => 'content',
'priority' => 99,
2020-04-07 13:03:04 +00:00
)
)
);
$wp_customize->add_setting(
'generate_spacing_settings[content_element_separator]',
array(
2020-04-07 13:03:04 +00:00
'default' => $defaults['content_element_separator'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_decimal_integer',
'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[content_element_separator]',
array(
'label' => __( 'Content Separator', 'gp-premium' ),
'sub_description' => __( 'The content separator controls the space between the featured image, title, content and entry meta.', 'gp-premium' ),
'section' => $content_section,
'settings' => array(
'desktop' => 'generate_spacing_settings[content_element_separator]',
),
'choices' => array(
'desktop' => array(
'min' => 0,
'max' => 10,
'step' => .1,
'edit' => true,
'unit' => 'em',
),
),
)
)
);