| 1 |
<?php |
| 2 |
/* |
| 3 |
+----------------------------------------------------------------+ |
| 4 |
| | |
| 5 |
| WordPress 1.5 Plugin: WP-Print 2.00 | |
| 6 |
| Copyright (c) 2005 Lester "GaMerZ" Chan | |
| 7 |
| | |
| 8 |
| File Written By: | |
| 9 |
| - Lester "GaMerZ" Chan | |
| 10 |
| - http://www.lesterchan.net | |
| 11 |
| | |
| 12 |
| File Information: | |
| 13 |
| - Printer Friendly Page | |
| 14 |
| - wp-print.php | |
| 15 |
| | |
| 16 |
+----------------------------------------------------------------+ |
| 17 |
*/ |
| 18 |
|
| 19 |
|
| 20 |
### Require WordPress Header |
| 21 |
require('wp-blog-header.php'); |
| 22 |
|
| 23 |
### Variables |
| 24 |
$links_text = ''; |
| 25 |
$page_title = single_post_title('', false); |
| 26 |
|
| 27 |
### Print The Content With URLs Footer |
| 28 |
function print_content() { |
| 29 |
global $links_text; |
| 30 |
// Default WordPress Way Of Getting Content |
| 31 |
$content = get_the_content($more_link_text, $stripteaser, $more_file); |
| 32 |
$content = apply_filters('the_content', $content); |
| 33 |
$content = str_replace(']]>', ']]>', $content); |
| 34 |
// Match Links |
| 35 |
preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches); |
| 36 |
// Count The Number Of Matched Links |
| 37 |
for ($i=0; $i < count($matches[0]); $i++) { |
| 38 |
$link_match = $matches[0][$i]; |
| 39 |
$link_number = '['.($i+1).']'; |
| 40 |
$link_url = $matches[2][$i]; |
| 41 |
$link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url; |
| 42 |
$link_text = $matches[4][$i]; |
| 43 |
$content = str_replace($link_match, $link_number." <a href=\"$link_url\" target=\"_blank\">".$link_text.'</a>', $content); |
| 44 |
if(preg_match('/<img(.+?)src=\"(.+?)\"(.*?)>/',$link_text)) { |
| 45 |
$links_text .= '<br />'.$link_number.' Image: <b>'.$link_url.'</b>'; |
| 46 |
} else { |
| 47 |
$links_text .= '<br />'.$link_number.' '.$link_text.': <b>'.$link_url.'</b>'; |
| 48 |
} |
| 49 |
} |
| 50 |
// Print Out The Content |
| 51 |
echo $content; |
| 52 |
} |
| 53 |
|
| 54 |
### If Page Title Is Empty, Display Error As Page Title |
| 55 |
if(empty($page_title)) { |
| 56 |
$page_title = 'Error'; |
| 57 |
} |
| 58 |
?> |
| 59 |
<!DOCTYPE HTML PUBLIC "-//W3C//Dp HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dp"> |
| 60 |
<html> |
| 61 |
<head> |
| 62 |
<title><?php bloginfo('name')?> > Print > <?php echo $page_title; ?></title> |
| 63 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| 64 |
<style type="text/css" media="screen, print"> |
| 65 |
Body { |
| 66 |
font-family: Verdana, Arial, Tahoma; |
| 67 |
font-size: 12px; |
| 68 |
color: #000000; |
| 69 |
} |
| 70 |
#Outline { |
| 71 |
text-align: left; |
| 72 |
width: 90%; |
| 73 |
margin-left: auto; |
| 74 |
margin-right: auto; |
| 75 |
padding: 10px; |
| 76 |
border: 1px solid #000000; |
| 77 |
} |
| 78 |
#BlogTitle { |
| 79 |
font-weight: bold; |
| 80 |
font-size: 16px; |
| 81 |
margin-bottom: 5px; |
| 82 |
} |
| 83 |
#BlogDate { |
| 84 |
margin-top: 5px; |
| 85 |
margin-bottom: 10px; |
| 86 |
} |
| 87 |
#BlogContent { |
| 88 |
padding: 10px; |
| 89 |
margin-top: 10px; |
| 90 |
} |
| 91 |
HR#Divider { |
| 92 |
width: 80%; |
| 93 |
height: 1px; |
| 94 |
color: #000000; |
| 95 |
} |
| 96 |
</style> |
| 97 |
</head> |
| 98 |
<body> |
| 99 |
<p align="center"><b>- <?php bloginfo('name'); ?> - <?php bloginfo('url')?> -</b></p> |
| 100 |
<center> |
| 101 |
<div id="Outline"> |
| 102 |
<?php if (have_posts()) : ?> |
| 103 |
<?php while (have_posts()) : the_post(); ?> |
| 104 |
<p id="BlogTitle"><?php the_title(); ?></p> |
| 105 |
<p id="BlogDate">Posted By <?php the_author(); ?> On <?php the_time('jS F Y @ H:i'); ?> In <?php the_category(', '); ?> | <a href="<?php comments_link(); ?>"><?php comments_number(); ?></a></p> |
| 106 |
<div id="BlogContent"> |
| 107 |
<?php for($page = 1; $page <= $numpages; $page++) { ?> |
| 108 |
<?php print_content(); ?> |
| 109 |
<?php } ?> |
| 110 |
</div> |
| 111 |
<?php endwhile; ?> |
| 112 |
<p><hr id="Divider" align="center"></p> |
| 113 |
<p align="left">Article printed from <?=get_bloginfo('name')?>: <b><?=get_bloginfo('url')?></b></p> |
| 114 |
<p align="left">URL to article: <b><?=get_permalink()?></b></p> |
| 115 |
<p align="left"><?php if(!empty($links_text)) { echo 'URLs in this post:'.$links_text; } ?></p> |
| 116 |
<p align="right">Click <a href="javascript:window.print();">here</a> to print.</p> |
| 117 |
<?php else : ?> |
| 118 |
<p align="center">No posts matched your criteria.</p> |
| 119 |
<?php endif; ?> |
| 120 |
</div> |
| 121 |
</center> |
| 122 |
</body> |
| 123 |
</html> |