Advertisement
catchmahesh

Replace H1 with H2 Catch Responsive: Featured Content

Aug 4th, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 19.64 KB | None | 0 0
  1. /* Featured Content h1 to h2 */
  2.  
  3. function catchresponsive_featured_content_display() {
  4.     catchresponsive_flush_transients();
  5.     global $post, $wp_query;
  6.  
  7.     // get data value from options
  8.     $options        = catchresponsive_get_theme_options();
  9.     $enablecontent  = $options['featured_content_option'];
  10.     $contentselect  = $options['featured_content_type'];
  11.  
  12.     // Front page displays in Reading Settings
  13.     $page_on_front  = get_option('page_on_front') ;
  14.     $page_for_posts = get_option('page_for_posts');
  15.  
  16.  
  17.     // Get Page ID outside Loop
  18.     $page_id = $wp_query->get_queried_object_id();
  19.     if ( $enablecontent == 'entire-site' || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && $enablecontent == 'homepage' ) ) {
  20.         if ( $contentselect == 'featured-widget-content' ) {
  21.             get_sidebar( 'featured-widget-content' );
  22.         }
  23.         else {
  24.             if ( ( !$catchresponsive_featured_content = get_transient( 'catchresponsive_featured_content' ) ) ) {
  25.                 $layouts     = $options ['featured_content_layout'];
  26.                 $headline    = $options ['featured_content_headline'];
  27.                 $subheadline = $options ['featured_content_subheadline'];
  28.  
  29.                 echo '<!-- refreshing cache -->';
  30.  
  31.                 if ( !empty( $layouts ) ) {
  32.                     $classes = $layouts ;
  33.                 }
  34.  
  35.                 if ( $contentselect == 'demo-featured-content' ) {
  36.                     $classes    .= ' demo-featured-content' ;
  37.                     $headline       = __( 'Featured Content', 'catch-responsive' );
  38.                     $subheadline    = __( 'Here you can showcase the x number of Featured Content. You can edit this Headline, Subheadline and Feaured Content from "Appearance -> Customize -> Featured Content Options".', 'catch-responsive' );
  39.                 }
  40.                 else if ( $contentselect == 'featured-post-content' ) {
  41.                     $classes    .= ' featured-post-content' ;
  42.                 }
  43.                 elseif ( $contentselect == 'featured-page-content' ) {
  44.                     $classes .= ' featured-page-content' ;
  45.                 }
  46.                 elseif ( $contentselect == 'featured-category-content' ) {
  47.                     $classes .= ' featured-category-content' ;
  48.                 }
  49.                 elseif ( $contentselect == 'featured-image-content' ) {
  50.                     $classes .= ' featured-image-content' ;
  51.                 }
  52.  
  53.                 $featured_content_position = $options [ 'featured_content_position' ];
  54.  
  55.                 if ( '1' == $featured_content_position ) {
  56.                     $classes .= ' border-top' ;
  57.                 }
  58.  
  59.                 $catchresponsive_featured_content ='
  60.                     <section id="featured-content" class="' . $classes . '">
  61.                         <div class="wrapper">';
  62.                             if ( !empty( $headline ) || !empty( $subheadline ) ) {
  63.                                 $catchresponsive_featured_content .='<div class="featured-heading-wrap">';
  64.                                     if ( !empty( $headline ) ) {
  65.                                         $catchresponsive_featured_content .='<h2 id="featured-heading" class="entry-title">'. $headline .'</h2>';
  66.                                     }
  67.                                     if ( !empty( $subheadline ) ) {
  68.                                         $catchresponsive_featured_content .='<p>'. $subheadline .'</p>';
  69.                                     }
  70.                                 $catchresponsive_featured_content .='</div><!-- .featured-heading-wrap -->';
  71.                             }
  72.  
  73.                             $catchresponsive_featured_content .='
  74.                             <div class="featured-content-wrap">';
  75.                                 // Select content
  76.                                 if ( $contentselect == 'demo-featured-content' && function_exists( 'catchresponsive_demo_content' ) ) {
  77.                                     $catchresponsive_featured_content .= catchresponsive_demo_content( $options );
  78.                                 }
  79.                                 else if ( $contentselect == 'featured-post-content' && function_exists( 'catchresponsive_post_content' ) ) {
  80.                                     $catchresponsive_featured_content .= catchresponsive_post_content( $options );
  81.                                 }
  82.                                 elseif ( $contentselect == 'featured-page-content' && function_exists( 'catchresponsive_page_content' ) ) {
  83.                                     $catchresponsive_featured_content .= catchresponsive_page_content( $options );
  84.                                 }
  85.                                 elseif ( $contentselect == 'featured-category-content' && function_exists( 'catchresponsive_category_content' ) ) {
  86.                                     $catchresponsive_featured_content .= catchresponsive_category_content( $options );
  87.                                 }
  88.                                 elseif ( $contentselect == 'featured-image-content' && function_exists( 'catchresponsive_image_content' ) ) {
  89.                                     $catchresponsive_featured_content .= catchresponsive_image_content( $options );
  90.                                 }
  91.  
  92.                 $catchresponsive_featured_content .='
  93.                             </div><!-- .featured-content-wrap -->
  94.                         </div><!-- .wrapper -->
  95.                     </section><!-- #featured-content -->';
  96.                 set_transient( 'catchresponsive_featured_content', $catchresponsive_featured_content, 86940 );
  97.  
  98.             }
  99.             echo $catchresponsive_featured_content;
  100.         }
  101.     }
  102. }
  103.  
  104. function catchresponsive_demo_content( $options ) {
  105.     $catchresponsive_demo_content = '
  106.         <article id="featured-post-1" class="post hentry post-demo">
  107.             <figure class="featured-content-image">
  108.                 <img alt="Central Park" class="wp-post-image" src="'.get_template_directory_uri() . '/images/gallery/featured1-350x197.jpg" />
  109.             </figure>
  110.             <div class="entry-container">
  111.                 <header class="entry-header">
  112.                     <h2 class="entry-title">
  113.                         <a title="Central Park" href="#">Central Park</a>
  114.                     </h2>
  115.                 </header>
  116.                 <div class="entry-content">
  117.                     <p>Central Park is is the most visited urban park in the United States as well as one of the most filmed locations in the world. It was opened in 1857 and is expanded in 843 acres of city-owned land.</p>
  118.                 </div>
  119.             </div><!-- .entry-container -->
  120.         </article>
  121.  
  122.         <article id="featured-post-2" class="post hentry post-demo">
  123.             <figure class="featured-content-image">
  124.                 <img alt="Home Office" class="wp-post-image" src="'.get_template_directory_uri() . '/images/gallery/featured2-350x197.jpg" />
  125.             </figure>
  126.             <div class="entry-container">
  127.                 <header class="entry-header">
  128.                     <h2 class="entry-title">
  129.                         <a title="Home Office" href="#">Home Office</a>
  130.                     </h2>
  131.                 </header>
  132.                 <div class="entry-content">
  133.                     <p>It might be work, but it doesn\'t have to feel like it. All you need is a comfortable desk, nice laptop, home office furniture that keeps things organized, and the right lighting for the job.</p>
  134.                 </div>
  135.             </div><!-- .entry-container -->
  136.         </article>
  137.  
  138.         <article id="featured-post-3" class="post hentry post-demo">
  139.             <figure class="featured-content-image">
  140.                 <img alt="Vespa Scooter" class="wp-post-image" src="'.get_template_directory_uri() . '/images/gallery/featured3-350x197.jpg" />
  141.             </figure>
  142.             <div class="entry-container">
  143.                 <header class="entry-header">
  144.                     <h2 class="entry-title">
  145.                         <a title="Vespa Scooter" href="#">Vespa Scooter</a>
  146.                     </h2>
  147.                 </header>
  148.                 <div class="entry-content">
  149.                     <p>The Vespa Scooter has evolved from a single model motor scooter manufactured in the year 1946 by Piaggio & Co. S.p.A. of Pontedera, Italy-to a full line of scooters, today owned by Piaggio.</p>
  150.                 </div>
  151.             </div><!-- .entry-container -->
  152.         </article>';
  153.  
  154.     if( 'layout-four' == $options ['featured_content_layout'] || 'layout-two' == $options ['featured_content_layout'] ) {
  155.         $catchresponsive_demo_content .= '
  156.         <article id="featured-post-4" class="post hentry post-demo">
  157.             <figure class="featured-content-image">
  158.                 <img alt="Antique Clock" class="wp-post-image" src="'.get_template_directory_uri() . '/images/gallery/featured4-350x197.jpg" />
  159.             </figure>
  160.             <div class="entry-container">
  161.                 <header class="entry-header">
  162.                     <h2 class="entry-title">
  163.                         <a title="Antique Clock" href="#">Antique Clock</a>
  164.                     </h2>
  165.                 </header>
  166.                 <div class="entry-content">
  167.                     <p>Antique clocks increase in value with the rarity of the design, their condition, and appeal in the market place. Many different materials were used in antique clocks.</p>
  168.                 </div>
  169.             </div><!-- .entry-container -->
  170.         </article>';
  171.     }
  172.  
  173.     return $catchresponsive_demo_content;
  174. }
  175.  
  176. function catchresponsive_post_content( $options ) {
  177.     global $post;
  178.  
  179.     $quantity       = $options [ 'featured_content_number' ];
  180.  
  181.     $number_of_post = 0;        // for number of posts
  182.  
  183.     $post_list      = array();  // list of valid post ids
  184.  
  185.     $show_content   = isset( $options['featured_content_show'] ) ? $options['featured_content_show'] : 'excerpt';
  186.  
  187.     $catchresponsive_post_content = '';
  188.  
  189.     //Get valid number of posts
  190.     for( $i = 1; $i <= $quantity; $i++ ){
  191.         if( isset ( $options['featured_content_post_' . $i] ) && $options['featured_content_post_' . $i] > 0 ){
  192.             $number_of_post++;
  193.  
  194.             $post_list  =   array_merge( $post_list, array( $options['featured_content_post_' . $i] ) );
  195.         }
  196.  
  197.     }
  198.  
  199.     if ( !empty( $post_list ) && $number_of_post > 0 ) {
  200.         $get_featured_posts = new WP_Query( array(
  201.                     'posts_per_page' => $number_of_post,
  202.                     'post__in'       => $post_list,
  203.                     'orderby'        => 'post__in',
  204.                     'ignore_sticky_posts' => 1 // ignore sticky posts
  205.                 ));
  206.  
  207.         $i=0;
  208.         while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
  209.             $title_attribute = the_title_attribute( array( 'before' => __( 'Permalink to: ', 'catch-responsive' ), 'echo' => false ) );
  210.             $excerpt = get_the_excerpt();
  211.             $catchresponsive_post_content .= '
  212.                 <article id="featured-post-' . $i . '" class="post hentry featured-post-content">';
  213.                 if ( has_post_thumbnail() ) {
  214.                     $catchresponsive_post_content .= '
  215.                     <figure class="featured-homepage-image">
  216.                         <a href="' . get_permalink() . '" title="'.the_title( '', '', false ).'">
  217.                         '. get_the_post_thumbnail( $post->ID, 'catchresponsive-featured-content', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ) .'
  218.                         </a>
  219.                     </figure>';
  220.                 }
  221.                 else {
  222.                     $catchresponsive_first_image = catchresponsive_get_first_image( $post->ID, 'catchresponsive-featured-content', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) );
  223.  
  224.                     if ( '' != $catchresponsive_first_image ) {
  225.                         $catchresponsive_post_content .= '
  226.                         <figure class="featured-homepage-image">
  227.                             <a href="' . get_permalink() . '" title="'.the_title( '', '', false ).'">
  228.                                 '. $catchresponsive_first_image .'
  229.                             </a>
  230.                         </figure>';
  231.                     }
  232.                 }
  233.  
  234.                 $catchresponsive_post_content .= '
  235.                     <div class="entry-container">
  236.                         <header class="entry-header">
  237.                             <h2 class="entry-title">
  238.                                 <a href="' . get_permalink() . '" rel="bookmark">' . the_title( '','', false ) . '</a>
  239.                             </h2>
  240.                         </header>';
  241.                         if ( 'excerpt' == $show_content ) {
  242.                             $catchresponsive_post_content .= '<div class="entry-excerpt"><p>' . $excerpt . '</p></div><!-- .entry-excerpt -->';
  243.                         }
  244.                         elseif ( 'full-content' == $show_content ) {
  245.                             $content = apply_filters( 'the_content', get_the_content() );
  246.                             $content = str_replace( ']]>', ']]&gt;', $content );
  247.                             $catchresponsive_post_content .= '<div class="entry-content">' . $content . '</div><!-- .entry-content -->';
  248.                         }
  249.                     $catchresponsive_post_content .= '
  250.                     </div><!-- .entry-container -->
  251.                 </article><!-- .featured-post-'. $i .' -->';
  252.         endwhile;
  253.  
  254.         wp_reset_query();
  255.     }
  256.  
  257.     return $catchresponsive_post_content;
  258. }
  259.  
  260. function catchresponsive_page_content( $options ) {
  261.     global $post;
  262.  
  263.     $quantity       = $options [ 'featured_content_number' ];
  264.  
  265.     $more_link_text = $options['excerpt_more_text'];
  266.  
  267.     $show_content   = isset( $options['featured_content_show'] ) ? $options['featured_content_show'] : 'excerpt';
  268.  
  269.     $number_of_page = 0;        // for number of pages
  270.  
  271.     $page_list      = array();  // list of valid pages ids
  272.  
  273.     $catchresponsive_page_content   = '';
  274.  
  275.     //Get valid pages
  276.     for( $i = 1; $i <= $quantity; $i++ ){
  277.         if( isset ( $options['featured_content_page_' . $i] ) && $options['featured_content_page_' . $i] > 0 ){
  278.             $number_of_page++;
  279.  
  280.             $page_list  =   array_merge( $page_list, array( $options['featured_content_page_' . $i] ) );
  281.         }
  282.  
  283.     }
  284.     if ( !empty( $page_list ) && $number_of_page > 0 ) {
  285.         $get_featured_posts = new WP_Query( array(
  286.                     'posts_per_page'        => $number_of_page,
  287.                     'post__in'              => $page_list,
  288.                     'orderby'               => 'post__in',
  289.                     'post_type'             => 'page',
  290.                 ));
  291.  
  292.         $i=0;
  293.         while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
  294.             $title_attribute = the_title_attribute( array( 'before' => __( 'Permalink to: ', 'catch-responsive' ), 'echo' => false ) );
  295.  
  296.             $excerpt = get_the_excerpt();
  297.  
  298.             $catchresponsive_page_content .= '
  299.                 <article id="featured-post-' . $i . '" class="post hentry featured-page-content">';
  300.                 if ( has_post_thumbnail() ) {
  301.                     $catchresponsive_page_content .= '
  302.                     <figure class="featured-homepage-image">
  303.                         <a href="' . get_permalink() . '" title="'.the_title( '', '', false ).'">
  304.                         '. get_the_post_thumbnail( $post->ID, 'catchresponsive-featured-content', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ) .'
  305.                         </a>
  306.                     </figure>';
  307.                 }
  308.                 else {
  309.                     $catchresponsive_first_image = catchresponsive_get_first_image( $post->ID, 'catchresponsive-featured-content', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) );
  310.  
  311.                     if ( '' != $catchresponsive_first_image ) {
  312.                         $catchresponsive_page_content .= '
  313.                         <figure class="featured-homepage-image">
  314.                             <a href="' . get_permalink() . '" title="'.the_title( '', '', false ).'">
  315.                                 '. $catchresponsive_first_image .'
  316.                             </a>
  317.                         </figure>';
  318.                     }
  319.                 }
  320.  
  321.                 $catchresponsive_page_content .= '
  322.                     <div class="entry-container">
  323.                         <header class="entry-header">
  324.                             <h2 class="entry-title">
  325.                                 <a href="' . get_permalink() . '" rel="bookmark">' . the_title( '','', false ) . '</a>
  326.                             </h2>
  327.                         </header>';
  328.                         if ( 'excerpt' == $show_content ) {
  329.                             $catchresponsive_page_content .= '<div class="entry-excerpt"><p>' . $excerpt . '</p></div><!-- .entry-excerpt -->';
  330.                         }
  331.                         elseif ( 'full-content' == $show_content ) {
  332.                             $content = apply_filters( 'the_content', get_the_content() );
  333.                             $content = str_replace( ']]>', ']]&gt;', $content );
  334.                             $catchresponsive_page_content .= '<div class="entry-content">' . $content . '</div><!-- .entry-content -->';
  335.                         }
  336.                     $catchresponsive_page_content .= '
  337.                     </div><!-- .entry-container -->
  338.                 </article><!-- .featured-post-'. $i .' -->';
  339.         endwhile;
  340.  
  341.         wp_reset_query();
  342.     }
  343.  
  344.     return $catchresponsive_page_content;
  345. }
  346.  
  347. function catchresponsive_category_content( $options ) {
  348.     global $post;
  349.  
  350.     $quantity       = $options [ 'featured_content_number' ];
  351.  
  352.     $more_link_text = $options['excerpt_more_text'];
  353.  
  354.     $category_list  = array_filter( $options['featured_content_select_category']);
  355.  
  356.     $show_content   = isset( $options['featured_content_show'] ) ? $options['featured_content_show'] : 'excerpt';
  357.  
  358.     $catchresponsive_category_content = '';
  359.  
  360.     $get_featured_posts = new WP_Query( array(
  361.         'posts_per_page'        => $quantity,
  362.         'category__in'          => $category_list,
  363.         'ignore_sticky_posts'   => 1 // ignore sticky posts
  364.     ));
  365.  
  366.     $i=0;
  367.     while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
  368.         $title_attribute = the_title_attribute( array( 'before' => __( 'Permalink to: ', 'catch-responsive' ), 'echo' => false ) );
  369.         $excerpt = get_the_excerpt();
  370.         $catchresponsive_category_content .= '
  371.             <article id="featured-post-' . $i . '" class="post hentry featured-category-content">';
  372.             if ( has_post_thumbnail() ) {
  373.                 $catchresponsive_category_content .= '
  374.                 <figure class="featured-homepage-image">
  375.                     <a href="' . get_permalink() . '" title="'.the_title( '', '', false ).'">
  376.                     '. get_the_post_thumbnail( $post->ID, 'catchresponsive-featured-content', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ) .'
  377.                     </a>
  378.                 </figure>';
  379.             }
  380.             else {
  381.                     $catchresponsive_first_image = catchresponsive_get_first_image( $post->ID, 'catchresponsive-featured-content', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) );
  382.  
  383.                     if ( '' != $catchresponsive_first_image ) {
  384.                         $catchresponsive_category_content .= '
  385.                         <figure class="featured-homepage-image">
  386.                             <a href="' . get_permalink() . '" title="'.the_title( '', '', false ).'">
  387.                                 '. $catchresponsive_first_image .'
  388.                             </a>
  389.                         </figure>';
  390.                     }
  391.                 }
  392.  
  393.             $catchresponsive_category_content .= '
  394.                 <div class="entry-container">
  395.                     <header class="entry-header">
  396.                         <h2 class="entry-title">
  397.                             <a href="' . get_permalink() . '" rel="bookmark">' . the_title( '','', false ) . '</a>
  398.                         </h2>
  399.                     </header>';
  400.                     if ( 'excerpt' == $show_content ) {
  401.                         $catchresponsive_category_content .= '<div class="entry-excerpt"><p>' . $excerpt . '</p></div><!-- .entry-excerpt -->';
  402.                     }
  403.                     elseif ( 'full-content' == $show_content ) {
  404.                         $content = apply_filters( 'the_content', get_the_content() );
  405.                         $content = str_replace( ']]>', ']]&gt;', $content );
  406.                         $catchresponsive_category_content .= '<div class="entry-content">' . $content . '</div><!-- .entry-content -->';
  407.                     }
  408.                 $catchresponsive_category_content .= '
  409.                 </div><!-- .entry-container -->
  410.             </article><!-- .featured-post-'. $i .' -->';
  411.     endwhile;
  412.  
  413.     wp_reset_query();
  414.     return $catchresponsive_category_content;
  415. }
  416.  
  417. function catchresponsive_image_content( $options ) {
  418.     $quantity       = $options [ 'featured_content_number' ];
  419.  
  420.     $more_link_text = $options['excerpt_more_text'];
  421.  
  422.     $show_content   = isset( $options['featured_content_show'] ) ? $options['featured_content_show'] : 'excerpt';
  423.  
  424.     $catchresponsive_image_content = '';
  425.  
  426.     for ( $i = 1; $i <= $quantity; $i++ ) {
  427.         if ( !empty ( $options[ 'featured_content_target_' . $i ] ) ) {
  428.             $target = '_blank';
  429.         } else {
  430.             $target = '_self';
  431.         }
  432.  
  433.         //Checking Link
  434.         if ( !empty ( $options[ 'featured_content_link_' . $i ] ) ) {
  435.             //support qTranslate plugin
  436.             if ( function_exists( 'qtrans_convertURL' ) ) {
  437.                 $link = qtrans_convertURL(  $options[ 'featured_content_link_' . $i ] );
  438.             }
  439.             else {
  440.                 $link =  $options[ 'featured_content_link_' . $i ];
  441.             }
  442.         }
  443.         else {
  444.             $link = '#';
  445.         }
  446.  
  447.         //Checking Title
  448.         if ( !empty ( $options[ 'featured_content_title_'. $i ] ) ) {
  449.             $title =$options[ 'featured_content_title_'. $i ];
  450.         }
  451.         else {
  452.             $title = '';
  453.         }
  454.  
  455.         //Checking Content
  456.         if ( !empty ( $options[ 'featured_content_content_'. $i ] ) ) {
  457.             $content =$options[ 'featured_content_content_'. $i ];
  458.         }
  459.         else {
  460.             $content = '';
  461.         }
  462.  
  463.         $catchresponsive_image_content .= '
  464.         <article id="featured-post-'.$i.'" class="post hentry featured-image-content">';
  465.             if ( !empty ( $options[ 'featured_content_image_' . $i ] ) ) {
  466.                 $catchresponsive_image_content .= '
  467.                 <figure class="featured-homepage-image">
  468.                     <a title="'.$title.'" href="'.$link.'" target="'.$target.'">
  469.                         <img src="'. $options[ 'featured_content_image_' . $i ] .'" class="wp-post-image" alt="'.$title.'" title="'.$title.'">
  470.                     </a>
  471.                 </figure>';
  472.             }
  473.             if ( $title != '' || $content!='' ) {
  474.                 $catchresponsive_image_content .= '
  475.                 <div class="entry-container">';
  476.                     if ( $title != '' ) {
  477.                         $catchresponsive_image_content .= '
  478.                         <header class="entry-header">
  479.                             <h2 class="entry-title">
  480.                                 <a href="'.$link.'" rel="bookmark" target="'.$target.'">'.$title.'</a>
  481.                             </h2>
  482.                         </header>';
  483.                     }
  484.                     if ( 'hide-content' != $show_content ) {
  485.                         if ( '' != $content )  {
  486.                             $catchresponsive_image_content .= '
  487.                             <div class="entry-content"><p>
  488.                                 ' . $content . '
  489.                             </p></div>';
  490.                         }
  491.                     }
  492.                 $catchresponsive_image_content .= '
  493.                 </div><!-- .entry-container -->';
  494.             }
  495.         $catchresponsive_image_content .= '
  496.         </article><!-- .featured-post-'.$i.' -->';
  497.  
  498.     }
  499.     return $catchresponsive_image_content;
  500. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement