hp-templates.php 3.3 KB

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