Content Blocks (Custom Post Widget) - Version 1.8.3

Version Description

The widget now emulates the $post loop. This means you can now make use of WordPress functionality such as inserting a [gallery]. Thanks to Jari Pennanen for providing the code.

=

Download this release

Release Info

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

Code changes from version 1.8.1 to 1.8.3

Files changed (4) hide show
  1. custom-post-widget.php +2 -2
  2. popup.php +41 -35
  3. post-widget.php +129 -147
  4. readme.txt +8 -2
custom-post-widget.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: Custom Post Widget
4
  Plugin URI: http://www.vanderwijk.com/services/web-design/wordpress-custom-post-widget/
5
  Description: Show the content of a custom post of the type 'content_block' in a widget.
6
- Version: 1.8.1
7
  Author: Johan van der Wijk
8
  Author URI: http://www.vanderwijk.com
9
  License: GPL2
10
 
11
- Release notes: Version 1.8 Button added above content editor to easily insert the shortcode.
12
 
13
  Copyright 2011 Johan van der Wijk (email: info@vanderwijk.com)
14
 
3
  Plugin Name: Custom Post Widget
4
  Plugin URI: http://www.vanderwijk.com/services/web-design/wordpress-custom-post-widget/
5
  Description: Show the content of a custom post of the type 'content_block' in a widget.
6
+ Version: 1.8.3
7
  Author: Johan van der Wijk
8
  Author URI: http://www.vanderwijk.com
9
  License: GPL2
10
 
11
+ Release notes: Version 1.8.3 The widget now emulates the $post loop.
12
 
13
  Copyright 2011 Johan van der Wijk (email: info@vanderwijk.com)
14
 
popup.php CHANGED
@@ -1,51 +1,57 @@
1
- <?php
2
- //Action target that displays the popup to insert a content block to a post/page
3
- function add_mce_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
 
13
- var win = window.dialogArguments || opener || parent || top;
14
- win.send_to_editor("[content_block id=" + content_id + "]");
15
- }
16
- </script>
 
 
 
 
 
 
 
17
 
18
  <div id="select_form" style="display:none;">
19
  <div class="wrap">
20
  <div>
21
  <div style="padding:15px 15px 0 15px;">
22
- <h3 style="color:#5A5A5A!important; font-family:Georgia,Times New Roman,Times,serif!important; font-size:1.8em!important; font-weight:normal!important;"><?php _e("Insert Content Block", 'custom-post-widget'); ?></h3>
23
- <span><?php _e("Select a Content Block below to add it to your post or page.", 'custom-post-widget'); ?></span>
 
 
 
 
24
  </div>
25
  <div style="padding:15px 15px 0 15px;">
26
  <select id="add_content_block_id">
27
- <option value=""><?php _e("Select a Content Block", 'custom-post-widget'); ?></option>
 
 
28
  <?php query_posts('post_type=content_block&orderby=ID&order=ASC&showposts=-1');
29
- if ( have_posts() ) : while ( have_posts() ) : the_post();
30
- $currentID = get_the_ID();
31
- if($currentID == $custom_post_id)
32
- $extra = 'selected' and
33
- $widgetExtraTitle = get_the_title();
34
- else
35
- $extra = '';
36
- echo '<option value="'.$currentID.'" '.$extra.'>'.get_the_title().'</option>';
37
- endwhile; else:
38
- echo '<option value="empty">' . __('No content blocks available', 'custom-post-widget') . '</option>';
39
- endif;
40
- ?>
41
- </select>
42
- <br/>
43
  <div style="padding:15px;">
44
- <input type="button" class="button-primary" value="Insert Content Block" onclick="InsertContentBlockForm();"/>&nbsp;&nbsp;&nbsp;
45
- <a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;"><?php _e("Cancel", 'custom-post-widget'); ?></a>
 
 
46
  </div>
47
  </div>
48
  </div>
49
  </div>
50
- <?php
51
- }
1
+ <?php //Action target that displays the popup to insert a content block to a post/page
 
 
2
 
3
+ function add_mce_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
 
17
  <div id="select_form" style="display:none;">
18
  <div class="wrap">
19
  <div>
20
  <div style="padding:15px 15px 0 15px;">
21
+ <h3 style="color:#5A5A5A!important; font-family:Georgia,Times New Roman,Times,serif!important; font-size:1.8em!important; font-weight:normal!important;">
22
+ <?php _e("Insert Content Block", 'custom-post-widget'); ?>
23
+ </h3>
24
+ <span>
25
+ <?php _e("Select a Content Block below to add it to your post or page.", 'custom-post-widget'); ?>
26
+ </span>
27
  </div>
28
  <div style="padding:15px 15px 0 15px;">
29
  <select id="add_content_block_id">
30
+ <option value="">
31
+ <?php _e("Select a Content Block", 'custom-post-widget'); ?>
32
+ </option>
33
  <?php query_posts('post_type=content_block&orderby=ID&order=ASC&showposts=-1');
34
+ if ( have_posts() ) : while ( have_posts() ) : the_post();
35
+ $currentID = get_the_ID();
36
+ if($currentID == $custom_post_id)
37
+ $extra = 'selected' and
38
+ $widgetExtraTitle = get_the_title();
39
+ else
40
+ $extra = '';
41
+ echo '<option value="'.$currentID.'" '.$extra.'>'.get_the_title().'</option>';
42
+ endwhile; else:
43
+ echo '<option value="empty">' . __('No content blocks available', 'custom-post-widget') . '</option>';
44
+ endif; ?>
45
+ </select>
46
+ <br />
 
47
  <div style="padding:15px;">
48
+ <input type="button" class="button-primary" value="<?php _e("Insert Content Block", 'custom-post-widget') ?>" onclick="InsertContentBlockForm();"/>
49
+ &nbsp;&nbsp;&nbsp; <a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;">
50
+ <?php _e("Cancel", 'custom-post-widget'); ?>
51
+ </a>
52
  </div>
53
  </div>
54
  </div>
55
  </div>
56
+ </div>
57
+ <?php } ?>
post-widget.php CHANGED
@@ -1,158 +1,141 @@
1
  <?php
2
 
3
  // First create the widget for the admin panel
4
- class custom_post_widget extends WP_Widget
5
- {
6
- function custom_post_widget()
7
- {
8
- $widget_ops = array('description' => __('Displays custom post content in a widget', 'custom-post-widget'));
9
- $this->WP_Widget('custom_post_widget', __('Content Block', 'custom-post-widget'), $widget_ops);
10
- }
11
-
12
- function form($instance)
13
- {
14
- $custom_post_id = esc_attr($instance['custom_post_id']);
15
- $show_custom_post_title = isset($instance['show_custom_post_title ']) ? $instance['show_custom_post_title '] : true;
16
-
17
- ?>
18
- <p>
19
- <label for="<?php echo $this->get_field_id('custom_post_id'); ?>"> <?php echo __('Content Block to Display:', 'custom-post-widget') ?>
20
- <select class="widefat" id="<?php echo $this->get_field_id('custom_post_id'); ?>" name="<?php echo $this->get_field_name('custom_post_id'); ?>">
21
- <?php query_posts('post_type=content_block&orderby=ID&order=ASC&showposts=-1');
22
- if ( have_posts() ) : while ( have_posts() ) : the_post();
23
- $currentID = get_the_ID();
24
- if($currentID == $custom_post_id)
25
- $extra = 'selected' and
26
- $widgetExtraTitle = get_the_title();
27
- else
28
- $extra = '';
29
- echo '<option value="'.$currentID.'" '.$extra.'>'.get_the_title().'</option>';
30
- endwhile; else:
31
- echo '<option value="empty">' . __('No content blocks available', 'custom-post-widget') . '</option>';
32
- endif;
33
- ?>
34
- </select>
35
- </label>
36
- </p>
37
- <?php ?>
38
- <input type="hidden" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $widgetExtraTitle; ?>" />
39
- <?php wp_reset_query(); ?>
40
- <p>
41
- <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_custom_post_title'], true ); ?> id="<?php echo $this->get_field_id( 'show_custom_post_title' ); ?>" name="<?php echo $this->get_field_name( 'show_custom_post_title' ); ?>" />
42
- <label for="<?php echo $this->get_field_id( 'show_custom_post_title' ); ?>"><?php echo __('Show Post Title', 'custom-post-widget') ?></label>
43
- </p>
44
-
45
- <?php
46
- }
47
-
48
- function update($new_instance, $old_instance)
49
- {
50
- $instance = $old_instance;
51
- $instance['custom_post_id'] = strip_tags($new_instance['custom_post_id']);
52
- $instance['show_custom_post_title'] = $new_instance['show_custom_post_title'];
53
-
54
- return $instance;
55
- }
56
-
57
- function widget($args, $instance)
58
- {
59
- extract($args);
60
-
61
- $custom_post_id = ( $instance['custom_post_id'] != '' ) ? esc_attr($instance['custom_post_id']) : __('Find', 'custom-post-widget');
62
-
63
- /* Variables from the widget settings. */
64
- $show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : false;
65
-
66
- $content_post = get_post($custom_post_id);
67
- $content = $content_post->post_content;
68
- $content = apply_filters('the_content', $content);
69
- $content = str_replace(']]>', ']]>', $content);
70
-
71
- echo $before_widget;
72
- if ( $show_custom_post_title )
73
- {
74
- echo $before_title . $content_post->post_title . $after_title; // This is the line that displays the title (only if show title is set)
75
- }
76
- echo $content; // This is where the actual content of the custom post is being displayed
77
- echo $after_widget;
78
-
79
- }
80
  }
81
 
82
  // Create the Content Block custom post type
83
  add_action('init', 'my_content_block_post_type_init');
84
 
85
- function my_content_block_post_type_init()
86
- {
87
- $labels = array(
88
- 'name' => _x('Content Blocks', 'post type general name', 'custom-post-widget'),
89
- 'singular_name' => _x('Content Block', 'post type singular name', 'custom-post-widget'),
90
- 'plural_name' => _x('Content Blocks', 'post type plural name', 'custom-post-widget'),
91
- 'add_new' => _x('Add Content Block', 'block', 'custom-post-widget'),
92
- 'add_new_item' => __('Add New Content Block', 'custom-post-widget'),
93
- 'edit_item' => __('Edit Content Block', 'custom-post-widget'),
94
- 'new_item' => __('New Content Block', 'custom-post-widget'),
95
- 'view_item' => __('View Content Block', 'custom-post-widget'),
96
- 'search_items' => __('Search Content Blocks', 'custom-post-widget'),
97
- 'not_found' => __('No Content Blocks Found', 'custom-post-widget'),
98
- 'not_found_in_trash' => __('No Content Blocks found in Trash', 'custom-post-widget'),
99
- 'parent_item_colon' => ''
100
- );
101
- $options = array(
102
- 'labels' => $labels,
103
- 'public' => false,
104
- 'publicly_queryable' => false,
105
- 'exclude_from_search' => true,
106
- 'show_ui' => true,
107
- 'query_var' => true,
108
- 'rewrite' => true,
109
- 'capability_type' => 'post',
110
- 'hierarchical' => false,
111
- 'menu_position' => null,
112
- 'supports' => array('title','editor','revisions','thumbnail','author')
113
- );
114
- register_post_type('content_block',$options);
115
- }
116
-
117
-
118
  // Add custom styles to admin screen and menu
119
  add_action('admin_head', 'content_block_header');
120
 
121
- function content_block_header() {
122
-
123
- global $post_type; ?>
124
-
125
- <style type="text/css"><!--
126
- <?php if (($post_type == 'content_block')) : ?>
127
- #icon-edit { background:transparent url('<?php echo CUSTOM_POST_WIDGET_URL; ?>images/contentblock-32.png') no-repeat 0 0 !important; }
128
- <?php endif; ?>
129
- #adminmenu #menu-posts-contentblock div.wp-menu-image{background:transparent url('<?php echo CUSTOM_POST_WIDGET_URL;?>images/contentblock.png') no-repeat center -32px;}
130
- #adminmenu #menu-posts-contentblock:hover div.wp-menu-image,#adminmenu #menu-posts-contentblock.wp-has-current-submenu div.wp-menu-image{background:transparent url('<?php echo CUSTOM_POST_WIDGET_URL;?>images/contentblock.png') no-repeat center 0px;}
131
- --></style><?php
132
-
133
- }
134
 
135
  add_filter('post_updated_messages', 'content_block_messages');
136
-
137
- function content_block_messages( $messages ) {
138
-
139
- $messages['content_block'] = array(
140
- 0 => '',
141
- 1 => sprintf( __('Content Block updated. <a href="%s">View Content Block</a>', 'custom-post-widget'), esc_url( get_permalink(isset($post->ID) ? $post->ID : null) ) ),
142
- 2 => __('Custom field updated.', 'custom-post-widget'),
143
- 3 => __('Custom field deleted.', 'custom-post-widget'),
144
- 4 => __('Content Block updated.', 'custom-post-widget'),
145
- 5 => isset($_GET['revision']) ? sprintf( __('Content Block restored to revision from %s', 'custom-post-widget'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
146
- 6 => sprintf( __('Content Block published. <a href="%s">View Content Block</a>', 'custom-post-widget'), esc_url( get_permalink(isset($post->ID) ? $post->ID : null) ) ),
147
- 7 => __('Block saved.', 'custom-post-widget'),
148
- 8 => sprintf( __('Content Block submitted. <a target="_blank" href="%s">Preview Content Block</a>', 'custom-post-widget'), esc_url( add_query_arg( 'preview', 'true', get_permalink(isset($post->ID) ? $post->ID : null) ) ) ),
149
- 9 => sprintf( __('Content Block scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview block</a>', 'custom-post-widget'), date_i18n( __( 'M j, Y @ G:i' , 'custom-post-widget'), strtotime(isset($post->post_date) ? $post->post_date : null) ), esc_url( get_permalink(isset($post->ID) ? $post->ID : null) ) ),
150
- 10 => sprintf( __('Content Block draft updated. <a target="_blank" href="%s">Preview Content Block</a>', 'custom-post-widget'), esc_url( add_query_arg( 'preview', 'true', get_permalink(isset($post->ID) ? $post->ID : null) ) ) ),
151
- );
152
-
153
- return $messages;
154
- }
155
-
156
  // Add the ability to display the content block in a reqular post using a shortcode
157
  function custom_post_widget_shortcode($atts) {
158
  extract(shortcode_atts(array(
@@ -182,9 +165,9 @@ add_shortcode('content_block', 'custom_post_widget_shortcode');
182
 
183
  // Add button above editor
184
  function add_content_block_icon($initcontext) {
185
- return $initcontext.
186
- '<a id="add_content_block" class="thickbox" title="' . __("Add Content Block", 'custom-post-widget') . '" href="' . CUSTOM_POST_WIDGET_URL . 'popup.php#TB_inline?width=450&inlineId=select_form">
187
- <img onclick="return false;" alt="' . __("Add Content Block", 'custom-post-widget') . '" src="' . CUSTOM_POST_WIDGET_URL . 'images/contentblock-13.png">
188
  </a>';
189
  }
190
 
@@ -193,8 +176,7 @@ add_filter('media_buttons_context', 'add_content_block_icon');
193
  require_once( CUSTOM_POST_WIDGET_DIR . '/popup.php' );
194
 
195
  if(!defined( 'CUSTOM_POST_WIDGET_CURRENT_PAGE' ))
196
- define( 'CUSTOM_POST_WIDGET_CURRENT_PAGE', basename($_SERVER['PHP_SELF']) );
197
-
198
  if(in_array(CUSTOM_POST_WIDGET_CURRENT_PAGE, array('post.php', 'page.php', 'page-new.php', 'post-new.php'))) {
199
  add_action('admin_footer', 'add_mce_popup');
200
  }
1
  <?php
2
 
3
  // First create the widget for the admin panel
4
+ class custom_post_widget extends WP_Widget {
5
+ function custom_post_widget() {
6
+ $widget_ops = array('description' => __('Displays custom post content in a widget', 'custom-post-widget'));
7
+ $this->WP_Widget('custom_post_widget', __('Content Block', 'custom-post-widget'), $widget_ops);
8
+ }
9
+
10
+ function form($instance) {
11
+ $custom_post_id = esc_attr($instance['custom_post_id']);
12
+ $show_custom_post_title = isset($instance['show_custom_post_title ']) ? $instance['show_custom_post_title '] : true; ?>
13
+
14
+ <p>
15
+ <label for="<?php echo $this->get_field_id('custom_post_id'); ?>"> <?php echo __('Content Block to Display:', 'custom-post-widget') ?>
16
+ <select class="widefat" id="<?php echo $this->get_field_id('custom_post_id'); ?>" name="<?php echo $this->get_field_name('custom_post_id'); ?>">
17
+ <?php query_posts('post_type=content_block&orderby=ID&order=ASC&showposts=-1');
18
+ if ( have_posts() ) : while ( have_posts() ) : the_post();
19
+ $currentID = get_the_ID();
20
+ if($currentID == $custom_post_id)
21
+ $extra = 'selected' and
22
+ $widgetExtraTitle = get_the_title();
23
+ else
24
+ $extra = '';
25
+ echo '<option value="'.$currentID.'" '.$extra.'>'.get_the_title().'</option>';
26
+ endwhile; else:
27
+ echo '<option value="empty">' . __('No content blocks available', 'custom-post-widget') . '</option>';
28
+ endif; ?>
29
+ </select>
30
+ </label>
31
+ </p>
32
+ <input type="hidden" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $widgetExtraTitle; ?>" />
33
+ <?php wp_reset_query(); ?>
34
+ <p>
35
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_custom_post_title'], true ); ?> id="<?php echo $this->get_field_id( 'show_custom_post_title' ); ?>" name="<?php echo $this->get_field_name( 'show_custom_post_title' ); ?>" />
36
+ <label for="<?php echo $this->get_field_id( 'show_custom_post_title' ); ?>"><?php echo __('Show Post Title', 'custom-post-widget') ?></label>
37
+ </p> <?php
38
+ }
39
+
40
+ function update($new_instance, $old_instance) {
41
+ $instance = $old_instance;
42
+ $instance['custom_post_id'] = strip_tags($new_instance['custom_post_id']);
43
+ $instance['show_custom_post_title'] = $new_instance['show_custom_post_title'];
44
+ return $instance;
45
+ }
46
+
47
+ function widget($args, $instance) {
48
+ global $post;
49
+ extract($args);
50
+ $custom_post_id = ( $instance['custom_post_id'] != '' ) ? esc_attr($instance['custom_post_id']) : __('Find', 'custom-post-widget');
51
+ /* Variables from the widget settings. */
52
+ $show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : false;
53
+ $old_post = &$post;
54
+ $post = $content_post = get_post($custom_post_id);
55
+ $content = $content_post->post_content;
56
+ $content = apply_filters('the_content', $content);
57
+ $content = str_replace(']]>', ']]>', $content);
58
+ echo $before_widget;
59
+ if ( $show_custom_post_title ) {
60
+ echo $before_title . $content_post->post_title . $after_title; // This is the line that displays the title (only if show title is set)
61
+ }
62
+ echo $content; // This is where the actual content of the custom post is being displayed
63
+ echo $after_widget;
64
+ $post = &$old_post;
65
+ }
66
+
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
 
69
  // Create the Content Block custom post type
70
  add_action('init', 'my_content_block_post_type_init');
71
 
72
+ function my_content_block_post_type_init() {
73
+ $labels = array(
74
+ 'name' => _x('Content Blocks', 'post type general name', 'custom-post-widget'),
75
+ 'singular_name' => _x('Content Block', 'post type singular name', 'custom-post-widget'),
76
+ 'plural_name' => _x('Content Blocks', 'post type plural name', 'custom-post-widget'),
77
+ 'add_new' => _x('Add Content Block', 'block', 'custom-post-widget'),
78
+ 'add_new_item' => __('Add New Content Block', 'custom-post-widget'),
79
+ 'edit_item' => __('Edit Content Block', 'custom-post-widget'),
80
+ 'new_item' => __('New Content Block', 'custom-post-widget'),
81
+ 'view_item' => __('View Content Block', 'custom-post-widget'),
82
+ 'search_items' => __('Search Content Blocks', 'custom-post-widget'),
83
+ 'not_found' => __('No Content Blocks Found', 'custom-post-widget'),
84
+ 'not_found_in_trash' => __('No Content Blocks found in Trash', 'custom-post-widget'),
85
+ 'parent_item_colon' => ''
86
+ );
87
+ $options = array(
88
+ 'labels' => $labels,
89
+ 'public' => false,
90
+ 'publicly_queryable' => false,
91
+ 'exclude_from_search' => true,
92
+ 'show_ui' => true,
93
+ 'query_var' => true,
94
+ 'rewrite' => true,
95
+ 'capability_type' => 'post',
96
+ 'hierarchical' => false,
97
+ 'menu_position' => null,
98
+ 'supports' => array('title','editor','revisions','thumbnail','author')
99
+ );
100
+ register_post_type('content_block',$options);
101
+ }
102
+
 
 
103
  // Add custom styles to admin screen and menu
104
  add_action('admin_head', 'content_block_header');
105
 
106
+ function content_block_header() {
107
+ global $post_type; ?>
108
+ <style type="text/css">
109
+ <!--
110
+ <?php if (($post_type == 'content_block')) : ?>
111
+ #icon-edit { background:transparent url('<?php echo CUSTOM_POST_WIDGET_URL; ?>images/contentblock-32.png') no-repeat 0 0 !important; }
112
+ <?php endif; ?>
113
+ #adminmenu #menu-posts-content_block div.wp-menu-image{background:transparent url('<?php echo CUSTOM_POST_WIDGET_URL;?>images/contentblock.png') no-repeat center -32px;}
114
+ #adminmenu #menu-posts-content_block:hover div.wp-menu-image,#adminmenu #menu-posts-content_block.wp-has-current-submenu div.wp-menu-image{background:transparent url('<?php echo CUSTOM_POST_WIDGET_URL;?>images/contentblock.png') no-repeat center 0px;}
115
+ -->
116
+ </style>
117
+ <?php
118
+ }
119
 
120
  add_filter('post_updated_messages', 'content_block_messages');
121
+
122
+ function content_block_messages( $messages ) {
123
+ $messages['content_block'] = array(
124
+ 0 => '',
125
+ 1 => sprintf( __('Content Block updated. <a href="%s">View Content Block</a>', 'custom-post-widget'), esc_url( get_permalink(isset($post->ID) ? $post->ID : null) ) ),
126
+ 2 => __('Custom field updated.', 'custom-post-widget'),
127
+ 3 => __('Custom field deleted.', 'custom-post-widget'),
128
+ 4 => __('Content Block updated.', 'custom-post-widget'),
129
+ 5 => isset($_GET['revision']) ? sprintf( __('Content Block restored to revision from %s', 'custom-post-widget'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
130
+ 6 => sprintf( __('Content Block published. <a href="%s">View Content Block</a>', 'custom-post-widget'), esc_url( get_permalink(isset($post->ID) ? $post->ID : null) ) ),
131
+ 7 => __('Block saved.', 'custom-post-widget'),
132
+ 8 => sprintf( __('Content Block submitted. <a target="_blank" href="%s">Preview Content Block</a>', 'custom-post-widget'), esc_url( add_query_arg( 'preview', 'true', get_permalink(isset($post->ID) ? $post->ID : null) ) ) ),
133
+ 9 => sprintf( __('Content Block scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview block</a>', 'custom-post-widget'), date_i18n( __( 'M j, Y @ G:i' , 'custom-post-widget'), strtotime(isset($post->post_date) ? $post->post_date : null) ), esc_url( get_permalink(isset($post->ID) ? $post->ID : null) ) ),
134
+ 10 => sprintf( __('Content Block draft updated. <a target="_blank" href="%s">Preview Content Block</a>', 'custom-post-widget'), esc_url( add_query_arg( 'preview', 'true', get_permalink(isset($post->ID) ? $post->ID : null) ) ) ),
135
+ );
136
+ return $messages;
137
+ }
138
+
 
 
139
  // Add the ability to display the content block in a reqular post using a shortcode
140
  function custom_post_widget_shortcode($atts) {
141
  extract(shortcode_atts(array(
165
 
166
  // Add button above editor
167
  function add_content_block_icon($initcontext) {
168
+ return $initcontext.
169
+ '<a id="add_content_block" style="text-decoration:none;" class="thickbox" title="' . __("Add Content Block", 'custom-post-widget') . '" href="' . CUSTOM_POST_WIDGET_URL . 'popup.php?type=add_mce_popup&amp;TB_inline=true&amp;inlineId=select_form">
170
+ <img onclick="return false;" alt="' . __("Add Content Block", 'custom-post-widget') . '" src="' . CUSTOM_POST_WIDGET_URL . 'images/contentblock-13.png">
171
  </a>';
172
  }
173
 
176
  require_once( CUSTOM_POST_WIDGET_DIR . '/popup.php' );
177
 
178
  if(!defined( 'CUSTOM_POST_WIDGET_CURRENT_PAGE' ))
179
+ define( 'CUSTOM_POST_WIDGET_CURRENT_PAGE', basename($_SERVER['PHP_SELF']) );
 
180
  if(in_array(CUSTOM_POST_WIDGET_CURRENT_PAGE, array('post.php', 'page.php', 'page-new.php', 'post-new.php'))) {
181
  add_action('admin_footer', 'add_mce_popup');
182
  }
readme.txt CHANGED
@@ -4,8 +4,8 @@ Author URI: http://www.vanderwijk.com/
4
  Donate link: http://www.vanderwijk.com/wordpress/support/
5
  Tags: custom-post, widget, sidebar
6
  Requires at least: 2.9.2
7
- Tested up to: 3.1
8
- Stable tag: 1.8.1
9
 
10
  This plugin enables you to display the content of a custom post type called Content Block in a sidebar widget.
11
 
@@ -103,6 +103,12 @@ This release fixes all the debug error messages Yoast discovered when [reviewing
103
  = 1.8 =
104
  Added a button above to content editor to make it easier to add the shortcode (no need for looking up the id).
105
 
 
 
 
 
 
 
106
  == Upgrade Notice ==
107
 
108
  = 1.8 =
4
  Donate link: http://www.vanderwijk.com/wordpress/support/
5
  Tags: custom-post, widget, sidebar
6
  Requires at least: 2.9.2
7
+ Tested up to: 3.2
8
+ Stable tag: 1.8.2
9
 
10
  This plugin enables you to display the content of a custom post type called Content Block in a sidebar widget.
11
 
103
  = 1.8 =
104
  Added a button above to content editor to make it easier to add the shortcode (no need for looking up the id).
105
 
106
+ = 1.8.2 =
107
+ Updated German translation and various bugfixes.
108
+
109
+ = 1.8.3 =
110
+ The widget now emulates the $post loop. This means you can now make use of WordPress functionality such as inserting a [gallery]. Thanks to Jari Pennanen for providing the code.
111
+
112
  == Upgrade Notice ==
113
 
114
  = 1.8 =