Content Blocks (Custom Post Widget) - Version 3.0.3

Version Description

Added the option to show the featured image in when using the shortcode. Add featured_image=yes to the shortcode to show it: [content_block featured_image=yes]. By default the medium image size is displayed, you can change it like this: [content_block featured_image=yes featured_image_size=full].

Download this release

Release Info

Developer vanderwijk
Plugin Icon 128x128 Content Blocks (Custom Post Widget)
Version 3.0.3
Comparing to
See all releases

Code changes from version 3.0.2 to 3.0.3

Files changed (3) hide show
  1. custom-post-widget.php +2 -2
  2. post-widget.php +10 -5
  3. readme.txt +5 -2
custom-post-widget.php CHANGED
@@ -3,14 +3,14 @@
3
  Plugin Name: Content Blocks (Custom Post Widget)
4
  Plugin URI: http://www.vanderwijk.com/wordpress/wordpress-custom-post-widget/?utm_source=wordpress&utm_medium=plugin&utm_campaign=custom_post_widget
5
  Description: Show the content of a custom post of the type 'content_block' in a widget or with a shortcode.
6
- Version: 3.0.2
7
  Author: Johan van der Wijk
8
  Author URI: http://vanderwijk.nl
9
  Text Domain: custom-post-widget
10
  Domain Path: /languages
11
  License: GPL2
12
 
13
- Release notes: Added esc_html to the post titles in the popup select box
14
 
15
  Copyright 2017 Johan van der Wijk
16
 
3
  Plugin Name: Content Blocks (Custom Post Widget)
4
  Plugin URI: http://www.vanderwijk.com/wordpress/wordpress-custom-post-widget/?utm_source=wordpress&utm_medium=plugin&utm_campaign=custom_post_widget
5
  Description: Show the content of a custom post of the type 'content_block' in a widget or with a shortcode.
6
+ Version: 3.0.3
7
  Author: Johan van der Wijk
8
  Author URI: http://vanderwijk.nl
9
  Text Domain: custom-post-widget
10
  Domain Path: /languages
11
  License: GPL2
12
 
13
+ Release notes: You can now show the featured image when using the shortcode to display a content block.
14
 
15
  Copyright 2017 Johan van der Wijk
16
 
post-widget.php CHANGED
@@ -173,6 +173,8 @@ function custom_post_widget_shortcode( $atts ) {
173
  'slug' => '',
174
  'class' => 'content_block',
175
  'suppress_content_filters' => 'no',
 
 
176
  'title' => 'no',
177
  'title_tag' => 'h3'
178
  ), $atts ) );
@@ -195,14 +197,17 @@ function custom_post_widget_shortcode( $atts ) {
195
  $content_post = get_posts( $args );
196
 
197
  foreach( $content_post as $post ) :
198
- $content .= '<div class="'. esc_attr($class) .'" id="custom_post_widget-' . $id . '">';
199
  if ( $title === 'yes' ) {
200
- $content .= '<' . esc_attr( $title_tag ) . '>' . $post->post_title . '</' . esc_attr( $title_tag ) . '>';
 
 
 
201
  }
202
  if ( $suppress_content_filters === 'no' ) {
203
- $content .= apply_filters( 'the_content', $post->post_content);
204
  } else {
205
- $content .= $post->post_content;
206
  }
207
  $content .= '</div>';
208
  endforeach;
@@ -220,4 +225,4 @@ function cpw_add_content_block_button() {
220
  add_action( 'admin_footer', 'add_content_block_popup' );
221
  }
222
  }
223
- add_action( 'admin_head', 'cpw_add_content_block_button' );
173
  'slug' => '',
174
  'class' => 'content_block',
175
  'suppress_content_filters' => 'no',
176
+ 'featured_image' => 'no',
177
+ 'featured_image_size' => 'medium',
178
  'title' => 'no',
179
  'title_tag' => 'h3'
180
  ), $atts ) );
197
  $content_post = get_posts( $args );
198
 
199
  foreach( $content_post as $post ) :
200
+ $content .= '<div class="'. esc_attr( $class ) .'" id="custom_post_widget-' . $id . '">';
201
  if ( $title === 'yes' ) {
202
+ $content .= '<' . esc_attr( $title_tag ) . '>' . $post -> post_title . '</' . esc_attr( $title_tag ) . '>';
203
+ }
204
+ if ( $featured_image === 'yes' ) {
205
+ $content .= get_the_post_thumbnail( $post -> ID, $featured_image_size );
206
  }
207
  if ( $suppress_content_filters === 'no' ) {
208
+ $content .= apply_filters( 'the_content', $post -> post_content );
209
  } else {
210
+ $content .= $post -> post_content;
211
  }
212
  $content .= '</div>';
213
  endforeach;
225
  add_action( 'admin_footer', 'add_content_block_popup' );
226
  }
227
  }
228
+ add_action( 'admin_head', 'cpw_add_content_block_button' );
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: vanderwijk
3
  Tags: widget, sidebar, content block, block, custom, post, shortcode, wysiwyg, wpml, featured image
4
  Requires at least: 4.0
5
- Tested up to: 4.8
6
- Stable tag: 3.0.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -126,6 +126,9 @@ Creating and supporting this plugin takes up a lot of my free time, therefore I
126
 
127
  == Changelog ==
128
 
 
 
 
129
  = 3.0.2 =
130
  Tested for WordPress 4.8 compatibility.
131
 
2
  Contributors: vanderwijk
3
  Tags: widget, sidebar, content block, block, custom, post, shortcode, wysiwyg, wpml, featured image
4
  Requires at least: 4.0
5
+ Tested up to: 4.9
6
+ Stable tag: 3.0.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
126
 
127
  == Changelog ==
128
 
129
+ = 3.0.3 =
130
+ Added the option to show the featured image in when using the shortcode. Add featured_image=yes to the shortcode to show it: `[content_block featured_image=yes]`. By default the medium image size is displayed, you can change it like this: `[content_block featured_image=yes featured_image_size=full]`.
131
+
132
  = 3.0.2 =
133
  Tested for WordPress 4.8 compatibility.
134