Content Blocks (Custom Post Widget) - Version 1.9.3

Version Description

Minor bugfix and added the French translation which was created by Alexandre Simard (http://brocheafoin.biz/).

=

Download this release

Release Info

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

Code changes from version 1.9.2 to 1.9.3

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.9.2
7
  Author: Johan van der Wijk
8
  Author URI: http://www.vanderwijk.com
9
  License: GPL2
10
 
11
- Release notes: Version 1.9.2 Added Polish translation.
12
 
13
  Copyright 2012 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.9.3
7
  Author: Johan van der Wijk
8
  Author URI: http://www.vanderwijk.com
9
  License: GPL2
10
 
11
+ Release notes: Version 1.9.3 Added French translation and minor bugfix.
12
 
13
  Copyright 2012 Johan van der Wijk (email: info@vanderwijk.com)
14
 
languages/custom-post-widget-fr_FR.mo ADDED
Binary file
languages/custom-post-widget-fr_FR.po ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Custom Post Widget v1.9.2\n"
4
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/custom-post-widget\n"
5
+ "POT-Creation-Date: 2011-02-25 20:06:24+00:00\n"
6
+ "PO-Revision-Date: 2012-06-21 17:06:30+0200\n"
7
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
+ "Language-Team: LANGUAGE <LL@li.org>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Poedit-Language: \n"
14
+ "X-Poedit-Country: \n"
15
+ "X-Poedit-SourceCharset: utf-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
17
+ "X-Poedit-Basepath: \n"
18
+ "X-Poedit-Bookmarks: \n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+ "X-Textdomain-Support: yes"
21
+
22
+ #: post-widget.php:6
23
+ #@ custom-post-widget
24
+ msgid "Displays custom post content in a widget"
25
+ msgstr "Affiche le contenu d'un bloc dans un widget."
26
+
27
+ #: post-widget.php:7
28
+ #@ custom-post-widget
29
+ msgid "Content Block"
30
+ msgstr "Bloc de contenu"
31
+
32
+ #: post-widget.php:15
33
+ #@ custom-post-widget
34
+ msgid "Content Block to Display:"
35
+ msgstr "Bloc de contenu à afficher:"
36
+
37
+ #: popup.php:43
38
+ #: post-widget.php:27
39
+ #@ custom-post-widget
40
+ msgid "No content blocks available"
41
+ msgstr "Aucun bloc disponible"
42
+
43
+ #: post-widget.php:45
44
+ #@ custom-post-widget
45
+ msgid "Show Post Title"
46
+ msgstr "Afficher le titre du bloc"
47
+
48
+ #: post-widget.php:58
49
+ #@ custom-post-widget
50
+ msgid "Find"
51
+ msgstr "Rechercher"
52
+
53
+ #: post-widget.php:83
54
+ #@ custom-post-widget
55
+ msgctxt "post type general name"
56
+ msgid "Content Blocks"
57
+ msgstr "Blocs de contenu"
58
+
59
+ #: post-widget.php:84
60
+ #@ custom-post-widget
61
+ msgctxt "post type singular name"
62
+ msgid "Content Block"
63
+ msgstr "Bloc de contenu"
64
+
65
+ #: post-widget.php:85
66
+ #@ custom-post-widget
67
+ msgctxt "post type plural name"
68
+ msgid "Content Blocks"
69
+ msgstr "Blocs de contenu"
70
+
71
+ #: post-widget.php:86
72
+ #@ custom-post-widget
73
+ msgctxt "block"
74
+ msgid "Add Content Block"
75
+ msgstr "Ajouter un bloc"
76
+
77
+ #: post-widget.php:87
78
+ #@ custom-post-widget
79
+ msgid "Add New Content Block"
80
+ msgstr "Ajouter un bloc"
81
+
82
+ #: post-widget.php:88
83
+ #@ custom-post-widget
84
+ msgid "Edit Content Block"
85
+ msgstr "Modifier le bloc"
86
+
87
+ #: post-widget.php:89
88
+ #@ custom-post-widget
89
+ msgid "New Content Block"
90
+ msgstr "Nouveau bloc"
91
+
92
+ #: post-widget.php:90
93
+ #@ custom-post-widget
94
+ msgid "View Content Block"
95
+ msgstr "Afficher le bloc"
96
+
97
+ #: post-widget.php:91
98
+ #@ custom-post-widget
99
+ msgid "Search Content Blocks"
100
+ msgstr "Recherche dans les blocs"
101
+
102
+ #: post-widget.php:92
103
+ #@ custom-post-widget
104
+ msgid "No Content Blocks Found"
105
+ msgstr "Aucun bloc trouvé"
106
+
107
+ #: post-widget.php:93
108
+ #@ custom-post-widget
109
+ msgid "No Content Blocks found in Trash"
110
+ msgstr "Aucun bloc trouvé dans la corbeille"
111
+
112
+ #: post-widget.php:136
113
+ #@ custom-post-widget
114
+ msgid "Custom field updated."
115
+ msgstr "Champ personnalisé mis à jour."
116
+
117
+ #: post-widget.php:137
118
+ #@ custom-post-widget
119
+ msgid "Custom field deleted."
120
+ msgstr "Champ personnalisé supprimé."
121
+
122
+ #: post-widget.php:135
123
+ #: post-widget.php:138
124
+ #@ custom-post-widget
125
+ msgid "Content Block updated."
126
+ msgstr "Bloc de contenu mis à jour."
127
+
128
+ #: post-widget.php:139
129
+ #, php-format
130
+ #@ custom-post-widget
131
+ msgid "Content Block restored to revision from %s"
132
+ msgstr "Bloc de contenu restauré à partir de la révision %s"
133
+
134
+ #: post-widget.php:141
135
+ #@ custom-post-widget
136
+ msgid "Block saved."
137
+ msgstr "Bloc sauvegardé."
138
+
139
+ #: post-widget.php:143
140
+ #@ custom-post-widget
141
+ msgid "M j, Y @ G:i"
142
+ msgstr "le j M Y, à G:i"
143
+
144
+ #: popup.php:9
145
+ #@ custom-post-widget
146
+ msgid "Please select a Content Block"
147
+ msgstr "Veuillez choisir un bloc de contenu"
148
+
149
+ #: popup.php:22
150
+ #: popup.php:48
151
+ #@ custom-post-widget
152
+ msgid "Insert Content Block"
153
+ msgstr "Insérer un bloc de contenu"
154
+
155
+ #: popup.php:25
156
+ #@ custom-post-widget
157
+ msgid "Select a Content Block below to add it to your post or page."
158
+ msgstr "Choisissez un bloc de contenu ci-bas pour l'ajouter à votre article ou page."
159
+
160
+ #: popup.php:31
161
+ #@ custom-post-widget
162
+ msgid "Select a Content Block"
163
+ msgstr "Choisissez un bloc"
164
+
165
+ #: popup.php:50
166
+ #@ custom-post-widget
167
+ msgid "Cancel"
168
+ msgstr "Annuler"
169
+
170
+ #: post-widget.php:135
171
+ #, php-format
172
+ #@ custom-post-widget
173
+ msgid "Content Block updated. <a href=\"%s\">Manage Widgets</a>"
174
+ msgstr "Bloc de contenu mis à jour. <a href=\"%s\">Gérer les widgets</a>"
175
+
176
+ #: post-widget.php:140
177
+ #, php-format
178
+ #@ custom-post-widget
179
+ msgid "Content Block published. <a href=\"%s\">Manage Widgets</a>"
180
+ msgstr "Bloc de contenu publié. <a href=\"%s\">Gérer les widgets</a>"
181
+
182
+ #: post-widget.php:140
183
+ #@ custom-post-widget
184
+ msgid "Content Block published."
185
+ msgstr "Bloc de contenu publié."
186
+
187
+ #: post-widget.php:142
188
+ #, php-format
189
+ #@ custom-post-widget
190
+ msgid "Content Block submitted. <a href=\"%s\">Manage Widgets</a>"
191
+ msgstr "Bloc de contenu envoyé. <a href=\"%s\">Gérer les widgets</a>"
192
+
193
+ #: post-widget.php:142
194
+ #@ custom-post-widget
195
+ msgid "Content Block submitted."
196
+ msgstr "Bloc de contenu envoyé."
197
+
198
+ #: post-widget.php:143
199
+ #, php-format
200
+ #@ custom-post-widget
201
+ msgid "Content Block scheduled for: <strong>%1$s</strong>."
202
+ msgstr "Publication du bloc prévue pour le <strong>%1$s</strong>."
203
+
204
+ #: post-widget.php:144
205
+ #, php-format
206
+ #@ custom-post-widget
207
+ msgid "Content Block draft updated. <a href=\"%s\">Manage Widgets</a>"
208
+ msgstr "Brouillon du bloc de contenu mis à jour. <a href=\"%s\">Gérer les widgets</a>"
209
+
210
+ #: post-widget.php:144
211
+ #@ custom-post-widget
212
+ msgid "Content Block draft updated."
213
+ msgstr "Brouillon du bloc de contenu mis à jour."
214
+
215
+ #: post-widget.php:180
216
+ #: post-widget.php:181
217
+ #@ custom-post-widget
218
+ msgid "Add Content Block"
219
+ msgstr "Ajouter un bloc de contenu"
220
+
post-widget.php CHANGED
@@ -1,194 +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
- // 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
  ?>
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', 'custom-post-widget') . '</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' => __('Content Blocks', 'post type general name', 'custom-post-widget'),
84
+ 'singular_name' => __('Content Block', 'post type singular name', 'custom-post-widget'),
85
+ 'plural_name' => __('Content Blocks', 'post type plural name', 'custom-post-widget'),
86
+ 'add_new' => __('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
@@ -4,8 +4,10 @@ Author URI: http://www.vanderwijk.com/
4
  Donate link: http://www.vanderwijk.com/wordpress/support/
5
  Tags: custom-post, widget, sidebar, content block, content, block, custom, post, shortcode
6
  Requires at least: 2.9.2
7
- Tested up to: 3.3.1
8
- Stable tag: 1.9.2
 
 
9
 
10
  This plugin enables you to display the content of a custom post type called Content Block in a sidebar widget.
11
 
@@ -22,7 +24,7 @@ This plugin creates a 'content_block' custom post type. You can choose to either
22
 
23
  To add content to a widget, drag it to the required position in the sidebar and select the title of the custom post in the widget configuration.
24
 
25
- This plugin is ready for localization and Dutch, German and Russian language files are included.
26
 
27
  You can find more information about this plugin and a screencast video which shows the plugin in action on the [plugin homepage](http://www.vanderwijk.com/wordpress/wordpress-custom-post-widget/).
28
 
@@ -127,6 +129,9 @@ Thanks to Vitaliy Kaplya (http://www.dasayt.com/) a Russian translation has been
127
  = 1.9.2 =
128
  Now includes Polish language files as created by Kuba Skublicki.
129
 
 
 
 
130
 
131
  == Upgrade Notice ==
132
 
4
  Donate link: http://www.vanderwijk.com/wordpress/support/
5
  Tags: custom-post, widget, sidebar, content block, content, block, custom, post, shortcode
6
  Requires at least: 2.9.2
7
+ Tested up to: 3.4
8
+ Stable tag: 1.9.3
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
  This plugin enables you to display the content of a custom post type called Content Block in a sidebar widget.
13
 
24
 
25
  To add content to a widget, drag it to the required position in the sidebar and select the title of the custom post in the widget configuration.
26
 
27
+ This plugin is ready for localization and Dutch, German, Polish and Russian language files are included.
28
 
29
  You can find more information about this plugin and a screencast video which shows the plugin in action on the [plugin homepage](http://www.vanderwijk.com/wordpress/wordpress-custom-post-widget/).
30
 
129
  = 1.9.2 =
130
  Now includes Polish language files as created by Kuba Skublicki.
131
 
132
+ = 1.9.3 =
133
+ Minor bugfix and added the French translation which was created by Alexandre Simard (http://brocheafoin.biz/).
134
+
135
 
136
  == Upgrade Notice ==
137