Skip to content

Instantly share code, notes, and snippets.

@TanvirAmi
Last active January 12, 2018 14:56
Show Gist options
  • Save TanvirAmi/1f5eb9a715734093e8b7f432bdfd85e9 to your computer and use it in GitHub Desktop.
Save TanvirAmi/1f5eb9a715734093e8b7f432bdfd85e9 to your computer and use it in GitHub Desktop.
<?php
/**
* Theme Customizer
* @package OOF Theme
*/
function oof_customizer_register(){
// Stores all the controls that will be added
$options = array();
// Stores all the sections to be added
$sections = array();
// Stores all the panels to be added
$panels = array();
// Adds the sections to the $options array
$options['sections'] = $sections;
// ======= Start Customizer Panels/Sections/Settings ======= //
// General Panels and Sections
$general_panel = 'general';
$panels[] = array(
'id' => $general_panel,
'title' => esc_html__( 'General', 'oof' ),
'description' => esc_html__( 'This panel is used for managing general section of your site.', 'oof' ),
'priority' => 10
);
// Footer Text
$section = 'footer-text-section';
$sections[] = array(
'id' => $section,
'title' => esc_html__( 'Footer Text', 'oof' ),
'priority' => 120,
'panel' => $general_panel,
);
$options['footer-text'] = array(
'id' =>'footer-text',
'label' => '',
'description' => esc_html__( 'Customize the footer text.', 'oof' ),
'section' => $section,
'type' => 'textarea',
'default' => '&copy; Copyright ' . date( 'Y' ) . ' <a href="' . esc_url( home_url() ) . '">' . esc_attr( get_bloginfo( 'name' ) ) . '</a> &middot; Designed by <a href="http://www.theme-junkie.com/">Theme Junkie</a>'
);
// Content Panel and Sections
$content_panel = 'content';
$panels[] = array(
'id' => $content_panel,
'title' => esc_html__( 'Contents', 'oof' ),
'description' => esc_html__( 'This panel is used for managing several custom content of your site.', 'oof' ),
'priority' => 35
);
// Featured posts
$section = 'featured-section';
$sections[] = array(
'id' => $section,
'title' => esc_html__( 'Featured Posts', 'oof' ),
'priority' => 5,
'panel' => $content_panel
);
$options['featured-num'] = array(
'id' => 'featured-num',
'label' => esc_html__( 'Number of posts', 'oof' ),
'section' => $section,
'type' => 'text',
'default' => 3
);
$options['featured-enable'] = array(
'id' => 'featured-enable',
'label' => esc_html__( 'Show featured slider', 'oof' ),
'section' => $section,
'type' => 'switch',
'default' => 1
);
$options['featured-tag'] = array(
'id' => 'featured-tag',
'label' => esc_html__( 'Select a tag', 'oof' ),
'description' => esc_html__( 'If you are not selecting any tag, the featured posts will display the most recent posts.', 'reviewpro' ),
'section' => $section,
'type' => 'select2',
'choices' => oof_tags_list()
);
// Adds the sections to the $options array
$options['sections'] = $sections;
// Adds the panels to the $options array
$options['panels'] = $panels;
$customizer_library = Customizer_Library::Instance();
$customizer_library->add_options( $options );
}
add_action('init', 'oof_customizer_register');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment