functions.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**********************************
  3. ######### Setup WordPress #########
  4. ***********************************/
  5. require get_template_directory() . '/inc/wp-cleaner.php';
  6. require get_template_directory() . '/inc/wp-nav-walker.php';
  7. require get_template_directory() . '/inc/wp-templates.php';
  8. require get_template_directory() . '/inc/theme.php';
  9. function boot23_scripts() {
  10. wp_enqueue_style( 'icons', get_template_directory_uri() . '/css/bootstrap-icons.css' );
  11. wp_enqueue_style( 'sass', get_template_directory_uri() . '/css/custom.css' );
  12. wp_enqueue_style( 'style', get_stylesheet_uri() );
  13. wp_enqueue_script('jquery');
  14. wp_enqueue_script('script', get_template_directory_uri() . '/js/script.min.js', array(), '', true );
  15. wp_enqueue_script('init', get_template_directory_uri() . '/js/init.js', array(), '', true );
  16. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  17. wp_enqueue_script( 'comment-reply' );
  18. }
  19. }
  20. add_action( 'wp_enqueue_scripts', 'boot23_scripts' );
  21. function boot23_setup() {
  22. add_theme_support( 'automatic-feed-links' );
  23. add_theme_support( 'title-tag' );
  24. add_theme_support( 'post-thumbnails' );
  25. add_theme_support( 'nav-menus' );
  26. register_nav_menus( array(
  27. 'primary' => __( 'Primary' ),
  28. 'bottom' =>__( 'Bottom' ),
  29. 'top' =>__( 'Top' )
  30. ));
  31. add_theme_support( 'html5', array(
  32. 'search-form',
  33. 'comment-form',
  34. 'comment-list',
  35. 'caption',
  36. ));
  37. add_theme_support( 'customize-selective-refresh-widgets' );
  38. }
  39. add_action( 'after_setup_theme', 'boot23_setup' );
  40. /************************************
  41. ######### WordPress Widgets #########
  42. *************************************/
  43. function boot23_widgets_init() {
  44. register_sidebar( array(
  45. 'name' => esc_html__( 'Homepage', 'hp-theme' ),
  46. 'id' => 'homepage-widget',
  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__( 'Sidebar', 'hp-theme' ),
  55. 'id' => 'sidebar-1',
  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 1', 'hp-theme' ),
  64. 'id' => 'footer-1',
  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. register_sidebar( array(
  72. 'name' => esc_html__( 'Footer 2', 'hp-theme' ),
  73. 'id' => 'footer-2',
  74. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  75. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  76. 'after_widget' => '</section>',
  77. 'before_title' => '<h3 class="widget-title">',
  78. 'after_title' => '</h3>',
  79. ) );
  80. register_sidebar( array(
  81. 'name' => esc_html__( 'Footer 3', 'hp-theme' ),
  82. 'id' => 'footer-3',
  83. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  84. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  85. 'after_widget' => '</section>',
  86. 'before_title' => '<h3 class="widget-title">',
  87. 'after_title' => '</h3>',
  88. ) );
  89. }
  90. add_action( 'widgets_init', 'boot23_widgets_init' );
  91. /**********************************
  92. ######## Gutenberg Editor #########
  93. ***********************************/
  94. function boot23_gutenberg_scripts() {
  95. wp_enqueue_script( 'hp-editor', get_stylesheet_directory_uri() . '/js/editor.js', array( 'wp-blocks', 'wp-dom' ), filemtime( get_stylesheet_directory() . '/js/editor.js' ), true );
  96. }
  97. add_action( 'enqueue_block_editor_assets', 'boot23_gutenberg_scripts' );
  98. function boot23_add_editor_styles() {
  99. add_theme_support( 'editor-styles' );
  100. add_editor_style([
  101. 'css/custom.css',
  102. 'style.css'
  103. ]);
  104. }
  105. add_action( 'after_setup_theme', 'boot23_add_editor_styles' );
  106. function boot23_gutenberg_filter_block( $block_content, $block ) {
  107. $block_content = str_replace(
  108. 'wp-block-button__link',
  109. 'wp-block-button__link btn',
  110. $block_content
  111. );
  112. return $block_content;
  113. }
  114. add_filter( 'render_block', 'boot23_gutenberg_filter_block', 10, 2);