hp-templates.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**********************************
  3. ######### WordPress Menus #########
  4. ***********************************/
  5. function hp_donate_nav_item( $items, $args ) {
  6. if( $args->theme_location == 'primary' ) {
  7. $items = $items .'<li id="donate-button" class="menu-item nav-item ps-lg-3">'."\n".'<a class="btn btn-outline-light" href="'.home_url().'/get-involved/donate" role="button">Donate <i class="bi bi-suit-heart-fill p-1 text-danger"></i></a></li>';
  8. }
  9. return $items;
  10. }
  11. add_filter('wp_nav_menu_items','hp_donate_nav_item',10,2);
  12. function hp_list_child_pages() {
  13. global $post;
  14. $children = get_pages( array( 'child_of' => $post->ID ) );
  15. $haschild = (count( $children ) > 0 );
  16. $page_id = ($haschild) ? $post->ID : wp_get_post_parent_id( $post->ID );
  17. wp_list_pages( array(
  18. 'title_li' => '',
  19. 'depth' => 0,
  20. 'sort_order' => 'asc',
  21. 'sort_column' => 'menu_order',
  22. 'child_of' => $page_id,
  23. ));
  24. }
  25. add_shortcode('hp_childpages', 'hp_list_child_pages');
  26. function wp_list_pages_filter($output) {
  27. $output = str_replace('page_item', 'nav-item list-group-item py-1 p-0', $output);
  28. return $output;
  29. }
  30. add_filter('wp_list_pages', 'wp_list_pages_filter');
  31. /**********************************
  32. ######### WordPress Posts #########
  33. ***********************************/
  34. if ( ! function_exists( 'hp_posted_on' ) ) :
  35. function hp_posted_on() {
  36. $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
  37. if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
  38. $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
  39. }
  40. $time_string = sprintf( $time_string,
  41. esc_attr( get_the_date( 'c' ) ),
  42. esc_html( get_the_date() )
  43. );
  44. $posted_on = sprintf(
  45. esc_html_x( 'Posted on %s', 'post date', 'wp-bootstrap-starter' ),
  46. '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
  47. );
  48. $byline = sprintf(
  49. esc_html_x( 'by %s', 'post author', 'wp-bootstrap-starter' ),
  50. '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
  51. );
  52. echo '<span class="posted-on">' . $posted_on . '</span> | <span class="byline"> ' . $byline . '</span>'; //
  53. if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
  54. echo ' | <span class="comments-link"><i class="fa fa-comments" aria-hidden="true"></i> ';
  55. comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'wp-bootstrap-starter' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) );
  56. echo '</span>';
  57. }
  58. }
  59. endif;
  60. if ( ! function_exists( 'hp_entry_footer' ) ) :
  61. function hp_entry_footer() {
  62. if ( 'post' === get_post_type() ) {
  63. $categories_list = get_the_category_list( esc_html__( ', ' ) );
  64. if ( $categories_list && wp_bootstrap_starter_categorized_blog() ) {
  65. printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s') . '</span>', $categories_list );
  66. }
  67. $tags_list = get_the_tag_list( '', esc_html__( ', ') );
  68. if ( $tags_list ) {
  69. printf( ' | <span class="tags-links">' . esc_html__( 'Tagged %1$s' ) . '</span>', $tags_list );
  70. }
  71. }
  72. edit_post_link(
  73. sprintf(
  74. esc_html__( 'Edit %s', 'wp-bootstrap-starter' ),
  75. the_title( '<span class="screen-reader-text">"', '"</span>', false )
  76. ),
  77. ' | <span class="edit-link">',
  78. '</span>'
  79. );
  80. }
  81. endif;