All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.

Author Topic: How to Print all the posts of the blog ?  (Read 35874 times)

0 Members and 1 Guest are viewing this topic.

Offline oliv

  • Newbie
  • *
  • Posts: 7
    • View Profile
How to Print all the posts of the blog ?
« on: 29 February 2008, 12:58 »
Hello,

Well all is in the title message: "How to Print all the posts of the blog ?"

I have seen that the print template contains a loop for posts but do not see how to call it.

Nice jobs anyway.

Thanks,

Oliv

Offline oliv

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #1 on: 29 February 2008, 13:06 »
Well,

I found some bit of solution:

That is to call the category with adding &print=1 in the url

But it do not shows any comments.

And I am still looking for printing all the posts of all the categories.

@+
Oliv

Offline Ttech

  • Official Support
  • Global Moderator
  • *****
  • Posts: 4,296
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #2 on: 29 February 2008, 20:55 »
Do you have a site url and whats your info?
Learning and Helping one day at a time.




DevNode.org Operator - The IRC network for Programers

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: How to Print all the posts of the blog ?
« Reply #3 on: 01 March 2008, 05:15 »
You can't show comments on a category page as your template is not told to do so by your theme.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline oliv

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #4 on: 01 March 2008, 11:55 »
Hello,

Finally I find solution (quick and dirty trick)


Here's the code of wp-print. You need to call the index page of your template with &print=1 in the url to print all posts with comments

Code: [Select]
<?php
/*
+----------------------------------------------------------------+
| |
| WordPress 2.1 Plugin: WP-Print 2.20 |
| Copyright (c) 2007 Lester "GaMerZ" Chan |
| |
| File Written By: |
| - Lester "GaMerZ" Chan |
| - http://lesterchan.net |
| |
| File Information: |
| - Printer Friendly Page |
| - wp-print.php |
| |
+----------------------------------------------------------------+
*/


### Variables
$links_text '';
global 
$wpdb;
global 
$id;
global 
$user_ID;
global 
$comments;
global 
$comment;
global 
$cat;
global 
$p;
$p=$_GET["p"];
$cat=$_GET["cat"];

### Actions
add_action('init''print_content');

### Filters
add_filter('wp_title''print_pagetitle');
add_filter('comments_template''print_template_comments');

### Print Options
$print_options get_option('print_options');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Robots" content="noindex, nofollow" />
<link rel="stylesheet" href="<?php bloginfo('wpurl'); ?>/wp-content/plugins/print/wp-print-css.css" type="text/css" media="screen, print" />
</head>
<body>
<p style="text-align: center;"><strong>- <?php bloginfo('name'); ?> - <?php bloginfo('url')?> -</strong></p>
<center>
<div id="Outline">

<?php if (!$p && !$cat): ?>

<?php query_posts('showposts=200'); ?>
<?php endif; ?>


<?php if (have_posts()): ?>
<?php while (have_posts()): the_post(); ?>

<p id="BlogTitle"><?php the_title(); ?></p>
<p id="BlogDate"><?php _e('Posted By''wp-print'); ?> <u><?php the_author(); ?></u> <?php _e('On''wp-print'); ?> <?php the_time(sprintf(__('%s @ %s''wp-print'), get_option('date_format'), get_option('time_format'))); ?> <?php _e('In''wp-print'); ?> <?php print_categories('<u>''</u>'); ?> | <u><a href='#comments_controls'><?php print_comments_number(); ?></a></u></p>
<div id="BlogContent"><?php print_content(); ?></div>
<hr class="Divider" style="text-align: center;" />
<?php $request "SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, post_title FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID WHERE $wpdb->comments.comment_post_ID=".$id." AND post_status IN ('publish','static') " ;


        
//if(!$show_pass_post) $request .= "AND post_password ='' ";
        //$request .= "AND comment_approved = '1' ORDER BY comment_ID DESC LIMIT $no_comments";
        
$comments $wpdb->get_results($request);
   
?>

 
          <?php if($comments) : ?>
            <?php $comment_count 1?>
            <span style='float:right' id='comments_controls'><?php print_comments_number(); ?> (<a  href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'block'; return false;"><?php _e('Open''wp-print'); ?></a> | <a href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'none'; return false;"><?php _e('Close''wp-print'); ?></a>)</span>
            <div id="comments_box">
              <p id="CommentTitle"><?php print_comments_number(); ?> <?php _e('To''wp-print'); ?> "<?php the_title(); ?>"</p>
              <?php foreach ($comments as $comment) : ?>
                <p class="CommentDate">
                  <strong>#<?php echo $comment_count?> <?php comment_type(); ?></strong> <?php _e('By''wp-print'); ?> <u><?php comment_author(); ?></u> <?php _e('On''wp-print'); ?> <?php comment_date(sprintf(__('%s @ %s''wp-print'), get_option('date_format'), get_option('time_format'))); ?>
                </p>
                <div class="CommentContent">
                  <?php if ($comment->comment_approved == '0') : ?>
                    <p><em><?php _e('Your comment is awaiting moderation.''wp-print'); ?></em></p>
                  <?php endif; ?>
                  <?php print_comments_content(); ?>
                </div>
                <?php $comment_count++; ?>
              <?php endforeach; ?>
              <hr class="Divider" style="text-align: center;" />
            </div>
          <?php endif; ?>



<?php endwhile; ?>



<p style="text-align: left;"><?php _e('Article printed from''wp-print'); ?> <?php bloginfo('name'); ?>: <strong><?php bloginfo('url'); ?></strong></p>
<p style="text-align: left;"><?php _e('URL to article''wp-print'); ?>: <strong><?php the_permalink(); ?></strong></p>
<?php if(print_can('links')): ?>
<p style="text-align: left;"><?php print_links(); ?></p>
<?php endif; ?>
<p style="text-align: right;" id="print-link"><?php _e('Click''wp-print'); ?> <a href="#Print" onclick="window.print(); return false;" title="<?php _e('Click here to print.''wp-print'); ?>"><?php _e('here''wp-print'); ?></a> <?php _e('to print.''wp-print'); ?></p>
<?php else: ?>
<p style="text-align: left;"><?php _e('No posts matched your criteria.''wp-print'); ?></p>
<?php endif; ?>
</div>
</center>
<p style="text-align: center;"><?php echo stripslashes($print_options['disclaimer']); ?></p>
</body>
</html>

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: How to Print all the posts of the blog ?
« Reply #5 on: 01 March 2008, 12:11 »
wow that is really a quick and dirty way.

Thanks for sharing.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline oliv

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #6 on: 01 March 2008, 17:14 »
Ok, I had a bit more time

here's the code for the wp-print.php and print.php files (copy/paste in your existing plugin directory)

plus the code to put on your template file to print all the blog:

Code: [Select]
<a href='<?php echo get_settings('home'?>/?print=1' rel='nofollow' >(<img src='<?php echo get_settings('home'?>/wp-content/plugins/print/images/print.gif' width='10px' height='10px'/>)</a>
I used it for my own personal blog (intranet) and I am not a pro coder so people who use it, must take it as is with no warranty

Code has been taken from post2pdf project (for the category icons)
And from the recent comments project (for the comment request)

So it is needed to check licence of this projects if you want to integrate it in the wp-print project.

@+Oliv (from France)

wp-print.php

Code: [Select]
<?php
/*
+----------------------------------------------------------------+
| |
| WordPress 2.1 Plugin: WP-Print 2.20 |
| Copyright (c) 2007 Lester "GaMerZ" Chan |
| |
| File Written By: |
| - Lester "GaMerZ" Chan |
| - http://lesterchan.net |
| |
| File Information: |
| - Printer Friendly Page |
| - wp-print.php |
| |
+----------------------------------------------------------------+
*/


### Variables
$links_text '';
global 
$wpdb;
global 
$id;
global 
$comments;
global 
$comment;
global 
$cat;
global 
$p;
$p=$_GET["p"];
$cat=$_GET["cat"];

### Actions
add_action('init''print_content');

### Filters
add_filter('wp_title''print_pagetitle');
add_filter('comments_template''print_template_comments');

### Print Options
$print_options get_option('print_options');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Robots" content="noindex, nofollow" />
<link rel="stylesheet" href="<?php bloginfo('wpurl'); ?>/wp-content/plugins/print/wp-print-css.css" type="text/css" media="screen, print" />
</head>
<body>
<p style="text-align: center;"><strong>- <?php bloginfo('name'); ?> - <?php bloginfo('url')?> -</strong></p>
<center>
<div id="Outline">

<?php if (!$p && !$cat): ?>

<?php query_posts('showposts=200'); ?>
<?php endif; ?>


<?php if (have_posts()): ?>
<?php while (have_posts()): the_post(); ?>

<p id="BlogTitle"><?php the_title(); ?></p>
<p id="BlogDate"><?php _e('Posted By''wp-print'); ?> <u><?php the_author(); ?></u> <?php _e('On''wp-print'); ?> <?php the_time(sprintf(__('%s @ %s''wp-print'), get_option('date_format'), get_option('time_format'))); ?> <?php _e('In''wp-print'); ?> <?php print_categories('<u>''</u>'); ?> | <u><a href='#comments_controls'><?php print_comments_number(); ?></a></u></p>
<div id="BlogContent"><?php print_content(); ?></div>
<hr class="Divider" style="text-align: center;" />

        <?php $request "SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, post_title FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID WHERE $wpdb->comments.comment_post_ID=".$id." AND post_status IN ('publish','static') " ;


          
$comments $wpdb->get_results($request);
            
?>

   
            <?php if($comments) : ?>
              <?php $comment_count 1?>
              <span style='float:right' id='comments_controls'><?php print_comments_number(); ?> (<a  href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'block'; return false;"><?php _e('Open''wp-print'); ?></a> | <a href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'none'; return false;"><?php _e('Close''wp-print'); ?></a>)</span>
              <div id="comments_box">
                <p id="CommentTitle"><?php print_comments_number(); ?> <?php _e('To''wp-print'); ?> "<?php the_title(); ?>"</p>
                <?php foreach ($comments as $comment) : ?>
                  <p class="CommentDate">
                    <strong>#<?php echo $comment_count?> <?php comment_type(); ?></strong> <?php _e('By''wp-print'); ?> <u><?php comment_author(); ?></u> <?php _e('On''wp-print'); ?> <?php comment_date(sprintf(__('%s @ %s''wp-print'), get_option('date_format'), get_option('time_format'))); ?>
                  </p>
                  <div class="CommentContent">
                    <?php if ($comment->comment_approved == '0') : ?>
                      <p><em><?php _e('Your comment is awaiting moderation.''wp-print'); ?></em></p>
                    <?php endif; ?>
                    <?php print_comments_content(); ?>
                  </div>
                  <?php $comment_count++; ?>
                <?php endforeach; ?>
                <hr class="Divider" style="text-align: center;" />
              </div>
            <?php endif; ?>
   


<?php endwhile; ?>



<p style="text-align: left;"><?php _e('Article printed from''wp-print'); ?> <?php bloginfo('name'); ?>: <strong><?php bloginfo('url'); ?></strong></p>
<p style="text-align: left;"><?php _e('URL to article''wp-print'); ?>: <strong><?php the_permalink(); ?></strong></p>
<?php if(print_can('links')): ?>
<p style="text-align: left;"><?php print_links(); ?></p>
<?php endif; ?>
<p style="text-align: right;" id="print-link"><?php _e('Click''wp-print'); ?> <a href="#Print" onclick="window.print(); return false;" title="<?php _e('Click here to print.''wp-print'); ?>"><?php _e('here''wp-print'); ?></a> <?php _e('to print.''wp-print'); ?></p>
<?php else: ?>
<p style="text-align: left;"><?php _e('No posts matched your criteria.''wp-print'); ?></p>
<?php endif; ?>
</div>
</center>
<p style="text-align: center;"><?php echo stripslashes($print_options['disclaimer']); ?></p>
</body>
</html>


print.php

Code: [Select]
<?php
/*
Plugin Name: WP-Print
Plugin URI: http://lesterchan.net/portfolio/programming.php
Description: Displays a printable version of your WordPress blog's post/page.
Version: 2.20
Author: Lester 'GaMerZ' Chan
Author URI: http://lesterchan.net
*/


/*  
Copyright 2007  Lester Chan  (email : gamerz84@hotmail.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
## Create Print icons
function archive_to_print($content$category=null){
    
    global 
$wpdb;
    
$export_category 1;
    
$html_category_code "&nbsp;<a href='##SITEURL##/?cat=##CATEGORYID##&amp;print=1' rel='nofollow' title='Export category ##CATEGORYNAME## as printable'>(<img src='##SITEURL##/wp-content/plugins/print/images/print.gif' width='10px' height='10px'/>)</a>";
    if (
$category && $export_category) {
        
$siteurl get_option("siteurl");
        
$temp eregi_replace("##CATEGORYID##"$category->cat_ID$html_category_code);
        
$temp eregi_replace("##CATEGORYNAME##"$category->cat_name$temp);
        
$temp eregi_replace("##SITEURL##",$siteurl,$temp);
        return 
$content." ".$temp;
    }else return 
$content;
}

function 
blog_to_print($content){
    
    global 
$wpdb;
   
    
$html_category_code "&nbsp;<a href='##SITEURL##/?print=1' rel='nofollow' title='Export category ##CATEGORYNAME## as printable'>(<img src='##SITEURL##/wp-content/plugins/print/images/print.gif' width='10px' height='10px'/>)</a>";
    
        
$siteurl get_option("siteurl");
        
$temp eregi_replace("##CATEGORYID##"$category->cat_ID$html_category_code);
        
$temp eregi_replace("##CATEGORYNAME##"$category->cat_name$temp);
        
$temp eregi_replace("##SITEURL##",$siteurl,$temp);
        return 
$content." ".$temp;
    
}

### Create Text Domain For Translations
add_action('init''print_textdomain');
function 
print_textdomain() {
load_plugin_textdomain('wp-print''wp-content/plugins/print');
}


### Function: Print Option Menu
add_action('admin_menu''print_menu');
function 
print_menu() {
if (function_exists('add_options_page')) {
add_options_page(__('Print''wp-print'), __('Print''wp-print'), 'manage_options''print/print-options.php') ;
}
}


### Function: Print htaccess ReWrite Rules
add_filter('generate_rewrite_rules''print_rewrite');
function 
print_rewrite($wp_rewrite) {
$r_rule '';
$r_link '';
$print_link get_permalink();
if(substr($print_link, -11) != '/' && substr($wp_rewrite->permalink_structure, -11) != '/') {
$print_link_text '/print';
} else {
$print_link_text 'print';
}
$rewrite_rules2 $wp_rewrite->generate_rewrite_rule($wp_rewrite->permalink_structure.$print_link_text);
array_splice($rewrite_rules21);
$r_rule array_keys($rewrite_rules2);
$r_rule array_shift($r_rule);
$r_rule str_replace('/trackback''',$r_rule);
$r_link array_values($rewrite_rules2);
$r_link array_shift($r_link);
$r_link str_replace('tb=1''print=1'$r_link); 
    
$print_rules = array($r_rule => $r_link'(.+)/printpage/?$' => 'index.php?pagename='.$wp_rewrite->preg_index(1).'&print=1');
    
$wp_rewrite->rules $print_rules $wp_rewrite->rules;
}


### Function: Print Public Variables
add_filter('query_vars''print_variables');
function 
print_variables($public_query_vars) {
$public_query_vars[] = 'print';
return $public_query_vars;
}


### Function: Display Print Link
function print_link($deprecated ''$deprecated2 =''$echo true) {
global $id;
if (function_exists('polyglot_get_lang')){
    global $polyglot_settings;
    $polyglot_append $polyglot_settings['uri_helpers']['lang_view'].'/'.polyglot_get_lang().'/';
}
$output '';
$using_permalink get_option('permalink_structure');
$print_options get_option('print_options');
$print_style intval($print_options['print_style']);
$print_text stripslashes($print_options['post_text']);
$print_icon get_option('siteurl').'/wp-content/plugins/print/images/'.$print_options['print_icon'];
$print_link get_permalink();
$print_html stripslashes($print_options['print_html']);
// Fix For Static Page
if(get_option('show_on_front') == 'page' && is_page()) {
if(intval(get_option('page_on_front')) > 0) {
$print_link _get_page_link();
}
}
if(!empty($using_permalink)) {
if(substr($print_link, -11) != '/') {
$print_link $print_link.'/';
}
if(is_page()) {
$print_text stripslashes($print_options['page_text']);
$print_link $print_link.'printpage/'.$polyglot_append;
} else {
$print_link $print_link.'print/'.$polyglot_append;
}
} else {
if(is_page()) {
$print_text stripslashes($print_options['page_text']);
}
$print_link $print_link.'&amp;print=1';
}
unset($print_options);
switch($print_style) {
// Icon + Text Link
case 1:
$output '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow"><img class="WP-PrintIcon" src="'.$print_icon.'" alt="'.$print_text.'" title="'.$print_text.'" style="border: 0px;" /></a>&nbsp;<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow">'.$print_text.'</a>';
break;
// Icon Only
case 2:
$output '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow"><img class="WP-PrintIcon" src="'.$print_icon.'" alt="'.$print_text.'" title="'.$print_text.'" style="border: 0px;" /></a>';
break;
// Text Link Only
case 3:
$output '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow">'.$print_text.'</a>';
break;
case 4:
$print_html str_replace("%PRINT_URL%"$print_link$print_html);
$print_html str_replace("%PRINT_TEXT%"$print_text$print_html);
$print_html str_replace("%PRINT_ICON_URL%"$print_icon$print_html);
$output $print_html;
break;
}
if($echo) {
echo $output."\n";
} else {
return $output;
}
}


### Function: Display Print Image Link (Deprecated)
function print_link_image() {
print_link();
}


### Function: Place Print Link
add_filter('the_content''place_printlink'7);
add_filter('the_excerpt''place_printlink'7);
function 
place_printlink($content){
if(!is_feed()) {
 $content str_replace("[print_link]"print_link(''''false), $content);
} else {
$content str_replace("[print_link]"__('Note: There is a print link embedded within this post, please visit this post to print it.''wp-print'), $content);
}   
return $content;
}


### Function: Print Content
function print_content($display true) {
global $links_text$link_number$pages$multipage$numpages$post;
$max_url_char 80;
if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
$content get_the_password_form();
} else {
if($multipage) {
for($page 0$page $numpages$page++) {
$content .= $pages[$page];
}
} else {
$content $pages[0];
}
$content apply_filters('the_content'$content);
$content str_replace(']]>'']]&gt;'$content);
if(!print_can('images')) {
$content remove_image($content);
}
if(print_can('links')) {
preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/'$content$matches);
for ($i=0$i count($matches[0]); $i++) {
$link_match $matches[0][$i];
$link_number++;
$link_url $matches[2][$i];
if(stristr($link_url'https://')) {
 $link_url =(strtolower(substr($link_url,0,8)) != 'https://') ?get_option('home') . $link_url $link_url;
} else if( stristr($link_url'mailto:')) {
$link_url =(strtolower(substr($link_url,0,7)) != 'mailto:') ?get_option('home') . $link_url $link_url;
} else if( $link_url[0] == '#' ) {
$link_url $link_url
} else {
$link_url =(strtolower(substr($link_url,0,7)) != 'http://') ?get_option('home') . $link_url $link_url;
}
$link_text $matches[4][$i];
$content str_replace_one($link_match'['.$link_number."] <a href=\"$link_url\" rel=\"external\">".$link_text.'</a>'$content);
if(strlen($link_url) > 100) {
$link_url chunk_split($link_url100"<br />\n");
}
if(preg_match('/<img(.+?)src=\"(.+?)\"(.*?)>/',$link_text)) {
$links_text .= '<br />['.$link_number.'] '.__('Image''wp-print').': <b>'.$link_url.'</b>';
} else {
$links_text .= '<br />['.$link_number.'] '.$link_text.': <b>'.$link_url.'</b>';
}
}
}
}
if($display) {
echo $content;
} else {
return $content;
}
}


### Function: Print Categories
function print_categories($before ''$after '') {
$temp_cat strip_tags(get_the_category_list(',' $parents));
$temp_cat explode(', '$temp_cat);
$temp_cat implode($after.', '.$before$temp_cat);
echo $before.$temp_cat.$after;
}


### Function: Print Comments Content
function print_comments_content($display true) {
global $links_text$link_number;
$content  get_comment_text();
$content apply_filters('comment_text'$content);
if(!print_can('images')) {
$content remove_image($content);
}
if(print_can('links')) {
preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/'$content$matches);
for ($i=0$i count($matches[0]); $i++) {
$link_match $matches[0][$i];
$link_number++;
$link_url $matches[2][$i];
if(stristr($link_url'https://')) {
 $link_url =(strtolower(substr($link_url,0,8)) != 'https://') ?get_option('home') . $link_url $link_url;
} else if(stristr($link_url'mailto:')) {
$link_url =(strtolower(substr($link_url,0,7)) != 'mailto:') ?get_option('home') . $link_url $link_url;
} else if($link_url[0] == '#') {
$link_url $link_url
} else {
$link_url =(strtolower(substr($link_url,0,7)) != 'http://') ?get_option('home') . $link_url $link_url;
}
$link_text $matches[4][$i];
$content str_replace_one($link_match'['.$link_number."] <a href=\"$link_url\" rel=\"external\">".$link_text.'</a>'$content);
if(strlen($link_url) > 100) {
$link_url chunk_split($link_url100"<br />\n");
}
if(preg_match('/<img(.+?)src=\"(.+?)\"(.*?)>/',$link_text)) {
$links_text .= '<br />['.$link_number.'] '.__('Image''wp-print').': <b>'.$link_url.'</b>';
} else {
$links_text .= '<br />['.$link_number.'] '.$link_text.': <b>'.$link_url.'</b>';
}
}
}
if($display) {
echo $content;
} else {
return $content;
}
}


### Function: Print Comments
function print_comments_number() {
global $post;
$comment_text '';
$comment_status $post->comment_status;
if($comment_status == 'open') {
$num_comments get_comments_number();
if($num_comments == 0) {
$comment_text __('No Comments''wp-print');
} elseif($num_comments == 1) {
$comment_text __('1 Comment''wp-print');
} else {
$comment_text sprintf(__('%s Comments''wp-print'), $num_comments);
}
} else {
$comment_text __('Comments Disabled''wp-print');
}
if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
_e('Comments Hidden''wp-print');
} else {
echo $comment_text;
}
}


### Function: Print Links
function print_links($text_links '') {
global $links_text;
if(empty($text_links)) {
$text_links __('URLs in this post:''wp-print');
}
if(!empty($links_text)) { 
echo $text_links.$links_text
}
}


### Function: Load WP-Print
add_action('template_redirect''wp_print');
function 
wp_print() {
if(intval(get_query_var('print')) == 1) {
include(ABSPATH.'wp-content/plugins/print/wp-print.php');
exit;
}
}


### Function: Add Print Comments Template
function print_template_comments($file '') {
$file ABSPATH.'wp-content/plugins/print/wp-print-comments.php';
return $file;
}


### Function: Print Page Title
function print_pagetitle($print_pagetitle) {
return '&raquo; Print'.$print_pagetitle;
}


### Function: Can Print?
function print_can($type) {
$print_options get_option('print_options');
return intval($print_options[$type]);
}


### Function: Remove Image From Text
function remove_image($content) {
$contentpreg_replace('/<img(.+?)src=\"(.+?)\"(.*?)>/''',$content);
return $content;
}


### Function: Replace One Time Only
function str_replace_one($search$replace$content){
if ($pos strpos($content$search)) {
return substr($content0$pos).$replace.substr($content$pos+strlen($search));
} else {
return $content;
}
}


### Function: Print Options
add_action('activate_print/print.php''print_init');
function 
print_init() {
// Add Options
$print_options = array();
$print_options['post_text'] = __('Print This Post''wp-print');
$print_options['page_text'] = __('Print This Page''wp-print');
$print_options['print_icon'] = 'print.gif';
$print_options['print_style'] = 1;
$print_options['print_html'] = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
$print_options['comments'] = 1;
$print_options['links'] = 1;
$print_options['images'] = 1;
$print_options['disclaimer'] = sprintf(__('Copyright &copy; %s %s. All rights reserved.''wp-print'), date('Y'), get_option('blogname'));
add_option('print_options'$print_options'Print Options');
}

add_filter("list_cats""archive_to_print",10,2);

?>

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: How to Print all the posts of the blog ?
« Reply #7 on: 01 March 2008, 17:49 »
Thanks for sharing, I think I will leave this as a hack unless more people request it =)

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Ttech

  • Official Support
  • Global Moderator
  • *****
  • Posts: 4,296
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #8 on: 02 March 2008, 03:10 »
;)
Learning and Helping one day at a time.




DevNode.org Operator - The IRC network for Programers

Offline oliv

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #9 on: 02 April 2008, 07:09 »
Hello,


Well, still me,

I was wondering wp-print is not in GPL isn't it ?

I would like to integrate it in my project : http://cooperation.gensys-net.eu (that's in French) which is in GPL.

To sum up I am trying to develop a nomad intranet web server based on ubuntu liveusb with already installed web application like wordpress, mediawiki, moodle, gallery2, ...

And your plugin would be interesting, especially the modified version I proposed.

@+Oliv




Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: How to Print all the posts of the blog ?
« Reply #10 on: 02 April 2008, 07:18 »
It is GPLed =D Feel free to modify it

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline oliv

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #11 on: 07 April 2008, 15:06 »
Ok, thanks,  ;D

here's the code with page printing working and TOC for category printing.

need is to change url of image logo in wp-print and copy/paste in existing 2.20 wp-print directory

I have not seen it was already GPL ...

@+Oliv

wp-print.php

Code: [Select]
<?php
/*
+----------------------------------------------------------------+
| |
| WordPress 2.1 Plugin: WP-Print 2.20 |
| Copyright (c) 2007 Lester "GaMerZ" Chan |
| |
| File Written By: |
| - Lester "GaMerZ" Chan |
| - http://lesterchan.net |
| |
| File Information: |
| - Printer Friendly Page |
| - wp-print.php |
| |
+----------------------------------------------------------------+
*/


### Variables
$links_text '';
global 
$wpdb;
global 
$id;
global 
$comments;
global 
$comment;
global 
$cat;
global 
$p;
global 
$page;

$p=$_GET["p"];
$cat=$_GET["cat"];
$page=$_GET["page_id"];
### Actions
add_action('init''print_content');

### Filters
add_filter('wp_title''print_pagetitle');
add_filter('comments_template''print_template_comments');

### Print Options
$print_options get_option('print_options');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Robots" content="noindex, nofollow" />
<link rel="stylesheet" href="<?php bloginfo('wpurl'); ?>/wp-content/plugins/print/wp-print-css.css" type="text/css" media="screen, print" />
</head>
<body>

<center>
<div id="Outline">

<p style="text-align: center;"><strong>- <?php bloginfo('name'); ?> - <?php bloginfo('url')?> -</strong></p>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<center><img src="<?php bloginfo('wpurl'); ?>/wp-content/plugins/print/images/toc.jpg" ></center>
<hr class="Divider" style="text-align: center;" />

<?php if (!$p && !$cat && !$page): ?>
    <?php query_posts('showposts=200'); ?>
<?php endif; ?>

<?php if ($cat): ?>
        <?php $query="cat=".$cat."&showposts=200" ?>
<?php query_posts($query); ?>

<?php endif; ?>
<?php if (!$p && !$page): ?>
<center><H1>Contents</H1></center><br><br><br><br>
      <?php if (have_posts()): ?>
      <?php $post_count 1?>
          <?php while (have_posts()): the_post(); ?>
          <?php echo $post_count ?>. <a href="#<?php echo $post_count ?>"><?php the_title(); ?></a> by <?php the_author(); ?> <br>
          <?php $post_count ++; ?>
          <?php endwhile; ?>
           <?php rewind_posts(); ?>
      <hr class="Divider" style="text-align: center;" />
      <?php endif; ?>
    <?php endif; ?>
    <?php $post_count 1?>
   <?php if (have_posts()): ?>
<?php while (have_posts()): the_post(); ?>
          <a name="<?php echo $post_count ?>"><?php $post_count ++; ?>
<p id="BlogTitle"><?php the_title(); ?></p>
<p id="BlogDate"><?php _e('Posted By''wp-print'); ?> <u><?php the_author(); ?></u> <?php _e('On''wp-print'); ?> <?php the_time(sprintf(__('%s @ %s''wp-print'), get_option('date_format'), get_option('time_format'))); ?> <?php _e('In''wp-print'); ?> <?php print_categories('<u>''</u>'); ?> | <u><a href='#comments_controls'><?php print_comments_number(); ?></a></u></p>
<div id="BlogContent"><?php print_content(); ?></div>
<hr class="Divider" style="text-align: center;" />

        <?php $request "SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, post_title FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID WHERE $wpdb->comments.comment_post_ID=".$id." AND post_status IN ('publish','static') " ;


          
$comments $wpdb->get_results($request);
            
?>

   
            <?php if($comments) : ?>
              <?php $comment_count 1?>
              <span style='float:right' id='comments_controls'><?php print_comments_number(); ?> (<a  href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'block'; return false;"><?php _e('Open''wp-print'); ?></a> | <a href="#" onclick="javascript:document.getElementById('comments_box').style.display = 'none'; return false;"><?php _e('Close''wp-print'); ?></a>)</span>
              <div id="comments_box">
                <p id="CommentTitle"><?php print_comments_number(); ?> <?php _e('To''wp-print'); ?> "<?php the_title(); ?>"</p>
                <?php foreach ($comments as $comment) : ?>
                 
                  <p class="CommentDate">
                    <strong>#<?php echo $comment_count?> <?php comment_type(); ?></strong> <?php _e('By''wp-print'); ?> <u><?php comment_author(); ?></u> <?php _e('On''wp-print'); ?> <?php comment_date(sprintf(__('%s @ %s''wp-print'), get_option('date_format'), get_option('time_format'))); ?>
                  </p>
                  <div class="CommentContent">
                    <?php if ($comment->comment_approved == '0') : ?>
                      <p><em><?php _e('Your comment is awaiting moderation.''wp-print'); ?></em></p>
                    <?php endif; ?>
                    <?php print_comments_content(); ?>
                  </div>
                  <?php $comment_count++; ?>
                <?php endforeach; ?>
                <hr class="Divider" style="text-align: center;" />
              </div>
            <?php endif; ?>
   


<?php endwhile; ?>



<p style="text-align: left;"><?php _e('Article printed from''wp-print'); ?> <?php bloginfo('name'); ?>: <strong><?php bloginfo('url'); ?></strong></p>
<p style="text-align: left;"><?php _e('URL to article''wp-print'); ?>: <strong><?php the_permalink(); ?></strong></p>
<?php if(print_can('links')): ?>
<p style="text-align: left;"><?php print_links(); ?></p>
<?php endif; ?>
<p style="text-align: right;" id="print-link"><?php _e('Click''wp-print'); ?> <a href="#Print" onclick="window.print(); return false;" title="<?php _e('Click here to print.''wp-print'); ?>"><?php _e('here''wp-print'); ?></a> <?php _e('to print.''wp-print'); ?></p>
<?php else: ?>
<p style="text-align: left;"><?php _e('No posts matched your criteria.''wp-print'); ?></p>
<?php endif; ?>
</div>
</center>
<p style="text-align: center;"><?php echo stripslashes($print_options['disclaimer']); ?></p>
</body>
</html>

print.php
Code: [Select]
<?php
/*
Plugin Name: WP-Print
Plugin URI: http://lesterchan.net/portfolio/programming.php
Description: Displays a printable version of your WordPress blog's post/page.
Version: 2.20
Author: Lester 'GaMerZ' Chan
Author URI: http://lesterchan.net
*/


/*  
Copyright 2007  Lester Chan  (email : gamerz84@hotmail.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
## Create Print icons
function archive_to_print($content$category=null){
    
    global 
$wpdb;
    
$export_category 1;
    
$html_category_code "&nbsp;<a href='##SITEURL##/?cat=##CATEGORYID##&amp;print=1' rel='nofollow' title='Export category ##CATEGORYNAME## as printable'>(<img src='##SITEURL##/wp-content/plugins/print/images/print.gif' width='10px' height='10px'/>)</a>";
    if (
$category && $export_category) {
        
$siteurl get_option("siteurl");
        
$temp eregi_replace("##CATEGORYID##"$category->cat_ID$html_category_code);
        
$temp eregi_replace("##CATEGORYNAME##"$category->cat_name$temp);
        
$temp eregi_replace("##SITEURL##",$siteurl,$temp);
        return 
$content." ".$temp;
    }else return 
$content;
}

function 
blog_to_print($content){
    
    global 
$wpdb;
   
    
$html_category_code "&nbsp;<a href='##SITEURL##/?print=1' rel='nofollow' title='Export category ##CATEGORYNAME## as printable'>(<img src='##SITEURL##/wp-content/plugins/print/images/print.gif' width='10px' height='10px'/>)</a>";
    
        
$siteurl get_option("siteurl");
        
$temp eregi_replace("##CATEGORYID##"$category->cat_ID$html_category_code);
        
$temp eregi_replace("##CATEGORYNAME##"$category->cat_name$temp);
        
$temp eregi_replace("##SITEURL##",$siteurl,$temp);
        return 
$content." ".$temp;
    
}

### Create Text Domain For Translations
add_action('init''print_textdomain');
function 
print_textdomain() {
load_plugin_textdomain('wp-print''wp-content/plugins/print');
}


### Function: Print Option Menu
add_action('admin_menu''print_menu');
function 
print_menu() {
if (function_exists('add_options_page')) {
add_options_page(__('Print''wp-print'), __('Print''wp-print'), 'manage_options''print/print-options.php') ;
}
}


### Function: Print htaccess ReWrite Rules
add_filter('generate_rewrite_rules''print_rewrite');
function 
print_rewrite($wp_rewrite) {
$r_rule '';
$r_link '';
$print_link get_permalink();
if(substr($print_link, -11) != '/' && substr($wp_rewrite->permalink_structure, -11) != '/') {
$print_link_text '/print';
} else {
$print_link_text 'print';
}
$rewrite_rules2 $wp_rewrite->generate_rewrite_rule($wp_rewrite->permalink_structure.$print_link_text);
array_splice($rewrite_rules21);
$r_rule array_keys($rewrite_rules2);
$r_rule array_shift($r_rule);
$r_rule str_replace('/trackback''',$r_rule);
$r_link array_values($rewrite_rules2);
$r_link array_shift($r_link);
$r_link str_replace('tb=1''print=1'$r_link); 
    
$print_rules = array($r_rule => $r_link'(.+)/printpage/?$' => 'index.php?pagename='.$wp_rewrite->preg_index(1).'&print=1');
    
$wp_rewrite->rules $print_rules $wp_rewrite->rules;
}


### Function: Print Public Variables
add_filter('query_vars''print_variables');
function 
print_variables($public_query_vars) {
$public_query_vars[] = 'print';
return $public_query_vars;
}


### Function: Display Print Link
function print_link($deprecated ''$deprecated2 =''$echo true) {
global $id;
if (function_exists('polyglot_get_lang')){
    global $polyglot_settings;
    $polyglot_append $polyglot_settings['uri_helpers']['lang_view'].'/'.polyglot_get_lang().'/';
}
$output '';
$using_permalink get_option('permalink_structure');
$print_options get_option('print_options');
$print_style intval($print_options['print_style']);
$print_text stripslashes($print_options['post_text']);
$print_icon get_option('siteurl').'/wp-content/plugins/print/images/'.$print_options['print_icon'];
$print_link get_permalink();
$print_html stripslashes($print_options['print_html']);
// Fix For Static Page
if(get_option('show_on_front') == 'page' && is_page()) {
if(intval(get_option('page_on_front')) > 0) {
$print_link _get_page_link();
}
}
if(!empty($using_permalink)) {
if(substr($print_link, -11) != '/') {
$print_link $print_link.'/';
}
if(is_page()) {
$print_text stripslashes($print_options['page_text']);
$print_link $print_link.'printpage/'.$polyglot_append;
} else {
$print_link $print_link.'print/'.$polyglot_append;
}
} else {
if(is_page()) {
$print_text stripslashes($print_options['page_text']);
}
$print_link $print_link.'&amp;print=1';
}
unset($print_options);
switch($print_style) {
// Icon + Text Link
case 1:
$output '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow"><img class="WP-PrintIcon" src="'.$print_icon.'" alt="'.$print_text.'" title="'.$print_text.'" style="border: 0px;" /></a>&nbsp;<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow">'.$print_text.'</a>';
break;
// Icon Only
case 2:
$output '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow"><img class="WP-PrintIcon" src="'.$print_icon.'" alt="'.$print_text.'" title="'.$print_text.'" style="border: 0px;" /></a>';
break;
// Text Link Only
case 3:
$output '<a href="'.$print_link.'" title="'.$print_text.'" rel="nofollow">'.$print_text.'</a>';
break;
case 4:
$print_html str_replace("%PRINT_URL%"$print_link$print_html);
$print_html str_replace("%PRINT_TEXT%"$print_text$print_html);
$print_html str_replace("%PRINT_ICON_URL%"$print_icon$print_html);
$output $print_html;
break;
}
if($echo) {
echo $output."\n";
} else {
return $output;
}
}


### Function: Display Print Image Link (Deprecated)
function print_link_image() {
print_link();
}


### Function: Place Print Link
add_filter('the_content''place_printlink'7);
add_filter('the_excerpt''place_printlink'7);
function 
place_printlink($content){
if(!is_feed()) {
 $content str_replace("[print_link]"print_link(''''false), $content);
} else {
$content str_replace("[print_link]"__('Note: There is a print link embedded within this post, please visit this post to print it.''wp-print'), $content);
}   
return $content;
}


### Function: Print Content
function print_content($display true) {
global $links_text$link_number$pages$multipage$numpages$post;
$max_url_char 80;
if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
$content get_the_password_form();
} else {
if($multipage) {
for($page 0$page $numpages$page++) {
$content .= $pages[$page];
}
} else {
$content $pages[0];
}
$content apply_filters('the_content'$content);
$content str_replace(']]>'']]&gt;'$content);
if(!print_can('images')) {
$content remove_image($content);
}
if(print_can('links')) {
preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/'$content$matches);
for ($i=0$i count($matches[0]); $i++) {
$link_match $matches[0][$i];
$link_number++;
$link_url $matches[2][$i];
if(stristr($link_url'https://')) {
 $link_url =(strtolower(substr($link_url,0,8)) != 'https://') ?get_option('home') . $link_url $link_url;
} else if( stristr($link_url'mailto:')) {
$link_url =(strtolower(substr($link_url,0,7)) != 'mailto:') ?get_option('home') . $link_url $link_url;
} else if( $link_url[0] == '#' ) {
$link_url $link_url
} else {
$link_url =(strtolower(substr($link_url,0,7)) != 'http://') ?get_option('home') . $link_url $link_url;
}
$link_text $matches[4][$i];
$content str_replace_one($link_match'['.$link_number."] <a href=\"$link_url\" rel=\"external\">".$link_text.'</a>'$content);
if(strlen($link_url) > 100) {
$link_url chunk_split($link_url100"<br />\n");
}
if(preg_match('/<img(.+?)src=\"(.+?)\"(.*?)>/',$link_text)) {
$links_text .= '<br />['.$link_number.'] '.__('Image''wp-print').': <b>'.$link_url.'</b>';
} else {
$links_text .= '<br />['.$link_number.'] '.$link_text.': <b>'.$link_url.'</b>';
}
}
}
}
if($display) {
echo $content;
} else {
return $content;
}
}


### Function: Print Categories
function print_categories($before ''$after '') {
$temp_cat strip_tags(get_the_category_list(',' $parents));
$temp_cat explode(', '$temp_cat);
$temp_cat implode($after.', '.$before$temp_cat);
echo $before.$temp_cat.$after;
}


### Function: Print Comments Content
function print_comments_content($display true) {
global $links_text$link_number;
$content  get_comment_text();
$content apply_filters('comment_text'$content);
if(!print_can('images')) {
$content remove_image($content);
}
if(print_can('links')) {
preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/'$content$matches);
for ($i=0$i count($matches[0]); $i++) {
$link_match $matches[0][$i];
$link_number++;
$link_url $matches[2][$i];
if(stristr($link_url'https://')) {
 $link_url =(strtolower(substr($link_url,0,8)) != 'https://') ?get_option('home') . $link_url $link_url;
} else if(stristr($link_url'mailto:')) {
$link_url =(strtolower(substr($link_url,0,7)) != 'mailto:') ?get_option('home') . $link_url $link_url;
} else if($link_url[0] == '#') {
$link_url $link_url
} else {
$link_url =(strtolower(substr($link_url,0,7)) != 'http://') ?get_option('home') . $link_url $link_url;
}
$link_text $matches[4][$i];
$content str_replace_one($link_match'['.$link_number."] <a href=\"$link_url\" rel=\"external\">".$link_text.'</a>'$content);
if(strlen($link_url) > 100) {
$link_url chunk_split($link_url100"<br />\n");
}
if(preg_match('/<img(.+?)src=\"(.+?)\"(.*?)>/',$link_text)) {
$links_text .= '<br />['.$link_number.'] '.__('Image''wp-print').': <b>'.$link_url.'</b>';
} else {
$links_text .= '<br />['.$link_number.'] '.$link_text.': <b>'.$link_url.'</b>';
}
}
}
if($display) {
echo $content;
} else {
return $content;
}
}


### Function: Print Comments
function print_comments_number() {
global $post;
$comment_text '';
$comment_status $post->comment_status;
if($comment_status == 'open') {
$num_comments get_comments_number();
if($num_comments == 0) {
$comment_text __('No Comments''wp-print');
} elseif($num_comments == 1) {
$comment_text __('1 Comment''wp-print');
} else {
$comment_text sprintf(__('%s Comments''wp-print'), $num_comments);
}
} else {
$comment_text __('Comments Disabled''wp-print');
}
if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
_e('Comments Hidden''wp-print');
} else {
echo $comment_text;
}
}


### Function: Print Links
function print_links($text_links '') {
global $links_text;
if(empty($text_links)) {
$text_links __('URLs in this post:''wp-print');
}
if(!empty($links_text)) { 
echo $text_links.$links_text
}
}


### Function: Load WP-Print
add_action('template_redirect''wp_print');
function 
wp_print() {
if(intval(get_query_var('print')) == 1) {
include(ABSPATH.'wp-content/plugins/print/wp-print.php');
exit;
}
}


### Function: Add Print Comments Template
function print_template_comments($file '') {
$file ABSPATH.'wp-content/plugins/print/wp-print-comments.php';
return $file;
}


### Function: Print Page Title
function print_pagetitle($print_pagetitle) {
return '&raquo; Print'.$print_pagetitle;
}


### Function: Can Print?
function print_can($type) {
$print_options get_option('print_options');
return intval($print_options[$type]);
}


### Function: Remove Image From Text
function remove_image($content) {
$contentpreg_replace('/<img(.+?)src=\"(.+?)\"(.*?)>/''',$content);
return $content;
}


### Function: Replace One Time Only
function str_replace_one($search$replace$content){
if ($pos strpos($content$search)) {
return substr($content0$pos).$replace.substr($content$pos+strlen($search));
} else {
return $content;
}
}


### Function: Print Options
add_action('activate_print/print.php''print_init');
function 
print_init() {
// Add Options
$print_options = array();
$print_options['post_text'] = __('Print This Post''wp-print');
$print_options['page_text'] = __('Print This Page''wp-print');
$print_options['print_icon'] = 'print.gif';
$print_options['print_style'] = 1;
$print_options['print_html'] = '<a href="%PRINT_URL%" rel="nofollow" title="%PRINT_TEXT%">%PRINT_TEXT%</a>';
$print_options['comments'] = 1;
$print_options['links'] = 1;
$print_options['images'] = 1;
$print_options['disclaimer'] = sprintf(__('Copyright &copy; %s %s. All rights reserved.''wp-print'), date('Y'), get_option('blogname'));
add_option('print_options'$print_options'Print Options');
}

add_filter("list_cats""archive_to_print",10,2);

?>

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: How to Print all the posts of the blog ?
« Reply #12 on: 07 April 2008, 15:29 »
Sticky this topic as I believe it will be useful for those who needs to print all the posts on the blog =D

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline strawbleu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #13 on: 23 July 2008, 16:49 »
This addition is exactly what I'm looking for - however I can only find v2.31 of the script; and my site is in v2.6 of Wordpress - is there any chance I'll be able to get this to work?

Thanks in advance for any help... Jon

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: How to Print all the posts of the blog ?
« Reply #14 on: 23 July 2008, 17:02 »
You may want to drop Oliv an email =)

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline oliv

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #15 on: 24 July 2008, 11:16 »
Hi All,

I upgraded the code to 2.5.1. It is available in the mirror of my project Cooperation-IWS.

The file url is here: http://prdownload.berlios.de/ciws/print_custom.zip

Sorry Lester, for posting an outside download link to your web site, but as wp-print is only a part of my project, if You want to  integrate my modifications in your own code, there is no problem.

I think there is a future for nice printable blog that output something like a book.

My project is here : http://cooperation-iws.gensys-net.eu/blog/ if someone is interested.

@+Oliv

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: How to Print all the posts of the blog ?
« Reply #16 on: 24 July 2008, 13:25 »
Hi Oliv, no need to apologized :), I really appreciate your work on WP-Print. Thank you so much =)

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline strawbleu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #17 on: 24 July 2008, 14:03 »
And my thanks to both of you!

Offline Ttech

  • Official Support
  • Global Moderator
  • *****
  • Posts: 4,296
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #18 on: 26 July 2008, 22:37 »
Glad it works
Learning and Helping one day at a time.




DevNode.org Operator - The IRC network for Programers

Offline shrunkviolet

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: How to Print all the posts of the blog ?
« Reply #19 on: 28 October 2008, 15:11 »
I would love to see this feature incorporated into WP-Print as a regular feature!!  Printing of all or selected articles by title or date range would be so great!  Now, if it could be done optionally in booklet format too, well that would just be too much to hope for!