Last active
June 22, 2018 08:32
-
-
Save tommcfarlin/7dc870daf85b82578582 to your computer and use it in GitHub Desktop.
[WordPress] An example of a long form implementation of the Theme Customizer.
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 | |
| function acme_theme_customizer( $wp_customizer ) { | |
| $wp_customizer->add_section( | |
| 'acme_header_section', | |
| array( | |
| 'title' => __( 'Header Settings', 'acme' ), | |
| 'priority' => 200 | |
| ) | |
| ); | |
| $wp_customizer->add_setting( | |
| 'acme_header_text_color', | |
| array( | |
| 'default' => '', | |
| 'transport' => 'postMessage' | |
| ) | |
| ); | |
| $wp_customizer->add_control( | |
| new WP_Customize_Color_Control( | |
| $wp_customizer, | |
| 'acme_header_text_color', | |
| array( | |
| 'label' => __( 'Text Color', 'acme' ), | |
| 'section' => 'acme_header_section', | |
| 'settings' => 'acme_header_text_color' | |
| ) | |
| ) | |
| ); | |
| $wp_customizer->add_setting( | |
| 'acme_header_background_image', | |
| array( | |
| 'default' => '', | |
| 'transport' => 'postMessage' | |
| ) | |
| ); | |
| $wp_customizer->add_control( | |
| new WP_Customize_Image_Control( | |
| $wp_customizer, | |
| 'acme_header_background_image', | |
| array( | |
| 'label' => __( 'Background Image', 'acme' ), | |
| 'section' => 'acme_header_section', | |
| 'settings' => 'acme_header_background_image', | |
| ) | |
| ) | |
| ); | |
| $wp_customizer->add_setting( | |
| 'acme_header_background_color', | |
| array( | |
| 'default' => '', | |
| 'transport' => 'postMessage' | |
| ) | |
| ); | |
| $wp_customizer->add_control( | |
| new WP_Customize_Color_Control( | |
| $wp_customizer, | |
| 'acme_header_background_color', | |
| array( | |
| 'label' => __( 'Background Color', 'acme' ), | |
| 'section' => 'acme_header_section', | |
| 'settings' => 'acme_header_background_color' | |
| ) | |
| ) | |
| ); | |
| } // end acme_theme_customizer | |
| add_action( 'customize_register', 'acme_theme_customizer' ); |
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 | |
| function acme_theme_customizer( $wp_customizer ) { | |
| // Header | |
| $wp_customizer->add_section( | |
| 'acme_header_section', | |
| array( | |
| 'title' => __( 'Header Settings', 'acme' ), | |
| 'priority' => 200 | |
| ) | |
| ); | |
| _acme_add_header_color_picker( $wp_customizer ); | |
| _acme_add_header_background_color_picker( $wp_customizer ); | |
| _acme_add_header_background_image_picker( $wp_customizer ); | |
| } // end acme_theme_customizer | |
| add_action( 'customize_register', 'acme_theme_customizer' ); | |
| function _acme_add_header_color_picker( $wp_customizer ) { | |
| $wp_customizer->add_setting( | |
| 'acme_header_text_color', | |
| array( | |
| 'default' => '', | |
| 'transport' => 'postMessage' | |
| ) | |
| ); | |
| $wp_customizer->add_control( | |
| new WP_Customize_Color_Control( | |
| $wp_customizer, | |
| 'acme_header_text_color', | |
| array( | |
| 'label' => __( 'Text Color', 'acme' ), | |
| 'section' => 'acme_header_section', | |
| 'settings' => 'acme_header_text_color' | |
| ) | |
| ) | |
| ); | |
| } // end _acme_add_header_color_picker | |
| function _acme_add_header_background_image_picker( $wp_customizer ) { | |
| $wp_customizer->add_setting( | |
| 'acme_header_background_image', | |
| array( | |
| 'default' => '', | |
| 'transport' => 'postMessage' | |
| ) | |
| ); | |
| $wp_customizer->add_control( | |
| new WP_Customize_Image_Control( | |
| $wp_customizer, | |
| 'acme_header_background_image', | |
| array( | |
| 'label' => __( 'Background Image', 'acme' ), | |
| 'section' => 'acme_header_section', | |
| 'settings' => 'acme_header_background_image', | |
| ) | |
| ) | |
| ); | |
| } // end _acme_add_header_background_image_picker | |
| function _acme_add_header_background_color_picker( $wp_customizer ) { | |
| $wp_customizer->add_setting( | |
| 'acme_header_background_color', | |
| array( | |
| 'default' => '', | |
| 'transport' => 'postMessage' | |
| ) | |
| ); | |
| $wp_customizer->add_control( | |
| new WP_Customize_Color_Control( | |
| $wp_customizer, | |
| 'acme_header_background_color', | |
| array( | |
| 'label' => __( 'Background Color', 'acme' ), | |
| 'section' => 'acme_header_section', | |
| 'settings' => 'acme_header_background_color' | |
| ) | |
| ) | |
| ); | |
| } // _acme_add_header_background_color_picker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment