Created
February 16, 2026 15:03
-
-
Save atelierbram/7a349a4b6cbeb0600988b1f9b9ea0491 to your computer and use it in GitHub Desktop.
Colophon section which can be edited in WordPress customizer (GeneratePress child-theme)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php // colophon section which can be edited in WordPress customizer (GeneratePress child-theme) | |
| add_action( 'customize_register', function( $wp_customize ) { | |
| $wp_customize->add_section( 'fia_colophon_section', array( | |
| 'title' => __( 'Colofon Informatie', 'fia-theme' ), | |
| 'priority' => 120, | |
| ) ); | |
| // Velden configuratie | |
| $fields = array( | |
| 'colophon_social_link' => 'Social Media URL', | |
| 'colophon_address' => 'Adres', | |
| 'colophon_phone' => 'Telefoonnummer', | |
| 'colophon_hours' => 'Openingstijden', | |
| ); | |
| foreach ( $fields as $id => $label ) { | |
| $wp_customize->add_setting( $id, array( | |
| 'default' => '', | |
| 'transport' => 'refresh', | |
| ) ); | |
| $wp_customize->add_control( $id, array( | |
| 'label' => $label, | |
| 'section' => 'fia_colophon_section', | |
| 'type' => ( $id === 'colophon_address' ) ? 'textarea' : 'text', | |
| ) ); | |
| } | |
| } ); | |
| add_action( 'generate_before_footer', function() { | |
| $social_url = get_theme_mod( 'colophon_social_link' ); | |
| $address = get_theme_mod( 'colophon_address' ); | |
| $phone = get_theme_mod( 'colophon_phone' ); | |
| $hours = get_theme_mod( 'colophon_hours' ); | |
| // Alleen tonen als er minstens één veld is ingevuld | |
| if ( $social_url || $address || $phone || $hours ) { | |
| ?> | |
| <section class="custom-colophon"> | |
| <div class="grid-container"> | |
| <ul class="colophon-list"> | |
| <?php if ( $social_url ) : ?> | |
| <li><a href="<?php echo esc_url( $social_url ); ?>" target="_blank" rel="noopener">Social Media</a></li> | |
| <?php endif; ?> | |
| <?php if ( $address ) : ?> | |
| <li><?php echo wp_kses_post( $address ); ?></li> | |
| <?php endif; ?> | |
| <?php if ( $phone ) : ?> | |
| <li><a href="tel:<?php echo esc_attr( str_replace(' ', '', $phone) ); ?>"><?php echo esc_html( $phone ); ?></a></li> | |
| <?php endif; ?> | |
| <?php if ( $hours ) : ?> | |
| <li><?php echo esc_html( $hours ); ?></li> | |
| <?php endif; ?> | |
| </ul> | |
| </div> | |
| </section> | |
| <?php | |
| } | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment