functions.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. require get_template_directory() . '/inc/hp-cleaner.php';
  3. require get_template_directory() . '/inc/hp-nav-walker.php';
  4. require get_template_directory() . '/inc/hp-templates.php';
  5. if ( ! function_exists( 'hp_setup' ) ) :
  6. function hp_setup() {
  7. add_theme_support( 'automatic-feed-links' );
  8. add_theme_support( 'title-tag' );
  9. add_theme_support( 'post-thumbnails' );
  10. register_nav_menus( array(
  11. 'primary' => esc_html__( 'Primary', 'hp' ),
  12. ));
  13. add_theme_support( 'html5', array(
  14. 'comment-form',
  15. 'comment-list',
  16. 'caption',
  17. ));
  18. add_theme_support( 'customize-selective-refresh-widgets' );
  19. add_theme_support( 'editor-styles' );
  20. function hp_add_editor_styles() {
  21. add_editor_style([
  22. 'css/bootstrap.css',
  23. 'style.css'
  24. ] );
  25. }
  26. add_action( 'admin_init', 'hp_add_editor_styles' );
  27. }
  28. endif;
  29. add_action( 'after_setup_theme', 'hp_setup' );
  30. function hp_content_width() {
  31. $GLOBALS['content_width'] = apply_filters( 'hp_content_width', 1170 );
  32. }
  33. add_action( 'after_setup_theme', 'hp_content_width', 0 );
  34. function hp_widgets_init() {
  35. register_sidebar( array(
  36. 'name' => esc_html__( 'Sidebar', 'hp-theme' ),
  37. 'id' => 'sidebar-1',
  38. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  39. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  40. 'after_widget' => '</section>',
  41. 'before_title' => '<h3 class="widget-title">',
  42. 'after_title' => '</h3>',
  43. ) );
  44. register_sidebar( array(
  45. 'name' => esc_html__( 'Footer 1', 'hp-theme' ),
  46. 'id' => 'footer-1',
  47. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  48. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  49. 'after_widget' => '</section>',
  50. 'before_title' => '<h3 class="widget-title">',
  51. 'after_title' => '</h3>',
  52. ) );
  53. register_sidebar( array(
  54. 'name' => esc_html__( 'Footer 2', 'hp-theme' ),
  55. 'id' => 'footer-2',
  56. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  57. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  58. 'after_widget' => '</section>',
  59. 'before_title' => '<h3 class="widget-title">',
  60. 'after_title' => '</h3>',
  61. ) );
  62. register_sidebar( array(
  63. 'name' => esc_html__( 'Footer 3', 'hp-theme' ),
  64. 'id' => 'footer-3',
  65. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  66. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  67. 'after_widget' => '</section>',
  68. 'before_title' => '<h3 class="widget-title">',
  69. 'after_title' => '</h3>',
  70. ) );
  71. }
  72. add_action( 'widgets_init', 'hp_widgets_init' );
  73. function hp_scripts() {
  74. wp_enqueue_style( 'hp-boot-css', get_template_directory_uri() . '/css/bootstrap.css' );
  75. wp_enqueue_style( 'hp-boot-font', get_template_directory_uri() . '/css/bootstrap-icons.css' );
  76. //wp_enqueue_style( 'hp-montserrat-opensans-font', 'https://fonts.googleapis.com/css?family=Montserrat|Open+Sans:300,300i,400,400i,600,600i,700,800' );
  77. wp_enqueue_style( 'hp-style', get_stylesheet_uri() );
  78. wp_enqueue_script('jquery');
  79. wp_enqueue_script('hp-init', get_template_directory_uri() . '/js/init.js', array(), '', true );
  80. wp_enqueue_script('wp-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus.js', array(), '20151215', true );
  81. wp_enqueue_script('hp-boot-js', get_template_directory_uri() . '/js/bootstrap.bundle.js', array(), '', true );
  82. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  83. wp_enqueue_script( 'comment-reply' );
  84. }
  85. }
  86. add_action( 'wp_enqueue_scripts', 'hp_scripts' );