functions.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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-jasny-boot-css', get_template_directory_uri() . '/css/jasny-bootstrap.css' );
  76. wp_enqueue_style( 'hp-boot-font', get_template_directory_uri() . '/css/bootstrap-icons.css' );
  77. wp_enqueue_style( 'hp-style', get_stylesheet_uri() );
  78. wp_enqueue_script('jquery');
  79. wp_enqueue_script('wp-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus.js', array(), '20151215', true );
  80. wp_enqueue_script('hp-boot-js', get_template_directory_uri() . '/js/bootstrap.bundle.js', array(), '', true );
  81. //wp_enqueue_script('hp-jasny-boot-js', get_template_directory_uri() . '/js/jasny-bootstrap.js', array(), '', true );
  82. wp_enqueue_script('hp-init', get_template_directory_uri() . '/js/init.js', array(), '', true );
  83. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  84. wp_enqueue_script( 'comment-reply' );
  85. }
  86. }
  87. add_action( 'wp_enqueue_scripts', 'hp_scripts' );
  88. function hp_seamless_style() {
  89. if ( !is_page('donate') ) {
  90. wp_deregister_style('seamless_donations_css');
  91. }
  92. }
  93. add_action('wp_print_styles', 'hp_seamless_style', 100);
  94. function hp_seamless_scripts() {
  95. if ( !is_page('donate') ) {
  96. wp_dequeue_script( 'seamless_javascript_code' );
  97. wp_deregister_script( 'seamless_javascript_code' );
  98. wp_dequeue_script( 'seamless_javascript_uuid' );
  99. wp_deregister_script( 'seamless_javascript_uuid' );
  100. }
  101. }
  102. add_action( 'wp_enqueue_scripts', 'hp_seamless_scripts', 100);