Esempio n. 1
0
function et_divi_customize_register($wp_customize)
{
    $wp_customize->remove_section('title_tagline');
    $wp_customize->remove_section('background_image');
    $wp_customize->remove_section('colors');
    $wp_customize->register_control_type('ET_Divi_Customize_Color_Alpha_Control');
    wp_register_script('wp-color-picker-alpha', get_template_directory_uri() . '/includes/builder/scripts/ext/wp-color-picker-alpha.min.js', array('jquery', 'wp-color-picker'));
    $option_set_name = 'et_customizer_option_set';
    $option_set_allowed_values = apply_filters('et_customizer_option_set_allowed_values', array('module', 'theme'));
    $customizer_option_set = '';
    /**
     * Set a transient,
     * if 'et_customizer_option_set' query parameter is set to one of the allowed values
     */
    if (isset($_GET[$option_set_name]) && in_array($_GET[$option_set_name], $option_set_allowed_values)) {
        $customizer_option_set = $_GET[$option_set_name];
        set_transient('et_divi_customizer_option_set', $customizer_option_set, DAY_IN_SECONDS);
    }
    if ('' === $customizer_option_set && ($et_customizer_option_set_value = get_transient('et_divi_customizer_option_set'))) {
        $customizer_option_set = $et_customizer_option_set_value;
    }
    et_builder_init_global_settings();
    if (isset($customizer_option_set) && 'module' === $customizer_option_set) {
        // display wp error screen if module customizer disabled for current user
        if (!et_pb_is_allowed('module_customizer')) {
            wp_die(esc_html__("you don't have sufficient permissions to access this page", 'Divi'));
        }
        $removed_default_sections = array('nav', 'static_front_page');
        foreach ($removed_default_sections as $default_section) {
            $wp_customize->remove_section($default_section);
        }
        et_divi_customizer_module_settings($wp_customize);
    } else {
        // display wp error screen if theme customizer disabled for current user
        if (!et_pb_is_allowed('theme_customizer')) {
            wp_die(esc_html__("you don't have sufficient permissions to access this page", 'Divi'));
        }
        et_divi_customizer_theme_settings($wp_customize);
    }
}
Esempio n. 2
0
function et_divi_customize_register($wp_customize)
{
    $wp_customize->remove_section('title_tagline');
    $wp_customize->remove_section('background_image');
    $wp_customize->remove_section('colors');
    $wp_customize->register_control_type('ET_Divi_Customize_Color_Alpha_Control');
    wp_register_script('wp-color-picker-alpha', get_template_directory_uri() . '/includes/builder/scripts/ext/wp-color-picker-alpha.min.js', array('jquery', 'wp-color-picker'));
    $option_set_name = 'et_customizer_option_set';
    $option_set_allowed_values = apply_filters('et_customizer_option_set_allowed_values', array('module', 'theme'));
    $customizer_option_set_cookie = '';
    /**
     * Set cookie,
     * if 'et_customizer_option_set' query parameter is set to one of the allowed values
     */
    if (isset($_GET[$option_set_name]) && in_array($_GET[$option_set_name], $option_set_allowed_values)) {
        $customizer_option_set_cookie = $_GET[$option_set_name];
        $secure = 'https' === parse_url(site_url(), PHP_URL_SCHEME);
        setcookie($option_set_name, $customizer_option_set_cookie, time() + DAY_IN_SECONDS, COOKIEPATH, null, $secure);
    }
    if ('' === $customizer_option_set_cookie && isset($_COOKIE[$option_set_name])) {
        $customizer_option_set_cookie = $_COOKIE[$option_set_name];
    }
    et_builder_init_global_settings();
    if (isset($customizer_option_set_cookie) && 'module' === $customizer_option_set_cookie) {
        $removed_default_sections = array('nav', 'static_front_page');
        foreach ($removed_default_sections as $default_section) {
            $wp_customize->remove_section($default_section);
        }
        $wp_customize->remove_panel('widgets');
        et_divi_customizer_module_settings($wp_customize);
    } else {
        et_divi_customizer_theme_settings($wp_customize);
    }
}