hp-templates.php 3.1 KB

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