-
-
Save Arcath/2257969b108907d295126586f810598e to your computer and use it in GitHub Desktop.
Theme Options Post Code
This file contains 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 | |
$themeOptions = new Arcath\ThemeOptions('theme_slug'); | |
add_action('init', function(){ | |
global $themeOptions; | |
// Add an option using a custom control class | |
$themeOptions->addThemeOptionCustomControl('logo_light', | |
array( | |
'type' => 'option', | |
'default' => 0 | |
), | |
array( | |
'section' => 'home', | |
'label' => __('Light Logo', 'theme_slug'), | |
'description' => __('Light Logo used on darker backgrounds', 'theme_slug'), | |
), | |
'WP_Customize_Image_Control' | |
); | |
// Add an option with the standard control class | |
$themeOptions->addThemeOption('phone_number', | |
array( | |
'capability' => 'edit_theme_options', | |
'type' => 'option', | |
'default' => '0123456789', | |
), | |
array( | |
'label' => 'Phone Number', | |
'section' => 'home', | |
'description' => __('Your Phone Number', 'theme_slug') | |
) | |
); | |
}); | |
add_action('customize_register', function($wp_customize){ | |
// Create the required sections | |
$wp_customize->add_section( | |
'home', | |
array( | |
'title' => 'Home', | |
'description' => __('Home Page Template options.', 'theme_slug'), | |
'capability' => 'edit_theme_options', | |
) | |
); | |
}); | |
?> |
This file contains 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 | |
global $themeOptions; | |
echo($themeOptions->themeOption('phone_number')); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment