/** * Display recent posts with shortcode. * * @since 0.9.4 */ function rpwe_shortcode($atts, $content) { if (isset($atts['cssid'])) { $atts['cssID'] = $atts['cssid']; unset($atts['cssid']); } $args = shortcode_atts(rpwe_get_default_args(), $atts); return rpwe_get_recent_posts($args); }
/** * Displays the widget control options in the Widgets admin screen. * * @since 0.1 */ function form($instance) { // Merge the user-selected arguments with the defaults. $instance = wp_parse_args((array) $instance, rpwe_get_default_args()); // Extract the array to allow easy use of variables. extract($instance); // Loads the widget form. include RPWE_INCLUDES . 'form.php'; }
/** * 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']; }
/** * 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']; }
/** * Display recent posts with shortcode. * * @since 0.9.4 */ function rpwe_shortcode($atts, $content) { $args = shortcode_atts(rpwe_get_default_args(), $atts); return rpwe_get_recent_posts($args); }
/** * 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']; }
/** * 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'); // Get the posts query. $posts = rpwe_get_posts($args); if ($posts->have_posts()) { $tmpl = apply_filters('rpwe_tmpl', $args['tmpl']); $template_name = "{$tmpl}.php"; if (file_exists(STYLESHEETPATH . '/' . $template_name)) { $tmpl = STYLESHEETPATH . '/' . $template_name; } else { if (file_exists(TEMPLATEPATH . '/' . $template_name)) { $tmpl = TEMPLATEPATH . '/' . $template_name; } } if (file_exists($tmpl)) { ob_start(); require $tmpl; $html = ob_get_clean(); } else { ?> <?php ob_start(); ?> <div <?php echo !empty($args['cssID']) ? 'id="' . sanitize_html_class($args['cssID']) . '"' : ''; ?> class="rpwe-block <?php echo !empty($args['css_class']) ? '' . sanitize_html_class($args['css_class']) . '' : ''; ?> "> <?php if (!empty($args['title'])) { ?> <h2 class="widgettitle"> <?php echo apply_filters('esc_html', $args['title']); ?> <?php if (!empty($args['subtitle'])) { ?> <span class="sub-title"><?php echo apply_filters('esc_html', $args['subtitle']); ?> </span> <?php } ?> </h2> <?php } ?> <div class="rpwe-div jv-posts <?php if ($args['col'] > 1) { echo 'row'; } ?> "> <?php while ($posts->have_posts()) { $posts->the_post(); ?> <?php // 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); if (!($args['thumb_width'] + $args['thumb_height'])) { $image = $img_url; } ?> <?php if ($args['col'] > 1) { ?> <div class="<?php echo 'col-md-' . 12 / sanitize_html_class($args['col']); ?> "> <?php } ?> <div class="item"> <div class="innerItem"> <?php if ($args['thumb']) { ?> <?php $audio = get_post_meta(get_the_ID(), 'audio_setting', true); ?> <?php $video = get_post_meta(get_the_ID(), 'video_setting', true); ?> <?php $album = function_exists('jv_get_album') ? jv_get_album(get_the_ID()) : ''; ?> <?php $album = apply_filters('jv_get_album', $album); ?> <?php if (has_post_thumbnail() or $audio or $video or $album) { ?> <?php if ($audio or $video or $album) { ?> <?php if ($audio and $video) { ?> <?php $media = $video; ?> <?php } else { ?> <?php $media = $audio . $video . $album; ?> <?php } ?> <?php echo apply_filters('the_content', $media); ?> <?php } else { ?> <a class="rpwe-img moduleItemImage" href="<?php echo esc_url(get_permalink()); ?> " rel="bookmark"> <?php if ($image) { ?> <img class="<?php echo esc_attr($args['thumb_align']); ?> rpwe-thumb" src="<?php echo esc_url($image); ?> " alt="<?php echo esc_attr(get_the_title()); ?> "> <?php } else { ?> <?php 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()))); ?> <?php } ?> </a> <?php } ?> <?php } elseif (function_exists('get_the_image')) { ?> <?php echo 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']))); ?> <?php } elseif (!empty($args['thumb_default'])) { ?> <?php echo 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']); } } ?> <div class="content-item-description"> <?php if (isset($args['dtitle']) && intval($args['dtitle'])) { ?> <h4 class="post-title"> <a href="<?php echo esc_url(get_permalink()); ?> " title="<?php echo sprintf(esc_attr__('Permalink to %s', 'rpwe'), the_title_attribute('echo=0')); ?> " rel="bookmark"><?php echo esc_attr(get_the_title()); ?> </a> </h4> <?php } ?> <?php if ($args['date'] or intval($args['dcategory']) && ($cposts = get_the_category(get_the_ID())) && count($cposts) or intval($args['dauthor']) or intval($args['dcomment'])) { ?> <div class="ItemLinks ItemLinksInline "> <?php if ($args['date']) { ?> <span> <?php if ($idate = apply_filters('rpwe_icon', 'date', $args['idate'])) { ?> <i class="<?php echo $idate; ?> "></i> <?php } ?> <span class="d"><?php echo apply_filters('get_the_date', get_the_date('d')); ?> </span> <span class="m"><?php echo apply_filters('get_the_date', get_the_date('M')); ?> </span> <span class="y"><?php echo apply_filters('get_the_date', get_the_date('Y')); ?> </span> </span> <?php } ?> <?php if (intval($args['dcategory']) && ($cposts = get_the_category(get_the_ID())) && count($cposts)) { ?> <span class="categories"> <?php if ($icategory = apply_filters('rpwe_icon', 'category', $args['icate'])) { ?> <i class="<?php echo $icategory; ?> "></i> <?php } ?> <?php foreach ($cposts as $cpost) { ?> <a class="category-name" href="<?php echo get_category_link($cpost->term_id); ?> "> <?php echo esc_html($cpost->cat_name); ?> </a> <?php } ?> <?php } ?> <?php if (intval($args['dtag']) && ($tags_post = get_the_tags(get_the_ID())) && count($tags_post)) { ?> <span class="categories"> <?php if ($itag = apply_filters('rpwe_icon', 'tag', $args['itag'])) { ?> <i class="<?php echo $itag; ?> "></i> <?php } ?> <?php foreach ($tags_post as $tag_post) { ?> <span class="tag-name"> <?php echo esc_html($tag_post->name); ?> </span> <?php } ?> </span> <?php } ?> <?php if (intval($args['dauthor'])) { ?> <span> <?php if ($iauthor = apply_filters('rpwe_icon', 'author', $args['iauthor'])) { ?> <i class="<?php echo $iauthor; ?> "></i> <?php } ?> <?php echo get_the_author_link(); ?> </span> <?php } ?> <?php if (intval($args['dcomment'])) { $comments = get_comments(array('post_id' => get_the_ID(), 'count' => 1)); $clink = get_comments_link(get_the_ID()); $icomment = apply_filters('rpwe_icon', 'comment', $args['icomment']); ?> <?php echo sprintf('<a href="%1$s" class="moduleItemComments"><i class="%2$s"></i> %3$s</a>', $clink, $icomment, $comments); } ?> </div> <?php } ?> <?php if (isset($args['excerpt']) && intval($args['excerpt'])) { ?> <div class="moduleItemIntrotext"> <?php echo wp_trim_words(apply_filters('the_content', get_the_content()), $args['length'], ' […]'); ?> </div> <?php } ?> <?php if ($args['readmore']) { ?> <div class="readmore"> <a href="<?php echo esc_url(get_permalink()); ?> " class="moduleItemReadMore"> <?php echo apply_filters('rpwe_readmore', $args['readmore_text']); ?> </a> </div> <?php } ?> </div> </div> </div> <?php if ($args['col'] > 1) { ?> </div> <?php } ?> <?php } ?> </div> </div> <?php $html = ob_get_clean(); } } // 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']; }