Permalink
Browse files

Merged in grzegorzdrozd/insert-pages-with-excerpt/feature-excerpt (pu…

…ll request #1)


Excerpt option for page embedding.
  • Loading branch information...
figureone committed Jan 6, 2015
2 parents d1bf278 + 8f053de commit 0f6402c98058858f76f3f865bb3f8c5aba4cda65
Showing with 9 additions and 7 deletions.
  1. +9 −7 insert-pages.php
View
@@ -27,7 +27,7 @@
*/
/* Shortcode Format:
[insert page='{slug}|{id}' display='title|link|content|all|{custom-template.php}']
[insert page='{slug}|{id}' display='title|link|excerpt|content|all|{custom-template.php}']
*/
// Define the InsertPagesPlugin class (variables and functions)
@@ -98,7 +98,7 @@ function insertPages_handleShortcode_insert($atts, $content=null) {
// Validation checks
if ($page==='0')
return $content;
//if (!preg_match('/_(title|link|content|all|.*\.tpl\.php/)', $display, $matches))
//if (!preg_match('/_(title|link|excerpt|content|all|.*\.tpl\.php/)', $display, $matches))
// return $content;
if ($page==$post->ID || $page==$post->post_name) // trying to embed same page in itself
return $content;
@@ -126,6 +126,12 @@ function insertPages_handleShortcode_insert($atts, $content=null) {
the_post();
echo "<a href='"; the_permalink(); echo "'>"; echo the_title(); echo "</a>";
break;
case "excerpt":
the_post();
echo "<h1>"; the_title(); echo "</h1>";
echo the_excerpt();
echo "<a href='"; the_permalink(); echo "'>"; echo the_title(); echo "</a>";
break;
case "content":
the_post();
echo the_content();
@@ -226,6 +232,7 @@ function insertPages_wp_tinymce_dialog() {
<select name="insertpage-format-select" id="insertpage-format-select">
<option value='title'>Title</option>
<option value='link'>Link</option>
<option value='excerpt'>Excerpt</option>
<option value='content'>Content</option>
<option value='all'>All (includes custom fields)</option>
<option value='template'>Use a custom template &raquo;</option>
@@ -345,8 +352,3 @@ function insertPages_wp_query( $args = array() ) {
add_action('wp_ajax_insertpage', array($insertPages_plugin, 'insertPages_insert_page_callback')); // Populate page search in TinyMCE button popup in this ajax call
}
?>

0 comments on commit 0f6402c

Please sign in to comment.