use WP_Customize_Manager;
use WP_Customize_Control;
+use WP_Customize_Image_Control;
class Setup {
* @return void
*/
add_action('customize_register', function (WP_Customize_Manager $wp_customize) {
+ $this->site_details($wp_customize);
+ $this->footer_icons($wp_customize);
+ });
- // Rename "Site Identity" section
- $wp_customize->get_section('title_tagline')->title = __('Site Details', 'usines');
- // Remove tagline control
- $wp_customize->remove_control('blogdescription');
+ }
- //-- Contact e-mail address (used in footer)
- $wp_customize->add_setting(
- 'contact_email',
- [
- 'type' => 'option',
- 'capability' => 'edit_theme_options'
- ]
- );
+ public function site_details(WP_Customize_Manager $wp_customize) {
+
+ // Rename "Site Identity" section
+ $wp_customize->get_section('title_tagline')->title = __('Site Details', 'usines');
+ // Remove tagline control
+ $wp_customize->remove_control('blogdescription');
+
+ //-- Contact e-mail address (used in footer)
+ $wp_customize->add_setting(
+ 'contact_email',
+ [
+ 'type' => 'option',
+ 'capability' => 'edit_theme_options'
+ ]
+ );
+
+ $wp_customize->add_control(new WP_Customize_Control(
+ $wp_customize,
+ 'contact_email',
+ [
+ 'label' => __('Adresse email', 'usines'),
+ 'settings' => 'contact_email',
+ 'section' => 'title_tagline',
+ 'type' => 'text',
+ 'priority' => 11,
+ ]
+ ));
+
+ //-- Contact phone number (used in header and footer)
+ $wp_customize->add_setting(
+ 'contact_phone',
+ [
+ 'type' => 'option',
+ 'capability' => 'edit_theme_options'
+ ]
+ );
+
+ $wp_customize->add_control(new WP_Customize_Control(
+ $wp_customize,
+ 'contact_phone',
+ [
+ 'label' => __('Numéro de téléphone', 'usines'),
+ 'description' => __("Utilisé dans l'en-tête et le pied de page", 'usines'),
+ 'settings' => 'contact_phone',
+ 'section' => 'title_tagline',
+ 'type' => 'text',
+ 'priority' => 11,
+ ]
+ ));
+
+ //-- Header contact text
+ $wp_customize->add_setting(
+ 'contact_header_text',
+ [
+ 'type' => 'option',
+ 'capability' => 'edit_theme_options'
+ ]
+ );
+
+ $wp_customize->add_control(new WP_Customize_Control(
+ $wp_customize,
+ 'contact_header_text',
+ [
+ 'label' => __("Texte de contact d'en-tête", 'usines'),
+ 'settings' => 'contact_header_text',
+ 'section' => 'title_tagline',
+ 'type' => 'text',
+ 'priority' => 12,
+ ]
+ ));
+
+ //-- Footer contact text
+ $wp_customize->add_setting(
+ 'contact_footer_text',
+ [
+ 'type' => 'option',
+ 'capability' => 'edit_theme_options'
+ ]
+ );
+
+ $wp_customize->add_control(new WP_Customize_Control(
+ $wp_customize,
+ 'contact_footer_text',
+ [
+ 'label' => __('Texte de contact de pied de page', 'usines'),
+ 'settings' => 'contact_footer_text',
+ 'section' => 'title_tagline',
+ 'type' => 'textarea',
+ 'priority' => 13,
+ ]
+ ));
- $wp_customize->add_control(new WP_Customize_Control(
- $wp_customize,
- 'contact_email',
- [
- 'label' => __('Adresse email', 'usines'),
- 'settings' => 'contact_email',
- 'section' => 'title_tagline',
- 'type' => 'text',
- 'priority' => 11,
- ]
- ));
+ }
- //-- Contact phone number (used in header and footer)
- $wp_customize->add_setting(
- 'contact_phone',
- [
- 'type' => 'option',
- 'capability' => 'edit_theme_options'
- ]
- );
+ public function footer_icons(WP_Customize_Manager $wp_customize) {
- $wp_customize->add_control(new WP_Customize_Control(
- $wp_customize,
- 'contact_phone',
- [
- 'label' => __('Numéro de téléphone', 'usines'),
- 'description' => __("Utilisé dans l'en-tête et le pied de page", 'usines'),
- 'settings' => 'contact_phone',
- 'section' => 'title_tagline',
- 'type' => 'text',
- 'priority' => 11,
- ]
- ));
+ $icon_count = 4; // How many icons should there be?
- //-- Header contact text
+ // Rename "Site Identity" section
+ $wp_customize->add_section('footer_icons')->title = __('Footer Icons', 'usines');
+
+ for ($i = 1; $i <= $icon_count; $i++) {
$wp_customize->add_setting(
- 'contact_header_text',
+ "footer_icon_$i",
[
'type' => 'option',
'capability' => 'edit_theme_options'
]
);
- $wp_customize->add_control(new WP_Customize_Control(
+ $wp_customize->add_control(new WP_Customize_Image_Control(
$wp_customize,
- 'contact_header_text',
+ "footer_icon_$i",
[
- 'label' => __("Texte de contact d'en-tête", 'usines'),
- 'settings' => 'contact_header_text',
- 'section' => 'title_tagline',
- 'type' => 'text',
- 'priority' => 12,
+ 'label' => sprintf(__('Icône %d', 'usines'), $i),
+ 'settings' => "footer_icon_$i",
+ 'section' => 'footer_icons',
+ 'priority' => 10 * $i,
]
));
- //-- Footer contact text
$wp_customize->add_setting(
- 'contact_footer_text',
+ "footer_icon_text_$i",
[
'type' => 'option',
'capability' => 'edit_theme_options'
$wp_customize->add_control(new WP_Customize_Control(
$wp_customize,
- 'contact_footer_text',
+ "footer_icon_text_$i",
[
- 'label' => __('Texte de contact de pied de page', 'usines'),
- 'settings' => 'contact_footer_text',
- 'section' => 'title_tagline',
+ 'label' => sprintf(__('Description', 'usines'), $i),
+ 'settings' => "footer_icon_text_$i",
+ 'section' => 'footer_icons',
'type' => 'textarea',
- 'priority' => 13,
+ 'priority' => 10 * $i + 1,
]
));
-
-
- });
+ }
}