Admin panel is under presentation tab. Need Help? Visit the Official INAP support thread Author: Aaron Dowden Version: 2.2.3 Author URI: http://anthologyoi.com/ Liscense: This Plugin is free for use, and may be modified, but may not be included in any bundled download, nor may it or its derivitive works be distributed in such a way that it can create a profit. */ $use_options = get_option('inap_use_options'); $inapall = array(); if($use_options || strpos($_SERVER['PHP_SELF'], 'wp-admin')){ $inapall = get_option('inap'); } add_action('init', 'inap_init'); function inap_init() { $currentLocale = get_locale(); if(!empty($currentLocale)) { $moFile = dirname(__FILE__) . "/inap-" . $currentLocale . ".mo"; if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('inap', $moFile); } //Fix a conflict with Postviews Plus if(function_exists('process_postviews')){ remove_action('the_content', 'process_postviews'); add_action('loop_start', 'process_postviews'); } } add_action('wp_head', 'inap_header'); function inap_header(){ global $inapall,$wp_version; $home = get_settings('siteurl'); if($wp_version == 2.1){ if($inapall['use_prototype'] == 1 || $inapall['use_scriptaculous'] == 1){ $ajax = 'prototype'; }else{ $ajax='sack'; } if($inapall['use_scriptaculous'] == 1){ wp_print_scripts('scriptaculous-effects'); } wp_register_script('inap-misc', $home.'/wp-content/plugins'.inap_get_base().'/inap-misc.js.php', false, '1'); if($inapall['add_comments_tags'] == 1){ wp_register_script('inap-quicktags', $home.'/wp-content/plugins'.inap_get_base().'/inap-quicktags.js', false, '1'); wp_print_scripts('inap-quicktags'); } wp_print_scripts(array($ajax, 'inap-misc', 'inap-quicktags')); }else{ if($inapall['use_prototype'] == 1 && $inapall['use_scriptaculous'] != 1){ $ajax = $inapall['prototype_library_url']; }elseif($inapall['use_scriptaculous'] == 1){ echo ''."\n"; echo ''."\n"; echo ''."\n"; }else{ $ajax = '/wp-includes/js/tw-sack.js'; } echo ''."\n"; if($ajax){ echo ''."\n"; } } if($inapall['do_effect'] == 'Fade'){ //this is for IE support only. Everybody BOOOOOOO IE //It's not like they could make it easy for us... $style = "zoom:1; \n background-color:$inapall[background_color];"; } ?> 1){ while (list($key, $value) = each ($inapall)){ if(!empty($value) && $value != ''){ $$key = $value; } } reset($inapall); } $link_show_text = inap_get_text($link_show_text); $link_hide_text = inap_get_text($link_hide_text); if ( !empty($post->post_password) ) { // if there's a password if ( stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) { // and it doesn't match the cookie $output = get_the_password_form(); } }else // decide on the content if ($post->post_excerpt != ''){ inap_split('more', $split_mode, $inapall['line_break'], $inapall['word_limit']); }elseif($is_single){ inap_split('nextpage',1); }else{ $content = $post->post_content; if($show_html == 0){ $content = strip_tags($content); } inap_split('more', $split_mode, $inapall['line_break'], $inapall['word_limit']); } $output = $pages[0]; //lets make it look good if ( $preview ){ // preview fix for javascript bug with foreign languages $output =preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); } if ($default_behavior =='content'){ $output = apply_filters('the_content', $output.chr(13)); }else{ $output = apply_filters('the_excerpt', $output); } $output = str_replace(']]>', ']]>', $output); // Start the output. echo '
'.$output.'
'; //if there is more to show then we need an empty div and some links. if ( count($pages) > 1 || $show_more == 1) { echo ''; if(count($pages) > 2){ echo inap_pages(); }else{ echo ''.stripslashes($link_show_text).''; } } } if($inapall['simple_posts'] == 1){ add_filter('the_content', 'inap_content_filter',-10); add_filter('the_excerpt', 'inap_content_filter',0); add_filter('the_content','inap_break_content',99999); } function inap_content_filter($content='',$link_show_text='Click to continue reading', $link_hide_text='Hide Post', $split_mode=1, $show_html=1, $default_behavior='content', $word_limit=301, $line_break=2){ global $use_options,$inapall; global $id, $post, $page, $pages; global $is_home, $is_single; $is_single= is_single(); if(is_page()){ return $content; } if($use_options == 1 && count($inapall)>1){ while (list($key, $value) = each ($inapall)){ if(!empty($value) && $value != ''){ $$key = $value; } } reset($inapall); } $link_show_text = inap_get_text($link_show_text); $link_hide_text = inap_get_text($link_hide_text); if ( !empty($post->post_password) ) { // if there's a password if ( stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) { // and it doesn't match the cookie $output = get_the_password_form(); } }else // decide on the content if ($post->post_excerpt != ''){ inap_split('more', $split_mode, $inapall['line_break'], $inapall['word_limit']); }elseif($is_single){ inap_split('nextpage',1); }else{ $content = $post->post_content; if($show_html == 0){ $content = strip_tags($content); } inap_split('more', $split_mode, $inapall['line_break'], $inapall['word_limit']); } $output = $pages[0]; //lets make it look good if ( $preview ){ // preview fix for javascript bug with foreign languages $output =preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); } // temporary fix // inap_remove_bad_filters(); remove_filter('the_content','inap_break_content',99999); if ($default_behavior =='content'){ remove_filter('the_content', 'inap_content_filter',-10); $output = apply_filters('the_content', $output.chr(13)); add_filter('the_content', 'inap_content_filter',-10); }else{ remove_filter('the_excerpt', 'inap_content_filter',0); $output = apply_filters('the_excerpt', $output); add_filter('the_excerpt', 'inap_content_filter',0); } add_filter('the_content','inap_break_content',99999); // inap_add_bad_filters(); $output = str_replace(']]>', ']]>', $output); // Start the output. echo '
'.$output.'
'; //if there is more to show then we need an empty div and some links. if ( count($pages) > 1 || $show_more == 1) { echo ''; if(count($pages) > 2){ echo inap_pages(); }else{ echo ''.stripslashes($link_show_text).''; } } } function inap_break_content($content){ if(is_page()){ return $content; }else{ return ''; } } // // Emulates setup_postdata() // function inap_paginate(){ global $inapall; inap_split('nextpage', $inapall['split_mode'], $inapall['line_break'], $inapall['word_limit']); } function inap_split($mode='more', $split_mode=1, $line_break=2, $word_limit=300){ global $pages,$inapall,$post; global $is_page, $is_single; $pages = ''; $word_limit2 = ($inapall['paginate_word_limit'] != '')? $inapall['paginate_word_limit']: $inapall['word_limit']; $line_break2 = ($inapall['paginate_line_break'] != '')? $inapall['paginate_line_break']: $inapall['line_break']; $content = trim($post->post_content); $stripexcerpt = $inapall['strip_excerpt']; $content = force_balance_tags($content); $k = $y = $n = $x = 0; if($split_mode == 1 ||strpos($content, '') != false || strpos($content, '') != false || $is_page || $is_single){ $content = preg_replace("/\n\n/", '', $content); $content = preg_replace("/\n/", '', $content); $content = preg_replace("/\<\!--(nextpage|more)--\>\n/", '', $content); $output = preg_split('/\<\!--(nextpage|more)--\>/', $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; $output[$k] = force_balance_tags($output[$k]); $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; $output[$k] .= '...'; $output[$k] = force_balance_tags($output[$k]); $x=0; $k++; } } }else{ $output[0]=$content; } } if($post->post_excerpt != ''){ array_unshift($output, $post->post_excerpt); } $output = array_values(array_diff($output, array("","\n"))); $count = count($output); if($count <= 1){ $output[0] = $content; } if(is_feed() && $inapall['trimfeeds'] != 1){ $pages[0] = implode(' ',$output); }elseif($inapall['paginate_mode'] == 0 ){ if($mode == 'nextpage'){ $pages[0] = implode(' ',$output); }else{ $pages[0] = $output[0]; if($count > 1){ unset($output[0]); $pages[] = implode(' ',$output); } } }else{ $output = array_values(array_diff($output, array("","\n"))); $pages = $output; } } //modified version of wp_link_pages function inap_pages(){ global $id,$inapall, $pages; global $is_page, $is_single; $k = 1; if(!$inapall['pagelinks']){ $inapall['pagelinks'] = '%'; } $numpages = count($pages); if ( $numpages >0 ) { $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']; } return $output; } add_action('inap_comments','inap_comments'); function inap_comments(){ global $id, $post,$inapall; if ($post->comment_count > 0|| comments_open()){ if ( (is_single() && $inapall['show_comments_single'] == 1) || (is_page() && $inapall['show_comments_page'] == 1 )){ $inapall['split_comments'] = 2; include('inap-comments.php'); }else{ echo "\n".''; } } } add_action('inap_addcomments','inap_addcomments'); function inap_addcomments(){ global $id, $post,$inapall,$user_ID; if($inapall['comment_template'] == 1){ return; } if ( comments_open() ) { if ( (is_single() && $inapall['show_addcomments_single'] == 1) || (is_page() && $inapall['show_addcomments_page'] == 1 )){ echo "\n".'
'; include('inap-add-comments.php'); echo '
'; }else{ echo "\n".''; } } } add_action('inap_addcomments_link','inap_addcomments_link'); function inap_addcomments_link($addcomment_open='Add Comment', $addcomment_hide='Hide Comment Form',$num = ''){ global $id,$use_options,$inapall; global $is_page, $is_single; if($use_options == 1){ // basically we are going to dowhat we did in s_inap_post all over again. if ($inapall['addcomment_open'] != ''){ $addcomment_open = inap_get_text($inapall['addcomment_open']); } if ($inapall['addcomment_hide'] != ''){ $addcomment_hide = inap_get_text($inapall['addcomment_hide']); } if($inapall['comment_template'] == 1){ return; } } if( !$addcomment_open ) $addcomment_open='Add Comments'; $show2 = $addcomment_open; $show = $addcomment_open; if ( ($is_single && $inapall['show_addcomments_single'] == 1) || ($is_page && $inapall['show_addcomments_page'] == 1 )){ $show2 = $addcomment_hide; } if ( comments_open() ) { echo "\n".''.$show2.''; }else{ echo '1); return false;" rel="nofollow">'.$show.''; } }else{ if($inapall['closed_comments'] == ''){ _e('Comments are closed','inap'); }else{ echo inap_get_text($inapall['closed_comments']); } } } add_action('inap_comments_link','inap_comments_link'); function inap_comments_link($comment_open='Show Posts Comments', $comment_hide='Hide Post Comments'){ global $id,$post,$use_options,$inapall; if($use_options == 1){ // basically we are going to do what we did in s_inap_post all over again. if ($inapall['comment_open'] != ''){ $comment_open = inap_get_text($inapall['comment_open']); } if ($inapall['comment_hide'] != ''){ $comment_hide = inap_get_text($inapall['comment_hide']); } } if( !$comment_open ) $comment_open='Show Posts Comments'; $show = $comment_open; // this is the most cheating way to do it, but it makes it Soooo easy. if ( (is_single() && $inapall['show_comments_single'] == 1) || (is_page() && $inapall['show_comments_single'] == 1 )){ $show = $comment_hide; } if ($post->comment_count == 0 && comments_open() && $inapall['comment_template'] != 1){ echo "\n".''; if($inapall['no_comments'] == ''){ _e('No Comments','inap'); }else{ echo inap_get_text($inapall['no_comments']); } echo ' '; echo "\n".' '; }elseif($post->comment_count == 0&& !comments_open()){ if($inapall['no_comments'] == ''){ _e('No Comments','inap'); }else{ echo inap_get_text($inapall['no_comments']); } }else{ echo "\n".''.$show.''; } } add_action('live_preview', 'inap_live_preview'); function inap_live_preview(){ global $inapall,$id; if($inapall['live_preview'] == 1){ echo $inapall['live_preview_before']; echo '
Go ahead and start typing.
'; echo $inapall['live_preview_after']; } } add_action('admin_menu', 'inap_menu'); function inap_menu() { add_submenu_page('themes.php', 'INAP Managment', 'INAP Managment', 8,dirname(__FILE__).'/inap_admin.php'); } function inap_update_options($options){ global $inapall; if(!$options['strip_excerpt']){ $options['strip_excerpt'] = 0; } if(!$options['show_html']){ $options['show_html'] = 0; } if(!$options['use_fade']){ $options['use_fade'] = 0; } if(!$options['simple_posts']){ $options['simple_posts'] = 0; } if(!$options['simple_comments']){ $options['simple_comments'] = 0; } if(!$options['use_prototype']){ $options['use_prototype'] = 0; } if(!$options['use_scriptaculous']){ $options['use_scriptaculous'] =0; } if(!$options['use_scriptaculous_posts']){ $options['use_scriptaculous_posts'] = 0; } if(!$options['paginate_even']){ $options['paginate_even'] = 0; } if(!$options['show_addcomments_single']){ $options['show_addcomments_single'] = 0; } if(!$options['show_comments_single']){ $options['show_comments_single'] = 0; } if(!$options['show_addcomments_page']){ $options['show_addcomments_page'] = 0; } if(!$options['show_comments_page']){ $options['show_comments_page'] = 0; } if(!$options['show_addcomments_home']){ $options['show_addcomments_home'] = 0; } if(!$options['show_comments_home']){ $options['show_comments_home'] = 0; } if(!$options['trimfeeds']){ $options['trimfeeds'] = 0; } if(!$options['live_preview']){ $options['live_preview'] = 0; } if(!$options['live_preview_smilies']){ $options['live_preview_smilies'] = 0; } if(!$options['live_preview_html']){ $options['live_preview_html'] = 0; } while (list($option, $value) = each($options)) { if( get_magic_quotes_gpc() ) { $value = stripslashes($value); } $inapall[$option] =$value; } return $inapall; } function inap_embedded_post($pid){ global $inapall,$wpdb,$id; if(count($pid)>0 || !is_int($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_show_text'],$pid); $link_hide_text = inap_get_text($inapall['link_hide_text'],$pid); $link_show_text= str_replace("'",'’',$link_show_text); $link_hide_text= str_replace("'",'’',$link_hide_text); $add = ''.$output.''. ''. ''.stripslashes($link_show_text).''; if($return){ return $add; }else{ echo $add; } } } } 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); } if($inapall['simple_comments'] == 1){ add_filter('comments_template','inap_comment_filter',1); } function inap_comment_filter($i){ global $id, $post,$inapall; return(ABSPATH . 'wp-content/plugins/inap/inap-comments.php'); } function inap_next_posts_link($label='Next Page »', $max_page=0) { global $paged, $wpdb, $wp_query; if ( !$max_page ) { $max_page = $wp_query->max_num_pages; } if ( !$paged ) $paged = 1; $nextpage = intval($paged) + 1; if ( (! is_single()) && (empty($paged) || $nextpage <= $max_page) ) { echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; } } function inap_previous_posts_link($label='« Previous Page') { global $paged; if ( (!is_single()) && ($paged > 1) ) { echo ''. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .''; } } function inap_posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') { global $wp_query; if ( !is_singular() ) { $max_num_pages = $wp_query->max_num_pages; $paged = get_query_var('paged'); //only have sep if there's both prev and next results if ($paged < 2 || $paged >= $max_num_pages) { $sep = ''; } if ( $max_num_pages > 1 ) { inap_previous_posts_link($prelabel); echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep); inap_next_posts_link($nxtlabel); } } } function inap_previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { if ( is_attachment() ) $post = & get_post($GLOBALS['post']->post_parent); else $post = get_previous_post($in_same_cat, $excluded_categories); if ( !$post ) return; $title = apply_filters('the_title', $post->post_title, $post); $string = ''; $link = str_replace('%title', $title, $link); $link = $pre . $string . $link . ''; $format = str_replace('%link', $link, $format); echo $format; } function inap_next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { $post = get_next_post($in_same_cat, $excluded_categories); if ( !$post ) return; $title = apply_filters('the_title', $post->post_title, $post); $string = ''; $link = str_replace('%title', $title, $link); $link = $string . $link . ''; $format = str_replace('%link', $link, $format); echo $format; } // // The following two functions are a temporary fix to prevent certain filters from being called twice. // function inap_remove_bad_filters(){ if(function_exists('akst_add_share_link_to_content')){ remove_filter('the_content','akst_add_share_link_to_content'); } if(function_exists('sf_setup_forum')){ remove_filter('the_content','sf_setup_forum'); } } function inap_add_bad_filters(){ if(function_exists('akst_add_share_link_to_content')){ add_filter('the_content','akst_add_share_link_to_content'); } if(function_exists('sf_setup_forum')){ add_filter('the_content','sf_setup_forum'); } } // // To integrate with the subscribe to comments plugin. // function inap_show_subscription_checkbox($buffer){ global $id; $buffer = str_replace('id="subscribe"','id="subscribe_'.$id.'"',$buffer); echo $buffer; } // // To integrate with the WP-PostViews plugin // function inap_process_postviews() { global $id; $post_views = get_post_custom($post_id); $post_views = intval($post_views['views'][0]); if(empty($_COOKIE[USER_COOKIE])) { if($post_views > 0) { update_post_meta($id, 'views', ($post_views+1)); } else { add_post_meta($id, 'views', 1, true); } } } function inap_get_base(){ return '/'.end(explode('/', str_replace(array('\\','/inap.php'),array('/',''),__FILE__))); } /** * * The Following functions are officially deprecated, and may be removed in upcoming versions * * **/ function inap_post_s($args=''){ $args= str_replace('’','\'',$args); $args= str_replace('“','"',$args); $args= str_replace('”','"',$args); parse_str($args,$r); if ($r['link_show_text'] == ''){ $r['link_show_text'] = 'Click to continue reading'; } if ($r['link_hide_text'] == ''){ $r['link_hide_text'] = 'Hide Post'; } if ($r['split_mode'] == ''){ $r['split_mode'] = '0'; } if ($r['show_html'] == ''){ $r['show_html']= '1'; } if ($r['default_behavior'] == ''){ $r['default_behavior'] = 'content'; } if ($r['word_limit'] == ''){ $r['word_limit'] = '121'; } if ($r['line_break'] == ''){ $r['line_break'] = '1'; } $r['link_show_text'] = stripslashes(htmlspecialchars($r['link_show_text'], ENT_QUOTES)); $r['link_hide_text'] = stripslashes(htmlspecialchars( $r['link_hide_text'], ENT_QUOTES)); return inap_post($r['link_show_text'], $r['link_hide_text'], $r['split_mode'], $r['show_html'], $r['default_behavior'],$r['word_limit'], $r['line_break']); } function inap_content($link_show_text = 'Continue Reading', $link_hide_text='Hide Post', $stripteaser = 0){ return inap_post($link_show_text, $link_hide_text,1,1,'content'); } function inap_excerpt($link_show_text = 'Continue Reading', $link_hide_text='Hide Post'){ return inap_post($link_show_text, $link_hide_text,3,0,'excerpt',55); } ?>