Content Blocks (Custom Post Widget) - Version 2.6

Version Description

Added the possibility for using the content block slug in the shortcode.

Download this release

Release Info

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

Code changes from version 2.5.7 to 2.6

Files changed (3) hide show
  1. custom-post-widget.php +2 -2
  2. post-widget.php +12 -4
  3. readme.txt +10 -2
custom-post-widget.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: Custom Post Widget
4
  Plugin URI: http://www.vanderwijk.com/wordpress/wordpress-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: 2.5.7
7
  Author: Johan van der Wijk
8
  Author URI: http://www.vanderwijk.com
9
  License: GPL2
10
 
11
- Release notes: Version 2.5 adds the content block information column to the overview page
12
 
13
  Copyright 2014 Johan van der Wijk (email: info@vanderwijk.com)
14
 
3
  Plugin Name: Custom Post Widget
4
  Plugin URI: http://www.vanderwijk.com/wordpress/wordpress-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: 2.6
7
  Author: Johan van der Wijk
8
  Author URI: http://www.vanderwijk.com
9
  License: GPL2
10
 
11
+ Release notes: Version 2.6 allows you to use the content block slug in the shortcode
12
 
13
  Copyright 2014 Johan van der Wijk (email: info@vanderwijk.com)
14
 
post-widget.php CHANGED
@@ -167,9 +167,17 @@ add_filter( 'post_updated_messages', 'content_block_messages' );
167
  function custom_post_widget_shortcode( $atts ) {
168
  extract( shortcode_atts( array(
169
  'id' => '',
 
170
  'class' => 'content_block'
171
  ), $atts ) );
172
-
 
 
 
 
 
 
 
173
  $content = "";
174
 
175
  if( $id != "" ) {
@@ -177,16 +185,16 @@ function custom_post_widget_shortcode( $atts ) {
177
  'post__in' => array( $id ),
178
  'post_type' => 'content_block',
179
  );
180
-
181
  $content_post = get_posts( $args );
182
-
183
  foreach( $content_post as $post ) :
184
  $content .= '<div class="'. esc_attr($class) .'" id="custom_post_widget-' . $id . '">';
185
  $content .= apply_filters( 'the_content', $post->post_content);
186
  $content .= '</div>';
187
  endforeach;
188
  }
189
-
190
  return $content;
191
  }
192
  add_shortcode( 'content_block', 'custom_post_widget_shortcode' );
167
  function custom_post_widget_shortcode( $atts ) {
168
  extract( shortcode_atts( array(
169
  'id' => '',
170
+ 'slug' => '',
171
  'class' => 'content_block'
172
  ), $atts ) );
173
+
174
+ if ( $slug ) {
175
+ $block = get_page_by_path( $slug, OBJECT, 'content_block' );
176
+ if ( $block ) {
177
+ $id = $block->ID;
178
+ }
179
+ }
180
+
181
  $content = "";
182
 
183
  if( $id != "" ) {
185
  'post__in' => array( $id ),
186
  'post_type' => 'content_block',
187
  );
188
+
189
  $content_post = get_posts( $args );
190
+
191
  foreach( $content_post as $post ) :
192
  $content .= '<div class="'. esc_attr($class) .'" id="custom_post_widget-' . $id . '">';
193
  $content .= apply_filters( 'the_content', $post->post_content);
194
  $content .= '</div>';
195
  endforeach;
196
  }
197
+
198
  return $content;
199
  }
200
  add_shortcode( 'content_block', 'custom_post_widget_shortcode' );
readme.txt CHANGED
@@ -4,8 +4,8 @@ Author URI: http://www.vanderwijk.com/
4
  Donate link: http://www.vanderwijk.com/wordpress/support/
5
  Tags: widget, sidebar, content block, block, custom, post, shortcode, wysiwyg, wpml, featured image
6
  Requires at least: 2.9.2
7
- Tested up to: 3.9.1
8
- Stable tag: 2.5.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -86,6 +86,11 @@ Currently the shortcode function only outputs the post content of the content bl
86
 
87
  You can create your own widget template and upload this to your theme folder. See [this support topic](http://wordpress.org/support/topic/patch-custom-widget-frontends?replies=1) for more information about this feature.
88
 
 
 
 
 
 
89
  = How can I embed a content block in my template file using php code? =
90
 
91
  You can use the do_shortcode function for this: `echo do_shortcode('[content_block id= ]');`
@@ -103,6 +108,9 @@ Creating and supporting this plugin takes up a lot of my free time, therefore I
103
 
104
  == Changelog ==
105
 
 
 
 
106
  = 2.5.7 =
107
  Changed the way the button above the content editor is inserted. For background see: http://wordpress.org/support/topic/soliloquy-conflict-1?replies=2
108
 
4
  Donate link: http://www.vanderwijk.com/wordpress/support/
5
  Tags: widget, sidebar, content block, block, custom, post, shortcode, wysiwyg, wpml, featured image
6
  Requires at least: 2.9.2
7
+ Tested up to: 4.0
8
+ Stable tag: 2.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
86
 
87
  You can create your own widget template and upload this to your theme folder. See [this support topic](http://wordpress.org/support/topic/patch-custom-widget-frontends?replies=1) for more information about this feature.
88
 
89
+ = Post ID's confuse me, can I use the post slug for embedding a content block? =
90
+
91
+ Yes, v2.6 now gives you the option to use the content block's url slug in the shortcode. Use the following syntax for doing this: `[content_block slug=my-content-block]`.
92
+ Note that if you ever change the slug of a content block, the embedding no longer works. Therefore I recommend using the post ID instead (which never changes).
93
+
94
  = How can I embed a content block in my template file using php code? =
95
 
96
  You can use the do_shortcode function for this: `echo do_shortcode('[content_block id= ]');`
108
 
109
  == Changelog ==
110
 
111
+ = 2.6 =
112
+ Added the possibility for using the content block slug in the shortcode.
113
+
114
  = 2.5.7 =
115
  Changed the way the button above the content editor is inserted. For background see: http://wordpress.org/support/topic/soliloquy-conflict-1?replies=2
116