Guest User

Untitled

a guest
Aug 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. add_action( 'init', 'pz_child_page_featured_image' );
  2.  
  3. function pz_child_page_featured_image() {
  4. add_action( 'pizzaro_page', 'pizzaro_page_header', 10 );
  5. }
  6.  
  7. if ( ! function_exists( 'pizzaro_page_header' ) ) {
  8. /**
  9. * Display the post header with a link to the single post
  10. *
  11. * @since 1.0.0
  12. */
  13. function pizzaro_page_header() {
  14. global $post;
  15. $page_meta_values = get_post_meta( $post->ID, '_pizzaro_page_metabox', true );
  16.  
  17. if ( isset( $page_meta_values['page_title'] ) && ! empty( $page_meta_values['page_title'] ) ) {
  18. $page_title = $page_meta_values['page_title'];
  19. } else {
  20. $page_title = get_the_title();
  21. }
  22.  
  23. if( apply_filters( 'pizzaro_show_page_header', true ) ) {
  24.  
  25.  
  26. $header_image_url = pizzaro_get_page_header_image();
  27. if( $header_image_url != '' ) {
  28. ?>
  29. <header class="entry-header header-with-cover-image stretch-full-width" style="background-image: url(<?php echo esc_url( $header_image_url ) ?>);">
  30. <div class="caption">
  31. <h1 class="entry-title"><?php echo apply_filters( 'pizzaro_page_title', wp_kses_post( $page_title ) ); ?></h1>
  32. <?php pizzaro_page_subtitle(); ?>
  33. </div>
  34. </header>
  35. <?php
  36. } else {
  37. ?>
  38. <header class="entry-header">
  39. <h1 class="entry-title"><?php echo apply_filters( 'pizzaro_page_title', wp_kses_post( $page_title ) ); ?></h1>
  40. <?php pizzaro_page_subtitle(); ?>
  41. </header>
  42. <?php
  43. }
  44. }
  45. }
  46. }
  47.  
  48. if( ! function_exists( 'pizzaro_get_page_header_image' ) ) {
  49.  
  50. function pizzaro_get_page_header_image() {
  51. global $post;
  52.  
  53. $image_url = apply_filters( 'pizzaro_default_page_header_image', '' );
  54.  
  55. if( ! is_front_page() ) {
  56.  
  57. $image_width = apply_filters( 'pizzaro_page_header_image_width', 1170 );
  58.  
  59. if( $post ){
  60. $image_id = get_post_thumbnail_id( $post->ID );
  61. $image = wp_get_attachment_image_src( $image_id, array( $image_width, $image_width ) );
  62. if ( is_page() && has_post_thumbnail( $post->ID ) && $image[1] >= $image_width ) {
  63. $image_url = $image[0];
  64. }
  65. }
  66. }
  67. return $image_url;
  68. }
  69. }
Add Comment
Please, Sign In to add comment