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 | Content Blocks (Custom Post Widget) |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8.6 to 1.9
- custom-post-widget.php +47 -48
- post-widget.php +193 -189
- 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.
|
7 |
-
Author: Johan van der Wijk
|
8 |
-
Author URI: http://www.vanderwijk.com
|
9 |
-
License: GPL2
|
10 |
-
|
11 |
-
Release notes: Version 1.
|
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 |
-
//
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
echo
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
'
|
84 |
-
'
|
85 |
-
'
|
86 |
-
'
|
87 |
-
'
|
88 |
-
'
|
89 |
-
'
|
90 |
-
'
|
91 |
-
|
92 |
-
|
93 |
-
'
|
94 |
-
'
|
95 |
-
|
96 |
-
|
97 |
-
'
|
98 |
-
'
|
99 |
-
'
|
100 |
-
'
|
101 |
-
'
|
102 |
-
'
|
103 |
-
'
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
#
|
121 |
-
|
122 |
-
|
123 |
-
<?php
|
124 |
-
}
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
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&TB_inline=true&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.
|
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ü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ü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 =
|