Skip to content

Instantly share code, notes, and snippets.

@yuriitaran
Last active November 7, 2017 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuriitaran/06e5da4dfb669e3d2396d380aff3d70b to your computer and use it in GitHub Desktop.
Save yuriitaran/06e5da4dfb669e3d2396d380aff3d70b to your computer and use it in GitHub Desktop.
WP Theme Options
/**
* Theme Options
*/
add_action('customize_register', function($wp_customize) {
/**
* Add Custom Logo
*/
$wp_customize->add_setting('logo_img');
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'logo_img',
array(
'label' => 'Logo',
'section' => 'title_tagline',
'settings' => 'logo_img'
)
)
);
/**
* Add Section for Design Settings
*/
$wp_customize->add_section(
'design_section',
array(
'title' => 'Design',
'description' => 'Visual settings',
'priority' => 71,
// 'panel' => 'design_option_panel',
)
);
/**
* Add Custom Background
*/
$wp_customize->add_setting('background_img');
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'background_img',
array(
'label' => 'Background image',
'section' => 'design_section',
'settings' => 'background_img'
)
)
);
/**
* Add Section for Footer Settings
*/
$wp_customize->add_section(
'footer_section',
array(
'title' => 'Footer',
'description' => 'Bottom logo and copyright',
'priority' => 71,
// 'panel' => 'design_option_panel',
)
);
/**
* Add Custom Bottom Logo
*/
$wp_customize->add_setting('bottom_logo');
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'bottom_logo',
array(
'label' => 'Bottom logo',
'section' => 'footer_section',
'settings' => 'bottom_logo'
)
)
);
/**
* Add Copyright
*/
$wp_customize->add_setting(
'copyright_text',
array('default' => '')
);
$wp_customize->add_control(
'copyright_text',
array(
'label' => 'Copyright Text',
'section' => 'footer_section',
'type' => 'text',
)
);
// echo (get_theme_mod('copyright_text') ? get_theme_mod('copyright_text') : bloginfo('name'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment