functions.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. add_theme_support( 'editor-styles' );
  39. }
  40. add_action( 'after_setup_theme', 'boot23_setup' );
  41. /************************************
  42. ######### WordPress Widgets #########
  43. *************************************/
  44. function boot23_widgets_init() {
  45. register_sidebar( array(
  46. 'name' => esc_html__( 'Sidebar', 'hp-theme' ),
  47. 'id' => 'sidebar-1',
  48. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  49. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  50. 'after_widget' => '</section>',
  51. 'before_title' => '<h3 class="widget-title">',
  52. 'after_title' => '</h3>',
  53. ) );
  54. register_sidebar( array(
  55. 'name' => esc_html__( 'Footer 1', 'hp-theme' ),
  56. 'id' => 'footer-1',
  57. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  58. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  59. 'after_widget' => '</section>',
  60. 'before_title' => '<h3 class="widget-title">',
  61. 'after_title' => '</h3>',
  62. ) );
  63. register_sidebar( array(
  64. 'name' => esc_html__( 'Footer 2', 'hp-theme' ),
  65. 'id' => 'footer-2',
  66. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  67. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  68. 'after_widget' => '</section>',
  69. 'before_title' => '<h3 class="widget-title">',
  70. 'after_title' => '</h3>',
  71. ) );
  72. register_sidebar( array(
  73. 'name' => esc_html__( 'Footer 3', 'hp-theme' ),
  74. 'id' => 'footer-3',
  75. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  76. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  77. 'after_widget' => '</section>',
  78. 'before_title' => '<h3 class="widget-title">',
  79. 'after_title' => '</h3>',
  80. ) );
  81. }
  82. add_action( 'widgets_init', 'boot23_widgets_init' );
  83. /**********************************
  84. ######## Gutenberg Editor #########
  85. ***********************************/
  86. function boot23_add_editor_styles() {
  87. add_editor_style([
  88. 'css/custom.css',
  89. 'style.css'
  90. ] );
  91. }
  92. add_action( 'admin_init', 'boot23_add_editor_styles' );
  93. function boot23_gutenberg_scripts() {
  94. 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 );
  95. }
  96. add_action( 'enqueue_block_editor_assets', 'boot23_gutenberg_scripts' );
  97. function boot23_gutenberg_style() {
  98. echo '<style>.wp-block{max-width:992px;}.wp-block[data-align="wide"]{}.wp-block[data-align="full"]{max-width:none;}.editor-post-title__block .editor-post-title__input,.edit-post-visual-editor, .edit-post-visual-editor p{font-family: Helvetica, Arial, sans-serif;}</style>';
  99. }
  100. add_action('admin_head', 'boot23_gutenberg_style');
  101. function boot23_gutenberg_filter_block( $block_content, $block ) {
  102. $block_content = str_replace(
  103. 'wp-block-button__link',
  104. 'wp-block-button__link btn',
  105. $block_content
  106. );
  107. return $block_content;
  108. }
  109. add_filter( 'render_block', 'boot23_gutenberg_filter_block', 10, 2);