Changeset 9442

Show
Ignore:
Timestamp:
03/25/07 17:37:02 (1 year ago)
Author:
alexkingorg
Message:

exclude certain file types

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • link-harvest/trunk/link-harvest.php

    r9391 r9442  
    55Plugin URI: http://alexking.org/projects/wordpress 
    66Description: 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.0 
     7Version: 1.1b1 
    88Author: Alex King 
    99Author URI: http://alexking.org 
     
    2727@define('AK_WPROOT', '../../'); 
    2828 
     29@define('AKLH_DEBUG', false); 
     30 
     31if (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 
    2940if (!isset($wpdb)) { 
    3041      require(AK_WPROOT.'wp-blog-header.php'); 
    3142} 
    3243 
    33 load_plugin_textdomain('alexking.org'); 
     44load_plugin_textdomain('link-harvest'); 
    3445 
    3546if (!function_exists('is_admin_page')) { 
     
    7081 
    7182if (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      "); 
    7786      if (!in_array($wpdb->ak_linkharvest, $tables) && !in_array($wpdb->ak_domains, $tables)) { 
    7887            $aklh->install(); 
     
    102111                  , 'harvest_enabled' => 'int' 
    103112                  , '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' 
    104132            ); 
    105133      } 
     
    179207            header('Location: '.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=link-harvest.php&updated=true'); 
    180208            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      } 
    182219       
    183220      function get_links($body) { 
     
    210247            if (preg_match_all($regex, $body, $links)) { 
    211248                  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)) { 
    213250                              $urls[] = $link; 
    214251                        } 
     
    268305                  return; 
    269306            } 
     307             
     308            aklh_log('Found '.count($links).' links in post id: '.$post_id); 
    270309 
    271310            $domains = array(); 
     
    302341                        $harvest[] = array($link, $domain); 
    303342                  } 
     343 
     344                  aklh_log('Processed link: '.$link); 
     345 
    304346            } 
    305347             
     
    321363       
    322364      function add_link($url, $domain_id, $post_id) { 
     365 
     366            aklh_log('About to add link for post id: '.$post_id.' - '.$url); 
     367 
    323368            global $wpdb; 
    324369            $title = stripslashes($this->get_page_title($url)); 
     
    340385            "); 
    341386            if (!$result) { 
     387 
     388                  aklh_log('Failed to add link for post id: '.$post_id.' - '.$url); 
     389 
    342390                  return false; 
    343391            } 
    344392            else { 
     393 
     394                  aklh_log('Added link for for post id: '.$post_id.' - '.$url); 
     395 
    345396                  return true; 
    346397            } 
     
    363414            "); 
    364415            if (!$result) { 
     416 
     417                  aklh_log('Failed to add domain: '.$domain); 
     418 
    365419                  return false; 
    366420            } 
    367421            else { 
     422 
     423                  aklh_log('Added domain: '.$domain); 
     424 
    368425                  return mysql_insert_id(); 
    369426            } 
     
    458515            } 
    459516            foreach ($posts as $post) { 
     517 
     518                  aklh_log('== Start processing post id: '.$post->ID); 
     519 
    460520                  $this->process_content($post->post_content, $post->ID); 
    461521                  $external = get_post_meta($post->ID, 'external_link', true); 
     
    467527                        $this->process_content($via, $post->ID); 
    468528                  } 
     529 
     530                  aklh_log('== Done processing post id: '.$post->ID."\n"); 
     531 
    469532            } 
    470533      } 
     
    481544                  $urls[] = $link->url; 
    482545            } 
    483             $domains = $this->domain_counts($links); 
     546            $domains = $this->domain_counts($urls); 
    484547            foreach ($domains as $domain => $count) { 
    485548                  $this->set_domain_counter($domain, null, $count, $mod = '-'); 
     
    563626      <thead> 
    564627            <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> 
    569632            </tr> 
    570633      </thead> 
     
    573636                        if (count($domains) == 0) { 
    574637                              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> 
    576639                              '); 
    577640                        } 
     
    594657                  <td><a href="http://'.$domain->domain.'">'.$title.'</a><div id="domain_'.$domain->id.'"></div></td> 
    595658                  <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> 
    598661            </tr> 
    599662                                    '); 
     
    644707            } 
    645708            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>'; 
    647710            } 
    648711            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>'; 
    650713            } 
    651714            print(' 
    652715                  <div class="wrap"> 
    653                         <h2>'.__('Link Harvest Options', 'alexking.org').'</h2> 
     716                        <h2>'.__('Link Harvest Options', 'link-harvest').'</h2> 
    654717                        <form name="ak_linkharvest" action="'.get_bloginfo('wpurl').'/wp-admin/options-general.php" method="post"> 
    655718                              <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> 
    658721                                    <p><textarea name="exclude" id="exclude">'.htmlspecialchars(implode(' ', $this->exclude)).'</textarea></p> 
    659722                                    <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> 
    661724                                          <input type="text" size="5" name="table_length" id="table_length" value="'.$this->table_length.'" /> 
    662725                                    </p> 
    663726                                    <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> 
    665728                                          <select name="aklh_token" id="token">'.$token_options.'</select> 
    666729                                    </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> 
    668731                                    <ul> 
    669732                                          <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> 
     
    673736                              </fieldset> 
    674737                              <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').'" /> 
    676739                              </p> 
    677740                        </form> 
    678                         <h2>'.__('Harvest Links', 'alexking.org').'</h2> 
     741                        <h2>'.__('Harvest Links', 'link-harvest').'</h2> 
    679742                        <form> 
    680743                              <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> 
    682745                                    <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.\'); }" /> 
    684747                                    </p>                           
    685748                              </fieldset> 
    686749                        </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> 
    689752                        <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> 
    692755                        </ul> 
    693756                        <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> 
    699762                              <dl> 
    700763                                    <dt><code>aklh_show_harvest($limit = 10, $type = &quot;table&quot; or &quot;list&quot;)</code></dt> 
    701764                                    <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> 
    703766                                          <p>Examples:</p>  
    704767                                          <ul> 
     
    713776                              </dl> 
    714777                        </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> 
    715781                  </div> 
    716782            '); 
     
    776842                        '; 
    777843                        $body = ' 
    778             <h1>'.__('Harvest Links', 'alexking.org').'</h1> 
     844            <h1>'.__('Harvest Links', 'link-harvest').'</h1> 
    779845                        '; 
    780846                        if ($count == 0) { 
    781847                              $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> 
    783849                              '; 
    784850                        } 
    785851                        else { 
    786852                              $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> 
    790856            <form action="#" method="get" onsubmit="return false;"> 
    791857                  <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\';" /> 
    795861                  </fieldset> 
    796862            </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> 
    800866                              '; 
    801867                        } 
     
    850916                        '; 
    851917                        $body = ' 
    852             <h1>'.__('Backfill Empty Domain Titles', 'alexking.org').'</h1> 
     918            <h1>'.__('Backfill Empty Domain Titles', 'link-harvest').'</h1> 
    853919                        '; 
    854920                        if ($count == '0') { 
    855921                              $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> 
    857923                              '; 
    858924                        } 
    859925                        else { 
    860926                              $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> 
    863929            <p id="last">0</p> 
    864930            <form action="#" method="get" onsubmit="return false;"> 
    865931                  <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\';" /> 
    869935                  </fieldset> 
    870936            </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> 
    873939                              '; 
    874940                        } 
    875941                        $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> 
    877943                        '; 
    878944                        break; 
     
    926992                        '; 
    927993                        $body = ' 
    928             <h1>'.__('Backfill Empty Page Titles', 'alexking.org').'</h1> 
     994            <h1>'.__('Backfill Empty Page Titles', 'link-harvest').'</h1> 
    929995                        '; 
    930996                        if ($count == '0') { 
    931997                              $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> 
    933999                              '; 
    9341000                        } 
    9351001                        else { 
    9361002                              $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> 
    9391005            <p id="last">0</p> 
    9401006            <form action="#" method="get" onsubmit="return false;"> 
    9411007                  <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\';" /> 
    9451011                  </fieldset> 
    9461012            </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> 
    9491015                              '; 
    9501016                        } 
    9511017                        $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> 
    9531019                        '; 
    9541020                        break; 
     
    9561022            if (!$this->harvest_enabled) { 
    9571023                  $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> 
    9601026                  '; 
    9611027            } 
     
    9671033<html xmlns="http://www.w3.org/1999/xhtml"> 
    9681034<head> 
    969       <title>'.__('Link Harvest', 'alexking.org').'</title> 
     1035      <title>'.__('Link Harvest', 'link-harvest').'</title> 
    9701036      <script src="'.get_bloginfo('wpurl').'/wp-includes/js/prototype.js" type="text/javascript"></script> 
    9711037      <script type="text/javascript"> 
     
    10681134      if (function_exists('add_options_page')) { 
    10691135            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') 
    10721138                  , 10 
    10731139                  , basename(__FILE__) 
     
    10781144            add_submenu_page( 
    10791145                  'index.php' 
    1080                   , __('Link Harvest', 'alexking.org') 
    1081                   , __('Link Harvest', 'alexking.org') 
     1146                  , __('Link Harvest', 'link-harvest') 
     1147                  , __('Link Harvest', 'link-harvest') 
    10821148                  , 0 
    10831149                  , basename(__FILE__) 
     
    11131179      print(' 
    11141180            <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> 
    11171183      '); 
    11181184      $aklh->show_harvest(); 
     
    12911357                        print(' 
    12921358                              <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> 
    12941360                              <ul> 
    12951361                        '); 
     
    13091375                        else { 
    13101376                              print(' 
    1311                                     <li>'.__('(none found)', 'alexking.org').'</li> 
     1377                                    <li>'.__('(none found)', 'link-harvest').'</li> 
    13121378                              '); 
    13131379                        } 
     
    13391405                        print(' 
    13401406                              <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> 
    13421408                              <ul> 
    13431409                        '); 
     
    13521418                        else { 
    13531419                              print(' 
    1354                                     <li>'.__('(none found)', 'alexking.org').'</li> 
     1420                                    <li>'.__('(none found)', 'link-harvest').'</li> 
    13551421                              '); 
    13561422                        } 
     
    14051471      height: 60px; 
    14061472      width: 80%; 
     1473} 
     1474#ak_readme { 
     1475      height: 300px; 
     1476      width: 95%; 
    14071477} 
    14081478<?php 
     
    14631533      $aklh->show_harvest($count, 'table'); 
    14641534      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> 
    14661536      '); 
    14671537} 
     
    14701540      $aklh->show_harvest($count, 'list'); 
    14711541      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> 
    14731543      '); 
    14741544} 
    14751545 
     1546// debug logging 
     1547 
     1548function 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} 
    14761560 
    14771561// -- GET HOOKED