Version Description
- 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+).
Example 1:
`/**
- Enable nested shortcodes by hooking into insert_pages_wrap_content. *
- @param string $wrapper_tag The html element to wrap the content in (typically div or span).
- @param string $extra_classes Space-delimited list of classes to add to the wrapper element.
- @param int $post_id The ID of the inserted page.
- @param string $content The post content of the inserted page.
/
function your_custom_wrapper_function( $wrapper_tag, $extra_classes, $post_id, $content ) {
return do_shortcode( $content );
}
add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function', 9, 4 );
Example 2:
/* - Completely modify markup generated by Insert Pages by hooking into insert_pages_wrap_content. *
- @param string $wrapper_tag The html element to wrap the content in (typically div or span).
- @param string $extra_classes Space-delimited list of classes to add to the wrapper element.
- @param int $post_id The ID of the inserted page.
- @param string $content The post content of the inserted page.
*/
function your_custom_wrapper_function( $wrapper_tag, $extra_classes, $post_id, $content ) {
return "
$content "; } add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function', 11, 4 );`
Download this release
Release Info
Developer | figureone |
Plugin | Insert Pages |
Version | 2.9 |
Comparing to | |
See all releases |
Code changes from version 2.8 to 2.9
- insert-pages.php +22 -6
- readme.txt +31 -2
insert-pages.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
/*
|
4 |
Plugin Name: Insert Pages
|
5 |
-
Plugin URI: https://
|
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: 2.
|
9 |
Author URI: http://www.linkedin.com/in/paulrryan
|
10 |
License: GPL2
|
11 |
*/
|
@@ -106,12 +106,14 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
106 |
// Shortcode hook: Replace the [insert ...] shortcode with the inserted page's content
|
107 |
function insertPages_handleShortcode_insert( $atts, $content = null ) {
|
108 |
global $wp_query, $post, $wp_current_filter;
|
109 |
-
|
|
|
110 |
'page' => '0',
|
111 |
'display' => 'all',
|
112 |
'class' => '',
|
113 |
'inline' => false,
|
114 |
-
), $atts )
|
|
|
115 |
|
116 |
// Get options set in WordPress dashboard (Settings > Insert Pages).
|
117 |
$options = get_option( 'wpip_settings' );
|
@@ -172,7 +174,7 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
172 |
);
|
173 |
}
|
174 |
|
175 |
-
query_posts( $args );
|
176 |
|
177 |
$should_apply_the_content_filter = true;
|
178 |
/**
|
@@ -275,11 +277,24 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
|
|
275 |
wp_reset_query();
|
276 |
|
277 |
$wrapper_tag = $should_use_inline_wrapper ? 'span' : 'div';
|
278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
return $content;
|
280 |
//return do_shortcode($content); // careful: watch for infinite loops with nested inserts
|
281 |
}
|
282 |
|
|
|
|
|
|
|
|
|
283 |
|
284 |
// Filter hook: Add a button to the TinyMCE toolbar for our insert page tool
|
285 |
function insertPages_handleFilter_mceButtons( $buttons ) {
|
@@ -531,4 +546,5 @@ if ( isset( $insertPages_plugin ) ) {
|
|
531 |
add_action( 'before_wp_tiny_mce', array( $insertPages_plugin, 'insertPages_wp_tinymce_dialog' ), 1 ); // Preload TinyMCE popup
|
532 |
add_action( 'wp_ajax_insertpage', array( $insertPages_plugin, 'insertPages_insert_page_callback' ) ); // Populate page search in TinyMCE button popup in this ajax call
|
533 |
add_action( 'admin_print_footer_scripts', array( $insertPages_plugin, 'insertPages_add_quicktags' ) );
|
|
|
534 |
}
|
2 |
|
3 |
/*
|
4 |
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: 2.9
|
9 |
Author URI: http://www.linkedin.com/in/paulrryan
|
10 |
License: GPL2
|
11 |
*/
|
106 |
// Shortcode hook: Replace the [insert ...] shortcode with the inserted page's content
|
107 |
function insertPages_handleShortcode_insert( $atts, $content = null ) {
|
108 |
global $wp_query, $post, $wp_current_filter;
|
109 |
+
|
110 |
+
$shortcode_attributes = shortcode_atts( array(
|
111 |
'page' => '0',
|
112 |
'display' => 'all',
|
113 |
'class' => '',
|
114 |
'inline' => false,
|
115 |
+
), $atts );
|
116 |
+
extract( $shortcode_attributes );
|
117 |
|
118 |
// Get options set in WordPress dashboard (Settings > Insert Pages).
|
119 |
$options = get_option( 'wpip_settings' );
|
174 |
);
|
175 |
}
|
176 |
|
177 |
+
$posts = query_posts( $args );
|
178 |
|
179 |
$should_apply_the_content_filter = true;
|
180 |
/**
|
277 |
wp_reset_query();
|
278 |
|
279 |
$wrapper_tag = $should_use_inline_wrapper ? 'span' : 'div';
|
280 |
+
/**
|
281 |
+
* Filter the markup generated for the inserted page.
|
282 |
+
*
|
283 |
+
* @param string $wrapper_tag The html element to wrap the content in (typically div or span).
|
284 |
+
* @param string $extra_classes Space-delimited list of classes to add to the wrapper element.
|
285 |
+
* @param int $post_id The ID of the inserted page.
|
286 |
+
* @param string $content The post content of the inserted page.
|
287 |
+
*/
|
288 |
+
$content = apply_filters( 'insert_pages_wrap_content', $wrapper_tag, $class, $page, $content );
|
289 |
+
|
290 |
return $content;
|
291 |
//return do_shortcode($content); // careful: watch for infinite loops with nested inserts
|
292 |
}
|
293 |
|
294 |
+
// Default filter for insert_pages_wrap_content.
|
295 |
+
function insertPages_wrap_content( $wrapper_tag, $extra_classes, $post_id, $content ) {
|
296 |
+
return "<{$wrapper_tag} data-post-id='{$post_id}' class='insert-page insert-page-{$post_id} {$extra_classes}'>{$content}</{$wrapper_tag}>";
|
297 |
+
}
|
298 |
|
299 |
// Filter hook: Add a button to the TinyMCE toolbar for our insert page tool
|
300 |
function insertPages_handleFilter_mceButtons( $buttons ) {
|
546 |
add_action( 'before_wp_tiny_mce', array( $insertPages_plugin, 'insertPages_wp_tinymce_dialog' ), 1 ); // Preload TinyMCE popup
|
547 |
add_action( 'wp_ajax_insertpage', array( $insertPages_plugin, 'insertPages_insert_page_callback' ) ); // Populate page search in TinyMCE button popup in this ajax call
|
548 |
add_action( 'admin_print_footer_scripts', array( $insertPages_plugin, 'insertPages_add_quicktags' ) );
|
549 |
+
add_filter( 'insert_pages_wrap_content', array( $insertPages_plugin, 'insertPages_wrap_content' ), 10, 4 );
|
550 |
}
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: figureone, the_magician
|
3 |
Tags: insert, pages, shortcode, embed
|
4 |
Requires at least: 3.0.1
|
5 |
-
Tested up to: 4.
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -86,6 +86,35 @@ Just one! The plugin prevents you from embedding a page in itself, but you can t
|
|
86 |
|
87 |
== Changelog ==
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
= 2.8 =
|
90 |
* Feature: Add options page with option to insert page IDs instead of page slugs (users of WPML will need this feature if translated pages all share the same page slug).
|
91 |
* Feature: Inserted pages with Beaver Builder enabled now embed correctly.
|
@@ -166,7 +195,7 @@ add_action( 'init', 'theme_init' );`
|
|
166 |
|
167 |
= 1.7 =
|
168 |
* Tested and works on WordPress 4.1;
|
169 |
-
* New display format: excerpt. Props to bitbucket user grzegorzdrozd for the pull request. https://
|
170 |
|
171 |
= 1.6 =
|
172 |
* Fix for long page template names causing Display field to wrap in the tinymce popup;
|
2 |
Contributors: figureone, the_magician
|
3 |
Tags: insert, pages, shortcode, embed
|
4 |
Requires at least: 3.0.1
|
5 |
+
Tested up to: 4.4
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
86 |
|
87 |
== Changelog ==
|
88 |
|
89 |
+
= 2.9 =
|
90 |
+
* 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+).
|
91 |
+
Example 1:
|
92 |
+
`/**
|
93 |
+
* Enable nested shortcodes by hooking into insert_pages_wrap_content.
|
94 |
+
*
|
95 |
+
* @param string $wrapper_tag The html element to wrap the content in (typically div or span).
|
96 |
+
* @param string $extra_classes Space-delimited list of classes to add to the wrapper element.
|
97 |
+
* @param int $post_id The ID of the inserted page.
|
98 |
+
* @param string $content The post content of the inserted page.
|
99 |
+
*/
|
100 |
+
function your_custom_wrapper_function( $wrapper_tag, $extra_classes, $post_id, $content ) {
|
101 |
+
return do_shortcode( $content );
|
102 |
+
}
|
103 |
+
add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function', 9, 4 );`
|
104 |
+
Example 2:
|
105 |
+
`/**
|
106 |
+
* Completely modify markup generated by Insert Pages by hooking into insert_pages_wrap_content.
|
107 |
+
*
|
108 |
+
* @param string $wrapper_tag The html element to wrap the content in (typically div or span).
|
109 |
+
* @param string $extra_classes Space-delimited list of classes to add to the wrapper element.
|
110 |
+
* @param int $post_id The ID of the inserted page.
|
111 |
+
* @param string $content The post content of the inserted page.
|
112 |
+
*/
|
113 |
+
function your_custom_wrapper_function( $wrapper_tag, $extra_classes, $post_id, $content ) {
|
114 |
+
return "<section class='my-section $extra_classes'>$content</section>";
|
115 |
+
}
|
116 |
+
add_filter( 'insert_pages_wrap_content', 'your_custom_wrapper_function', 11, 4 );`
|
117 |
+
|
118 |
= 2.8 =
|
119 |
* Feature: Add options page with option to insert page IDs instead of page slugs (users of WPML will need this feature if translated pages all share the same page slug).
|
120 |
* Feature: Inserted pages with Beaver Builder enabled now embed correctly.
|
195 |
|
196 |
= 1.7 =
|
197 |
* Tested and works on WordPress 4.1;
|
198 |
+
* New display format: excerpt. Props to bitbucket user grzegorzdrozd for the pull request. https://github.com/uhm-coe/insert-pages/commit/0f6402c98058858f76f3f865bb3f8c5aba4cda65
|
199 |
|
200 |
= 1.6 =
|
201 |
* Fix for long page template names causing Display field to wrap in the tinymce popup;
|