Content Blocks (Custom Post Widget) - Version 2.4.5

Version Description

Download this release

Release Info

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

Code changes from version 2.4.3 to 2.4.5

Files changed (4) hide show
  1. custom-post-widget.php +2 -2
  2. popup.php +11 -8
  3. post-widget.php +1 -1
  4. readme.txt +3 -0
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.4.3
7
  Author: Johan van der Wijk
8
  Author URI: http://www.vanderwijk.com
9
  License: GPL2
10
 
11
- Release notes: Version 2.4 Added an meta box for describing the content block and included sv_SE translation
12
 
13
  Copyright 2013 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.4.5
7
  Author: Johan van der Wijk
8
  Author URI: http://www.vanderwijk.com
9
  License: GPL2
10
 
11
+ Release notes: Version 2.4.5 javaScript fix for inserting shortcode
12
 
13
  Copyright 2013 Johan van der Wijk (email: info@vanderwijk.com)
14
 
popup.php CHANGED
@@ -3,14 +3,17 @@
3
  function add_content_block_popup() { ?>
4
 
5
  <script>
6
- function InsertContentBlockForm() {
7
- var content_id = jQuery("#add-content-block-id").val();
8
- if(content_id == "") {
9
- alert("<?php _e( 'Please select a Content Block', 'custom-post-widget' ); ?>");
 
 
 
10
  return;
11
  }
12
  var win = window.dialogArguments || opener || parent || top;
13
- win.send_to_editor("[content_block id=" + content_id + "]");
14
  }
15
  </script>
16
 
@@ -22,12 +25,12 @@ function add_content_block_popup() { ?>
22
  <?php _e( 'Select a Content Block below to add it to your post or page.', 'custom-post-widget' ); ?>
23
  </p>
24
  <p>
25
- <select id="add-content-block-id">
26
  <option value="">
27
  <?php _e( 'Select a Content Block', 'custom-post-widget' ); ?>
28
  </option>
29
  <?php
30
- $args = array('post_type' => 'content_block', 'suppress_filters' => 0, 'numberposts' => -1, 'order' => 'ASC');
31
  $content_block = get_posts( $args );
32
  if ($content_block) {
33
  foreach( $content_block as $content_block ) : setup_postdata( $content_block );
@@ -40,7 +43,7 @@ function add_content_block_popup() { ?>
40
  </select>
41
  </p>
42
  <p>
43
- <input type="button" class="button-primary" value="<?php _e( 'Insert Content Block', 'custom-post-widget' ) ?>" onclick="InsertContentBlockForm();"/>
44
  </p>
45
  </div>
46
 
3
  function add_content_block_popup() { ?>
4
 
5
  <script>
6
+ jQuery( '.add-content-block-id' ).change( function() {
7
+ content_id = jQuery( this ).val();
8
+ console.log( 'content_id: ' + content_id );
9
+ });
10
+ function insertContentBlockShortcode() {
11
+ if( content_id == "" ) {
12
+ alert( "<?php _e( 'Please select a Content Block', 'custom-post-widget' ); ?>" );
13
  return;
14
  }
15
  var win = window.dialogArguments || opener || parent || top;
16
+ win.send_to_editor( "[content_block id=" + content_id + "]" );
17
  }
18
  </script>
19
 
25
  <?php _e( 'Select a Content Block below to add it to your post or page.', 'custom-post-widget' ); ?>
26
  </p>
27
  <p>
28
+ <select id="add-content-block-id" class="add-content-block-id">
29
  <option value="">
30
  <?php _e( 'Select a Content Block', 'custom-post-widget' ); ?>
31
  </option>
32
  <?php
33
+ $args = array( 'post_type' => 'content_block', 'suppress_filters' => 0, 'numberposts' => -1, 'order' => 'ASC' );
34
  $content_block = get_posts( $args );
35
  if ($content_block) {
36
  foreach( $content_block as $content_block ) : setup_postdata( $content_block );
43
  </select>
44
  </p>
45
  <p>
46
+ <input type="button" class="button-primary" value="<?php _e( 'Insert Content Block', 'custom-post-widget' ) ?>" onclick="insertContentBlockShortcode();"/>
47
  </p>
48
  </div>
49
 
post-widget.php CHANGED
@@ -201,7 +201,7 @@ function custom_post_widget_shortcode( $atts ) {
201
  $content_post = get_posts( $args );
202
 
203
  foreach( $content_post as $post ) :
204
- $content .= '<div class="'. esc_attr($class) .'">';
205
  $content .= apply_filters( 'the_content', $post->post_content);
206
  $content .= '</div>';
207
  endforeach;
201
  $content_post = get_posts( $args );
202
 
203
  foreach( $content_post as $post ) :
204
+ $content .= '<div class="'. esc_attr($class) .'" id="custom_post_widget-' . $id . '">';
205
  $content .= apply_filters( 'the_content', $post->post_content);
206
  $content .= '</div>';
207
  endforeach;
readme.txt CHANGED
@@ -101,6 +101,9 @@ Creating and supporting this plugin takes up a lot of my free time, therefore I
101
 
102
  == Changelog ==
103
 
 
 
 
104
  = 2.4.3 =
105
  Changed the way the shortcode button above the editor is called.
106
 
101
 
102
  == Changelog ==
103
 
104
+ = 2.4.4 =
105
+ Added unique ID to each content block that is inserted using the shortcode functionality
106
+
107
  = 2.4.3 =
108
  Changed the way the shortcode button above the editor is called.
109