/** * Main function to generate the related posts output * * @since 1.0.1 * @deprecated 2.2.0 * @see get_crp * * @param array $args Parameters in a query string format * @return string HTML formatted list of related posts */ function ald_crp($args = array()) { _deprecated_function(__FUNCTION__, '2.2.0', 'get_crp()'); $output = get_crp($args); /** * Filter the output * * @since 1.9.1 * * @param string $output Formatted list of related posts * @param array $args Complete set of arguments */ return apply_filters('ald_crp', $output, $args); }
function ald_crp( $args ) { $defaults = array( 'is_widget' => FALSE, 'echo' => TRUE, ); $defaults = array_merge($defaults, crp_read_options()); // Parse incomming $args into an array and merge it with $defaults $args = wp_parse_args( $args, $defaults ); // OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before. extract( $args, EXTR_SKIP ); return get_crp($is_widget, $limit, $show_excerpt, $post_thumb_op, $thumb_height, $thumb_width); }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { global $wpdb, $post, $crp_settings; extract($args, EXTR_SKIP); parse_str($crp_settings['exclude_on_post_types'], $exclude_on_post_types); // Save post types in $exclude_on_post_types variable if (is_object($post) && in_array($post->post_type, $exclude_on_post_types)) { return 0; // Exit without adding related posts } $exclude_on_post_ids = explode(',', $crp_settings['exclude_on_post_ids']); if (is_single() && !is_single($exclude_on_post_ids) || is_page() && !is_page($exclude_on_post_ids)) { $title = apply_filters('widget_title', empty($instance['title']) ? strip_tags(str_replace('%postname%', $post->post_title, $crp_settings['title'])) : $instance['title']); $limit = isset($instance['limit']) ? $instance['limit'] : $crp_settings['limit']; if (empty($limit)) { $limit = $crp_settings['limit']; } $post_thumb_op = isset($instance['post_thumb_op']) ? esc_attr($instance['post_thumb_op']) : 'text_only'; $thumb_height = isset($instance['thumb_height']) ? esc_attr($instance['thumb_height']) : $crp_settings['thumb_height']; $thumb_width = isset($instance['thumb_width']) ? esc_attr($instance['thumb_width']) : $crp_settings['thumb_width']; $show_excerpt = isset($instance['show_excerpt']) ? esc_attr($instance['show_excerpt']) : ''; $show_author = isset($instance['show_author']) ? esc_attr($instance['show_author']) : ''; $show_date = isset($instance['show_date']) ? esc_attr($instance['show_date']) : ''; $post_types = isset($instance['post_types']) ? $instance['post_types'] : $crp_settings['post_types']; $arguments = array('is_widget' => 1, 'limit' => $limit, 'show_excerpt' => $show_excerpt, 'show_author' => $show_author, 'show_date' => $show_date, 'post_thumb_op' => $post_thumb_op, 'thumb_height' => $thumb_height, 'thumb_width' => $thumb_width, 'post_types' => $post_types); /** * Filters arguments passed to crp_pop_posts for the widget. * * @since 2.0.0 * * @param array $arguments Widget options array */ $arguments = apply_filters('crp_widget_options', $arguments); $output = $before_widget; $output .= $before_title . $title . $after_title; $output .= get_crp($arguments); $output .= $after_widget; echo $output; } }
/** * Echos the related posts. Used for manual install * * @since 1.0.1 * * @param string List of arguments to control the output */ function echo_crp($args = array()) { echo get_crp($args); }
/** * Echos the related posts. Used for manual install * * @since 1.0.1 * * @param string List of arguments to control the output */ function echo_crp($args = array()) { $defaults = array('is_manual' => true); // Parse incomming $args into an array and merge it with $defaults $args = wp_parse_args($args, $defaults); echo get_crp($args); }
/** * Creates a shortcode [crp limit="5" heading="1" cache="1"]. * * @since 1.8.6 * * @param array $atts Shortcode attributes * @param string $content (default: null) * @return Related Posts */ function crp_shortcode($atts, $content = null) { global $crp_settings; $atts = shortcode_atts(array_merge($crp_settings, array('heading' => 1)), $atts, 'crp'); return get_crp($atts); }