functions.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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',
  96. get_stylesheet_directory_uri() . '/js/editor.js',
  97. array( 'wp-blocks', 'wp-dom' ),
  98. filemtime( get_stylesheet_directory() . '/js/editor.js' ), true );
  99. }
  100. add_action( 'enqueue_block_editor_assets', 'boot23_gutenberg_scripts' );
  101. function boot23_add_editor_styles() {
  102. add_theme_support( 'editor-styles' );
  103. add_editor_style([
  104. 'css/custom.css',
  105. 'style.css'
  106. ]);
  107. }
  108. add_action( 'after_setup_theme', 'boot23_add_editor_styles' );
  109. function boot23_block_styles(){
  110. wp_enqueue_style(
  111. 'boot23-css',
  112. get_stylesheet_directory_uri() . '/css/custom.css',
  113. array( 'wp-edit-blocks' ),
  114. time()
  115. );
  116. }
  117. add_action( 'enqueue_block_editor_assets', 'boot23_block_styles' );
  118. function boot23_gutenberg_filter_block( $block_content, $block ) {
  119. $block_content = str_replace(
  120. 'wp-block-button__link',
  121. 'wp-block-button__link btn',
  122. $block_content
  123. );
  124. return $block_content;
  125. }
  126. add_filter( 'render_block', 'boot23_gutenberg_filter_block', 10, 2);
  127. function boot23_allowed_block_types( $allowed_blocks, $post ) {
  128. return array(
  129. 'core/paragraph',
  130. 'core/image',
  131. 'core/heading',
  132. 'core/list',
  133. 'core/gallery',
  134. 'core/list',
  135. 'core/cover',
  136. 'core/file',
  137. 'core/video',
  138. 'core/table',
  139. 'core/html',
  140. 'core/pullquote',
  141. 'core/buttons',
  142. 'core/text-columns',
  143. 'core/more',
  144. 'core/separator',
  145. 'core/spacer',
  146. 'core/shortcode',
  147. 'core/embed'
  148. );
  149. }
  150. add_filter( 'allowed_block_types', 'boot23_allowed_block_types', 10, 2 );
  151. function boot23_remove_core_patterns() {
  152. $block_patterns = array (
  153. 'core/two-buttons',
  154. 'core/three-buttons',
  155. 'core/text-two-columns',
  156. 'core/text-two-columns-with-images',
  157. 'core/text-three-columns-buttons',
  158. 'core/two-images',
  159. 'core/large-header',
  160. 'core/large-header-button',
  161. 'core/heading-paragraph',
  162. 'core/quote'
  163. );
  164. foreach ( $block_patterns as $bp ):
  165. unregister_block_pattern( $bp );
  166. endforeach;
  167. }
  168. add_action('init', 'boot23_remove_core_patterns');