Changeset 9442
- Timestamp:
- 03/25/07 17:37:02 (1 year ago)
- Files:
-
- link-harvest/trunk/link-harvest.php (modified) (35 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
link-harvest/trunk/link-harvest.php
r9391 r9442 5 5 Plugin URI: http://alexking.org/projects/wordpress 6 6 Description: This will harvest links from your WordPress database, creating a links list sorted by popularity. Once you have activated the plugin, you can configure the <a href="options-general.php?page=link-harvest.php">Settings</a> and see your <a href="index.php?page=link-harvest.php">list of links</a>. Also see <a href="options-general.php?page=link-harvest.php#aklh_template_tags">how to show the list of links</a> in your blog. Questions on configuration, etc.? Make sure to read the README. 7 Version: 1. 07 Version: 1.1b1 8 8 Author: Alex King 9 9 Author URI: http://alexking.org … … 27 27 @define('AK_WPROOT', '../../'); 28 28 29 @define('AKLH_DEBUG', false); 30 31 if (AKLH_DEBUG) { 32 // ini_set('display_errors', '1'); 33 // ini_set('error_reporting', E_ALL); 34 $logfile = dirname(__FILE__).'/aklh_log.txt'; 35 if (!is_file($logfile) || !is_writeable($logfile)) { 36 die('Debugging is enabled, but there is no wp-content/plugins/aklh_log.txt file or the file is not writeable.'); 37 } 38 } 39 29 40 if (!isset($wpdb)) { 30 41 require(AK_WPROOT.'wp-blog-header.php'); 31 42 } 32 43 33 load_plugin_textdomain(' alexking.org');44 load_plugin_textdomain('link-harvest'); 34 45 35 46 if (!function_exists('is_admin_page')) { … … 70 81 71 82 if (isset($_GET['activate']) && $_GET['activate'] == 'true') { 72 $result = mysql_list_tables(DB_NAME); 73 $tables = array(); 74 while ($row = mysql_fetch_row($result)) { 75 $tables[] = $row[0]; 76 } 83 $tables = $wpdb->get_col(" 84 SHOW TABLES 85 "); 77 86 if (!in_array($wpdb->ak_linkharvest, $tables) && !in_array($wpdb->ak_domains, $tables)) { 78 87 $aklh->install(); … … 102 111 , 'harvest_enabled' => 'int' 103 112 , 'token' => 'int' 113 ); 114 $this->excluded_file_extensions = array( 115 '.mov' 116 , '.jpg' 117 , '.gif' 118 , '.png' 119 , '.pdf' 120 , '.mpg' 121 , '.mp3' 122 , '.mpeg' 123 , '.avi' 124 , '.swf' 125 , '.doc' 126 , '.xls' 127 , '.wmv' 128 , '.wmf' 129 , '.wma' 130 , '.txt' 131 , '.m4p' 104 132 ); 105 133 } … … 179 207 header('Location: '.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php&updated=true'); 180 208 die(); 181 } 209 } 210 211 function excluded_file_type($link) { 212 foreach ($this->excluded_file_extensions as $ext) { 213 if (substr($link, strlen($ext) * -1) == $ext) { 214 return true; 215 } 216 } 217 return false; 218 } 182 219 183 220 function get_links($body) { … … 210 247 if (preg_match_all($regex, $body, $links)) { 211 248 foreach ($links[1] as $link) { 212 if (in_array(substr($link, 0, 7), array('http://', 'https:/')) ) {249 if (in_array(substr($link, 0, 7), array('http://', 'https:/')) && !$this->excluded_file_type($link)) { 213 250 $urls[] = $link; 214 251 } … … 268 305 return; 269 306 } 307 308 aklh_log('Found '.count($links).' links in post id: '.$post_id); 270 309 271 310 $domains = array(); … … 302 341 $harvest[] = array($link, $domain); 303 342 } 343 344 aklh_log('Processed link: '.$link); 345 304 346 } 305 347 … … 321 363 322 364 function add_link($url, $domain_id, $post_id) { 365 366 aklh_log('About to add link for post id: '.$post_id.' - '.$url); 367 323 368 global $wpdb; 324 369 $title = stripslashes($this->get_page_title($url)); … … 340 385 "); 341 386 if (!$result) { 387 388 aklh_log('Failed to add link for post id: '.$post_id.' - '.$url); 389 342 390 return false; 343 391 } 344 392 else { 393 394 aklh_log('Added link for for post id: '.$post_id.' - '.$url); 395 345 396 return true; 346 397 } … … 363 414 "); 364 415 if (!$result) { 416 417 aklh_log('Failed to add domain: '.$domain); 418 365 419 return false; 366 420 } 367 421 else { 422 423 aklh_log('Added domain: '.$domain); 424 368 425 return mysql_insert_id(); 369 426 } … … 458 515 } 459 516 foreach ($posts as $post) { 517 518 aklh_log('== Start processing post id: '.$post->ID); 519 460 520 $this->process_content($post->post_content, $post->ID); 461 521 $external = get_post_meta($post->ID, 'external_link', true); … … 467 527 $this->process_content($via, $post->ID); 468 528 } 529 530 aklh_log('== Done processing post id: '.$post->ID."\n"); 531 469 532 } 470 533 } … … 481 544 $urls[] = $link->url; 482 545 } 483 $domains = $this->domain_counts($ links);546 $domains = $this->domain_counts($urls); 484 547 foreach ($domains as $domain => $count) { 485 548 $this->set_domain_counter($domain, null, $count, $mod = '-'); … … 563 626 <thead> 564 627 <tr> 565 <th>'.__('Web Site', ' alexking.org').'</th>566 <th>'.__('# of Links', ' alexking.org').'</th>567 <th><span class="hide">'.__('Show Links', ' alexking.org').'</span></th>568 <th><span class="hide">'.__('Show Posts', ' alexking.org').'</span></th>628 <th>'.__('Web Site', 'link-harvest').'</th> 629 <th>'.__('# of Links', 'link-harvest').'</th> 630 <th><span class="hide">'.__('Show Links', 'link-harvest').'</span></th> 631 <th><span class="hide">'.__('Show Posts', 'link-harvest').'</span></th> 569 632 </tr> 570 633 </thead> … … 573 636 if (count($domains) == 0) { 574 637 print(' 575 <tr><td colspan="4">'.__('No links harvested yet. (<a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?ak_action=harvest">Start Harvesting</a>)', ' alexking.org').'</td></tr>638 <tr><td colspan="4">'.__('No links harvested yet. (<a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?ak_action=harvest">Start Harvesting</a>)', 'link-harvest').'</td></tr> 576 639 '); 577 640 } … … 594 657 <td><a href="http://'.$domain->domain.'">'.$title.'</a><div id="domain_'.$domain->id.'"></div></td> 595 658 <td class="count">'.htmlspecialchars($domain->count).'</td> 596 <td class="action"><a href="javascript:void(aklh_show_for_domain(\''.$domain->id.'\', \'links\'));">'.__('Show Links', ' alexking.org').'</td>597 <td class="action"><a href="javascript:void(aklh_show_for_domain(\''.$domain->id.'\', \'posts\'));">'.__('Show Posts', ' alexking.org').'</td>659 <td class="action"><a href="javascript:void(aklh_show_for_domain(\''.$domain->id.'\', \'links\'));">'.__('Show Links', 'link-harvest').'</td> 660 <td class="action"><a href="javascript:void(aklh_show_for_domain(\''.$domain->id.'\', \'posts\'));">'.__('Show Posts', 'link-harvest').'</td> 598 661 </tr> 599 662 '); … … 644 707 } 645 708 if (get_option('aklh_token') == '0') { 646 $token_options = '<option value="1">'.__('Yes', ' alexking.org').'</option><option value="0" selected="selected">'.__('No', 'alexking.org').'</option>';709 $token_options = '<option value="1">'.__('Yes', 'link-harvest').'</option><option value="0" selected="selected">'.__('No', 'link-harvest').'</option>'; 647 710 } 648 711 else { 649 $token_options = '<option value="1" selected="selected">'.__('Yes', ' alexking.org').'</option><option value="0">'.__('No', 'alexking.org').'</option>';712 $token_options = '<option value="1" selected="selected">'.__('Yes', 'link-harvest').'</option><option value="0">'.__('No', 'link-harvest').'</option>'; 650 713 } 651 714 print(' 652 715 <div class="wrap"> 653 <h2>'.__('Link Harvest Options', ' alexking.org').'</h2>716 <h2>'.__('Link Harvest Options', 'link-harvest').'</h2> 654 717 <form name="ak_linkharvest" action="'.get_bloginfo('wpurl').'/wp-admin/options-general.php" method="post"> 655 718 <fieldset class="options"> 656 <p>'.__('You may want to exclude certain domains from your harvested links. For example, you may have a number of links to pages/posts on your own site and including your own links in the harvest will make your own site appear in your <a href="index.php?page=link-harvest.php">links list</a>.', ' alexking.org').'</p>657 <p><label for="exclude">'.__('Domains to exclude from link harvesting (separated by spaces, example: <code>example.com '.$this->get_domain(get_bloginfo('home')).'</code>):', ' alexking.org').'</label></p>719 <p>'.__('You may want to exclude certain domains from your harvested links. For example, you may have a number of links to pages/posts on your own site and including your own links in the harvest will make your own site appear in your <a href="index.php?page=link-harvest.php">links list</a>.', 'link-harvest').'</p> 720 <p><label for="exclude">'.__('Domains to exclude from link harvesting (separated by spaces, example: <code>example.com '.$this->get_domain(get_bloginfo('home')).'</code>):', 'link-harvest').'</label></p> 658 721 <p><textarea name="exclude" id="exclude">'.htmlspecialchars(implode(' ', $this->exclude)).'</textarea></p> 659 722 <p> 660 <label for="table_length">'.__('Number of domains to show in report table:', ' alexking.org').'</label>723 <label for="table_length">'.__('Number of domains to show in report table:', 'link-harvest').'</label> 661 724 <input type="text" size="5" name="table_length" id="table_length" value="'.$this->table_length.'" /> 662 725 </p> 663 726 <p> 664 <label for="aklh_token">'.__('Enable <a href="#token">token method</a> for showing the links list:', ' alexking.org').'</label>727 <label for="aklh_token">'.__('Enable <a href="#token">token method</a> for showing the links list:', 'link-harvest').'</label> 665 728 <select name="aklh_token" id="token">'.$token_options.'</select> 666 729 </p> 667 <p>'.__('Once the initial link harvest is complete, it is a good idea to disable link harvesting as it can be resource intensive for your server. This is done for you automatically after a successful harvest, but you can manually control it here.', ' alexking.org').'</p>730 <p>'.__('Once the initial link harvest is complete, it is a good idea to disable link harvesting as it can be resource intensive for your server. This is done for you automatically after a successful harvest, but you can manually control it here.', 'link-harvest').'</p> 668 731 <ul> 669 732 <li><input type="radio" name="harvest_enabled" value="1" id="harvest_enabled_y" '.$enabled.'/> <label for="harvest_enabled_y"><strong>Enable</strong> link harvest actions</label></li> … … 673 736 </fieldset> 674 737 <p class="submit"> 675 <input type="submit" name="submit" value="'.__('Update Link Harvest Settings', ' alexking.org').'" />738 <input type="submit" name="submit" value="'.__('Update Link Harvest Settings', 'link-harvest').'" /> 676 739 </p> 677 740 </form> 678 <h2>'.__('Harvest Links', ' alexking.org').'</h2>741 <h2>'.__('Harvest Links', 'link-harvest').'</h2> 679 742 <form> 680 743 <fieldset> 681 <p>'.__('When you are ready to harvest (or re-harvest) your links, press this button', ' alexking.org').'</p>744 <p>'.__('When you are ready to harvest (or re-harvest) your links, press this button', 'link-harvest').'</p> 682 745 <p class="submit"> 683 <input type="button" name="recount" value="'.__('(Re) Harvest All Links', ' alexking.org').'" onclick="if ($(\'harvest_enabled_y\').checked) { location.href=\''.get_bloginfo('wpurl').'/wp-admin/options-general.php?ak_action=harvest\'; } else { alert(\'Please enable link harvesting, save your settings, then try again.\'); }" />746 <input type="button" name="recount" value="'.__('(Re) Harvest All Links', 'link-harvest').'" onclick="if ($(\'harvest_enabled_y\').checked) { location.href=\''.get_bloginfo('wpurl').'/wp-admin/options-general.php?ak_action=harvest\'; } else { alert(\'Please enable link harvesting, save your settings, then try again.\'); }" /> 684 747 </p> 685 748 </fieldset> 686 749 </form> 687 <h2>'.__('Backfill Empty Titles', ' alexking.org').'</h2>688 <p>'.__('If a few domains or pages did not get proper titles the first time around, you can try filling them in here.', ' alexking.org').'</p>750 <h2>'.__('Backfill Empty Titles', 'link-harvest').'</h2> 751 <p>'.__('If a few domains or pages did not get proper titles the first time around, you can try filling them in here.', 'link-harvest').'</p> 689 752 <ul style="margin-bottom: 40px;"> 690 <li><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?ak_action=backfill_domains">'.__('Backfill empty domain titles', ' alexking.org').'</a></li>691 <li><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?ak_action=backfill_pages">'.__('Backfill empty page titles', ' alexking.org').'</a></li>753 <li><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?ak_action=backfill_domains">'.__('Backfill empty domain titles', 'link-harvest').'</a></li> 754 <li><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?ak_action=backfill_pages">'.__('Backfill empty page titles', 'link-harvest').'</a></li> 692 755 </ul> 693 756 <div id="aklh_template_tags"> 694 <h2>'.__('Showing the Links List', ' alexking.org').'</h2>695 <h3 id="token">'.__('Token Method', ' alexking.org').'</h3>696 <p>'.__('If you have enabled the token method above, you can simply add <strong>###linkharvest###</strong> to any post or page and your links list will be inserted at that place in the post/page.', ' alexking.org').'</p>697 <h3 id="template">'.__('Template Tag Method', ' alexking.org').'</h3>698 <p>'.__('You can always add a template tag to your theme (in a page template perhaps) to show your links list.', ' alexking.org').'</p>757 <h2>'.__('Showing the Links List', 'link-harvest').'</h2> 758 <h3 id="token">'.__('Token Method', 'link-harvest').'</h3> 759 <p>'.__('If you have enabled the token method above, you can simply add <strong>###linkharvest###</strong> to any post or page and your links list will be inserted at that place in the post/page.', 'link-harvest').'</p> 760 <h3 id="template">'.__('Template Tag Method', 'link-harvest').'</h3> 761 <p>'.__('You can always add a template tag to your theme (in a page template perhaps) to show your links list.', 'link-harvest').'</p> 699 762 <dl> 700 763 <dt><code>aklh_show_harvest($limit = 10, $type = "table" or "list")</code></dt> 701 764 <dd> 702 <p>'.__('Put this tag outside of <a href="http://codex.wordpress.org/The_Loop">The Loop</a> (perhaps in your sidebar?) to show a list (like the archives/categories/links list) of the sites you link to most. All arguments are optional, the defaults are included in the example above.', ' alexking.org').'</p>765 <p>'.__('Put this tag outside of <a href="http://codex.wordpress.org/The_Loop">The Loop</a> (perhaps in your sidebar?) to show a list (like the archives/categories/links list) of the sites you link to most. All arguments are optional, the defaults are included in the example above.', 'link-harvest').'</p> 703 766 <p>Examples:</p> 704 767 <ul> … … 713 776 </dl> 714 777 </div> 778 <h2>'.__('README', 'link-harvest').'</h2> 779 <p>'.__('Find answers to common questions here.', 'link-harvest').'</p> 780 <iframe id="ak_readme" src="http://alexking.org/projects/wordpress/readme?project=link-harvest"></iframe> 715 781 </div> 716 782 '); … … 776 842 '; 777 843 $body = ' 778 <h1>'.__('Harvest Links', ' alexking.org').'</h1>844 <h1>'.__('Harvest Links', 'link-harvest').'</h1> 779 845 '; 780 846 if ($count == 0) { 781 847 $body .= ' 782 <p>'.__('Oops, didn\'t find any links to harvest.', ' alexking.org').'</p>848 <p>'.__('Oops, didn\'t find any links to harvest.', 'link-harvest').'</p> 783 849 '; 784 850 } 785 851 else { 786 852 $body .= ' 787 <p>'.__('Harvesting links from your posts and pages can take a little while. Once you click the <strong>Start Link Harvest</strong> button below, all of your posts and pages will be scanned for links and those links will be pulled out and stored in the Link Harvest database so we can do cool things with them for you.', ' alexking.org').'</p>788 <p>'.__('Note: This is a one time step, future posts and pages will be added to the Link Harvest as you create them (and removed if you delete them).', ' alexking.org').'</p>789 <p id="progress" class="center">'.__('Processed: ', ' alexking.org').'<strong><span id="count">0</span> / '.$count.'</strong> '.__('posts and pages.', 'alexking.org').'</p>853 <p>'.__('Harvesting links from your posts and pages can take a little while. Once you click the <strong>Start Link Harvest</strong> button below, all of your posts and pages will be scanned for links and those links will be pulled out and stored in the Link Harvest database so we can do cool things with them for you.', 'link-harvest').'</p> 854 <p>'.__('Note: This is a one time step, future posts and pages will be added to the Link Harvest as you create them (and removed if you delete them).', 'link-harvest').'</p> 855 <p id="progress" class="center">'.__('Processed: ', 'link-harvest').'<strong><span id="count">0</span> / '.$count.'</strong> '.__('posts and pages.', 'link-harvest').'</p> 790 856 <form action="#" method="get" onsubmit="return false;"> 791 857 <fieldset> 792 <legend>'.__('Harvest Links', ' alexking.org').'</legend>793 <p id="submit" class="center"><input type="button" name="harvest_button" value="'.__('Start Link Harvest', ' alexking.org').'" onclick="harvest_links(0, '.$this->default_limit.'); return false;" /></p>794 <p id="cancel" class="center"><input type="button" name="cancel_button" value="'.__('Cancel', ' alexking.org').'" onclick="location.href=\''.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php\';" />858 <legend>'.__('Harvest Links', 'link-harvest').'</legend> 859 <p id="submit" class="center"><input type="button" name="harvest_button" value="'.__('Start Link Harvest', 'link-harvest').'" onclick="harvest_links(0, '.$this->default_limit.'); return false;" /></p> 860 <p id="cancel" class="center"><input type="button" name="cancel_button" value="'.__('Cancel', 'link-harvest').'" onclick="location.href=\''.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php\';" /> 795 861 </fieldset> 796 862 </form> 797 <p id="complete" class="center">'.__('The link harvest has completed successfully. View your <a href="'.get_bloginfo('wpurl').'/wp-admin/index.php?page=link-harvest.php">links list</a>.', ' alexking.org').'</p>798 <p id="error" class="center">'.__('The link harvest failed, make sure you have harvesting enabled in your <a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">options</a>.', ' alexking.org').'</p>799 <p class="center"><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">'.__('Back to WordPress Admin', ' alexking.org').'</a></p>863 <p id="complete" class="center">'.__('The link harvest has completed successfully. View your <a href="'.get_bloginfo('wpurl').'/wp-admin/index.php?page=link-harvest.php">links list</a>.', 'link-harvest').'</p> 864 <p id="error" class="center">'.__('The link harvest failed, make sure you have harvesting enabled in your <a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">options</a>.', 'link-harvest').'</p> 865 <p class="center"><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">'.__('Back to WordPress Admin', 'link-harvest').'</a></p> 800 866 '; 801 867 } … … 850 916 '; 851 917 $body = ' 852 <h1>'.__('Backfill Empty Domain Titles', ' alexking.org').'</h1>918 <h1>'.__('Backfill Empty Domain Titles', 'link-harvest').'</h1> 853 919 '; 854 920 if ($count == '0') { 855 921 $body .= ' 856 <p>'.__('Oops, didn\'t find any domains without titles.', ' alexking.org').'</p>922 <p>'.__('Oops, didn\'t find any domains without titles.', 'link-harvest').'</p> 857 923 '; 858 924 } 859 925 else { 860 926 $body .= ' 861 <p>'.sprintf(__('Sometimes a web page can be slow to load (for whatever reason). This will go through the <strong>%s</strong> domain(s) that have empty titles and try to fill them in for you.', ' alexking.org'), $count).'</p>862 <p id="progress" class="center">'.__('Processed: ', ' alexking.org').'<strong><span id="count">0</span> / '.$count.'</strong> '.__('empty domain titles.', 'alexking.org').'</p>927 <p>'.sprintf(__('Sometimes a web page can be slow to load (for whatever reason). This will go through the <strong>%s</strong> domain(s) that have empty titles and try to fill them in for you.', 'link-harvest'), $count).'</p> 928 <p id="progress" class="center">'.__('Processed: ', 'link-harvest').'<strong><span id="count">0</span> / '.$count.'</strong> '.__('empty domain titles.', 'link-harvest').'</p> 863 929 <p id="last">0</p> 864 930 <form action="#" method="get" onsubmit="return false;"> 865 931 <fieldset> 866 <legend>'.__('Backfill Empty Domain Titles', ' alexking.org').'</legend>867 <p id="submit" class="center"><input type="button" name="backfill_button" value="'.__('Start', ' alexking.org').'" onclick="backfill_titles(0, 1); return false;" /></p>868 <p id="cancel" class="center"><input type="button" name="cancel_button" value="'.__('Cancel', ' alexking.org').'" onclick="location.href=\''.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php\';" />932 <legend>'.__('Backfill Empty Domain Titles', 'link-harvest').'</legend> 933 <p id="submit" class="center"><input type="button" name="backfill_button" value="'.__('Start', 'link-harvest').'" onclick="backfill_titles(0, 1); return false;" /></p> 934 <p id="cancel" class="center"><input type="button" name="cancel_button" value="'.__('Cancel', 'link-harvest').'" onclick="location.href=\''.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php\';" /> 869 935 </fieldset> 870 936 </form> 871 <p id="complete" class="center">'.__('The domain title backfill has completed successfully. View your <a href="'.get_bloginfo('wpurl').'/wp-admin/index.php?page=link-harvest.php">updated links list</a>.', ' alexking.org').'</p>872 <p id="error" class="center">'.__('The domain title backfill failed, make sure you have harvest actions enabled in your <a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">options</a>.', ' alexking.org').'</p>937 <p id="complete" class="center">'.__('The domain title backfill has completed successfully. View your <a href="'.get_bloginfo('wpurl').'/wp-admin/index.php?page=link-harvest.php">updated links list</a>.', 'link-harvest').'</p> 938 <p id="error" class="center">'.__('The domain title backfill failed, make sure you have harvest actions enabled in your <a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">options</a>.', 'link-harvest').'</p> 873 939 '; 874 940 } 875 941 $body .= ' 876 <p class="center"><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">'.__('Back to WordPress Admin', ' alexking.org').'</a></p>942 <p class="center"><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">'.__('Back to WordPress Admin', 'link-harvest').'</a></p> 877 943 '; 878 944 break; … … 926 992 '; 927 993 $body = ' 928 <h1>'.__('Backfill Empty Page Titles', ' alexking.org').'</h1>994 <h1>'.__('Backfill Empty Page Titles', 'link-harvest').'</h1> 929 995 '; 930 996 if ($count == '0') { 931 997 $body .= ' 932 <p>'.__('Oops, didn\'t find any pages without titles.', ' alexking.org').'</p>998 <p>'.__('Oops, didn\'t find any pages without titles.', 'link-harvest').'</p> 933 999 '; 934 1000 } 935 1001 else { 936 1002 $body .= ' 937 <p>'.sprintf(__('Sometimes a web page can be slow to load (for whatever reason). This will go through the <strong>%s</strong> page(s) that have empty titles and try to fill them in for you.', ' alexking.org'), $count).'</p>938 <p id="progress" class="center">'.__('Processed: ', ' alexking.org').'<strong><span id="count">0</span> / '.$count.'</strong> '.__('empty page titles.', 'alexking.org').'</p>1003 <p>'.sprintf(__('Sometimes a web page can be slow to load (for whatever reason). This will go through the <strong>%s</strong> page(s) that have empty titles and try to fill them in for you.', 'link-harvest'), $count).'</p> 1004 <p id="progress" class="center">'.__('Processed: ', 'link-harvest').'<strong><span id="count">0</span> / '.$count.'</strong> '.__('empty page titles.', 'link-harvest').'</p> 939 1005 <p id="last">0</p> 940 1006 <form action="#" method="get" onsubmit="return false;"> 941 1007 <fieldset> 942 <legend>'.__('Backfill Empty Page Titles', ' alexking.org').'</legend>943 <p id="submit" class="center"><input type="button" name="backfill_button" value="'.__('Start', ' alexking.org').'" onclick="backfill_titles(0, 1); return false;" /></p>944 <p id="cancel" class="center"><input type="button" name="cancel_button" value="'.__('Cancel', ' alexking.org').'" onclick="location.href=\''.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php\';" />1008 <legend>'.__('Backfill Empty Page Titles', 'link-harvest').'</legend> 1009 <p id="submit" class="center"><input type="button" name="backfill_button" value="'.__('Start', 'link-harvest').'" onclick="backfill_titles(0, 1); return false;" /></p> 1010 <p id="cancel" class="center"><input type="button" name="cancel_button" value="'.__('Cancel', 'link-harvest').'" onclick="location.href=\''.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php\';" /> 945 1011 </fieldset> 946 1012 </form> 947 <p id="complete" class="center">'.__('The page title backfill has completed successfully. View your <a href="'.get_bloginfo('wpurl').'/wp-admin/index.php?page=link-harvest.php">updated links list</a>.', ' alexking.org').'</p>948 <p id="error" class="center">'.__('The page title backfill failed, make sure you have harvest actions enabled in your <a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">options</a>.', ' alexking.org').'</p>1013 <p id="complete" class="center">'.__('The page title backfill has completed successfully. View your <a href="'.get_bloginfo('wpurl').'/wp-admin/index.php?page=link-harvest.php">updated links list</a>.', 'link-harvest').'</p> 1014 <p id="error" class="center">'.__('The page title backfill failed, make sure you have harvest actions enabled in your <a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">options</a>.', 'link-harvest').'</p> 949 1015 '; 950 1016 } 951 1017 $body .= ' 952 <p class="center"><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">'.__('Back to WordPress Admin', ' alexking.org').'</a></p>1018 <p class="center"><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">'.__('Back to WordPress Admin', 'link-harvest').'</a></p> 953 1019 '; 954 1020 break; … … 956 1022 if (!$this->harvest_enabled) { 957 1023 $body = ' 958 <h1>'.__('Link Harvest', ' alexking.org').'</h1>959 <p>'.__('Oops, harvest actions aren\'t enabled. Turn them on <a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">in your options</a>', ' alexking.org').'</p>1024 <h1>'.__('Link Harvest', 'link-harvest').'</h1> 1025 <p>'.__('Oops, harvest actions aren\'t enabled. Turn them on <a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php">in your options</a>', 'link-harvest').'</p> 960 1026 '; 961 1027 } … … 967 1033 <html xmlns="http://www.w3.org/1999/xhtml"> 968 1034 <head> 969 <title>'.__('Link Harvest', ' alexking.org').'</title>1035 <title>'.__('Link Harvest', 'link-harvest').'</title> 970 1036 <script src="'.get_bloginfo('wpurl').'/wp-includes/js/prototype.js" type="text/javascript"></script> 971 1037 <script type="text/javascript"> … … 1068 1134 if (function_exists('add_options_page')) { 1069 1135 add_options_page( 1070 __('Link Harvest Options', ' alexking.org')1071 , __('Link Harvest', ' alexking.org')1136 __('Link Harvest Options', 'link-harvest') 1137 , __('Link Harvest', 'link-harvest') 1072 1138 , 10 1073 1139 , basename(__FILE__) … … 1078 1144 add_submenu_page( 1079 1145 'index.php' 1080 , __('Link Harvest', ' alexking.org')1081 , __('Link Harvest', ' alexking.org')1146 , __('Link Harvest', 'link-harvest') 1147 , __('Link Harvest', 'link-harvest') 1082 1148 , 0 1083 1149 , basename(__FILE__) … … 1113 1179 print(' 1114 1180 <div class="wrap"> 1115 <h2>'.__('Link Harvest', ' alexking.org').'</h2>1116 <p>'.__('Set domains to exclude and how many links to display in this list on the <a href="options-general.php?page=link-harvest.php">options page</a>.', ' alexking.org').'</p>1181 <h2>'.__('Link Harvest', 'link-harvest').'</h2> 1182 <p>'.__('Set domains to exclude and how many links to display in this list on the <a href="options-general.php?page=link-harvest.php">options page</a>.', 'link-harvest').'</p> 1117 1183 '); 1118 1184 $aklh->show_harvest(); … … 1291 1357 print(' 1292 1358 <a href="javascript:void($(\'domain_'.$domain_id.'\').style.display=\'none\');" class="close">Close</a> 1293 <h4>'.__('Links', ' alexking.org').'</h4>1359 <h4>'.__('Links', 'link-harvest').'</h4> 1294 1360 <ul> 1295 1361 '); … … 1309 1375 else { 1310 1376 print(' 1311 <li>'.__('(none found)', ' alexking.org').'</li>1377 <li>'.__('(none found)', 'link-harvest').'</li> 1312 1378 '); 1313 1379 } … … 1339 1405 print(' 1340 1406 <a href="javascript:void($(\'domain_'.$domain_id.'\').style.display=\'none\');" class="close">Close</a> 1341 <h4>'.__('Posts and Pages', ' alexking.org').'</h4>1407 <h4>'.__('Posts and Pages', 'link-harvest').'</h4> 1342 1408 <ul> 1343 1409 '); … … 1352 1418 else { 1353 1419 print(' 1354 <li>'.__('(none found)', ' alexking.org').'</li>1420 <li>'.__('(none found)', 'link-harvest').'</li> 1355 1421 '); 1356 1422 } … … 1405 1471 height: 60px; 1406 1472 width: 80%; 1473 } 1474 #ak_readme { 1475 height: 300px; 1476 width: 95%; 1407 1477 } 1408 1478 <?php … … 1463 1533 $aklh->show_harvest($count, 'table'); 1464 1534 print(' 1465 <p id="aklh_credit">'.__('Powered by ', ' alexking.org').'<a href="http://alexking.org/projects/wordpress">Link Harvest</a>.</p>1535 <p id="aklh_credit">'.__('Powered by ', 'link-harvest').'<a href="http://alexking.org/projects/wordpress">Link Harvest</a>.</p> 1466 1536 '); 1467 1537 } … … 1470 1540 $aklh->show_harvest($count, 'list'); 1471 1541 print(' 1472 <p id="aklh_credit">'.__('Powered by ', ' alexking.org').'<a href="http://alexking.org/projects/wordpress">Link Harvest</a>.</p>1542 <p id="aklh_credit">'.__('Powered by ', 'link-harvest').'<a href="http://alexking.org/projects/wordpress">Link Harvest</a>.</p> 1473 1543 '); 1474 1544 } 1475 1545 1546 // debug logging 1547 1548 function aklh_log($msg) { 1549 if (!AKLH_DEBUG) { 1550 return; 1551 } 1552 $logfile = dirname(__FILE__).'/aklh_log.txt'; 1553 $file = fopen($logfile, 'a'); 1554 if ($file) { 1555 if (!fwrite($file, $msg."\n")) { 1556 die('Error writing to log file.'); 1557 } 1558 } 1559 } 1476 1560 1477 1561 // -- GET HOOKED
