Version Description
Download this release
Release Info
Developer | vanderwijk |
Plugin | Content Blocks (Custom Post Widget) |
Version | 2.5 |
Comparing to | |
See all releases |
Code changes from version 2.4.5 to 2.5
- custom-post-widget.php +5 -4
- images/contentblock-13.png +0 -0
- images/contentblock-32.png +0 -0
- images/contentblock.png +0 -0
- meta-box.php +20 -1
- popup.php +27 -10
- post-widget.php +9 -50
- readme.txt +8 -2
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
custom-post-widget.php
CHANGED
@@ -3,14 +3,14 @@
|
|
3 |
Plugin Name: Custom Post Widget
|
4 |
Plugin URI: http://www.vanderwijk.com/wordpress/wordpress-custom-post-widget/
|
5 |
Description: Show the content of a custom post of the type 'content_block' in a widget or with a shortcode.
|
6 |
-
Version: 2.
|
7 |
Author: Johan van der Wijk
|
8 |
Author URI: http://www.vanderwijk.com
|
9 |
License: GPL2
|
10 |
|
11 |
-
Release notes: Version 2.
|
12 |
|
13 |
-
Copyright
|
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
|
@@ -42,4 +42,5 @@ function custom_post_widget_load_widgets() {
|
|
42 |
register_widget( 'custom_post_widget' );
|
43 |
}
|
44 |
|
45 |
-
require( 'meta-box.php' );
|
|
3 |
Plugin Name: Custom Post Widget
|
4 |
Plugin URI: http://www.vanderwijk.com/wordpress/wordpress-custom-post-widget/
|
5 |
Description: Show the content of a custom post of the type 'content_block' in a widget or with a shortcode.
|
6 |
+
Version: 2.5
|
7 |
Author: Johan van der Wijk
|
8 |
Author URI: http://www.vanderwijk.com
|
9 |
License: GPL2
|
10 |
|
11 |
+
Release notes: Version 2.5 adds the content block information column to the overview page
|
12 |
|
13 |
+
Copyright 2014 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
|
42 |
register_widget( 'custom_post_widget' );
|
43 |
}
|
44 |
|
45 |
+
require( 'meta-box.php' );
|
46 |
+
require( 'popup.php' );
|
images/contentblock-13.png
DELETED
Binary file
|
images/contentblock-32.png
DELETED
Binary file
|
images/contentblock.png
DELETED
Binary file
|
meta-box.php
CHANGED
@@ -40,4 +40,23 @@ function cpw_save_postdata( $post_id ) {
|
|
40 |
$content_block_information = sanitize_text_field( $_POST['cpw_content_block_information'] );
|
41 |
update_post_meta( $post_id, '_content_block_information', $content_block_information );
|
42 |
}
|
43 |
-
add_action( 'save_post', 'cpw_save_postdata' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
$content_block_information = sanitize_text_field( $_POST['cpw_content_block_information'] );
|
41 |
update_post_meta( $post_id, '_content_block_information', $content_block_information );
|
42 |
}
|
43 |
+
add_action( 'save_post', 'cpw_save_postdata' );
|
44 |
+
|
45 |
+
// Add content block information column to overview
|
46 |
+
function cpw_modify_material_table( $column ) {
|
47 |
+
$column['content_block_information'] = __( 'Content Block Information', 'custom-post-widget' );
|
48 |
+
return $column;
|
49 |
+
}
|
50 |
+
add_filter( 'manage_edit-content_block_columns', 'cpw_modify_material_table' );
|
51 |
+
|
52 |
+
function cpw_modify_post_table_row( $column_name, $post_id ) {
|
53 |
+
$custom_fields = get_post_custom( $post_id );
|
54 |
+
switch ( $column_name ) {
|
55 |
+
case 'content_block_information' :
|
56 |
+
if ( !empty( $custom_fields['_content_block_information'][0] ) ) {
|
57 |
+
echo $custom_fields['_content_block_information'][0];
|
58 |
+
}
|
59 |
+
break;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
add_action( 'manage_posts_custom_column', 'cpw_modify_post_table_row', 10, 2 );
|
popup.php
CHANGED
@@ -1,22 +1,39 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
// Displays the lightbox popup to insert a content block shortcode to a post/page
|
3 |
function add_content_block_popup() { ?>
|
4 |
-
|
5 |
<script>
|
6 |
-
|
7 |
-
content_id =
|
8 |
-
|
9 |
-
});
|
10 |
function insertContentBlockShortcode() {
|
11 |
-
if( content_id
|
12 |
alert( "<?php _e( 'Please select a Content Block', 'custom-post-widget' ); ?>" );
|
13 |
-
return;
|
14 |
}
|
15 |
var win = window.dialogArguments || opener || parent || top;
|
16 |
win.send_to_editor( "[content_block id=" + content_id + "]" );
|
17 |
}
|
18 |
</script>
|
19 |
-
|
20 |
<div id="content-block-form" style="display: none;">
|
21 |
<h3>
|
22 |
<?php _e( 'Insert Content Block', 'custom-post-widget' ); ?>
|
@@ -25,7 +42,7 @@ function add_content_block_popup() { ?>
|
|
25 |
<?php _e( 'Select a Content Block below to add it to your post or page.', 'custom-post-widget' ); ?>
|
26 |
</p>
|
27 |
<p>
|
28 |
-
<select
|
29 |
<option value="">
|
30 |
<?php _e( 'Select a Content Block', 'custom-post-widget' ); ?>
|
31 |
</option>
|
@@ -47,4 +64,4 @@ function add_content_block_popup() { ?>
|
|
47 |
</p>
|
48 |
</div>
|
49 |
|
50 |
-
<?php }
|
1 |
<?php
|
2 |
+
|
3 |
+
// Add button above editor if not editing content_block
|
4 |
+
function add_content_block_icon() {
|
5 |
+
echo '<style>
|
6 |
+
#add-content-block .dashicons-screenoptions {
|
7 |
+
color: #888;
|
8 |
+
height: 18px;
|
9 |
+
margin: 0 4px 0 0;
|
10 |
+
vertical-align: text-top;
|
11 |
+
width: 18px;
|
12 |
+
}
|
13 |
+
#add-content-block {
|
14 |
+
padding-left: 0.4em;
|
15 |
+
}
|
16 |
+
</style>
|
17 |
+
<a id="add-content-block" class="button thickbox" title="' . __("Add Content Block", 'custom-post-widget' ) . '" href="' . plugins_url() . 'popup.php?type=add_content_block_popup&TB_inline=true&inlineId=content-block-form">
|
18 |
+
<div class="dashicons dashicons-screenoptions"></div>' . __("Add Content Block", "custom-post-widget") . '
|
19 |
+
</a>';
|
20 |
+
}
|
21 |
+
|
22 |
// Displays the lightbox popup to insert a content block shortcode to a post/page
|
23 |
function add_content_block_popup() { ?>
|
|
|
24 |
<script>
|
25 |
+
function selectContentBlockId(select) {
|
26 |
+
content_id = select.options[select.selectedIndex].value;
|
27 |
+
}
|
|
|
28 |
function insertContentBlockShortcode() {
|
29 |
+
if (typeof content_id === 'undefined') {
|
30 |
alert( "<?php _e( 'Please select a Content Block', 'custom-post-widget' ); ?>" );
|
31 |
+
return false;
|
32 |
}
|
33 |
var win = window.dialogArguments || opener || parent || top;
|
34 |
win.send_to_editor( "[content_block id=" + content_id + "]" );
|
35 |
}
|
36 |
</script>
|
|
|
37 |
<div id="content-block-form" style="display: none;">
|
38 |
<h3>
|
39 |
<?php _e( 'Insert Content Block', 'custom-post-widget' ); ?>
|
42 |
<?php _e( 'Select a Content Block below to add it to your post or page.', 'custom-post-widget' ); ?>
|
43 |
</p>
|
44 |
<p>
|
45 |
+
<select class="add-content-block-id" id="add-content-block-id" onchange="selectContentBlockId(this)">
|
46 |
<option value="">
|
47 |
<?php _e( 'Select a Content Block', 'custom-post-widget' ); ?>
|
48 |
</option>
|
64 |
</p>
|
65 |
</div>
|
66 |
|
67 |
+
<?php }
|
post-widget.php
CHANGED
@@ -45,7 +45,7 @@ class custom_post_widget extends WP_Widget {
|
|
45 |
</label>
|
46 |
</p>
|
47 |
|
48 |
-
<input type="hidden" id="<?php echo $this -> get_field_id( 'title' ); ?>" name="<?php echo $this -> get_field_name( 'title' ); ?>" value="<?php echo $widgetExtraTitle ?>" />
|
49 |
|
50 |
<p>
|
51 |
<?php
|
@@ -113,9 +113,7 @@ class custom_post_widget extends WP_Widget {
|
|
113 |
}
|
114 |
|
115 |
// Create the Content Block custom post type
|
116 |
-
|
117 |
-
|
118 |
-
function my_content_block_post_type_init() {
|
119 |
$labels = array(
|
120 |
'name' => _x( 'Content Blocks', 'post type general name', 'custom-post-widget' ),
|
121 |
'singular_name' => _x( 'Content Block', 'post type singular name', 'custom-post-widget' ),
|
@@ -127,8 +125,7 @@ function my_content_block_post_type_init() {
|
|
127 |
'view_item' => __( 'View Content Block', 'custom-post-widget' ),
|
128 |
'search_items' => __( 'Search Content Blocks', 'custom-post-widget' ),
|
129 |
'not_found' => __( 'No Content Blocks Found', 'custom-post-widget' ),
|
130 |
-
'not_found_in_trash' => __( 'No Content Blocks found in Trash', 'custom-post-widget' )
|
131 |
-
'parent_item_colon' => ''
|
132 |
);
|
133 |
$options = array(
|
134 |
'labels' => $labels,
|
@@ -140,31 +137,12 @@ function my_content_block_post_type_init() {
|
|
140 |
'rewrite' => true,
|
141 |
'capability_type' => 'post',
|
142 |
'hierarchical' => false,
|
143 |
-
'
|
144 |
'supports' => array( 'title','editor','revisions','thumbnail','author' )
|
145 |
);
|
146 |
register_post_type( 'content_block',$options );
|
147 |
}
|
148 |
-
|
149 |
-
// Add custom styles to admin screen and menu
|
150 |
-
add_action( 'admin_head', 'content_block_header' );
|
151 |
-
|
152 |
-
function content_block_header() {
|
153 |
-
global $post_type; ?>
|
154 |
-
<style type="text/css">
|
155 |
-
<!--
|
156 |
-
<?php if (($post_type == 'content_block' )) : ?>
|
157 |
-
#icon-edit { background:transparent url( '<?php echo plugins_url( 'images/contentblock-32.png', __FILE__ ); ?>' ) no-repeat 0 0 !important;}
|
158 |
-
#minor-publishing-actions { display:none; /* Hide the Save Draft and Preview buttons */}
|
159 |
-
<?php endif; ?>
|
160 |
-
#adminmenu #menu-posts-content_block div.wp-menu-image{background:transparent url( '<?php echo plugins_url( 'images/contentblock.png', __FILE__ ); ?>' ) no-repeat center -32px;}
|
161 |
-
#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 plugins_url( 'images/contentblock.png', __FILE__ ); ?>' ) no-repeat center 0px;}
|
162 |
-
-->
|
163 |
-
</style>
|
164 |
-
<?php
|
165 |
-
}
|
166 |
-
|
167 |
-
add_filter( 'post_updated_messages', 'content_block_messages' );
|
168 |
|
169 |
function content_block_messages( $messages ) {
|
170 |
$messages['content_block'] = array(
|
@@ -182,6 +160,7 @@ function content_block_messages( $messages ) {
|
|
182 |
);
|
183 |
return $messages;
|
184 |
}
|
|
|
185 |
|
186 |
// Add the ability to display the content block in a reqular post using a shortcode
|
187 |
function custom_post_widget_shortcode( $atts ) {
|
@@ -211,32 +190,12 @@ function custom_post_widget_shortcode( $atts ) {
|
|
211 |
}
|
212 |
add_shortcode( 'content_block', 'custom_post_widget_shortcode' );
|
213 |
|
214 |
-
// Add button above editor if not editing content_block
|
215 |
-
function add_content_block_icon() {
|
216 |
-
echo '<style>
|
217 |
-
#add-content-block .wp-media-buttons-icon {
|
218 |
-
background: url( ' . plugins_url( "images/contentblock.png", __FILE__ ). ' ) no-repeat -7px -40px;
|
219 |
-
margin-right: 3px;
|
220 |
-
}
|
221 |
-
#add-content-block:hover .wp-media-buttons-icon {
|
222 |
-
background: url( ' . plugins_url( "images/contentblock.png", __FILE__ ). ' ) no-repeat -7px -8px;
|
223 |
-
}
|
224 |
-
#add-content-block {
|
225 |
-
padding-left: 0.4em;
|
226 |
-
}
|
227 |
-
</style>
|
228 |
-
<a id="add-content-block" class="button thickbox" title="' . __("Add Content Block", 'custom-post-widget' ) . '" href="' . plugins_url() . 'popup.php?type=add_content_block_popup&TB_inline=true&inlineId=content-block-form">
|
229 |
-
<span class="wp-media-buttons-icon"></span>' . __("Add Content Block", "custom-post-widget") . '</a>';
|
230 |
-
}
|
231 |
-
|
232 |
// Only add content_block icon above posts and pages
|
233 |
function cpw_add_content_block_button() {
|
234 |
global $current_screen;
|
235 |
if( 'content_block' != $current_screen -> post_type ) {
|
236 |
-
add_filter( '
|
237 |
-
add_action( '
|
238 |
}
|
239 |
}
|
240 |
-
add_action( 'admin_head', 'cpw_add_content_block_button' );
|
241 |
-
|
242 |
-
require( 'popup.php' );
|
45 |
</label>
|
46 |
</p>
|
47 |
|
48 |
+
<input type="hidden" id="<?php echo $this -> get_field_id( 'title' ); ?>" name="<?php echo $this -> get_field_name( 'title' ); ?>" value="<?php if ( !empty( $widgetExtraTitle ) ) { echo $widgetExtraTitle; } ?>" />
|
49 |
|
50 |
<p>
|
51 |
<?php
|
113 |
}
|
114 |
|
115 |
// Create the Content Block custom post type
|
116 |
+
function cpw_post_type_init() {
|
|
|
|
|
117 |
$labels = array(
|
118 |
'name' => _x( 'Content Blocks', 'post type general name', 'custom-post-widget' ),
|
119 |
'singular_name' => _x( 'Content Block', 'post type singular name', 'custom-post-widget' ),
|
125 |
'view_item' => __( 'View Content Block', 'custom-post-widget' ),
|
126 |
'search_items' => __( 'Search Content Blocks', 'custom-post-widget' ),
|
127 |
'not_found' => __( 'No Content Blocks Found', 'custom-post-widget' ),
|
128 |
+
'not_found_in_trash' => __( 'No Content Blocks found in Trash', 'custom-post-widget' )
|
|
|
129 |
);
|
130 |
$options = array(
|
131 |
'labels' => $labels,
|
137 |
'rewrite' => true,
|
138 |
'capability_type' => 'post',
|
139 |
'hierarchical' => false,
|
140 |
+
'menu_icon' => 'dashicons-screenoptions',
|
141 |
'supports' => array( 'title','editor','revisions','thumbnail','author' )
|
142 |
);
|
143 |
register_post_type( 'content_block',$options );
|
144 |
}
|
145 |
+
add_action( 'init', 'cpw_post_type_init' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
function content_block_messages( $messages ) {
|
148 |
$messages['content_block'] = array(
|
160 |
);
|
161 |
return $messages;
|
162 |
}
|
163 |
+
add_filter( 'post_updated_messages', 'content_block_messages' );
|
164 |
|
165 |
// Add the ability to display the content block in a reqular post using a shortcode
|
166 |
function custom_post_widget_shortcode( $atts ) {
|
190 |
}
|
191 |
add_shortcode( 'content_block', 'custom_post_widget_shortcode' );
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
// Only add content_block icon above posts and pages
|
194 |
function cpw_add_content_block_button() {
|
195 |
global $current_screen;
|
196 |
if( 'content_block' != $current_screen -> post_type ) {
|
197 |
+
add_filter( 'media_buttons_context', 'add_content_block_icon' );
|
198 |
+
add_action( 'admin_footer', 'add_content_block_popup' );
|
199 |
}
|
200 |
}
|
201 |
+
add_action( 'admin_head', 'cpw_add_content_block_button' );
|
|
|
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Author URI: http://www.vanderwijk.com/
|
|
4 |
Donate link: http://www.vanderwijk.com/wordpress/support/
|
5 |
Tags: widget, sidebar, content block, block, custom, post, shortcode, wysiwyg, wpml, featured image
|
6 |
Requires at least: 2.9.2
|
7 |
-
Tested up to: 3.8
|
8 |
-
Stable tag: 2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -101,6 +101,12 @@ Creating and supporting this plugin takes up a lot of my free time, therefore I
|
|
101 |
|
102 |
== Changelog ==
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
= 2.4.4 =
|
105 |
Added unique ID to each content block that is inserted using the shortcode functionality
|
106 |
|
4 |
Donate link: http://www.vanderwijk.com/wordpress/support/
|
5 |
Tags: widget, sidebar, content block, block, custom, post, shortcode, wysiwyg, wpml, featured image
|
6 |
Requires at least: 2.9.2
|
7 |
+
Tested up to: 3.8.1
|
8 |
+
Stable tag: 2.5
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
101 |
|
102 |
== Changelog ==
|
103 |
|
104 |
+
= 2.5
|
105 |
+
Added 'Content Block Information' to overview page, updated styling to reflect new 3.8 interface and rewrote javaScript code for inserting shortcode tag
|
106 |
+
|
107 |
+
= 2.4.5 =
|
108 |
+
2.4.5 javaScript fix for inserting shortcode tag
|
109 |
+
|
110 |
= 2.4.4 =
|
111 |
Added unique ID to each content block that is inserted using the shortcode functionality
|
112 |
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
ADDED
Binary file
|
screenshot-4.png
ADDED
Binary file
|