Version Description
- Hotfix: 2.9.1 broke extra classes added to the inserted page wrapper.
- Feature: Expose extra classes and inline status in tinymce dialog.
- One more API change to insert_pages_wrap_content_filter (2nd parameter is a WP_Post now instead of an array of WP_Posts, since we only ever insert one page).
Example 1:
`/**
- Enable nested shortcodes by hooking into insert_pages_wrap_content. *
- @param string $content The post content of the inserted page.
- @param array $inserted_page The post object returned from querying the inserted page.
- @param array $attributes Extra parameters modifying the inserted page.
- page: Page ID or slug of page to be inserted.
- display: Content to display from inserted page.
- class: Extra classes to add to inserted page wrapper element.
- inline: Boolean indicating wrapper element should be a span.
- should_apply_nesting_check: Whether to disable nested inserted pages.
- should_apply_the_content_filter: Whether to apply the_content filter to post contents and excerpts.
- wrapper_tag: Tag to use for the wrapper element (e.g., div, span).
/
function your_custom_wrapper_function( $content, $inserted_page, $attributes ) {
return do_shortcode( $content );
}
add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function', 9, 3 );
Example 2:
/* - Completely modify markup generated by Insert Pages by hooking into insert_pages_wrap_content. *
- @param string $content The post content of the inserted page.
- @param array $inserted_page The post object returned from querying the inserted page.
- @param array $attributes Extra parameters modifying the inserted page.
- page: Page ID or slug of page to be inserted.
- display: Content to display from inserted page.
- class: Extra classes to add to inserted page wrapper element.
- inline: Boolean indicating wrapper element should be a span.
- should_apply_nesting_check: Whether to disable nested inserted pages.
- should_apply_the_content_filter: Whether to apply the_content filter to post contents and excerpts.
- wrapper_tag: Tag to use for the wrapper element (e.g., div, span).
*/
function your_custom_wrapper_function( $content, $inserted_page, $attributes ) {
// Remove the default filter that wraps the content in a div or span.
remove_all_filters( 'insert_pages_wrap_content', 10 );
// Return your custom wrapper around the content.
return "
$content "; } add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function', 9, 3 );`
Download this release
Release Info
Developer | figureone |
Plugin | Insert Pages |
Version | 3.0 |
Comparing to | |
See all releases |
Code changes from version 2.9.1 to 3.0
- css/wpinsertpages.css +15 -4
- insert-pages.php +148 -82
- js/wpinsertpages.js +29 -2
- readme.txt +15 -7
css/wpinsertpages.css
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
-webkit-box-shadow: 0 3px 6px rgba(0,0,0,.3);
|
9 |
box-shadow: 0 3px 6px rgba(0,0,0,.3);
|
10 |
width: 500px;
|
11 |
-
height:
|
12 |
overflow: hidden;
|
13 |
margin-left: -250px;
|
14 |
margin-top: -250px;
|
@@ -125,7 +125,7 @@
|
|
125 |
}
|
126 |
|
127 |
#wp-insertpage p.howto {
|
128 |
-
margin:
|
129 |
}
|
130 |
|
131 |
#insertpage-options-toggle {
|
@@ -141,6 +141,9 @@
|
|
141 |
margin-top: 5px;
|
142 |
width: 77%;
|
143 |
}
|
|
|
|
|
|
|
144 |
|
145 |
#wp-insertpage #insertpage-search-panel label span.search-label {
|
146 |
display: inline-block;
|
@@ -182,7 +185,7 @@
|
|
182 |
left: 16px;
|
183 |
right: 16px;
|
184 |
top: 38px;
|
185 |
-
height:
|
186 |
}
|
187 |
|
188 |
#wp-insertpage li,
|
@@ -286,10 +289,14 @@
|
|
286 |
|
287 |
@media screen and ( max-width: 782px ) {
|
288 |
#wp-insertpage-wrap {
|
289 |
-
height:
|
290 |
margin-top: -250px;
|
291 |
}
|
292 |
|
|
|
|
|
|
|
|
|
293 |
#wp-insertpage-wrap.options-panel-visible {
|
294 |
height: 530px;
|
295 |
}
|
@@ -320,6 +327,10 @@
|
|
320 |
max-width: 500px;
|
321 |
}
|
322 |
|
|
|
|
|
|
|
|
|
323 |
#wp-insertpage-wrap.options-panel-visible {
|
324 |
height: 550px;
|
325 |
}
|
8 |
-webkit-box-shadow: 0 3px 6px rgba(0,0,0,.3);
|
9 |
box-shadow: 0 3px 6px rgba(0,0,0,.3);
|
10 |
width: 500px;
|
11 |
+
height: 400px;
|
12 |
overflow: hidden;
|
13 |
margin-left: -250px;
|
14 |
margin-top: -250px;
|
125 |
}
|
126 |
|
127 |
#wp-insertpage p.howto {
|
128 |
+
margin: 255px 0 3px;
|
129 |
}
|
130 |
|
131 |
#insertpage-options-toggle {
|
141 |
margin-top: 5px;
|
142 |
width: 77%;
|
143 |
}
|
144 |
+
#wp-insertpage label input#insertpage-extra-classes {
|
145 |
+
width: 66%;
|
146 |
+
}
|
147 |
|
148 |
#wp-insertpage #insertpage-search-panel label span.search-label {
|
149 |
display: inline-block;
|
185 |
left: 16px;
|
186 |
right: 16px;
|
187 |
top: 38px;
|
188 |
+
height: 245px;
|
189 |
}
|
190 |
|
191 |
#wp-insertpage li,
|
289 |
|
290 |
@media screen and ( max-width: 782px ) {
|
291 |
#wp-insertpage-wrap {
|
292 |
+
height: 420px;
|
293 |
margin-top: -250px;
|
294 |
}
|
295 |
|
296 |
+
#wp-insertpage label input#insertpage-extra-classes {
|
297 |
+
width: 62%;
|
298 |
+
}
|
299 |
+
|
300 |
#wp-insertpage-wrap.options-panel-visible {
|
301 |
height: 530px;
|
302 |
}
|
327 |
max-width: 500px;
|
328 |
}
|
329 |
|
330 |
+
#wp-insertpage label input#insertpage-extra-classes {
|
331 |
+
width: 48%;
|
332 |
+
}
|
333 |
+
|
334 |
#wp-insertpage-wrap.options-panel-visible {
|
335 |
height: 550px;
|
336 |
}
|
insert-pages.php
CHANGED
@@ -5,7 +5,7 @@ Plugin Name: Insert Pages
|
|
5 |
Plugin URI: https://github.com/uhm-coe/insert-pages
|
6 |
Description: Insert Pages lets you embed any WordPress content (e.g., pages, posts, custom post types) into other WordPress content using the Shortcode API.
|
7 |
Author: Paul Ryan
|
8 |
-
Version:
|
9 |
Author URI: http://www.linkedin.com/in/paulrryan
|
10 |
License: GPL2
|
11 |
*/
|
@@ -71,7 +71,7 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
71 |
'wpinsertpages',
|
72 |
plugins_url( '/js/wpinsertpages.js', __FILE__ ),
|
73 |
array( 'wpdialogs' ),
|
74 |
-
'
|
75 |
);
|
76 |
wp_localize_script(
|
77 |
'wpinsertpages',
|
@@ -91,7 +91,7 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
91 |
'wpinsertpagescss',
|
92 |
plugins_url( '/css/wpinsertpages.css', __FILE__ ),
|
93 |
array( 'wp-jquery-ui-dialog' ),
|
94 |
-
'
|
95 |
);
|
96 |
|
97 |
add_filter( 'mce_external_plugins', array( $this, 'insertPages_handleFilter_mceExternalPlugins' ) );
|
@@ -180,80 +180,143 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
180 |
}
|
181 |
}
|
182 |
|
183 |
-
//
|
184 |
if ( ! is_numeric( $attributes['page'] ) ) {
|
185 |
-
$
|
186 |
-
$attributes['page'] = $
|
|
|
|
|
187 |
}
|
188 |
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
199 |
}
|
200 |
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
-
// Start
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
$old_post_id = $post->ID;
|
212 |
-
$post->ID = $attributes['page'];
|
213 |
-
FLBuilder::enqueue_layout_styles_scripts( $attributes['page'] );
|
214 |
-
$post->ID = $old_post_id;
|
215 |
}
|
|
|
|
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
$template = locate_template( $attributes['display'] );
|
258 |
if ( strlen( $template ) > 0 ) {
|
259 |
include $template; // execute the template code
|
@@ -263,25 +326,18 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
263 |
}
|
264 |
break;
|
265 |
}
|
|
|
266 |
|
267 |
-
$content = ob_get_contents(); // Save off output buffer
|
268 |
-
ob_end_clean(); // End output buffering
|
269 |
-
} else {
|
270 |
-
/**
|
271 |
-
* Filter the html that should be displayed if an inserted page was not found.
|
272 |
-
*
|
273 |
-
* @param string $content html to be displayed. Defaults to an empty string.
|
274 |
-
*/
|
275 |
-
$content = apply_filters( 'insert_pages_not_found_message', $content );
|
276 |
}
|
277 |
|
278 |
-
|
|
|
279 |
|
280 |
/**
|
281 |
* Filter the markup generated for the inserted page.
|
282 |
*
|
283 |
* @param string $content The post content of the inserted page.
|
284 |
-
* @param
|
285 |
* @param array $attributes Extra parameters modifying the inserted page.
|
286 |
* page: Page ID or slug of page to be inserted.
|
287 |
* display: Content to display from inserted page.
|
@@ -291,14 +347,14 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
291 |
* should_apply_the_content_filter: Whether to apply the_content filter to post contents and excerpts.
|
292 |
* wrapper_tag: Tag to use for the wrapper element (e.g., div, span).
|
293 |
*/
|
294 |
-
$content = apply_filters( 'insert_pages_wrap_content', $content, $
|
295 |
|
296 |
return $content;
|
297 |
}
|
298 |
|
299 |
// Default filter for insert_pages_wrap_content.
|
300 |
function insertPages_wrap_content( $content, $posts, $attributes ) {
|
301 |
-
return "<{$attributes['wrapper_tag']} data-post-id='{$attributes['page']}' class='insert-page insert-page-{$attributes['page']} {$attributes['
|
302 |
}
|
303 |
|
304 |
// Filter hook: Add a button to the TinyMCE toolbar for our insert page tool
|
@@ -372,7 +428,7 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
372 |
<div class="insertpage-options-wrapper">
|
373 |
<label for="insertpage-slug-field">
|
374 |
<span><?php _e( 'Slug or ID' ); ?></span>
|
375 |
-
<input id="insertpage-slug-field" type="text"
|
376 |
<input id="insertpage-pageID" type="hidden" />
|
377 |
</label>
|
378 |
</div>
|
@@ -394,6 +450,16 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
394 |
</select>
|
395 |
</label>
|
396 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
</div>
|
398 |
</div>
|
399 |
<div class="submitbox">
|
5 |
Plugin URI: https://github.com/uhm-coe/insert-pages
|
6 |
Description: Insert Pages lets you embed any WordPress content (e.g., pages, posts, custom post types) into other WordPress content using the Shortcode API.
|
7 |
Author: Paul Ryan
|
8 |
+
Version: 3.0
|
9 |
Author URI: http://www.linkedin.com/in/paulrryan
|
10 |
License: GPL2
|
11 |
*/
|
71 |
'wpinsertpages',
|
72 |
plugins_url( '/js/wpinsertpages.js', __FILE__ ),
|
73 |
array( 'wpdialogs' ),
|
74 |
+
'20151230'
|
75 |
);
|
76 |
wp_localize_script(
|
77 |
'wpinsertpages',
|
91 |
'wpinsertpagescss',
|
92 |
plugins_url( '/css/wpinsertpages.css', __FILE__ ),
|
93 |
array( 'wp-jquery-ui-dialog' ),
|
94 |
+
'20151230'
|
95 |
);
|
96 |
|
97 |
add_filter( 'mce_external_plugins', array( $this, 'insertPages_handleFilter_mceExternalPlugins' ) );
|
180 |
}
|
181 |
}
|
182 |
|
183 |
+
// Get the WP_Post object from the provided slug or ID.
|
184 |
if ( ! is_numeric( $attributes['page'] ) ) {
|
185 |
+
$inserted_page = get_page_by_path( $attributes['page'], OBJECT, get_post_types() );
|
186 |
+
$attributes['page'] = $inserted_page ? $inserted_page->ID : $attributes['page'];
|
187 |
+
} else {
|
188 |
+
$inserted_page = get_post( intval( $attributes['page'] ) );
|
189 |
}
|
190 |
|
191 |
+
// If we couldn't retrieve the page, fire the filter hook showing a not-found message.
|
192 |
+
if ( $inserted_page === null ) {
|
193 |
+
/**
|
194 |
+
* Filter the html that should be displayed if an inserted page was not found.
|
195 |
+
*
|
196 |
+
* @param string $content html to be displayed. Defaults to an empty string.
|
197 |
+
*/
|
198 |
+
$content = apply_filters( 'insert_pages_not_found_message', $content );
|
199 |
+
|
200 |
+
// Short-circuit since we didn't find the page.
|
201 |
+
return $content;
|
202 |
}
|
203 |
|
204 |
+
// If Beaver Builder plugin is enabled, load any cached styles associated with the inserted page.
|
205 |
+
// Note: Temporarily set the global $post->ID to the inserted page ID,
|
206 |
+
// since Beaver Builder relies on it to load the appropriate styles.
|
207 |
+
if ( class_exists( 'FLBuilder' ) ) {
|
208 |
+
$old_post_id = $post->ID;
|
209 |
+
$post->ID = $inserted_page->ID;
|
210 |
+
FLBuilder::enqueue_layout_styles_scripts( $inserted_page->ID );
|
211 |
+
$post->ID = $old_post_id;
|
212 |
+
}
|
213 |
|
214 |
+
// Start output buffering so we can save the output to a string.
|
215 |
+
ob_start();
|
216 |
+
|
217 |
+
// Show either the title, link, content, everything, or everything via a custom template
|
218 |
+
// Note: if the sharing_display filter exists, it means Jetpack is installed and Sharing is enabled;
|
219 |
+
// This plugin conflicts with Sharing, because Sharing assumes the_content and the_excerpt filters
|
220 |
+
// are only getting called once. The fix here is to disable processing of filters on the_content in
|
221 |
+
// the inserted page. @see https://codex.wordpress.org/Function_Reference/the_content#Alternative_Usage
|
222 |
+
switch ( $attributes['display'] ) {
|
223 |
+
|
224 |
+
case "title":
|
225 |
+
$title_tag = $attributes['inline'] ? 'span' : 'h1';
|
226 |
+
echo "<$title_tag class='insert-page-title'>";
|
227 |
+
get_the_title( $inserted_page->ID );
|
228 |
+
echo "</$title_tag>";
|
229 |
+
break;
|
230 |
+
|
231 |
+
case "link":
|
232 |
+
?><a href="<?php echo esc_url( get_permalink( $inserted_page->ID ) ); ?>"><?php get_the_title( $inserted_page->ID ); ?></a><?php
|
233 |
+
break;
|
234 |
+
|
235 |
+
case "excerpt":
|
236 |
+
?><h1><a href="<?php echo esc_url( get_permalink( $inserted_page->ID ) ); ?>"><?php get_the_title( $inserted_page->ID ); ?></a></h1><?php
|
237 |
+
$excerpt = get_post_field( 'post_excerpt', $inserted_page->ID );
|
238 |
+
if ( $attributes['should_apply_the_content_filter'] ) {
|
239 |
+
$excerpt = apply_filters( 'the_excerpt', $excerpt );
|
240 |
+
}
|
241 |
+
echo $excerpt;
|
242 |
+
break;
|
243 |
|
244 |
+
case "excerpt-only":
|
245 |
+
$excerpt = get_post_field( 'post_excerpt', $inserted_page->ID );
|
246 |
+
if ( $attributes['should_apply_the_content_filter'] ) {
|
247 |
+
$excerpt = apply_filters( 'the_excerpt', $excerpt );
|
|
|
|
|
|
|
|
|
248 |
}
|
249 |
+
echo $excerpt;
|
250 |
+
break;
|
251 |
|
252 |
+
case "content":
|
253 |
+
$content = get_post_field( 'post_content', $inserted_page->ID );
|
254 |
+
if ( $attributes['should_apply_the_content_filter'] ) {
|
255 |
+
$content = apply_filters( 'the_content', $content );
|
256 |
+
}
|
257 |
+
echo $content;
|
258 |
+
break;
|
259 |
+
|
260 |
+
case "all":
|
261 |
+
// Title.
|
262 |
+
$title_tag = $attributes['inline'] ? 'span' : 'h1';
|
263 |
+
echo "<$title_tag class='insert-page-title'>";
|
264 |
+
get_the_title( $inserted_page->ID );
|
265 |
+
echo "</$title_tag>";
|
266 |
+
// Content.
|
267 |
+
$content = get_post_field( 'post_content', $inserted_page->ID );
|
268 |
+
if ( $attributes['should_apply_the_content_filter'] ) {
|
269 |
+
$content = apply_filters( 'the_content', $content );
|
270 |
+
}
|
271 |
+
echo $content;
|
272 |
+
// Meta.
|
273 |
+
// @ref https://core.trac.wordpress.org/browser/tags/4.4/src/wp-includes/post-template.php#L968
|
274 |
+
if ( $keys = get_post_custom_keys( $inserted_page->ID ) ) {
|
275 |
+
echo "<ul class='post-meta'>\n";
|
276 |
+
foreach ( (array) $keys as $key ) {
|
277 |
+
$keyt = trim( $key );
|
278 |
+
if ( is_protected_meta( $keyt, 'post' ) ) {
|
279 |
+
continue;
|
280 |
+
}
|
281 |
+
$values = array_map( 'trim', get_post_custom_values( $key ) );
|
282 |
+
$value = implode( $values, ', ' );
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Filter the HTML output of the li element in the post custom fields list.
|
286 |
+
*
|
287 |
+
* @since 2.2.0
|
288 |
+
*
|
289 |
+
* @param string $html The HTML output for the li element.
|
290 |
+
* @param string $key Meta key.
|
291 |
+
* @param string $value Meta value.
|
292 |
+
*/
|
293 |
+
echo apply_filters( 'the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value );
|
294 |
+
}
|
295 |
+
echo "</ul>\n";
|
296 |
+
}
|
297 |
+
break;
|
298 |
+
|
299 |
+
default: // display is either invalid, or contains a template file to use
|
300 |
+
// Legacy/compatibility code: In order to use custom templates,
|
301 |
+
// we use query_posts() to provide the template with the global
|
302 |
+
// state it requires for the inserted page (in other words, all
|
303 |
+
// template tags will work with respect to the inserted page
|
304 |
+
// instead of the parent page / main loop). Note that this may
|
305 |
+
// cause some compatibility issues with other plugins.
|
306 |
+
// @ref https://codex.wordpress.org/Function_Reference/query_posts
|
307 |
+
if ( is_numeric( $attributes['page'] ) ) {
|
308 |
+
$args = array(
|
309 |
+
'p' => intval( $attributes['page'] ),
|
310 |
+
'post_type' => get_post_types(),
|
311 |
+
);
|
312 |
+
} else {
|
313 |
+
$args = array(
|
314 |
+
'name' => esc_attr( $attributes['page'] ),
|
315 |
+
'post_type' => get_post_types(),
|
316 |
+
);
|
317 |
+
}
|
318 |
+
$inserted_page = query_posts( $args );
|
319 |
+
if ( have_posts() ) {
|
320 |
$template = locate_template( $attributes['display'] );
|
321 |
if ( strlen( $template ) > 0 ) {
|
322 |
include $template; // execute the template code
|
326 |
}
|
327 |
break;
|
328 |
}
|
329 |
+
wp_reset_query();
|
330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
|
333 |
+
// Save output buffer contents.
|
334 |
+
$content = ob_get_clean();
|
335 |
|
336 |
/**
|
337 |
* Filter the markup generated for the inserted page.
|
338 |
*
|
339 |
* @param string $content The post content of the inserted page.
|
340 |
+
* @param object $inserted_page The post object returned from querying the inserted page.
|
341 |
* @param array $attributes Extra parameters modifying the inserted page.
|
342 |
* page: Page ID or slug of page to be inserted.
|
343 |
* display: Content to display from inserted page.
|
347 |
* should_apply_the_content_filter: Whether to apply the_content filter to post contents and excerpts.
|
348 |
* wrapper_tag: Tag to use for the wrapper element (e.g., div, span).
|
349 |
*/
|
350 |
+
$content = apply_filters( 'insert_pages_wrap_content', $content, $inserted_page, $attributes );
|
351 |
|
352 |
return $content;
|
353 |
}
|
354 |
|
355 |
// Default filter for insert_pages_wrap_content.
|
356 |
function insertPages_wrap_content( $content, $posts, $attributes ) {
|
357 |
+
return "<{$attributes['wrapper_tag']} data-post-id='{$attributes['page']}' class='insert-page insert-page-{$attributes['page']} {$attributes['class']}'>{$content}</{$attributes['wrapper_tag']}>";
|
358 |
}
|
359 |
|
360 |
// Filter hook: Add a button to the TinyMCE toolbar for our insert page tool
|
428 |
<div class="insertpage-options-wrapper">
|
429 |
<label for="insertpage-slug-field">
|
430 |
<span><?php _e( 'Slug or ID' ); ?></span>
|
431 |
+
<input id="insertpage-slug-field" type="text" autocomplete="off" />
|
432 |
<input id="insertpage-pageID" type="hidden" />
|
433 |
</label>
|
434 |
</div>
|
450 |
</select>
|
451 |
</label>
|
452 |
</div>
|
453 |
+
<div class="insertpage-extra">
|
454 |
+
<label for="insertpage-extra-classes">
|
455 |
+
<?php _e( 'Extra Classes' ); ?>
|
456 |
+
<input id="insertpage-extra-classes" type="text" autocomplete="off" />
|
457 |
+
</label>
|
458 |
+
<label for="insertpage-extra-inline">
|
459 |
+
<?php _e( 'Inline?' ); ?>
|
460 |
+
<input id="insertpage-extra-inline" type="checkbox" />
|
461 |
+
</label>
|
462 |
+
</div>
|
463 |
</div>
|
464 |
</div>
|
465 |
<div class="submitbox">
|
js/wpinsertpages.js
CHANGED
@@ -25,6 +25,9 @@ var wpInsertPages;
|
|
25 |
inputs.parentPageID = $( '#insertpage-parent-pageID' );
|
26 |
// Format field (title, link, content, all, choose a custom template ->)
|
27 |
inputs.format = $( '#insertpage-format-select' );
|
|
|
|
|
|
|
28 |
// Custom template select field
|
29 |
inputs.template = $( '#insertpage-template-select' );
|
30 |
inputs.search = $( '#insertpage-search-field' );
|
@@ -199,7 +202,7 @@ var wpInsertPages;
|
|
199 |
// Set slug/id (also set the slug as the search term)
|
200 |
regexp = /page=['"]([^['"]*)['"]/;
|
201 |
matches = regexp.exec( shortcode );
|
202 |
-
if ( matches.length > 1 ) {
|
203 |
// Indicate that this search term is a slug or id.
|
204 |
if ( isNaN( parseInt( matches[1] ) ) ) {
|
205 |
inputs.search.data( 'type', 'slug' );
|
@@ -215,7 +218,7 @@ var wpInsertPages;
|
|
215 |
// Update display dropdown to match the selected shortcode.
|
216 |
regexp = /display=['"]([^['"]*)['"]/;
|
217 |
matches = regexp.exec( shortcode );
|
218 |
-
if ( matches.length > 1 ) {
|
219 |
if ( ['title', 'link', 'excerpt', 'excerpt-only', 'content', 'all', ].indexOf( matches[1] ) >= 0 ) {
|
220 |
inputs.format.val( matches[1] );
|
221 |
inputs.template.val( 'all' );
|
@@ -226,6 +229,24 @@ var wpInsertPages;
|
|
226 |
inputs.format.change();
|
227 |
}
|
228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
// Update save prompt.
|
230 |
inputs.submit.val( 'Update' );
|
231 |
|
@@ -243,6 +264,8 @@ var wpInsertPages;
|
|
243 |
inputs.format.val('title');
|
244 |
inputs.format.change();
|
245 |
inputs.template.val('all');
|
|
|
|
|
246 |
inputs.search.val( '' );
|
247 |
inputs.search.data( 'type', 'text' );
|
248 |
inputs.search.keyup();
|
@@ -269,6 +292,8 @@ var wpInsertPages;
|
|
269 |
page: inputs.slug.val(),
|
270 |
pageID: inputs.pageID.val(),
|
271 |
display: inputs.format.val()=='template' ? inputs.template.val() : inputs.format.val(),
|
|
|
|
|
272 |
};
|
273 |
},
|
274 |
|
@@ -298,6 +323,8 @@ var wpInsertPages;
|
|
298 |
editor.selection.setContent("[insert " +
|
299 |
"page='" + attrs.page +"' " +
|
300 |
"display='" + attrs.display + "'" +
|
|
|
|
|
301 |
"]");
|
302 |
editor.execCommand("mceEndUndoLevel");
|
303 |
},
|
25 |
inputs.parentPageID = $( '#insertpage-parent-pageID' );
|
26 |
// Format field (title, link, content, all, choose a custom template ->)
|
27 |
inputs.format = $( '#insertpage-format-select' );
|
28 |
+
// Extra fields (wrapper classes, inline checkbox)
|
29 |
+
inputs.extraClasses = $( '#insertpage-extra-classes' );
|
30 |
+
inputs.extraInline = $( '#insertpage-extra-inline' );
|
31 |
// Custom template select field
|
32 |
inputs.template = $( '#insertpage-template-select' );
|
33 |
inputs.search = $( '#insertpage-search-field' );
|
202 |
// Set slug/id (also set the slug as the search term)
|
203 |
regexp = /page=['"]([^['"]*)['"]/;
|
204 |
matches = regexp.exec( shortcode );
|
205 |
+
if ( matches && matches.length > 1 ) {
|
206 |
// Indicate that this search term is a slug or id.
|
207 |
if ( isNaN( parseInt( matches[1] ) ) ) {
|
208 |
inputs.search.data( 'type', 'slug' );
|
218 |
// Update display dropdown to match the selected shortcode.
|
219 |
regexp = /display=['"]([^['"]*)['"]/;
|
220 |
matches = regexp.exec( shortcode );
|
221 |
+
if ( matches && matches.length > 1 ) {
|
222 |
if ( ['title', 'link', 'excerpt', 'excerpt-only', 'content', 'all', ].indexOf( matches[1] ) >= 0 ) {
|
223 |
inputs.format.val( matches[1] );
|
224 |
inputs.template.val( 'all' );
|
229 |
inputs.format.change();
|
230 |
}
|
231 |
|
232 |
+
// Update extra classes.
|
233 |
+
regexp = /class=['"]([^['"]*)['"]/;
|
234 |
+
matches = regexp.exec( shortcode );
|
235 |
+
if ( matches && matches.length > 1 ) {
|
236 |
+
inputs.extraClasses.val( matches[1] );
|
237 |
+
} else {
|
238 |
+
inputs.extraClasses.val( '' );
|
239 |
+
}
|
240 |
+
|
241 |
+
// Update extra inline (i.e., use span instead of div for wrapper).
|
242 |
+
regexp = /inline/;
|
243 |
+
matches = regexp.exec( shortcode );
|
244 |
+
if ( matches && matches.length > 0 ) {
|
245 |
+
inputs.extraInline.attr( 'checked', true );
|
246 |
+
} else {
|
247 |
+
inputs.extraInline.attr( 'checked', false );
|
248 |
+
}
|
249 |
+
|
250 |
// Update save prompt.
|
251 |
inputs.submit.val( 'Update' );
|
252 |
|
264 |
inputs.format.val('title');
|
265 |
inputs.format.change();
|
266 |
inputs.template.val('all');
|
267 |
+
inputs.extraClasses.val('');
|
268 |
+
inputs.extraInline.attr( 'checked', false );
|
269 |
inputs.search.val( '' );
|
270 |
inputs.search.data( 'type', 'text' );
|
271 |
inputs.search.keyup();
|
292 |
page: inputs.slug.val(),
|
293 |
pageID: inputs.pageID.val(),
|
294 |
display: inputs.format.val()=='template' ? inputs.template.val() : inputs.format.val(),
|
295 |
+
class: inputs.extraClasses.val(),
|
296 |
+
inline: inputs.extraInline.is( ':checked' ),
|
297 |
};
|
298 |
},
|
299 |
|
323 |
editor.selection.setContent("[insert " +
|
324 |
"page='" + attrs.page +"' " +
|
325 |
"display='" + attrs.display + "'" +
|
326 |
+
( attrs['class'].length > 0 ? " class='" + attrs['class'] + "'" : "" ) +
|
327 |
+
( attrs.inline ? " inline" : "" ) +
|
328 |
"]");
|
329 |
editor.execCommand("mceEndUndoLevel");
|
330 |
},
|
readme.txt
CHANGED
@@ -86,14 +86,16 @@ Just one! The plugin prevents you from embedding a page in itself, but you can t
|
|
86 |
|
87 |
== Changelog ==
|
88 |
|
89 |
-
=
|
90 |
-
*
|
|
|
|
|
91 |
Example 1:
|
92 |
`/**
|
93 |
* Enable nested shortcodes by hooking into insert_pages_wrap_content.
|
94 |
*
|
95 |
* @param string $content The post content of the inserted page.
|
96 |
-
* @param array $
|
97 |
* @param array $attributes Extra parameters modifying the inserted page.
|
98 |
* page: Page ID or slug of page to be inserted.
|
99 |
* display: Content to display from inserted page.
|
@@ -103,7 +105,7 @@ Example 1:
|
|
103 |
* should_apply_the_content_filter: Whether to apply the_content filter to post contents and excerpts.
|
104 |
* wrapper_tag: Tag to use for the wrapper element (e.g., div, span).
|
105 |
*/
|
106 |
-
function your_custom_wrapper_function( $content, $
|
107 |
return do_shortcode( $content );
|
108 |
}
|
109 |
add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function', 9, 3 );`
|
@@ -112,7 +114,7 @@ Example 2:
|
|
112 |
* Completely modify markup generated by Insert Pages by hooking into insert_pages_wrap_content.
|
113 |
*
|
114 |
* @param string $content The post content of the inserted page.
|
115 |
-
* @param array $
|
116 |
* @param array $attributes Extra parameters modifying the inserted page.
|
117 |
* page: Page ID or slug of page to be inserted.
|
118 |
* display: Content to display from inserted page.
|
@@ -122,10 +124,16 @@ Example 2:
|
|
122 |
* should_apply_the_content_filter: Whether to apply the_content filter to post contents and excerpts.
|
123 |
* wrapper_tag: Tag to use for the wrapper element (e.g., div, span).
|
124 |
*/
|
125 |
-
function your_custom_wrapper_function( $content, $
|
|
|
|
|
|
|
126 |
return "<section class='my-section {$attributes['class']}'>$content</section>";
|
127 |
}
|
128 |
-
add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function',
|
|
|
|
|
|
|
129 |
|
130 |
= 2.9 =
|
131 |
* Add filter for altering the markup generated by Insert Pages. This filter is used internally at priority 10, so if you want to modify $content, do it earlier (priority 1-9); if you want to reconstruct the generated markup using the supplied parameters, do it after (priority 11+). Props @heiglandreas!
|
86 |
|
87 |
== Changelog ==
|
88 |
|
89 |
+
= 3.0 =
|
90 |
+
* Hotfix: 2.9.1 broke extra classes added to the inserted page wrapper.
|
91 |
+
* Feature: Expose extra classes and inline status in tinymce dialog.
|
92 |
+
* One more API change to insert_pages_wrap_content_filter (2nd parameter is a WP_Post now instead of an array of WP_Posts, since we only ever insert one page).
|
93 |
Example 1:
|
94 |
`/**
|
95 |
* Enable nested shortcodes by hooking into insert_pages_wrap_content.
|
96 |
*
|
97 |
* @param string $content The post content of the inserted page.
|
98 |
+
* @param array $inserted_page The post object returned from querying the inserted page.
|
99 |
* @param array $attributes Extra parameters modifying the inserted page.
|
100 |
* page: Page ID or slug of page to be inserted.
|
101 |
* display: Content to display from inserted page.
|
105 |
* should_apply_the_content_filter: Whether to apply the_content filter to post contents and excerpts.
|
106 |
* wrapper_tag: Tag to use for the wrapper element (e.g., div, span).
|
107 |
*/
|
108 |
+
function your_custom_wrapper_function( $content, $inserted_page, $attributes ) {
|
109 |
return do_shortcode( $content );
|
110 |
}
|
111 |
add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function', 9, 3 );`
|
114 |
* Completely modify markup generated by Insert Pages by hooking into insert_pages_wrap_content.
|
115 |
*
|
116 |
* @param string $content The post content of the inserted page.
|
117 |
+
* @param array $inserted_page The post object returned from querying the inserted page.
|
118 |
* @param array $attributes Extra parameters modifying the inserted page.
|
119 |
* page: Page ID or slug of page to be inserted.
|
120 |
* display: Content to display from inserted page.
|
124 |
* should_apply_the_content_filter: Whether to apply the_content filter to post contents and excerpts.
|
125 |
* wrapper_tag: Tag to use for the wrapper element (e.g., div, span).
|
126 |
*/
|
127 |
+
function your_custom_wrapper_function( $content, $inserted_page, $attributes ) {
|
128 |
+
// Remove the default filter that wraps the content in a div or span.
|
129 |
+
remove_all_filters( 'insert_pages_wrap_content', 10 );
|
130 |
+
// Return your custom wrapper around the content.
|
131 |
return "<section class='my-section {$attributes['class']}'>$content</section>";
|
132 |
}
|
133 |
+
add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function', 9, 3 );`
|
134 |
+
|
135 |
+
= 2.9.1 =
|
136 |
+
* API Change: modify insert_pages_wrap_content filter. Props @heiglandreas.
|
137 |
|
138 |
= 2.9 =
|
139 |
* Add filter for altering the markup generated by Insert Pages. This filter is used internally at priority 10, so if you want to modify $content, do it earlier (priority 1-9); if you want to reconstruct the generated markup using the supplied parameters, do it after (priority 11+). Props @heiglandreas!
|