add_setting( 'alux_overlay_logo', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint' ) ); $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'alux_overlay_logo', array( 'label' => __( 'Overlay Logo', 'alux' ), 'description' => __( 'Displayed instead of the regular logo on pages using the Cover Template.', 'alux' ), 'priority' => 8, 'mime_type' => 'image', 'section' => 'title_tagline', ) ) ); /* ------------------------------------------------------------------------ * Colors * ------------------------------------------------------------------------ */ $alux_accent_color_options = self::alux_get_color_options(); // Loop over the color options and add them to the customizer foreach ( $alux_accent_color_options as $color_option_name => $color_option ) { $wp_customize->add_setting( $color_option_name, array( 'default' => $color_option['default'], 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $color_option_name, array( 'label' => $color_option['label'], 'section' => 'colors', 'settings' => $color_option_name, 'priority' => 10, ) ) ); } /* ------------------------------------------------------------------------ * Fonts * ------------------------------------------------------------------------ */ $wp_customize->add_section( 'alux_fonts_options', array( 'title' => __( 'Fonts', 'alux' ), 'priority' => 40, 'capability' => 'edit_theme_options', 'description' => __( 'Specify which fonts to use. alux supports all fonts on Google Fonts and all web safe fonts.', 'alux' ) ) ); /* Font Options ------------------ */ $alux_font_options = apply_filters( 'alux_font_options', array( 'alux_body_font' => array( 'default' => '', 'label' => __( 'Body Font', 'alux' ), 'slug' => 'body' ), 'alux_headings_font' => array( 'default' => 'Merriweather', 'label' => __( 'Headings Font', 'alux' ), 'slug' => 'headings' ), ) ); // Loop over the font options and add them to the customizer foreach ( $alux_font_options as $font_option_name => $font_option ) { $wp_customize->add_setting( $font_option_name, array( 'default' => $font_option['default'], 'sanitize_callback' => 'wp_filter_nohtml_kses', 'type' => 'theme_mod', ) ); $wp_customize->add_control( $font_option_name, array( 'type' => 'text', 'label' => $font_option['label'], 'description' => self::alux_suggested_fonts_data_list( $font_option['slug'] ), 'section' => 'alux_fonts_options', 'input_attrs' => array( 'autocapitalize' => 'off', 'autocomplete' => 'off', 'autocorrect' => 'off', 'class' => 'font-suggestions', 'list' => 'alux-suggested-fonts-list-' . $font_option['slug'], 'placeholder' => __( 'Enter the font name', 'alux' ), 'spellcheck' => 'false', ), ) ); } /* Separator --------------------- */ $wp_customize->add_setting( 'alux_fonts_separator_1', array( 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( new alux_Separator_Control( $wp_customize, 'alux_fonts_separator_1', array( 'section' => 'alux_fonts_options', ) ) ); /* Headings Weight --------------- */ $wp_customize->add_setting( 'alux_headings_weight', array( 'default' => '700', 'sanitize_callback' => 'alux_sanitize_select', ) ); $wp_customize->add_control( 'alux_headings_weight', array( 'label' => __( 'Headings Weight', 'alux' ), 'description' => __( 'Note: All fonts do not support all weights.', 'alux' ), 'section' => 'alux_fonts_options', 'settings' => 'alux_headings_weight', 'type' => 'select', 'choices' => array( '100' => __( 'Thin (100)', 'alux' ), '200' => __( 'Ultra Light (200)', 'alux' ), '300' => __( 'Light (300)', 'alux' ), '400' => __( 'Normal (400)', 'alux' ), '500' => __( 'Medium (500)', 'alux' ), '600' => __( 'Semi Bold (600)', 'alux' ), '700' => __( 'Bold (700)', 'alux' ), '800' => __( 'Extra Bold (800)', 'alux' ), '900' => __( 'Black (900)', 'alux' ), ), ) ); /* Headings Text Case ------------ */ $wp_customize->add_setting( 'alux_headings_letter_case', array( 'default' => 'normal', 'sanitize_callback' => 'alux_sanitize_select', ) ); $wp_customize->add_control( 'alux_headings_letter_case', array( 'label' => __( 'Headings Case', 'alux' ), 'section' => 'alux_fonts_options', 'settings' => 'alux_headings_letter_case', 'type' => 'select', 'choices' => array( 'normal' => __( 'Normal', 'alux' ), 'uppercase' => __( 'Uppercase', 'alux' ), 'lowercase' => __( 'Lowercase', 'alux' ), ), ) ); /* Headings Letter Spacing ------- */ $wp_customize->add_setting( 'alux_headings_letterspacing', array( 'default' => 'normal', 'sanitize_callback' => 'alux_sanitize_select', ) ); $wp_customize->add_control( 'alux_headings_letterspacing', array( 'label' => __( 'Headings Letterspacing', 'alux' ), 'section' => 'alux_fonts_options', 'settings' => 'alux_headings_letterspacing', 'type' => 'select', 'choices' => array( '-0_3125' => __( '-50%', 'alux' ), '-0_28125' => __( '-45%', 'alux' ), '-0_25' => __( '-40%', 'alux' ), '-0_21875' => __( '-35%', 'alux' ), '-0_1875' => __( '-30%', 'alux' ), '-0_15625' => __( '-25%', 'alux' ), '-0_125' => __( '-20%', 'alux' ), '-0_09375' => __( '-15%', 'alux' ), '-0_0625' => __( '-10%', 'alux' ), '-0_03125' => __( '-5%', 'alux' ), 'normal' => __( 'Normal', 'alux' ), '0_03125' => __( '5%', 'alux' ), '0_0625' => __( '10%', 'alux' ), '0_09375' => __( '15%', 'alux' ), '0_125' => __( '20%', 'alux' ), '0_15625' => __( '25%', 'alux' ), '0_1875' => __( '30%', 'alux' ), '0_21875' => __( '35%', 'alux' ), '0_25' => __( '40%', 'alux' ), '0_28125' => __( '45%', 'alux' ), '0_3125' => __( '50%', 'alux' ), ), ) ); /* Separator --------------------- */ $wp_customize->add_setting( 'alux_fonts_separator_2', array( 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( new alux_Separator_Control( $wp_customize, 'alux_fonts_separator_2', array( 'section' => 'alux_fonts_options', ) ) ); /* Languages --------------------- */ $wp_customize->add_setting( 'alux_font_languages', array( 'capability' => 'edit_theme_options', 'default' => array( 'latin' ), 'sanitize_callback' => 'alux_sanitize_multiple_checkboxes', ) ); $wp_customize->add_control( new Alux_Customize_Control_Checkbox_Multiple( $wp_customize, 'alux_font_languages', array( 'section' => 'alux_fonts_options', 'label' => __( 'Languages', 'alux' ), 'description' => __( 'Note: All fonts do not support all languages. Check Google Fonts to make sure.', 'alux' ), 'choices' => apply_filters( 'alux_font_languages', array( 'latin' => __( 'Latin', 'alux' ), 'latin-ext' => __( 'Latin Extended', 'alux' ), 'cyrillic' => __( 'Cyrillic', 'alux' ), 'cyrillic-ext' => __( 'Cyrillic Extended', 'alux' ), 'greek' => __( 'Greek', 'alux' ), 'greek-ext' => __( 'Greek Extended', 'alux' ), 'vietnamese' => __( 'Vietnamese', 'alux' ), ) ), ) ) ); /* Sanitation Functions ---------- */ // Sanitize boolean for checkbox function alux_sanitize_checkbox( $checked ) { return ( ( isset( $checked ) && true == $checked ) ? true : false ); } // Sanitize booleans for multiple checkboxes function alux_sanitize_multiple_checkboxes( $values ) { $multi_values = ! is_array( $values ) ? explode( ',', $values ) : $values; return ! empty( $multi_values ) ? array_map( 'sanitize_text_field', $multi_values ) : array(); } // Sanitize select function alux_sanitize_select( $input, $setting ) { $input = sanitize_key( $input ); $choices = $setting->manager->get_control( $setting->id )->choices; return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } } // Return an array of suggested fonts public static function alux_suggested_fonts_data_list( $font_option ) { $suggested_fonts = Alux_Google_Fonts::get_suggested_fonts( $font_option ); $list = ''; return $list; } // Return the sitewide color options included public static function alux_get_color_options() { return apply_filters( 'alux_accent_color_options', array( 'alux_accent_color' => array( 'default' => '#007C89', 'label' => __( 'Accent Color', 'alux' ), 'slug' => 'accent', ), 'alux_primary_text_color' => array( 'default' => '#1A1B1F', 'label' => __( 'Primary Text Color', 'alux' ), 'slug' => 'primary', ), 'alux_headings_text_color' => array( 'default' => '#1A1B1F', 'label' => __( 'Headings Text Color', 'alux' ), 'slug' => 'headings', ), 'alux_buttons_background_color' => array( 'default' => '#007C89', 'label' => __( 'Buttons Background Color', 'alux' ), 'slug' => 'buttons-background', ), 'alux_buttons_text_color' => array( 'default' => '#FFFFFF', 'label' => __( 'Buttons Text Color', 'alux' ), 'slug' => 'buttons-text', ), ) ); } } // Setup the Theme Customizer settings and controls add_action( 'customize_register', array( 'Alux_Customize', 'alux_register' ) ); endif; /* --------------------------------------------------------------------------------------------- CUSTOM CONTROLS --------------------------------------------------------------------------------------------- */ if ( class_exists( 'WP_Customize_Control' ) ) : /* Separator Control --------------------- */ if ( ! class_exists( 'alux_Separator_Control' ) ) : class alux_Separator_Control extends WP_Customize_Control { public function render_content() { echo '