Exemple #1
0
 function mysiteapp_extract_thumbnail(&$content = null)
 {
     $thumb_url = null;
     $imageAlgos = uppsite_get_image_algos();
     if (uppsite_has_image_algo($imageAlgos, UppSiteImageAlgo::NATIVE_FUNC) && function_exists('has_post_thumbnail') && has_post_thumbnail()) {
         $thumb_url = get_the_post_thumbnail();
     }
     if (uppsite_has_image_algo($imageAlgos, UppSiteImageAlgo::THE_ATTACHED_IMAGE) && empty($thumb_url) && function_exists('the_attached_image')) {
         $temp_thumb = the_attached_image('img_size=thumb&echo=false');
         if (!empty($temp_thumb)) {
             $thumb_url = $temp_thumb;
         }
     }
     if (uppsite_has_image_algo($imageAlgos, UppSiteImageAlgo::GET_THE_IMAGE) && empty($thumb_url) && function_exists('get_the_image')) {
         $temp_thumb = get_the_image(array('size' => 'thumbnail', 'echo' => false, 'link_to_post' => false));
         if (!empty($temp_thumb)) {
             $thumb_url = $temp_thumb;
         }
     }
     if (uppsite_has_image_algo($imageAlgos, UppSiteImageAlgo::CUSTOM_FIELD) && empty($thumb_url) && !is_null($imageAlgos['extra'])) {
         $thumb_url = get_post_meta(get_the_ID(), $imageAlgos['extra'], true);
     }
     if (uppsite_has_image_algo($imageAlgos, UppSiteImageAlgo::FIRST_IMAGE) && empty($thumb_url)) {
         if (mysiteapp_is_fresh_wordpress_installation()) {
             $thumb_url = MYSITEAPP_HOMEPAGE_FRESH_COVER;
         } else {
             if (is_null($content)) {
                 ob_start();
                 the_content();
                 $content = ob_get_contents();
                 ob_get_clean();
             }
             $thumb_url = uppsite_extract_image_from_post_content($content);
         }
     }
     if (!empty($thumb_url)) {
         $thumb_url = uppsite_extract_src_url($thumb_url);
         if (!is_null($content)) {
             uppsite_nullify_thumb($content, $thumb_url);
         }
     }
     return $thumb_url;
 }
Exemple #2
0
<categories>
<?php 
if (!mysiteapp_homepage_is_only_show_posts()) {
    $cats_ar = uppsite_homepage_get_categories();
    foreach ($cats_ar as $cat) {
        $cat_query = array('cat' => $cat, 'posts_per_page' => mysiteapp_homepage_cat_posts(), 'order' => 'desc');
        if (!mysiteapp_is_fresh_wordpress_installation()) {
            $cat_query['post__not_in'] = mysiteapp_homepage_get_excluded_posts();
        }
        $query = mysiteapp_set_current_query($cat_query);
        if ($query->post_count > 0) {
            $catText = wp_list_categories(array('include' => $cat, 'echo' => 0));
            print str_replace("</category>", "", $catText);
            get_template_part('the_loop');
            print "</category>";
        }
    }
}
?>
</categories>