Guest User

promotion-headline.php

a guest
Jul 9th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. <?php
  2. if ( ! function_exists( 'adventurous_homepage_headline' ) ) :
  3. /**
  4. * Template for Homepage Headline
  5. *
  6. * To override this in a child theme
  7. * simply create your own adventurous_homepage_headline(), and that function will be used instead.
  8. *
  9. * @uses adventurous_before_main action to add it in the header
  10. * @since Adventurous 1.0
  11. */
  12. function adventurous_homepage_headline() {
  13. //delete_transient( 'adventurous_homepage_headline' );
  14.  
  15. global $post, $wp_query;
  16. $options = adventurous_get_options();
  17.  
  18. // Getting data from Theme Options
  19. $disable_headline = $options['disable_homepage_headline'];
  20. $disable_subheadline = $options['disable_homepage_subheadline'];
  21. $disable_button = $options['disable_homepage_button'];
  22. $homepage_headline = $options['homepage_headline'];
  23. $homepage_subheadline = $options['homepage_subheadline'];
  24. $homepage_headline_button = $options['homepage_headline_button'];
  25. $homepage_headline_target = $options['homepage_headline_target'];
  26.  
  27. //support qTranslate plugin
  28. if ( function_exists( 'qtrans_convertURL' ) ) {
  29. $homepage_headline_url = qtrans_convertURL($options['homepage_headline_url']);
  30. }
  31. else {
  32. $homepage_headline_url = $options['homepage_headline_url'];
  33. }
  34.  
  35. // Front page displays in Reading Settings
  36. $page_on_front = get_option('page_on_front') ;
  37. $page_for_posts = get_option('page_for_posts');
  38.  
  39. // Get Page ID outside Loop
  40. $page_id = $wp_query->get_queried_object_id();
  41.  
  42. if ( empty( $disable_headline ) || empty( $disable_subheadline ) || empty( $disable_button ) ) {
  43.  
  44. if ( !$adventurous_homepage_headline = get_transient( 'adventurous_homepage_headline' ) ) {
  45.  
  46. echo '<!-- refreshing cache -->';
  47.  
  48. $adventurous_homepage_headline = '<div id="homepage-message"><div class="container"><div class="left-section">';
  49.  
  50. if ( $disable_headline == "0" ) {
  51. $adventurous_homepage_headline .= '<h2>' . $homepage_headline . '</h2>';
  52. }
  53. if ( $disable_subheadline == "0" ) {
  54. $adventurous_homepage_headline .= '<p>' . $homepage_subheadline . '</p>';
  55. }
  56.  
  57. $adventurous_homepage_headline .= '</div><!-- .left-section -->';
  58.  
  59. if ( !empty ( $homepage_headline_url ) && $disable_button == "0" ) {
  60. if ( !empty ( $homepage_headline_target ) ) {
  61. $headlinetarget = '_blank';
  62. }
  63. else {
  64. $headlinetarget = '_self';
  65. }
  66.  
  67. $adventurous_homepage_headline .= '<div class="right-section"><a href="' . $homepage_headline_url . '" target="' . $headlinetarget . '">' . $homepage_headline_button . '</a><a class="add-button" href="' . $homepage_headline_url . '" target="' . $headlinetarget . '">' . $homepage_headline_button . '</a></div><!-- .right-section -->';
  68. }
  69.  
  70. $adventurous_homepage_headline .= '</div><!-- .container --></div><!-- #homepage-message -->';
  71.  
  72. set_transient( 'adventurous_homepage_headline', $adventurous_homepage_headline, 86940 );
  73. }
  74. echo $adventurous_homepage_headline;
  75. }
  76. }
  77. endif; // adventurous_homepage_featured_content
  78.  
  79.  
  80. if ( ! function_exists( 'adventurous_promotion_display' ) ) :
  81. /**
  82. * Shows Promotion Headline
  83. */
  84. function adventurous_promotion_display() {
  85. global $post, $wp_query;
  86. $options = adventurous_get_options();
  87.  
  88. // get data value from theme options
  89. $enablepromotion = $options['enable_promotion'];
  90. $promotionposition = $options['promotion_position'];
  91.  
  92. // Front page displays in Reading Settings
  93. $page_on_front = get_option('page_on_front') ;
  94. $page_for_posts = get_option('page_for_posts');
  95.  
  96. // Get Page ID outside Loop
  97. $page_id = $wp_query->get_queried_object_id();
  98.  
  99. if ( ( 'allpage' == $enablepromotion ) || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && 'homepage' == $enablepromotion ) ) :
  100. if ( 'beforeslider' == $promotionposition ) {
  101. add_action( 'adventurous_before_main', 'adventurous_homepage_headline', 30 );
  102. }
  103. elseif ( 'afterfeatured' == $promotionposition ) {
  104. add_action( 'adventurous_before_main', 'adventurous_homepage_headline', 100 );
  105. }
  106. elseif ( 'beforefooter' == $promotionposition ) {
  107. add_action( 'adventurous_before_footer', 'adventurous_homepage_headline', 10 );
  108. }
  109. else {
  110. add_action( 'adventurous_before_main', 'adventurous_homepage_headline', 60 );
  111. }
  112.  
  113. endif;
  114. }
  115. endif; // adventurous_promotion_display
  116.  
  117. add_action( 'adventurous_before_hgroup_wrap', 'adventurous_promotion_display', 20 );
Advertisement
Add Comment
Please, Sign In to add comment