/** * Generates the posts markup. * * @since 0.9.4 * @param array $args * @return string|array The HTML for the random posts. */ function rpwe_get_recent_posts($args = array()) { // Set up a default, empty variable. $html = ''; // Merge the input arguments and the defaults. $args = wp_parse_args($args, rpwe_get_default_args()); // Extract the array to allow easy use of variables. extract($args); // Allow devs to hook in stuff before the loop. do_action('rpwe_before_loop'); // Display the default style of the plugin. if ($args['styles_default'] === true) { rpwe_custom_styles(); } // If the default style is disabled then use the custom css if it's not empty. if ($args['styles_default'] === false && !empty($args['css'])) { echo '<style>' . $args['css'] . '</style>'; } // Get the posts query. $posts = rpwe_get_posts($args); if ($posts->have_posts()) { // Recent posts wrapper $html = '<div ' . (!empty($args['cssID']) ? 'id="' . sanitize_html_class($args['cssID']) . '"' : '') . ' class="participants-list ' . (!empty($args['css_class']) ? '' . sanitize_html_class($args['css_class']) . '' : '') . '">'; while ($posts->have_posts()) { $posts->the_post(); // Thumbnails $thumb_id = get_post_thumbnail_id(); // Get the featured image id. $img_url = wp_get_attachment_url($thumb_id); // Get img URL. // Display the image url and crop using the resizer. $image = rpwe_resize($img_url, $args['thumb_width'], $args['thumb_height'], true); $videoLink = get_post_meta(get_the_ID(), 'Video', true); $videoLink = substr($videoLink, strrpos($videoLink, "=") + 1); $audioLink = get_post_meta(get_the_ID(), 'Audio', true); $post_title_clean = sanitize_title(get_the_title()); $post_title_clean = str_replace("%e2%80%95", "-", $post_title_clean); // Start recent posts markup. $html .= '<div class="participant"><a id="' . $post_title_clean . '" class="participant-title"></a>'; $html .= '<div class="container">'; $html .= '<div class="row">'; $html .= '<div class="col-lg-8 col-md-10 col-sm-10 col-xs-10">'; $html .= '<h5><a>' . esc_attr(get_the_title()) . '</a></h5>'; if ($args['excerpt']) { $html .= '<div><p>'; $html .= get_the_excerpt(); $html .= '</p></div>'; } $html .= '</div>'; $html .= '<div class="col-lg-2 col-lg-offset-2 col-md-1 col-md-offset-1 col-sm-2 col-xs-2">'; $html .= '<div class="participant-hide"><i class="fa fa-chevron-down fa-2x participant-down"></i><i class="fa fa-chevron-up fa-2x participant-up"></i></div>'; $html .= '</div>'; $html .= '</div>'; $html .= '<div class="row participant-body">'; $html .= '<div class="col-lg-8 col-md-9 col-sm-10 col-xs-10">'; $html .= '<div class="participant-content">' . get_the_content() . '<br><a href="//' . get_post_meta(get_the_ID(), 'website', true) . '" target="_blank">' . get_post_meta(get_the_ID(), 'website', true) . '</a>'; if ($videoLink != '') { $html .= '<div class="participant-media"><a class="participant-video" id="' . $videoLink . '" ><i class="fa fa-play"></i> watch</a></div>'; } if ($audioLink != '') { $html .= '<div class="participant-media"><iframe width="70%" height="100" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=' . $audioLink . '&theme_color=969696&auto_play=false&hide_related=true&show_artwork=false&color=4696ff&show_bpm=false&show_comments=false&show_user=true&show_reposts=false"></iframe></div>'; } $html .= '</div>'; $html .= '</div>'; if ($args['share_icons']) { $html .= '<div class="col-lg-2 col-lg-offset-2 col-md-1 col-md-offset-2 col-sm-2 col-xs-2 share">'; $html .= '<span class="share-text">Share</span>'; $html .= '<p><a href="http://www.facebook.com/sharer/sharer.php?u=http://radio.serpentinegalleries.org/#!' . sanitize_title(get_the_title()) . '&title=' . get_the_title() . ' - Transformation Marathon" target="_blank"><i class="fa fa-facebook"></i></a></p>'; $html .= '<p><a href="http://twitter.com/intent/tweet?status=' . get_the_title() . ' - Transformation Marathon+http://radio.serpentinegalleries.org/%23' . sanitize_title(get_the_title()) . '" target="_blank"><i class="fa fa-twitter"></i></a></p>'; $html .= '</div>'; } $html .= '</div>'; $html .= '</div>'; $html .= '</div>'; $html .= '<hr>'; } $html .= '</div><!-- Generated by http://wordpress.org/plugins/recent-posts-widget-extended/ -->'; } // Restore original Post Data. wp_reset_postdata(); // Allow devs to hook in stuff after the loop. do_action('rpwe_after_loop'); // Return the posts markup. return $args['before'] . apply_filters('rpwe_markup', $html) . $args['after']; }
/** * Outputs the widget based on the arguments input through the widget controls. * * @since 0.1 */ function widget($args, $instance) { extract($args, EXTR_SKIP); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $title_url = esc_url($instance['title_url']); $cssID = $instance['cssID']; $limit = (int) $instance['limit']; $offset = (int) $instance['offset']; $order = $instance['order']; $orderby = $instance['orderby']; $excerpt = $instance['excerpt']; $length = (int) $instance['length']; $thumb = $instance['thumb']; $thumb_height = (int) $instance['thumb_height']; $thumb_width = (int) $instance['thumb_width']; $thumb_default = esc_url($instance['thumb_default']); $thumb_align = sanitize_html_class($instance['thumb_align']); $cat = $instance['cat']; $tag = $instance['tag']; $post_type = $instance['post_type']; $date = $instance['date']; $readmore = $instance['readmore']; $readmore_text = strip_tags($instance['readmore_text']); $styles_default = $instance['styles_default']; $css = wp_filter_nohtml_kses($instance['css']); echo $before_widget; /* Display the default style of the plugin. */ if ($styles_default == true) { rpwe_custom_styles(); } /* If the default style are disable then use the custom css. */ if ($styles_default == false && !empty($css)) { echo '<style>' . $css . '</style>'; } /* If both title and title url not empty then display the data. */ if (!empty($title_url) && !empty($title)) { echo $before_title . '<a href="' . $title_url . '" title="' . esc_attr($title) . '">' . $title . '</a>' . $after_title; /* If title not empty and title url empty then display just the title. */ } elseif (!empty($title)) { echo $before_title . $title . $after_title; } global $post; /* Set up the query arguments. */ $args = array('posts_per_page' => $limit, 'category__in' => $cat, 'tag__in' => $tag, 'post_type' => $post_type, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'suppress_filters' => $instance['suppress_filters']); /* Allow developer to filter the query. */ $default_args = apply_filters('rpwe_default_query_arguments', $args); /** * The main Query * * @link http://codex.wordpress.org/Function_Reference/get_posts */ $rpwewidget = get_posts($default_args); /* Check if posts exist. */ if ($rpwewidget) { ?> <div <?php echo !empty($cssID) ? 'id="' . $cssID . '"' : ''; ?> class="rpwe-block"> <ul class="rpwe-ul"> <?php foreach ($rpwewidget as $post) { setup_postdata($post); ?> <li class="rpwe-clearfix"> <?php if ($thumb == true) { // Check if the thumbnail option enable. ?> <?php if (has_post_thumbnail()) { // Check If post has post thumbnail. ?> <a href="<?php the_permalink(); ?> " title="<?php printf(esc_attr__('Permalink to %s', 'rpwe'), the_title_attribute('echo=0')); ?> " rel="bookmark"> <?php the_post_thumbnail(array($thumb_width, $thumb_height, true), array('class' => $thumb_align . ' rpwe-thumb the-post-thumbnail', 'alt' => esc_attr(get_the_title()))); ?> </a> <?php } elseif (function_exists('get_the_image')) { // Check if get-the-image plugin installed and active. ?> <?php get_the_image(array('height' => $thumb_height, 'width' => $thumb_width, 'size' => 'rpwe-thumbnail', 'image_class' => $thumb_align . ' rpwe-thumb get-the-image', 'image_scan' => true, 'default_image' => $thumb_default)); ?> <?php } elseif ($thumb_default) { // Check if the default image not empty. ?> <?php printf('<a href="%1$s" rel="bookmark"><img class="%2$s rpwe-thumb rpwe-default-thumb" src="%3$s" alt="%4$s" width="%5$s" height="%6$s"></a>', esc_url(get_permalink()), $thumb_align, $thumb_default, esc_attr(get_the_title()), $thumb_width, $thumb_height); ?> <?php } // endif ?> <?php } // endif ?> <h3 class="rpwe-title"> <a href="<?php the_permalink(); ?> " title="<?php printf(esc_attr__('Permalink to %s', 'rpwe'), the_title_attribute('echo=0')); ?> " rel="bookmark"><?php the_title(); ?> </a> </h3> <?php if ($date == true) { // Check if the date option enable. ?> <time class="rpwe-time published" datetime="<?php echo esc_attr(get_the_date('c')); ?> "><?php echo get_the_date(); ?> </time> <?php } // endif ?> <?php if ($excerpt == true) { // Check if the excerpt option enable. ?> <div class="rpwe-summary"> <?php echo rpwe_excerpt($length); ?> <?php if ($readmore == true) { echo '<a href="' . esc_url(get_permalink()) . '" class="more-link">' . $readmore_text . '</a>'; } ?> </div> <?php } // endif ?> </li> <?php } wp_reset_postdata(); ?> </ul> </div><!-- .rpwe-block - http://wordpress.org/plugins/recent-posts-widget-extended/ --> <?php } /* End check. */ echo $after_widget; }
/** * Generates the posts markup. * * @since 0.9.4 * @param array $args * @return string|array The HTML for the random posts. */ function rpwe_get_recent_posts($args = array()) { // Set up a default, empty variable. $html = ''; // Merge the input arguments and the defaults. $args = wp_parse_args($args, rpwe_get_default_args()); // Extract the array to allow easy use of variables. extract($args); // Allow devs to hook in stuff before the loop. do_action('rpwe_before_loop'); // Display the default style of the plugin. if ($args['styles_default'] === true) { rpwe_custom_styles(); } // If the default style is disabled then use the custom css if it's not empty. if ($args['styles_default'] === false && !empty($args['css'])) { echo '<style>' . $args['css'] . '</style>'; } // Get the posts query. $posts = rpwe_get_posts($args); if ($posts->have_posts()) { // Recent posts wrapper $html = '<div ' . (!empty($args['cssID']) ? 'id="' . sanitize_html_class($args['cssID']) . '"' : '') . ' class="rpwe-block ' . (!empty($args['css_class']) ? '' . sanitize_html_class($args['css_class']) . '' : '') . '">'; $html .= '<ul class="rpwe-ul">'; while ($posts->have_posts()) { $posts->the_post(); // Thumbnails $thumb_id = get_post_thumbnail_id(); // Get the featured image id. $img_url = wp_get_attachment_url($thumb_id); // Get img URL. // Display the image url and crop using the resizer. $image = rpwe_resize($img_url, $args['thumb_width'], $args['thumb_height'], true); // Start recent posts markup. $html .= '<li class="rpwe-li rpwe-clearfix">'; if ($args['thumb']) { // Check if post has post thumbnail. if (has_post_thumbnail()) { $html .= '<a class="rpwe-img" href="' . esc_url(get_permalink()) . '" rel="bookmark">'; if ($image) { $html .= '<img class="' . esc_attr($args['thumb_align']) . ' rpwe-thumb" src="' . esc_url($image) . '" alt="' . esc_attr(get_the_title()) . '">'; } else { $html .= get_the_post_thumbnail(get_the_ID(), array($args['thumb_width'], $args['thumb_height']), array('class' => $args['thumb_align'] . ' rpwe-thumb the-post-thumbnail', 'alt' => esc_attr(get_the_title()))); } $html .= '</a>'; // If no post thumbnail found, check if Get The Image plugin exist and display the image. } elseif (function_exists('get_the_image')) { $html .= get_the_image(array('height' => (int) $args['thumb_height'], 'width' => (int) $args['thumb_width'], 'image_class' => esc_attr($args['thumb_align']) . ' rpwe-thumb get-the-image', 'image_scan' => true, 'echo' => false, 'default_image' => esc_url($args['thumb_default']))); // Display default image. } elseif (!empty($args['thumb_default'])) { $html .= sprintf('<a class="rpwe-img" href="%1$s" rel="bookmark"><img class="%2$s rpwe-thumb rpwe-default-thumb" src="%3$s" alt="%4$s" width="%5$s" height="%6$s"></a>', esc_url(get_permalink()), esc_attr($args['thumb_align']), esc_url($args['thumb_default']), esc_attr(get_the_title()), (int) $args['thumb_width'], (int) $args['thumb_height']); } } $html .= '<h3 class="rpwe-title"><a href="' . esc_url(get_permalink()) . '" title="' . sprintf(esc_attr__('Permalink to %s', 'rpwe'), the_title_attribute('echo=0')) . '" rel="bookmark">' . esc_attr(get_the_title()) . '</a></h3>'; if ($args['date']) { $date = get_the_date(); if ($args['date_relative']) { $date = sprintf(__('%s ago', 'rpwe'), human_time_diff(get_the_date('U'), current_time('timestamp'))); } $html .= '<time class="rpwe-time published" datetime="' . esc_html(get_the_date('c')) . '">' . esc_html($date) . '</time>'; } elseif ($args['date_modified']) { // if both date functions are provided, we use date to be backwards compatible $date = get_the_modified_date(); if ($args['date_relative']) { $date = sprintf(__('%s ago', 'rpwe'), human_time_diff(get_the_modified_date('U'), current_time('timestamp'))); } $html .= '<time class="rpwe-time modfied" datetime="' . esc_html(get_the_modified_date('c')) . '">' . esc_html($date) . '</time>'; } if ($args['comment_count']) { if (get_comments_number() == 0) { $comments = __('No Comments', 'rpwe'); } elseif (get_comments_number() > 1) { $comments = sprintf(__('%s Comments', 'rpwe'), get_comments_number()); } else { $comments = __('1 Comment', 'rpwe'); } $html .= '<a class="rpwe-comment comment-count" href="' . get_comments_link() . '">' . $comments . '</a>'; } if ($args['excerpt']) { $html .= '<div class="rpwe-summary">'; $html .= wp_trim_words(apply_filters('rpwe_excerpt', get_the_excerpt()), $args['length'], ' …'); if ($args['readmore']) { $html .= '<a href="' . esc_url(get_permalink()) . '" class="more-link">' . $args['readmore_text'] . '</a>'; } $html .= '</div>'; } $html .= '</li>'; } $html .= '</ul>'; $html .= '</div><!-- Generated by http://wordpress.org/plugins/recent-posts-widget-extended/ -->'; } // Restore original Post Data. wp_reset_postdata(); // Allow devs to hook in stuff after the loop. do_action('rpwe_after_loop'); // Return the posts markup. return $args['before'] . apply_filters('rpwe_markup', $html) . $args['after']; }
/** * Generates the posts markup. * * @since 0.9.4 * @param array $args * @return string|array The HTML for the random posts. */ function rpwe_get_recent_posts($args = array()) { // Set up a default, empty variable. $html = ''; // Merge the input arguments and the defaults. $args = wp_parse_args($args, rpwe_get_default_args()); // Extract the array to allow easy use of variables. extract($args); // Allow devs to hook in stuff before the loop. do_action('rpwe_before_loop'); // Display the default style of the plugin. if ($args['styles_default'] == true) { rpwe_custom_styles(); } // If the default style is disbale then use the custom css if it not empty. if ($args['styles_default'] == false && !empty($args['css'])) { echo '<style>' . $args['css'] . '</style>'; } // Get the posts query. $posts = rpwe_get_posts($args); if ($posts->have_posts()) { $html = '<div ' . (!empty($args['cssID']) ? 'id="' . sanitize_html_class($args['cssID']) . '"' : '') . ' class="rpwe-block">'; $html .= '<ul class="rpwe-ul">'; while ($posts->have_posts()) { $posts->the_post(); // Experiment! // Cropping image using Aqua Resizer $thumb_id = get_post_thumbnail_id(); $img_url = wp_get_attachment_url($thumb_id, 'full'); // Get img URL. $image = aq_resize($img_url, $args['thumb_width'], $args['thumb_height'], true); // Resize & crop img. $html .= '<li class="rpwe-li rpwe-clearfix">'; if ($args['thumb']) { // Check if post has post thumbnail. if (has_post_thumbnail()) { $html .= '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">'; $html .= '<img class="' . $args['thumb_align'] . ' rpwe-thumb get-the-image" src="' . esc_url($image) . '" alt="' . esc_attr(get_the_title()) . '">'; $html .= '</a>'; // If no post thumbnail found, check if Get The Image plugin exist and display the image. } elseif (function_exists('get_the_image')) { $html .= get_the_image(array('height' => $args['thumb_height'], 'width' => $args['thumb_width'], 'image_class' => $args['thumb_align'] . ' rpwe-thumb get-the-image', 'image_scan' => true, 'default_image' => $args['thumb_default'])); // Display default image. } elseif (!empty($args['thumb_default'])) { $html .= sprintf('<a href="%1$s" rel="bookmark"><img class="%2$s rpwe-thumb rpwe-default-thumb" src="%3$s" alt="%4$s" width="%5$s" height="%6$s"></a>', esc_url(get_permalink()), $args['thumb_align'], $args['thumb_default'], esc_attr(get_the_title()), $args['thumb_width'], $args['thumb_height']); } } $html .= '<h3 class="rpwe-title"><a href="' . esc_url(get_permalink()) . '" title="' . sprintf(esc_attr__('Permalink to %s', 'rpwe'), the_title_attribute('echo=0')) . '" rel="bookmark">' . esc_attr(get_the_title()) . '</a></h3>'; if ($args['date']) { $date = get_the_date(); if ($args['date_relative']) { $date = human_time_diff(get_the_date('U'), current_time('timestamp')) . ' ago'; } $html .= '<time class="rpwe-time published" datetime="' . esc_html(get_the_date('c')) . '">' . esc_html($date) . '</time>'; } if ($args['excerpt']) { $html .= '<div class="rpwe-summary">'; $html .= wp_trim_words(apply_filters('rpwe_excerpt', get_the_excerpt()), $args['length'], ' …'); if ($args['readmore']) { $html .= '<a href="' . esc_url(get_permalink()) . '" class="more-link">' . $args['readmore_text'] . '</a>'; } $html .= '</div>'; } $html .= '</li>'; } $html .= '</ul>'; $html .= '</div><!-- Generated by http://wordpress.org/plugins/recent-posts-widget-extended/ -->'; } // Restore original Post Data. wp_reset_postdata(); // Allow devs to hook in stuff after the loop. do_action('rpwe_after_loop'); // Return the posts markup. return $args['before'] . apply_filters('rpwe_markup', $html) . $args['after']; }