wp-templates.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /****************************************
  3. // ######### WordPress Menus ######### //
  4. ****************************************/
  5. function boot23_list_child_pages() {
  6. global $post;
  7. $children = get_pages( array( 'child_of' => $post->ID ) );
  8. $haschild = (count( $children ) > 0 );
  9. $page_id = ($haschild) ? $post->ID : wp_get_post_parent_id( $post->ID );
  10. wp_list_pages( array(
  11. 'title_li' => '',
  12. 'depth' => 0,
  13. 'sort_order' => 'asc',
  14. 'sort_column' => 'menu_order',
  15. 'child_of' => $page_id,
  16. ));
  17. }
  18. add_shortcode('boot23_childpages', 'boot23_list_child_pages');
  19. function boot23_list_pages_filter($output) {
  20. $output = str_replace('page_item', 'nav-item list-group-item py-1 p-0', $output);
  21. return $output;
  22. }
  23. add_filter('wp_list_pages', 'boot23_list_pages_filter');
  24. /****************************************
  25. // ######### WordPress Posts ######### //
  26. ****************************************/
  27. function boot23_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' ),
  38. '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
  39. );
  40. $byline = sprintf(
  41. esc_html_x( 'by %s', 'post author' ),
  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>' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) );
  48. echo '</span>';
  49. }
  50. }
  51. function boot23_entry_footer() {
  52. if ( 'post' === get_post_type() ) {
  53. $categories_list = get_the_category_list( esc_html__( ', ' ) );
  54. if ( $categories_list ) {
  55. printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s') . '</span>', $categories_list );
  56. }
  57. $tags_list = get_the_tag_list( '', esc_html__( ', ') );
  58. if ( $tags_list ) {
  59. printf( ' | <span class="tags-links">' . esc_html__( 'Tagged %1$s' ) . '</span>', $tags_list );
  60. }
  61. }
  62. edit_post_link(
  63. sprintf(
  64. esc_html__( 'Edit %s' ),
  65. the_title( '<span class="screen-reader-text">"', '"</span>', false )
  66. ),
  67. ' | <span class="edit-link">',
  68. '</span>'
  69. );
  70. }