public function printComponent($args, ffOptionsQuery $query) { $categories = $query->getMultipleSelect('latest-news categories'); $numberOfPosts = $query->get('latest-news number-of-posts'); $postGetter = ffContainer()->getPostLayer()->getPostGetter(); $posts = $postGetter->setFilterRelation_OR()->setNumberOfPosts($numberOfPosts)->filterByCategory($categories)->getAllPosts(); echo $args['before_widget']; echo $args['before_title']; echo ff_wp_kses($query->get('latest-news title')); echo $args['after_title']; echo '<ul'; if ('alt' == $query->get('latest-news style')) { echo ' class="alt"'; } echo '>'; if ('alt' == $query->get('latest-news style')) { foreach ($posts as $onePost) { $featuredImageUrl = $onePost->getFeaturedImage(); if (empty($featuredImageUrl)) { continue; } $featuredImageUrlResized = fImg::resize($featuredImageUrl, 65, 65, true); echo '<li>'; echo '<img src="' . esc_url($featuredImageUrlResized) . '" alt="">'; echo '<a href="' . get_permalink($onePost->getID()) . '" class="post-title">' . ff_wp_kses($onePost->getTitle()) . '</a>'; echo '<p class="post-date">' . ff_wp_kses($onePost->getDateFormated('F d, Y')) . '</p>'; echo '</li>'; } } else { foreach ($posts as $onePost) { $featuredImageUrl = $onePost->getFeaturedImage(); if (empty($featuredImageUrl)) { continue; } $featuredImageUrlResized = fImg::resize($featuredImageUrl, 80, 80, true); echo '<li>'; echo '<img src="' . esc_url($featuredImageUrlResized) . '" alt="">'; echo '<p class="news-title">'; echo '<a href="' . get_permalink($onePost->getID()) . '">' . ff_wp_kses($onePost->getTitle()) . '</a>'; echo '</p>'; echo '<p class="news-date">' . ff_wp_kses($onePost->getDateFormated('F d, Y')) . '</p>'; echo '</li>'; } } echo '</ul>'; echo $args['after_widget']; }
public function printComponent($args, ffOptionsQuery $query) { $categories = $query->getMultipleSelect('latest-portfolio categories'); $categoriesCheck = $query->get('latest-portfolio categories'); if (empty($categoriesCheck) || $categoriesCheck == 'all') { $categories = null; } $numberOfPosts = $query->get('latest-portfolio number-of-posts'); $postGetter = ffContainer()->getPostLayer()->getPostGetter(); $posts = $postGetter->setFilterRelation_OR()->setNumberOfPosts($numberOfPosts)->filterByTaxonomy($categories, 'ff-portfolio-category')->getAll(); // var_dump( $posts, $categories, $numberOfPosts ); // var_Dump( $posts ); echo $args['before_widget']; echo $args['before_title']; echo ff_wp_kses($query->get('latest-portfolio title')); echo $args['after_title']; if (!empty($posts)) { echo '<div class="portfolio-photos">'; foreach ($posts as $onePost) { $featuredImage = $onePost->getFeaturedImage(); if (empty($featuredImage)) { continue; } echo '<div class="portfolio-badge-image">'; echo '<a href="' . get_permalink($onePost->getID()) . '">'; echo '<img width="75" height="75" title="" alt="" src="' . esc_url(fImg::resize($featuredImage, 75, 75, true)) . '">'; echo '</a>'; echo '</div>'; } if ($query->get('latest-portfolio show-description')) { echo '<p>' . ff_wp_kses($query->get('latest-portfolio description')) . '</p>'; } echo '</div>'; } echo $args['after_widget']; }