Content Blocks (Custom Post Widget) - Version 1.9

Version Description

The content blocks can now be translated using the WPML plugin, thanks to Jonathan Liuti (http://unboxed-logic.com/). Thanks to Vitaliy Kaplya (http://www.dasayt.com/) a Russian translation has been added to the plugin.

=

Download this release

Release Info

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

Code changes from version 1.8.6 to 1.9

Files changed (3) hide show
  1. custom-post-widget.php +47 -48
  2. post-widget.php +193 -189
  3. readme.txt +8 -5
custom-post-widget.php CHANGED
@@ -1,49 +1,48 @@
1
- <?php
2
- /*
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.6
7
- Author: Johan van der Wijk
8
- Author URI: http://www.vanderwijk.com
9
- License: GPL2
10
-
11
- Release notes: Version 1.8.6 Minor bugfix.
12
-
13
- Copyright 2011 Johan van der Wijk (email: info@vanderwijk.com)
14
-
15
- This program is free software; you can redistribute it and/or modify
16
- it under the terms of the GNU General Public License, version 2, as
17
- published by the Free Software Foundation.
18
-
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
-
24
- You should have received a copy of the GNU General Public License
25
- along with this program; if not, write to the Free Software
26
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
- */
28
-
29
- // Set constant path to the custom-post-widget plugin directory.
30
- define( 'CUSTOM_POST_WIDGET_DIR', plugin_dir_path( __FILE__ ) );
31
- define( 'CUSTOM_POST_WIDGET_URL', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),'',plugin_basename(__FILE__)) );
32
-
33
- // Launch the plugin.
34
- add_action( 'plugins_loaded', 'custom_post_widget_plugin_init' );
35
-
36
- // Load the required files needed for the plugin to run in the proper order and add needed functions to the required hooks.
37
- function custom_post_widget_plugin_init() {
38
- // Load the translation of the plugin.
39
- load_plugin_textdomain( 'custom-post-widget', false, 'custom-post-widget/languages' );
40
- add_action( 'widgets_init', 'custom_post_widget_load_widgets' );
41
- }
42
-
43
- // Loads the widgets packaged with the plugin.
44
- function custom_post_widget_load_widgets() {
45
- require_once( CUSTOM_POST_WIDGET_DIR . '/post-widget.php' );
46
- register_widget( 'custom_post_widget' );
47
- }
48
-
49
  ?>
1
+ <?php
2
+ /*
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.9
7
+ Author: Johan van der Wijk
8
+ Author URI: http://www.vanderwijk.com
9
+ License: GPL2
10
+
11
+ Release notes: Version 1.9 Added WPMU plugin compatibility and Russian translation.
12
+
13
+ Copyright 2011 Johan van der Wijk (email: info@vanderwijk.com)
14
+
15
+ This program is free software; you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License, version 2, as
17
+ published by the Free Software Foundation.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+
29
+ // Set constant path to the custom-post-widget plugin directory.
30
+ define( 'CUSTOM_POST_WIDGET_DIR', plugin_dir_path( __FILE__ ) );
31
+ define( 'CUSTOM_POST_WIDGET_URL', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),'',plugin_basename(__FILE__)) );
32
+
33
+ // Launch the plugin.
34
+ add_action( 'plugins_loaded', 'custom_post_widget_plugin_init' );
35
+
36
+ // Load the required files needed for the plugin to run in the proper order and add needed functions to the required hooks.
37
+ function custom_post_widget_plugin_init() {
38
+ // Load the translation of the plugin.
39
+ load_plugin_textdomain( 'custom-post-widget', false, 'custom-post-widget/languages' );
40
+ add_action( 'widgets_init', 'custom_post_widget_load_widgets' );
41
+ }
42
+
43
+ // Loads the widgets packaged with the plugin.
44
+ function custom_post_widget_load_widgets() {
45
+ require_once( CUSTOM_POST_WIDGET_DIR . '/post-widget.php' );
46
+ register_widget( 'custom_post_widget' );
47
+ }
 
48
  ?>
post-widget.php CHANGED
@@ -1,190 +1,194 @@
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
-
33
- <input type="hidden" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $widgetExtraTitle; ?>" />
34
-
35
- <p>
36
- <?php
37
- echo '<a href="post.php?post=' . $custom_post_id . '&action=edit">Edit Content Block</a>' ;
38
- ?>
39
- </p>
40
-
41
- <?php wp_reset_query(); ?>
42
-
43
- <p>
44
- <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' ); ?>" />
45
- <label for="<?php echo $this->get_field_id( 'show_custom_post_title' ); ?>"><?php echo __('Show Post Title', 'custom-post-widget') ?></label>
46
- </p> <?php
47
- }
48
-
49
- function update($new_instance, $old_instance) {
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
- return $instance;
54
- }
55
-
56
- function widget($args, $instance) {
57
- extract($args);
58
- $custom_post_id = ( $instance['custom_post_id'] != '' ) ? esc_attr($instance['custom_post_id']) : __('Find', 'custom-post-widget');
59
- // Variables from the widget settings.
60
- $show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : false;
61
- $content_post = get_post($custom_post_id);
62
- $content = $content_post->post_content;
63
- $content = apply_filters('the_content', $content);
64
- echo $before_widget;
65
- if ( $show_custom_post_title ) {
66
- echo $before_title . $content_post->post_title . $after_title; // This is the line that displays the title (only if show title is set)
67
- }
68
- echo do_shortcode($content); // This is where the actual content of the custom post is being displayed
69
- echo $after_widget;
70
- }
71
-
72
- }
73
-
74
- // Create the Content Block custom post type
75
- add_action('init', 'my_content_block_post_type_init');
76
-
77
- function my_content_block_post_type_init() {
78
- $labels = array(
79
- 'name' => _x('Content Blocks', 'post type general name', 'custom-post-widget'),
80
- 'singular_name' => _x('Content Block', 'post type singular name', 'custom-post-widget'),
81
- 'plural_name' => _x('Content Blocks', 'post type plural name', 'custom-post-widget'),
82
- 'add_new' => _x('Add Content Block', 'block', 'custom-post-widget'),
83
- 'add_new_item' => __('Add New Content Block', 'custom-post-widget'),
84
- 'edit_item' => __('Edit Content Block', 'custom-post-widget'),
85
- 'new_item' => __('New Content Block', 'custom-post-widget'),
86
- 'view_item' => __('View Content Block', 'custom-post-widget'),
87
- 'search_items' => __('Search Content Blocks', 'custom-post-widget'),
88
- 'not_found' => __('No Content Blocks Found', 'custom-post-widget'),
89
- 'not_found_in_trash' => __('No Content Blocks found in Trash', 'custom-post-widget'),
90
- 'parent_item_colon' => ''
91
- );
92
- $options = array(
93
- 'labels' => $labels,
94
- 'public' => false,
95
- 'publicly_queryable' => false,
96
- 'exclude_from_search' => true,
97
- 'show_ui' => true,
98
- 'query_var' => true,
99
- 'rewrite' => true,
100
- 'capability_type' => 'post',
101
- 'hierarchical' => false,
102
- 'menu_position' => null,
103
- 'supports' => array('title','editor','revisions','thumbnail','author')
104
- );
105
- register_post_type('content_block',$options);
106
- }
107
-
108
- // Add custom styles to admin screen and menu
109
- add_action('admin_head', 'content_block_header');
110
-
111
- function content_block_header() {
112
- global $post_type; ?>
113
- <style type="text/css">
114
- <!--
115
- <?php if (($post_type == 'content_block')) : ?>
116
- #icon-edit { background:transparent url('<?php echo CUSTOM_POST_WIDGET_URL; ?>images/contentblock-32.png') no-repeat 0 0 !important;}
117
- #minor-publishing-actions { display:none; /* Hide the Save Draft and Preview buttons */}
118
- <?php endif; ?>
119
- #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;}
120
- #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;}
121
- -->
122
- </style>
123
- <?php
124
- }
125
-
126
- add_filter('post_updated_messages', 'content_block_messages');
127
-
128
- function content_block_messages( $messages ) {
129
- $messages['content_block'] = array(
130
- 0 => '',
131
- 1 => current_user_can( 'edit_theme_options' ) ? sprintf( __('Content Block updated. <a href="%s">Manage Widgets</a>', 'custom-post-widget'), esc_url( 'widgets.php' ) ) : sprintf( __('Content Block updated.', 'custom-post-widget'), esc_url( 'widgets.php' ) ),
132
- 2 => __('Custom field updated.', 'custom-post-widget'),
133
- 3 => __('Custom field deleted.', 'custom-post-widget'),
134
- 4 => __('Content Block updated.', 'custom-post-widget'),
135
- 5 => isset($_GET['revision']) ? sprintf( __('Content Block restored to revision from %s', 'custom-post-widget'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
136
- 6 => current_user_can( 'edit_theme_options' ) ? sprintf( __('Content Block published. <a href="%s">Manage Widgets</a>', 'custom-post-widget'), esc_url( 'widgets.php' ) ) : sprintf( __('Content Block published.', 'custom-post-widget'), esc_url( 'widgets.php' ) ),
137
- 7 => __('Block saved.', 'custom-post-widget'),
138
- 8 => current_user_can( 'edit_theme_options' ) ? sprintf( __('Content Block submitted. <a href="%s">Manage Widgets</a>', 'custom-post-widget'), esc_url( 'widgets.php' ) ) : sprintf( __('Content Block submitted.', 'custom-post-widget'), esc_url( 'widgets.php' ) ),
139
- 9 => sprintf( __('Content Block scheduled for: <strong>%1$s</strong>.', 'custom-post-widget'), date_i18n( __( 'M j, Y @ G:i' , 'custom-post-widget'), strtotime(isset($post->post_date) ? $post->post_date : null) ), esc_url( 'widgets.php' ) ),
140
- 10 => current_user_can( 'edit_theme_options' ) ? sprintf( __('Content Block draft updated. <a href="%s">Manage Widgets</a>', 'custom-post-widget'), esc_url( 'widgets.php' ) ) : sprintf( __('Content Block draft updated.', 'custom-post-widget'), esc_url( 'widgets.php' ) ),
141
- );
142
- return $messages;
143
- }
144
-
145
- // Add the ability to display the content block in a reqular post using a shortcode
146
- function custom_post_widget_shortcode($atts) {
147
- extract(shortcode_atts(array(
148
- 'id' => '',
149
- ), $atts));
150
-
151
- $content = "";
152
-
153
- if($id != "")
154
- {
155
- $args = array(
156
- 'post__in' => array($id),
157
- 'post_type' => 'content_block',
158
- );
159
-
160
- $content_post = get_posts($args);
161
-
162
- foreach( $content_post as $post ) :
163
- $content .= apply_filters('the_content', $post->post_content);
164
- endforeach;
165
- }
166
-
167
- return $content;
168
- }
169
-
170
- add_shortcode('content_block', 'custom_post_widget_shortcode');
171
-
172
- // Add button above editor
173
- function add_content_block_icon($initcontext) {
174
- return $initcontext.
175
- '<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_content_block_popup&amp;TB_inline=true&amp;inlineId=content_block_form">
176
- <img onclick="return false;" alt="' . __("Add Content Block", 'custom-post-widget') . '" src="' . CUSTOM_POST_WIDGET_URL . 'images/contentblock-13.png">
177
- </a>';
178
- }
179
-
180
- add_filter('media_buttons_context', 'add_content_block_icon');
181
-
182
- require_once( CUSTOM_POST_WIDGET_DIR . '/popup.php' );
183
-
184
- if(!defined( 'CUSTOM_POST_WIDGET_CURRENT_PAGE' ))
185
- define( 'CUSTOM_POST_WIDGET_CURRENT_PAGE', basename($_SERVER['PHP_SELF']) );
186
- if(in_array(CUSTOM_POST_WIDGET_CURRENT_PAGE, array('post.php', 'page.php', 'page-new.php', 'post-new.php'))) {
187
- add_action('admin_footer', 'add_content_block_popup');
188
- }
189
-
 
 
 
 
190
  ?>
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
+
33
+ <input type="hidden" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $widgetExtraTitle; ?>" />
34
+
35
+ <p>
36
+ <?php
37
+ echo '<a href="post.php?post=' . $custom_post_id . '&action=edit">Edit Content Block</a>' ;
38
+ ?>
39
+ </p>
40
+
41
+ <?php wp_reset_query(); ?>
42
+
43
+ <p>
44
+ <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' ); ?>" />
45
+ <label for="<?php echo $this->get_field_id( 'show_custom_post_title' ); ?>"><?php echo __('Show Post Title', 'custom-post-widget') ?></label>
46
+ </p> <?php
47
+ }
48
+
49
+ function update($new_instance, $old_instance) {
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
+ return $instance;
54
+ }
55
+
56
+ function widget($args, $instance) {
57
+ extract($args);
58
+ $custom_post_id = ( $instance['custom_post_id'] != '' ) ? esc_attr($instance['custom_post_id']) : __('Find', 'custom-post-widget');
59
+ // Add support for WPML Plugin.
60
+ if ( function_exists( 'icl_object_id' ) ){
61
+ $custom_post_id = icl_object_id( $custom_post_id, 'content_block', true );
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
+ $content_post = get_post($custom_post_id);
66
+ $content = $content_post->post_content;
67
+ $content = apply_filters('the_content', $content);
68
+ echo $before_widget;
69
+ if ( $show_custom_post_title ) {
70
+ echo $before_title . apply_filters('widget_title',$content_post->post_title) . $after_title; // This is the line that displays the title (only if show title is set)
71
+ }
72
+ echo do_shortcode($content); // This is where the actual content of the custom post is being displayed
73
+ echo $after_widget;
74
+ }
75
+
76
+ }
77
+
78
+ // Create the Content Block custom post type
79
+ add_action('init', 'my_content_block_post_type_init');
80
+
81
+ function my_content_block_post_type_init() {
82
+ $labels = array(
83
+ 'name' => _x('Content Blocks', 'post type general name', 'custom-post-widget'),
84
+ 'singular_name' => _x('Content Block', 'post type singular name', 'custom-post-widget'),
85
+ 'plural_name' => _x('Content Blocks', 'post type plural name', 'custom-post-widget'),
86
+ 'add_new' => _x('Add Content Block', 'block', 'custom-post-widget'),
87
+ 'add_new_item' => __('Add New Content Block', 'custom-post-widget'),
88
+ 'edit_item' => __('Edit Content Block', 'custom-post-widget'),
89
+ 'new_item' => __('New Content Block', 'custom-post-widget'),
90
+ 'view_item' => __('View Content Block', 'custom-post-widget'),
91
+ 'search_items' => __('Search Content Blocks', 'custom-post-widget'),
92
+ 'not_found' => __('No Content Blocks Found', 'custom-post-widget'),
93
+ 'not_found_in_trash' => __('No Content Blocks found in Trash', 'custom-post-widget'),
94
+ 'parent_item_colon' => ''
95
+ );
96
+ $options = array(
97
+ 'labels' => $labels,
98
+ 'public' => false,
99
+ 'publicly_queryable' => false,
100
+ 'exclude_from_search' => true,
101
+ 'show_ui' => true,
102
+ 'query_var' => true,
103
+ 'rewrite' => true,
104
+ 'capability_type' => 'post',
105
+ 'hierarchical' => false,
106
+ 'menu_position' => null,
107
+ 'supports' => array('title','editor','revisions','thumbnail','author')
108
+ );
109
+ register_post_type('content_block',$options);
110
+ }
111
+
112
+ // Add custom styles to admin screen and menu
113
+ add_action('admin_head', 'content_block_header');
114
+
115
+ function content_block_header() {
116
+ global $post_type; ?>
117
+ <style type="text/css">
118
+ <!--
119
+ <?php if (($post_type == 'content_block')) : ?>
120
+ #icon-edit { background:transparent url('<?php echo CUSTOM_POST_WIDGET_URL; ?>images/contentblock-32.png') no-repeat 0 0 !important;}
121
+ #minor-publishing-actions { display:none; /* Hide the Save Draft and Preview buttons */}
122
+ <?php endif; ?>
123
+ #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;}
124
+ #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;}
125
+ -->
126
+ </style>
127
+ <?php
128
+ }
129
+
130
+ add_filter('post_updated_messages', 'content_block_messages');
131
+
132
+ function content_block_messages( $messages ) {
133
+ $messages['content_block'] = array(
134
+ 0 => '',
135
+ 1 => current_user_can( 'edit_theme_options' ) ? sprintf( __('Content Block updated. <a href="%s">Manage Widgets</a>', 'custom-post-widget'), esc_url( 'widgets.php' ) ) : sprintf( __('Content Block updated.', 'custom-post-widget'), esc_url( 'widgets.php' ) ),
136
+ 2 => __('Custom field updated.', 'custom-post-widget'),
137
+ 3 => __('Custom field deleted.', 'custom-post-widget'),
138
+ 4 => __('Content Block updated.', 'custom-post-widget'),
139
+ 5 => isset($_GET['revision']) ? sprintf( __('Content Block restored to revision from %s', 'custom-post-widget'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
140
+ 6 => current_user_can( 'edit_theme_options' ) ? sprintf( __('Content Block published. <a href="%s">Manage Widgets</a>', 'custom-post-widget'), esc_url( 'widgets.php' ) ) : sprintf( __('Content Block published.', 'custom-post-widget'), esc_url( 'widgets.php' ) ),
141
+ 7 => __('Block saved.', 'custom-post-widget'),
142
+ 8 => current_user_can( 'edit_theme_options' ) ? sprintf( __('Content Block submitted. <a href="%s">Manage Widgets</a>', 'custom-post-widget'), esc_url( 'widgets.php' ) ) : sprintf( __('Content Block submitted.', 'custom-post-widget'), esc_url( 'widgets.php' ) ),
143
+ 9 => sprintf( __('Content Block scheduled for: <strong>%1$s</strong>.', 'custom-post-widget'), date_i18n( __( 'M j, Y @ G:i' , 'custom-post-widget'), strtotime(isset($post->post_date) ? $post->post_date : null) ), esc_url( 'widgets.php' ) ),
144
+ 10 => current_user_can( 'edit_theme_options' ) ? sprintf( __('Content Block draft updated. <a href="%s">Manage Widgets</a>', 'custom-post-widget'), esc_url( 'widgets.php' ) ) : sprintf( __('Content Block draft updated.', 'custom-post-widget'), esc_url( 'widgets.php' ) ),
145
+ );
146
+ return $messages;
147
+ }
148
+
149
+ // Add the ability to display the content block in a reqular post using a shortcode
150
+ function custom_post_widget_shortcode($atts) {
151
+ extract(shortcode_atts(array(
152
+ 'id' => '',
153
+ 'class' => 'content_block'
154
+ ), $atts));
155
+
156
+ $content = "";
157
+
158
+ if($id != "") {
159
+ $args = array(
160
+ 'post__in' => array($id),
161
+ 'post_type' => 'content_block',
162
+ );
163
+
164
+ $content_post = get_posts($args);
165
+
166
+ foreach( $content_post as $post ) :
167
+ $content .= '<div class="'. esc_attr($class) .'">';
168
+ $content .= apply_filters('the_content', $post->post_content);
169
+ $content .= '</div>';
170
+ endforeach;
171
+ }
172
+
173
+ return $content;
174
+ }
175
+ add_shortcode('content_block', 'custom_post_widget_shortcode');
176
+
177
+ // Add button above editor
178
+ function add_content_block_icon($initcontext) {
179
+ return $initcontext.
180
+ '<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_content_block_popup&amp;TB_inline=true&amp;inlineId=content_block_form">
181
+ <img onclick="return false;" alt="' . __("Add Content Block", 'custom-post-widget') . '" src="' . CUSTOM_POST_WIDGET_URL . 'images/contentblock-13.png">
182
+ </a>';
183
+ }
184
+
185
+ add_filter('media_buttons_context', 'add_content_block_icon');
186
+
187
+ require_once( CUSTOM_POST_WIDGET_DIR . '/popup.php' );
188
+
189
+ if(!defined( 'CUSTOM_POST_WIDGET_CURRENT_PAGE' ))
190
+ define( 'CUSTOM_POST_WIDGET_CURRENT_PAGE', basename($_SERVER['PHP_SELF']) );
191
+ if(in_array(CUSTOM_POST_WIDGET_CURRENT_PAGE, array('post.php', 'page.php', 'page-new.php', 'post-new.php'))) {
192
+ add_action('admin_footer', 'add_content_block_popup');
193
+ }
194
  ?>
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: vanderwijk
3
  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.3
8
- Stable tag: 1.8.6
9
 
10
  This plugin enables you to display the content of a custom post type called Content Block in a sidebar widget.
11
 
@@ -91,8 +91,7 @@ Now the title of the content block is displayed in the admin interface to make i
91
  The plugin has been translated into Dutch and German. Hat tip: Caspar H&uuml;binger - glueckpress.com
92
 
93
  = 1.5 =
94
- Thanks to Caspar Huebinger the plugin
95
- now has its own icon and as requested by Stephen James the author field has been added to the Content Block edit screen.
96
 
97
  = 1.6 =
98
  The Custom Post Widget plugin is now using the more efficient get_post instead of query_posts to display the content block on the page. A code example for this change has been graciously provided by Paul de Wouters.
@@ -119,6 +118,10 @@ This release is to fix an issue with the WordPress plugin repository.
119
  = 1.8.6 =
120
  Minor bugfix for edit link in widget.
121
 
 
 
 
 
122
  == Upgrade Notice ==
123
 
124
  = 1.8 =
2
  Contributors: vanderwijk
3
  Author URI: http://www.vanderwijk.com/
4
  Donate link: http://www.vanderwijk.com/wordpress/support/
5
+ Tags: custom-post, widget, sidebar, content block, content, custom, post, shortcode
6
  Requires at least: 2.9.2
7
+ Tested up to: 3.3.1
8
+ Stable tag: 1.9
9
 
10
  This plugin enables you to display the content of a custom post type called Content Block in a sidebar widget.
11
 
91
  The plugin has been translated into Dutch and German. Hat tip: Caspar H&uuml;binger - glueckpress.com
92
 
93
  = 1.5 =
94
+ Thanks to Caspar Huebinger the plugin now has its own icon and as requested by Stephen James the author field has been added to the Content Block edit screen.
 
95
 
96
  = 1.6 =
97
  The Custom Post Widget plugin is now using the more efficient get_post instead of query_posts to display the content block on the page. A code example for this change has been graciously provided by Paul de Wouters.
118
  = 1.8.6 =
119
  Minor bugfix for edit link in widget.
120
 
121
+ = 1.9 =
122
+ The content blocks can now be translated using the WPML plugin, thanks to Jonathan Liuti (http://unboxed-logic.com/).
123
+ Thanks to Vitaliy Kaplya (http://www.dasayt.com/) a Russian translation has been added to the plugin.
124
+
125
  == Upgrade Notice ==
126
 
127
  = 1.8 =