', $tag, $class_str ); $html = apply_filters( 'apw_start_list', $_html, $instance, $query ); if( $echo ) { echo $html; } else { return $html; } } /** * Opens the list item for the current Posts widget instance. * * Use 'apw_start_list_item' filter to filter $html before output. * * @access public * * @since 1.0 * * @param array $instance Settings for the current Posts widget instance. * @param object $query WP_Query object. * @param bool $echo Flag to echo or return the method's output. * * @return string $html Opening tag element for the list item. */ public static function start_list_item( $instance, $query, $echo = true ) { $apw_post = get_post(); $apw_post_id = Advanced_Posts_Widget_Utils::get_apw_post_id( $apw_post, $instance ); $apw_post_class = Advanced_Posts_Widget_Utils::get_apw_post_class( $apw_post, $instance ); $class = 'apw-list-item ' . $apw_post_class; $tag = ( 'div' === $instance['list_style'] ) ? 'div' : 'li'; $_html = sprintf( '<%1$s id="%2$s" class="%3$s">', $tag, $apw_post_id, $class ); $html = apply_filters( 'apw_start_list_item', $_html, $instance, $query ); if( $echo ) { echo $html; } else { return $html; } } /** * Closes the list item for the current Posts widget instance. * * Use 'apw_end_list_item' filter to filter $html before output. * * @access public * * @since 1.0 * * @param array $instance Settings for the current Posts widget instance. * @param object $query WP_Query object. * @param bool $echo Flag to echo or return the method's output. * * @return string $html Closing tag element for the list item. */ public static function end_list_item( $instance, $query, $echo = true ) { $tag = ( 'div' === $instance['list_style'] ) ? 'div' : 'li'; $_html = sprintf( '', $tag ); $html = apply_filters( 'apw_end_list_item', $_html, $instance, $query ); if( $echo ) { echo $html; } else { return $html; } } /** * Closes the post list for the current Posts widget instance. * * Use 'apw_end_list' filter to filter $html before output. * * @access public * * @since 1.0 * * @param array $instance Settings for the current Posts widget instance. * @param object $query WP_Query object. * @param bool $echo Flag to echo or return the method's output. * * @return string $html Closing tag element for the post list. */ public static function end_list( $instance, $query, $echo = true ) { $_html = ''; switch ( $instance['list_style'] ) { case 'div': $_html = "\n"; break; case 'ol': $_html = "\n"; break; case 'ul': default: $_html = "\n"; break; } $html = apply_filters( 'apw_end_list', $_html, $instance, $query ); if( $echo ) { echo $html; } else { return $html; } } /** * Outputs plugin attribution * * @access public * * @since 1.0 * * @return string Plugin attribution. */ public static function colophon( $echo = true ) { $attribution = ''; if ( $echo ) { echo $attribution; } else { return $attribution; } } /** * Builds html for thumbnail section of post * * @access public * * @since 1.0 * * @param object $post Post object. * @param array $instance Settings for the current Posts widget instance. * @param bool $echo Flag to echo or return the method's output. * * @return string $html Post thumbnail section. */ public static function apw_post_thumbnail( $post = 0, $instance = array(), $echo = true ) { $_post = get_post( $post ); if ( empty( $_post ) ) { return ''; } $_html = ''; $_thumb = Advanced_Posts_Widget_Utils::get_apw_post_thumbnail( $_post, $instance ); $_classes = array(); $_classes[] = 'apw-post-thumbnail'; $classes = apply_filters( 'apw_thumbnail_div_class', $_classes, $instance, $_post ); $classes = ( ! is_array( $classes ) ) ? (array) $classes : $classes ; $classes = array_map( 'sanitize_html_class', $classes ); $class_str = implode( ' ', $classes ); if( '' !== $_thumb ) { $_html .= sprintf('%2$s', $class_str, sprintf('%s', esc_url( get_permalink( $_post ) ), $_thumb ) ); }; $html = apply_filters( 'apw_post_thumbnail', $_html, $_post, $instance ); if( $echo ) { echo $html; } else { return $html; } } /** * Builds html for post date section * * @access public * * @since 1.0 * * @param object $post Post object. * @param array $instance Settings for the current Posts widget instance. * @param bool $echo Flag to echo or return the method's output. * * @return string $html Post thumbnail section. */ public static function apw_posted_on( $post = 0, $instance = array(), $echo = true ) { $_post = get_post( $post ); if ( empty( $_post ) ) { return ''; } $_html = ''; $time_string = ''; $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), Advanced_Posts_Widget_Utils::get_apw_post_date( $_post, $instance ) ); $_html = sprintf( '%1$s %3$s', _x( 'Posted on', 'Used before publish date.' ), esc_url( get_permalink() ), $time_string ); $html = apply_filters( 'apw_posted_on', $_html, $_post, $instance ); if( $echo ) { echo $html; } else { return $html; } } }