', ']]>', $output);
echo '
'.$output.'
';
if(!$inapall['inap_pages'])
echo inap_pages();
}
if($inapall['simple_posts'] == 1){
add_filter('the_content', 'inap_content_filter',-10);
add_filter('the_excerpt', 'inap_content_filter',-10);
}
function inap_content_filter($default_content, $split_mode=1, $strip_html=1, $default_behavior='content', $word_limit=301, $line_break=2){
global $inapall,$inaped_posts,$content;
global $id, $post, $page, $pages;
if ( !empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) { // and it doesn't match the cookie
$pages[0] = get_the_password_form();
}elseif(is_page()){
return $default_content;
}else
if(!is_numeric($inaped_posts[$id])){
if((is_single() && !$inapall['paginate_mode']) || (is_feed() && !$inapall['trimfeeds'])){
return $default_content;
}else{
inap_paginate();
}
}
$pages[0] = str_replace(']]>', ']]>', $pages[0]);
// Start the output.
$output = ''."\n".chr(13)."\n".$pages[0]."\n".chr(13)."\n".'
';
if(!$inapall['inap_pages'])
$output .= inap_pages();
return $output;
}
function inap_paginate(){
global $pages,$inapall,$inaped_posts,$post,$content,$id;
global $is_page, $is_single;
$pages = '';
$content = $post->post_content;
if($inapall['strip_html'] == 1){
$content = strip_tags($content);
}
$content = force_balance_tags($content);
$output = inap_split();
$count = count($output);
if($is_single || $count== 1){
if($split_mode != 2){
$pages[0] = force_balance_tags(implode(' ',$output));
}else{
$pages[0] = force_balance_tags(implode("\n".chr(13)."\n",$output));
}
}elseif(!$inapall['paginate_mode'] || $count == 2){
$pages[0] = force_balance_tags($output[0]);
if($inapall['strip_excerpt']){
unset($output[0]);
}
if($split_mode != 2){
$pages[1] = force_balance_tags(implode(' ',$output));
}else{
$pages[1] = force_balance_tags(implode("\n".chr(13)."\n",$output));
}
if($inapall['split_mode'] == 3){
$pages[0] .= '...';
}
}else{
foreach($output as $page){
if($inapall['split_mode'] == 3 && $i < $count-1){
$pages[] = force_balance_tags($page).'...';
}else{
$pages[] = force_balance_tags($page);
}
$i++;
}
}
}
function inap_split($split_mode=1, $line_break=2, $word_limit=300){
global $pages,$inapall,$inaped_posts,$post,$content,$id;
global $is_page, $is_single;
$k = $y = $n = $x = 0;
$word_limit = ($inapall['word_limit'])? $inapall['word_limit']: $word_limit;
$line_break = ($inapall['line_break'])? $inapall['line_break']: $line_break;
$split_mode = ($inapall['split_mode'])? $inapall['split_mode']: $split_mode;
$word_limit2 = ($inapall['paginate_word_limit'] > 0)? $inapall['paginate_word_limit']: $inapall['word_limit'];
$line_break2 = ($inapall['paginate_line_break'] > 0)? $inapall['paginate_line_break']: $inapall['line_break'];
if($split_mode == 1 ||strpos($content, '') != false || strpos($content, '') != false || $is_page || $is_single){
$output = preg_split('/\S*\<\!--(nextpage|more)--\>\S*/', $content);
}elseif($split_mode == 2){
$lines = preg_split('/(\n'.chr(13).'\n+)/', $content,-1, PREG_SPLIT_DELIM_CAPTURE);
$i = count($lines);
if($i > $line_break){
for($y=$n; $y < $i; $y++){
$output[$k] .= $lines[$y];
$y++;
$output[$k] .= $lines[$y];
$x++;
if($x>=$line_break){
$line_break = $line_break2;
$x=0;
$k++;
}
}
}else{
$output[0]=$content;
}
}elseif($split_mode == 3){
$words = explode(' ', $content);
if (count($words) > $word_limit) {
$i = count($words);
for($y=$n; $y <=$i; $y++){
$output[$k] .= ' '.$words[$y];
$x++;
if($x >=$word_limit && ($i-$y >= $word_limit/2 || $k == 0)){
$word_limit = $word_limit2;
$x=0;
$k++;
}
}
}else{
$output[0]=$content;
}
}
if($post->post_excerpt != '' && !is_single() && !is_page()){
array_unshift($output, $post->post_excerpt);
}
$inaped_posts[$id] =1;
return array_values(array_diff($output, array("","\n")));
}
// Ensures that things added to the end of the content are not repeated.
function inap_break_content($content){
if(function_exists('wp_lightboxJS_replace')|| function_exists('wp_lightbox_plus')){
$content = preg_replace('@(]*?rel="lightbox")@', '${1} onclick="showLightbox(this); return false;"', $content);
}
$content = explode('@$%@$$%##$%#$%#$',$content);
return $content[0];
}
add_action('inap_pages','inap_pages');
//modified version of wp_link_pages
function inap_pages($link_show_text='Click to continue reading', $link_hide_text='Hide Post'){
global $id,$inapall,$inaped_posts, $pages;
global $is_page, $is_single;
$k = 1;
if($inapall['link_show_text']){
$link_show_text=$inapall['link_show_text'];
}
if($inapall['link_hide_text']){
$link_hide_text=$inapall['link_hide_text'];
}
if(!$link_show_text){
$link_show_text='Click to continue reading';
}
$link_show_text = inap_get_text($link_show_text);
$link_hide_text = inap_get_text($link_hide_text);
if(!is_numeric($inaped_posts[$id])){
if($is_single && !$inapall['paginate_mode']){
$pages[0] = $content;
}else{
inap_paginate();
}
}
if(!$inapall['pagelinks']){
$inapall['pagelinks'] = '%';
}
$numpages = count($pages);
if ( $numpages >2 ) {
$output = $inapall['beforepages'];
for ( $i = 1; $i <= $numpages; $i++ ) {
preg_match('//',$pages[$i-1],$matches);
if($matches[1]){
$j = htmlspecialchars($matches[1],ENT_QUOTES);
}else{
$j = str_replace('%',"$k",$inapall['pagelinks']);
}
if(!$is_single || !$is_page){
$ref = 'rel="nofollow"';
}
$output .= ' '.$inapall['beforepage'];
if ( '' == get_option('permalink_structure') ){
$output .= '';
}else{
$output .= '';
}
$output .= $j.''.$inapall['afterpage'];
$k++;
}
$output .= $inapall['afterpages'];
}elseif($numpages == 2){
$output.= ''.stripslashes($link_show_text).'';
}
if(!$inapall['inap_pages']){
return $output;
}else{
echo $output;
}
}
add_filter('the_content','inap_list_pages');
add_filter('the_excerpt','inap_list_pages');
function inap_embed_pages(){
global $id;
//wp_list_pages('sort_column=post_title&child_of='.$id.'&depth=1&title_li=');
$r = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'),
'child_of' => $id, 'exclude' => '', 'title_li' =>'', 'echo' => 1, 'authors' => '');
// Query pages.
$pages = get_pages($r);
foreach($pages as $page){
if($page->post_status != 'draft' && $page->post_status !='future'){
$output .= apply_filters('the_title', ''.$page->post_title.'
');
$output .= inap_embedded_post($page->ID);}
}
return $output;
}
function inap_list_pages($content){
return preg_replace_callback('!\[mychildren\]!ims', 'inap_embed_pages', $content);
}
function inap_embedded_post($pid){
global $inapall,$inaped_posts,$wpdb,$id;
if(!is_array($pid)){
$return = 1;
$pid = $pid;
}elseif(is_array($pid)){
$return = 1;
$pid = $pid[1];
}
if($id != $pid){
$good_post = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status != 'draft' && post_status !='future' && ID = '$pid'");
if($good_post){
$link_show_text = inap_get_text($inapall['link_embed_show_text'],$pid);
$link_hide_text = inap_get_text($inapall['link_embed_hide_text'],$pid);
$link_show_text= str_replace("'",'’',$link_show_text);
$link_hide_text= str_replace("'",'’',$link_hide_text);
$add = ''.
''.stripslashes($link_show_text).'';
if($return){
return $add;
}else{
echo $add;
}
}
}
}
function inap_title(){
global $inapall, $id, $post;
$title = the_title('','',false);
echo 'onclick="inap_request(\''.$id.'\',\'content\',\''.$title.'\',\''.$title.'\'); return false;" id="post_content_link_'.$id.'"';
}
add_filter('the_content','inap_embedded_post_tag');
add_filter('the_excerpt','inap_embedded_post_tag');
function inap_embedded_post_tag($content){
return preg_replace_callback('!\[embed=([0-9]*)\]!ims', 'inap_embedded_post', $content);
}
?>