4 Commits

Author SHA1 Message Date
Thuan Bui 12684b8b65 change default image_size to empty 2020-10-03 13:44:57 +07:00
Thuan Bui bd7a7b91ba Clear Cateogry ID array value 2020-10-03 13:12:00 +07:00
10h30 614ae1d45a Fix no category specified
Support when no category specified
2020-10-02 23:16:15 +07:00
10h30 b52d6a871b Support argument image_size="false"
Support argument image_size="false" to disable image
2020-10-02 23:07:35 +07:00
+8 -3
View File
@@ -253,7 +253,7 @@ if ( ! class_exists( 'Display_Posts_Remote' ) ) {
$url = trailingslashit( $atts['url'] ) . 'wp-json/wp/v2/posts';
$url = add_query_arg( '_embed' , '', $url );
if ( ! empty( $atts['category_id'] ) ) {
if ( ! empty( $atts['category_id'] ) && ( is_array( $atts['category_id'] ) || false !== filter_var( $atts['category_id'], FILTER_VALIDATE_BOOLEAN ) ) ) {
if ( is_array( $atts['category_id'] ) ) {
@@ -319,7 +319,7 @@ if ( ! class_exists( 'Display_Posts_Remote' ) ) {
public function getDefaults() {
return array(
'category_id' => 0,
'category_id' => '',
'content_class' => 'content',
'date_format' => '(n/j/Y)',
'include_content' => FALSE,
@@ -327,7 +327,7 @@ if ( ! class_exists( 'Display_Posts_Remote' ) ) {
'include_date_modified' => FALSE,
'include_link' => TRUE,
'include_title' => TRUE,
'image_size' => 'thumbnail',
'image_size' => '',
'no_posts_message' => __( 'No posts to display.', 'display-posts-shortcode-remote' ),
'order' => 'desc',
'orderby' => 'date',
@@ -464,9 +464,12 @@ if ( ! class_exists( 'Display_Posts_Remote' ) ) {
$title = '';
}
//print_r($post);
$imageAttributes = $self->getImageAttributes( $atts );
if ( ! empty ($atts['image_size'])) {
if ( $atts['image_size'] && $post->has_post_thumbnail() && $atts['include_link'] ) {
$image = '<a class="image" href="' . esc_url( $post->get_permalink() ) . '">' . $post->get_the_post_thumbnail( $atts['image_size'], $imageAttributes ) . '</a> ';
@@ -484,6 +487,8 @@ if ( ! class_exists( 'Display_Posts_Remote' ) ) {
$image = '<span class="image">' . $post->get_the_post_thumbnail( 'full', $imageAttributes ) . '</span> ';
}
}
if ( $atts['include_date'] ) {