Beispiel #1
0
 /**
  * Outputs the widget based on the arguments input through the widget controls.
  *
  * @since  0.0.1
  */
 function widget($args, $instance)
 {
     extract($args);
     // Output the theme's $before_widget wrapper.
     echo $before_widget;
     // If both title and title url is not empty, display it.
     if (!empty($instance['title_url']) && !empty($instance['title'])) {
         echo $before_title . '<a href="' . esc_url($instance['title_url']) . '" title="' . esc_attr($instance['title']) . '">' . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . '</a>' . $after_title;
         // If the title not empty, display it.
     } elseif (!empty($instance['title'])) {
         echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
     }
     // Get the random posts query.
     echo arpw_get_random_posts($instance);
     // Close the theme's widget wrapper.
     echo $after_widget;
 }
/**
 * Display random posts with shortcode
 *
 * @since  0.0.1
 */
function arpw_shortcode($atts, $content)
{
    $args = shortcode_atts(arpw_get_default_args(), $atts);
    return arpw_get_random_posts($args);
}
/**
 * Outputs the random posts.
 * 
 * @since  0.0.1
 */
function arpw_random_posts($args = array())
{
    echo arpw_get_random_posts($args);
}