Version Description
Added featured image support and now using query_posts instead of get_post
Download this release
Release Info
Developer | vanderwijk |
Plugin | Content Blocks (Custom Post Widget) |
Version | 1.9.7 |
Comparing to | |
See all releases |
Code changes from version 1.9.6 to 1.9.7
- custom-post-widget.php +2 -2
- post-widget.php +36 -12
- readme.txt +3 -0
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.
|
7 |
Author: Johan van der Wijk
|
8 |
Author URI: http://www.vanderwijk.com
|
9 |
License: GPL2
|
10 |
|
11 |
-
Release notes: Version 1.9.
|
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.7
|
7 |
Author: Johan van der Wijk
|
8 |
Author URI: http://www.vanderwijk.com
|
9 |
License: GPL2
|
10 |
|
11 |
+
Release notes: Version 1.9.7 Added featured image support and switched back to using query_posts
|
12 |
|
13 |
Copyright 2012 Johan van der Wijk (email: info@vanderwijk.com)
|
14 |
|
post-widget.php
CHANGED
@@ -1,5 +1,10 @@
|
|
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() {
|
@@ -13,6 +18,7 @@ class custom_post_widget extends WP_Widget {
|
|
13 |
$custom_post_id = esc_attr($instance['custom_post_id']);
|
14 |
};
|
15 |
$show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : true;
|
|
|
16 |
$apply_content_filters = isset( $instance['apply_content_filters'] ) ? $instance['apply_content_filters'] : true;
|
17 |
?>
|
18 |
|
@@ -49,7 +55,12 @@ class custom_post_widget extends WP_Widget {
|
|
49 |
<input class="checkbox" type="checkbox" <?php checked( (bool) isset( $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' ); ?>" />
|
50 |
<label for="<?php echo $this->get_field_id( 'show_custom_post_title' ); ?>"><?php echo __( 'Show Post Title', 'custom-post-widget' ) ?></label>
|
51 |
</p>
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
53 |
<p>
|
54 |
<input class="checkbox" type="checkbox" <?php checked( (bool) isset( $instance['apply_content_filters'] ), true ); ?> id="<?php echo $this->get_field_id( 'apply_content_filters' ); ?>" name="<?php echo $this->get_field_name( 'apply_content_filters' ); ?>" />
|
55 |
<label for="<?php echo $this->get_field_id( 'apply_content_filters' ); ?>"><?php echo __( 'Do not apply content filters', 'custom-post-widget' ) ?></label>
|
@@ -60,6 +71,7 @@ class custom_post_widget extends WP_Widget {
|
|
60 |
$instance = $old_instance;
|
61 |
$instance['custom_post_id'] = strip_tags( $new_instance['custom_post_id'] );
|
62 |
$instance['show_custom_post_title'] = $new_instance['show_custom_post_title'];
|
|
|
63 |
$instance['apply_content_filters'] = $new_instance['apply_content_filters'];
|
64 |
return $instance;
|
65 |
}
|
@@ -73,18 +85,30 @@ class custom_post_widget extends WP_Widget {
|
|
73 |
}
|
74 |
// Variables from the widget settings.
|
75 |
$show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : false;
|
|
|
76 |
$apply_content_filters = isset($instance['apply_content_filters']) ? $instance['apply_content_filters'] : false;
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
|
90 |
}
|
1 |
<?php
|
2 |
|
3 |
+
// Add featured image support
|
4 |
+
if ( function_exists( 'add_theme_support' ) ) {
|
5 |
+
add_theme_support( 'post-thumbnails' );
|
6 |
+
}
|
7 |
+
|
8 |
// First create the widget for the admin panel
|
9 |
class custom_post_widget extends WP_Widget {
|
10 |
function custom_post_widget() {
|
18 |
$custom_post_id = esc_attr($instance['custom_post_id']);
|
19 |
};
|
20 |
$show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : true;
|
21 |
+
$show_featured_image = isset( $instance['show_featured_image'] ) ? $instance['show_featured_image'] : true;
|
22 |
$apply_content_filters = isset( $instance['apply_content_filters'] ) ? $instance['apply_content_filters'] : true;
|
23 |
?>
|
24 |
|
55 |
<input class="checkbox" type="checkbox" <?php checked( (bool) isset( $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' ); ?>" />
|
56 |
<label for="<?php echo $this->get_field_id( 'show_custom_post_title' ); ?>"><?php echo __( 'Show Post Title', 'custom-post-widget' ) ?></label>
|
57 |
</p>
|
58 |
+
|
59 |
+
<p>
|
60 |
+
<input class="checkbox" type="checkbox" <?php checked( (bool) isset( $instance['show_featured_image'] ), true ); ?> id="<?php echo $this->get_field_id( 'show_featured_image' ); ?>" name="<?php echo $this->get_field_name( 'show_featured_image' ); ?>" />
|
61 |
+
<label for="<?php echo $this->get_field_id( 'show_featured_image' ); ?>"><?php echo __( 'Show Featured Image', 'custom-post-widget' ) ?></label>
|
62 |
+
</p>
|
63 |
+
|
64 |
<p>
|
65 |
<input class="checkbox" type="checkbox" <?php checked( (bool) isset( $instance['apply_content_filters'] ), true ); ?> id="<?php echo $this->get_field_id( 'apply_content_filters' ); ?>" name="<?php echo $this->get_field_name( 'apply_content_filters' ); ?>" />
|
66 |
<label for="<?php echo $this->get_field_id( 'apply_content_filters' ); ?>"><?php echo __( 'Do not apply content filters', 'custom-post-widget' ) ?></label>
|
71 |
$instance = $old_instance;
|
72 |
$instance['custom_post_id'] = strip_tags( $new_instance['custom_post_id'] );
|
73 |
$instance['show_custom_post_title'] = $new_instance['show_custom_post_title'];
|
74 |
+
$instance['show_featured_image'] = $new_instance['show_featured_image'];
|
75 |
$instance['apply_content_filters'] = $new_instance['apply_content_filters'];
|
76 |
return $instance;
|
77 |
}
|
85 |
}
|
86 |
// Variables from the widget settings.
|
87 |
$show_custom_post_title = isset( $instance['show_custom_post_title'] ) ? $instance['show_custom_post_title'] : false;
|
88 |
+
$show_featured_image = isset($instance['show_featured_image']) ? $instance['show_featured_image'] : false;
|
89 |
$apply_content_filters = isset($instance['apply_content_filters']) ? $instance['apply_content_filters'] : false;
|
90 |
+
|
91 |
+
// Output the query to find the custom post
|
92 |
+
query_posts( 'post_type=content_block&p=' . $custom_post_id );
|
93 |
+
while (have_posts()) : the_post();
|
94 |
+
echo $before_widget;
|
95 |
+
if ( $show_custom_post_title ) {
|
96 |
+
echo $before_title;
|
97 |
+
the_title();
|
98 |
+
echo $after_title; // This is the line that displays the title (only if show title is set)
|
99 |
+
}
|
100 |
+
if ( $show_featured_image ) {
|
101 |
+
the_post_thumbnail();
|
102 |
+
}
|
103 |
+
if ( $apply_content_filters ) { // Don't apply the content filter if checkbox selected
|
104 |
+
remove_filter('the_content', 'wpautop');
|
105 |
+
the_content(); // This is where the actual content of the custom post is being displayed
|
106 |
+
} else {
|
107 |
+
the_content(); // This is where the actual content of the custom post is being displayed
|
108 |
+
}
|
109 |
+
echo $after_widget;
|
110 |
+
endwhile;
|
111 |
+
wp_reset_query();
|
112 |
}
|
113 |
|
114 |
}
|
readme.txt
CHANGED
@@ -79,6 +79,9 @@ If your social media sharing plugin adds buttons to the widget areas you could c
|
|
79 |
|
80 |
== Changelog ==
|
81 |
|
|
|
|
|
|
|
82 |
= 1.9.6 =
|
83 |
Fixed debug notices when dragging a new content block to the widget areas and removed the add content block shortcode from the content block editing screen.
|
84 |
|
79 |
|
80 |
== Changelog ==
|
81 |
|
82 |
+
= 1.9.7 =
|
83 |
+
Added featured image support and now using query_posts instead of get_post
|
84 |
+
|
85 |
= 1.9.6 =
|
86 |
Fixed debug notices when dragging a new content block to the widget areas and removed the add content block shortcode from the content block editing screen.
|
87 |
|