From fac95a50160a1746020ede945840192a4ec1d21b Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Tue, 8 Dec 2020 18:55:26 +0100 Subject: [PATCH] WIP #4064 @7 --- .../mu-plugins/cube/src/Customizer/Setup.php | 179 ++++++++++++------ .../assets/styles/components/footer.styl | 11 -- .../resources/views/partials/footer.blade.php | 16 +- 3 files changed, 132 insertions(+), 74 deletions(-) diff --git a/web/app/mu-plugins/cube/src/Customizer/Setup.php b/web/app/mu-plugins/cube/src/Customizer/Setup.php index 9a91682..fa23886 100644 --- a/web/app/mu-plugins/cube/src/Customizer/Setup.php +++ b/web/app/mu-plugins/cube/src/Customizer/Setup.php @@ -4,6 +4,7 @@ namespace Cube\Customizer; use WP_Customize_Manager; use WP_Customize_Control; +use WP_Customize_Image_Control; class Setup { @@ -22,79 +23,135 @@ 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' @@ -103,18 +160,16 @@ class Setup { $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, ] )); - - - }); + } } diff --git a/web/app/themes/Usines/resources/assets/styles/components/footer.styl b/web/app/themes/Usines/resources/assets/styles/components/footer.styl index 63d7c93..3825d00 100644 --- a/web/app/themes/Usines/resources/assets/styles/components/footer.styl +++ b/web/app/themes/Usines/resources/assets/styles/components/footer.styl @@ -21,18 +21,7 @@ $breakpoint-footer-1-col = 650px &-col-2, &-col-3, &-col-4 margin-top: 5.25rem - &-col-2 +below($breakpoint-footer-2-cols) - order: 4 - margin-top: 3rem - &-col-3 - +below($breakpoint-footer-2-cols) - order: 2 - +below($breakpoint-footer-1-col) - margin-top: 3rem - &-col-4 - +below($breakpoint-footer-2-cols) - order: 3 margin-top: 3rem &-logo diff --git a/web/app/themes/Usines/resources/views/partials/footer.blade.php b/web/app/themes/Usines/resources/views/partials/footer.blade.php index 8fea83b..9226bb1 100644 --- a/web/app/themes/Usines/resources/views/partials/footer.blade.php +++ b/web/app/themes/Usines/resources/views/partials/footer.blade.php @@ -1,4 +1,18 @@ -