public static function getInstance() { if (self::$instance === null) { self::$instance = new QHThemeWidgetFooter(); } return self::$instance; }
public static function run() { add_action('init', function () { register_nav_menu('primary', 'Primary Menu'); register_sidebar(array('name' => 'Right Side Bar', 'id' => 'right_side_bar', 'description' => 'The right side bar', 'before_widget' => '<aside id="%1$s" class="%2s">', 'after_widget' => '</aside>')); register_sidebars(3, array('name' => 'Footer %d', 'id' => 'footer', 'before_widget' => '<aside id="%1$s" class="%2s">', 'after_widget' => '</aside>')); }); add_action('wp_enqueue_scripts', function () { //register style wp_register_style('bootstrap_css', QH_THEME_URL . '/style.css'); wp_enqueue_style('bootstrap_css'); //register script wp_register_script('jquery', QH_THEME_URL . '/scripts/js/jquery.min.js'); wp_register_script('bootstrap_js', QH_THEME_URL . '/scripts/js/bootstrap.min.js', array('jquery')); wp_enqueue_script('bootstrap_js'); }); add_action('after_setup_theme', function () { add_theme_support('post-thumbnails'); add_theme_support('post-formats', array('image', 'aside')); add_theme_support('custom-background'); //set_post_thumbnail_size(213, 213, true); add_image_size('qh_thumbnail', 213, 213, array('center', 'center')); add_image_size('qhlarge', 390, 300, array('center', 'center')); add_image_size('qhsmall', 195, 150, array('center', 'center')); }); //run widget QHThemeWidgetFooter::run(); //theme customization api add_action('customize_register', function ($customize) { //dang ky setting $customize->add_setting('qhtheme_special_post', array('default' => 1, 'transport' => 'postMessage')); $customize->add_setting('qhtheme_nav_color', array('default' => '#2E8DEF', 'transport' => 'postMessage')); $customize->add_setting('qhtheme_footer_color', array('default' => '#333', 'transport' => 'postMessage')); //dang ky session $customize->add_section('qhtheme_setting_section', array('title' => 'Theme setting', 'priority' => 1)); //dang ky control $customize->add_control(new WP_Customize_Control($customize, 'qhtheme_special_post_control', array('label' => 'Special Post', 'section' => 'qhtheme_setting_section', 'settings' => 'qhtheme_special_post', 'type' => 'select', 'choices' => array(1 => 'On', 2 => 'Off')))); $customize->add_control(new WP_Customize_Color_Control($customize, 'qhtheme_nav_color_control', array('label' => 'Navigation Bar Color', 'section' => 'qhtheme_setting_section', 'settings' => 'qhtheme_nav_color'))); $customize->add_control(new WP_Customize_Color_Control($customize, 'qhtheme_footer_color_control', array('label' => 'Footer Color', 'section' => 'qhtheme_setting_section', 'settings' => 'qhtheme_footer_color'))); //get setting $customize->get_setting('qhtheme_special_post')->transport = 'postMessage'; $customize->get_setting('qhtheme_nav_color')->transport = 'postMessage'; $customize->get_setting('qhtheme_footer_color')->transport = 'postMessage'; }); add_action('customize_preview_init', function () { wp_enqueue_script('theme-preview', QH_THEME_URL . '/scripts/js/theme-preview.js', array('jquery', 'customize-preview')); }); }