Insert Pages - Version 3.1.3

Version Description

  • Prevent menu items and page attachments from being insertable; this fixes problems with inserting pages via slug when there is a menu item with the same slug as a page/post. Props @k7f7 for tracking this one down!
Download this release

Release Info

Developer figureone
Plugin Icon wp plugin Insert Pages
Version 3.1.3
Comparing to
See all releases

Code changes from version 3.1.2 to 3.1.3

Files changed (2) hide show
  1. insert-pages.php +7 -2
  2. readme.txt +3 -0
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: 3.1.2
9
  Author URI: http://www.linkedin.com/in/paulrryan
10
  License: GPL2
11
  */
@@ -182,7 +182,12 @@ if ( !class_exists( 'InsertPagesPlugin' ) ) {
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'] ) );
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.1.3
9
  Author URI: http://www.linkedin.com/in/paulrryan
10
  License: GPL2
11
  */
182
 
183
  // Get the WP_Post object from the provided slug or ID.
184
  if ( ! is_numeric( $attributes['page'] ) ) {
185
+ // Get list of post types that can be inserted (page, post, custom
186
+ // types), excluding builtin types (nav_menu_item, attachment).
187
+ $insertable_post_types = array_filter( get_post_types(), function ( $type ) {
188
+ return ! in_array( $type, array( 'nav_menu_item', 'attachment' ) );
189
+ });
190
+ $inserted_page = get_page_by_path( $attributes['page'], OBJECT, $insertable_post_types );
191
  $attributes['page'] = $inserted_page ? $inserted_page->ID : $attributes['page'];
192
  } else {
193
  $inserted_page = get_post( intval( $attributes['page'] ) );
readme.txt CHANGED
@@ -86,6 +86,9 @@ Just one! The plugin prevents you from embedding a page in itself, but you can t
86
 
87
  == Changelog ==
88
 
 
 
 
89
  = 3.1.2 =
90
  * Fix for custom template dropdown not enabling when configuring the widget on the theme customizer page (customize.php). Props @aassouad for finding this!
91
 
86
 
87
  == Changelog ==
88
 
89
+ = 3.1.3 =
90
+ * Prevent menu items and page attachments from being insertable; this fixes problems with inserting pages via slug when there is a menu item with the same slug as a page/post. Props @k7f7 for tracking this one down!
91
+
92
  = 3.1.2 =
93
  * Fix for custom template dropdown not enabling when configuring the widget on the theme customizer page (customize.php). Props @aassouad for finding this!
94