Advertisement
Daniel_Dropik

Broken functions.php

Apr 2nd, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.70 KB | None | 0 0
  1. <!-- In a child theme, all of the functions of the parent theme are present, unless overridden here -->
  2. <?php
  3.  
  4. function cals_fetch_feed2($feed_uri,$num_items, $echo = 1, $length =-1, $exclude=''){
  5.     //NOTE: to disable cache, go to feed.php and replace timestamp in
  6.     // $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));
  7.     $i = rand(1,5);
  8.     // Get RSS Feed(s)
  9.     include_once(ABSPATH . WPINC . '/feed.php');
  10.    
  11.     // Get a SimplePie feed object from the specified feed source.
  12.     $rss = fetch_feed($feed_uri);
  13.      
  14.     if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
  15.        
  16.         //enable order by date
  17.         $rss->enable_order_by_date(true);
  18.        
  19.         // Figure out how many total items there are, but limit it to $num_items.
  20.         $maxitems = $rss->get_item_quantity($num_items);
  21.    
  22.         // Build an array of all the items, starting with element 0 (first element).
  23.         $rss_items = $rss->get_items(0, $maxitems);
  24.     endif;
  25.    
  26.     if($echo == 1){
  27.    
  28.         if (count($rss_items) == 0) {
  29.             //echo '<li>No items.</li>';
  30.             echo 'no items';
  31.         } else {
  32.             foreach ( $rss_items as $item ) {
  33.            
  34.                 //check for excluded posts
  35.                 if($exclude!='' && $exclude == $item->get_id()){
  36.                     continue;
  37.                 }
  38.                
  39.                
  40.                 $featuredImageSrc = $item->get_item_tags('', 'featuredimage');
  41.                
  42.                
  43.                 $featuredImage = $featuredImageSrc[0]['data'];
  44.                
  45.                
  46.                
  47.                 ?>
  48.                
  49.                 <?php  
  50.                 /*if($featuredImage) {*/
  51.                
  52.                     echo '<div class="newsItem fromFunctionsPHP ';
  53.                     if(!$featuredImage) {echo 'noImage ';}
  54.                    
  55.                    
  56.                    
  57.                    
  58.                     foreach ($item->get_categories() as $category)
  59.                         {
  60.                             echo $category->get_label()." ";
  61.                            
  62.                            
  63.                             /*$imageCat = $category->get_label();
  64.                        
  65.                         if($imageCat == "Agriculture" || $imageCat == "Food" || $imageCat == "Environment" || $imageCat == "Energy" || $imageCat == "Health" || $imageCat == "People" || $imageCat == "Communities" || $imageCat == "Events") {
  66.                            
  67.                             break;
  68.                            
  69.                         } else {
  70.                            
  71.                            
  72.                             echo "Announcements ";
  73.                             break;
  74.                         }*/
  75.                            
  76.                         }
  77.    
  78.                     echo '"><div class="previousa"><div class="additionalContent">';
  79.                    
  80.                     $notdisplayed = true;
  81.            
  82.                 if($featuredImage1) {
  83.                     echo '<img src="'.$featuredImage1.'" alt="" />';
  84.                 } else if($featuredImage) {
  85.                     echo '<img src="'.$featuredImage.'" alt="" />';
  86.                 } else {
  87.                     echo '<div class="noImageSpacer"></div>';
  88.                     /*foreach ($item->get_categories() as $category)
  89.                     {
  90.                         $imageCat = $category->get_label();
  91.                        
  92.                         if($imageCat == "Agriculture") {
  93.                            
  94.                             echo '<img src="';
  95.                             echo bloginfo('template_url');
  96.                             echo '/images/agriculture-pic-';
  97.                             echo rand(1,3);
  98.                             echo '.jpg" alt=" " />';
  99.                             break;
  100.                         } else if($imageCat == "Food") {
  101.                            
  102.                             echo '<img src="';
  103.                             echo bloginfo('template_url');
  104.                             echo '/images/food-pic-';
  105.                             echo rand(1,3);
  106.                             echo '.jpg" alt=" " />';
  107.                             break;
  108.                         } else if($imageCat == "Environment") {
  109.                            
  110.                             echo '<img src="';
  111.                             echo bloginfo('template_url');
  112.                             echo '/images/environment-pic-';
  113.                             echo rand(1,3);
  114.                             echo '.jpg" alt=" " />';
  115.                             break;
  116.                         } else if($imageCat == "Energy") {
  117.                            
  118.                             echo '<img src="';
  119.                             echo bloginfo('template_url');
  120.                             echo '/images/energy-pic-';
  121.                             echo rand(1,3);
  122.                             echo '.jpg" alt=" " />';
  123.                             break;
  124.                         } else if($imageCat == "Health") {
  125.                            
  126.                             echo '<img src="';
  127.                             echo bloginfo('template_url');
  128.                             echo '/images/health-pic-';
  129.                             echo rand(1,3);
  130.                             echo '.jpg" alt=" " />';
  131.                             break;
  132.                         } else if ($imageCat == "People" || $imageCat == "Communities") {
  133.                            
  134.                             echo '<img src="';
  135.                             echo bloginfo('template_url');
  136.                             echo '/images/people-pic-';
  137.                             echo rand(1,3);
  138.                             echo '.jpg" alt=" " />';
  139.                             break;
  140.                         } else if ($imageCat == "Events") {
  141.                            
  142.                             echo '<img src="';
  143.                             echo bloginfo('template_url');
  144.                             echo '/images/twitter-bg-';
  145.                             echo rand(1,3);
  146.                             echo '.jpg" alt=" " />';
  147.                             break;
  148.                         } else {
  149.                            
  150.                            
  151.                             echo '<img src="';
  152.                             echo bloginfo('template_url');
  153.                             echo '/images/generalcals-bg-';
  154.                             echo $i;
  155.                             echo '.jpg" alt=" " />';
  156.                             if($i < 5) {
  157.                                 $i = $i + 1;
  158.                             } else {
  159.                                 $i = 1;
  160.                             }
  161.                             break;
  162.                         }
  163.                          
  164.                        
  165.                        
  166.                     }*/
  167.                    
  168.                    
  169.                 }
  170.                 echo '</div>';
  171.                    
  172.                     echo '<div class="text"><div class="glyph"><div class="symbol"></div></div><div class="titleheading"><h3>';
  173.                     $title = $item->get_title();
  174.                     if($length != -1){
  175.                         if(strlen($title)>$length){
  176.                             echo substr($title,0,$length).'...'; }
  177.                         else {
  178.                             echo $title;
  179.                         }
  180.                     } else {
  181.                         echo $title;
  182.                     }
  183.                 echo '</h3></div><div class="excerpt">';
  184.                 $content = $item->get_description();
  185.                 echo $content;
  186.                 echo '</div><div class="dateheading">';
  187.                 echo $item->get_date('F j, Y');
  188.                 echo '</div><div class="hiddendate">';
  189.                 echo "-".$item->get_date('Ymd');
  190.                 echo '</div><div class="hiddengroup">';
  191.                 $cattemp = $item->get_category();
  192.                 echo $cattemp->get_label();
  193.                 echo '</div><span class="number">10</span></div>';
  194.                    
  195.                    
  196.            
  197.            
  198.                
  199.             echo '<a href="';
  200.             echo $item->get_permalink();
  201.             echo '" class="highlight" title="';
  202.             echo 'Posted '.$item->get_date('j F Y | g:i a');
  203.             echo '">Read more about ';
  204.             echo $item->get_title();
  205.             echo '<div class="loadingSpinner"><div class="progress"></div></div></a></div></div>';
  206.            
  207.            
  208.             /*}  else {
  209.                
  210.                 //What to display if no image is supplied by the article
  211.                
  212.                 echo '<div class="newsItem noImage ';
  213.                     foreach ($item->get_categories() as $category)
  214.                         {
  215.                             echo $category->get_label()." ";
  216.                         }
  217.    
  218.                     echo '"><div class="previousa"><div class="titleheading"><h3>';
  219.                     $title = $item->get_title();
  220.                     if($length != -1){
  221.                         if(strlen($title)>$length){
  222.                             echo substr($title,0,$length).'...'; }
  223.                         else {
  224.                             echo $title;
  225.                         }
  226.                     } else {
  227.                         echo $title;
  228.                     }
  229.                 echo '</h3></div><div class="text"><div class="glyph"><div class="symbol"></div></div><div class="excerpt">';
  230.                 $content = $item->get_description();
  231.                 echo $content;
  232.                 echo '</div><div class="dateheading">';
  233.                 echo $item->get_date('F j, Y');
  234.                 echo '</div><div class="hiddendate">';
  235.                 echo "-".$item->get_date('Ymd');
  236.                 echo '</div><div class="hiddengroup">';
  237.                 $cattemp = $item->get_category();
  238.                 echo $cattemp->get_label();
  239.                 echo '</div><span class="number">10</span></div><div class="additionalContent">';
  240.                    
  241.                        
  242.                
  243.            
  244.            
  245.                            
  246.            
  247.            
  248.                
  249.             echo '</div><a href="';
  250.             echo $item->get_permalink();
  251.             echo '" class="highlight" title="';
  252.             echo 'Posted '.$item->get_date('j F Y | g:i a');
  253.             echo '">Read more about ';
  254.             echo $item->get_title();
  255.             echo '<div class="loadingSpinner"><div class="progress"></div></div></a></div></div>';
  256.                
  257.                
  258.             }*/
  259.              ?>
  260.                
  261.            
  262.  
  263.                
  264.             <?php }
  265.         }
  266.  
  267.     } else {
  268.    
  269.         return $rss_items;
  270.    
  271.     }
  272. }
  273.  
  274. /*function soilsextension_enqueue_scripts(){
  275.      $handle = 'soilsextension_scripts';
  276.      $src = get_theme_root_uri() . '/soilsextension/js/min/master.min.js';
  277.  
  278.     wp_register_script($handle, $src, false, false, true);
  279.  
  280.     wp_enqueue_script('soilsextension_scripts');
  281. }
  282.  
  283. add_action('wp_enqueue_scripts', 'soilsextension_enqueue_scripts'); */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement