Version Description
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.
=
Download this release
Release Info
Developer | vanderwijk |
Plugin | Content Blocks (Custom Post Widget) |
Version | 1.6 |
Comparing to | |
See all releases |
Code changes from version 1.5 to 1.6
- custom-post-widget.php +3 -4
- post-widget.php +30 -34
- readme.txt +5 -2
custom-post-widget.php
CHANGED
@@ -3,14 +3,13 @@
|
|
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: 1.
|
12 |
-
|
13 |
-
to the Content Block edit screen.
|
14 |
|
15 |
Copyright 2011 Johan van der Wijk (email: info@vanderwijk.com)
|
16 |
|
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.6
|
7 |
Author: Johan van der Wijk
|
8 |
Author URI: http://www.vanderwijk.com
|
9 |
License: GPL2
|
10 |
|
11 |
+
Release notes: Version 1.6 of the Custom Post Widget plugin now uses the much more efficient
|
12 |
+
get_post instead of query_post to display the widget content.
|
|
|
13 |
|
14 |
Copyright 2011 Johan van der Wijk (email: info@vanderwijk.com)
|
15 |
|
post-widget.php
CHANGED
@@ -57,32 +57,29 @@ class custom_post_widget extends WP_Widget
|
|
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_TEXTDOMAIN);
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
wp_reset_query();
|
78 |
-
|
79 |
-
// Output $after_widget
|
80 |
echo $after_widget;
|
|
|
81 |
}
|
82 |
}
|
83 |
|
84 |
// Create the Content Block custom post type
|
85 |
-
|
86 |
add_action('init', 'my_content_block_post_type_init');
|
87 |
|
88 |
function my_content_block_post_type_init()
|
@@ -119,22 +116,21 @@ add_action('init', 'my_content_block_post_type_init');
|
|
119 |
|
120 |
|
121 |
// Add custom styles to admin screen and menu
|
122 |
-
|
123 |
add_action('admin_head', 'content_block_header');
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
|
139 |
add_filter('post_updated_messages', 'content_block_messages');
|
140 |
|
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_TEXTDOMAIN);
|
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()
|
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 |
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ 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.
|
9 |
|
10 |
This plugin enables you to display the content of a custom post type called Content Block in a sidebar widget.
|
11 |
|
@@ -92,7 +92,10 @@ The plugin has been translated into Dutch and German. Hat tip: Caspar Hübin
|
|
92 |
|
93 |
= 1.5 =
|
94 |
Thanks to Caspar Huebinger the plugin
|
95 |
-
|
|
|
|
|
|
|
96 |
|
97 |
|
98 |
== Upgrade Notice ==
|
5 |
Tags: custom-post, widget, sidebar
|
6 |
Requires at least: 2.9.2
|
7 |
Tested up to: 3.1
|
8 |
+
Stable tag: 1.6
|
9 |
|
10 |
This plugin enables you to display the content of a custom post type called Content Block in a sidebar widget.
|
11 |
|
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.
|
99 |
|
100 |
|
101 |
== Upgrade Notice ==
|