Changeset 144083
- Timestamp:
- 08/08/2009 09:07:45 PM (17 years ago)
- Location:
- faviroll/trunk
- Files:
-
- 1 added
- 3 edited
-
Faviroll.class.php (modified) (19 diffs)
-
faviroll.php (modified) (8 diffs)
-
readme.txt (modified) (3 diffs)
-
screenshot-4.png (added)
Legend:
- Unmodified
- Added
- Removed
-
faviroll/trunk/Faviroll.class.php
r139728 r144083 25 25 26 26 // Members 27 var $basename = null;28 27 var $cachedir = null; 29 28 var $cacheurl = null; 30 29 var $pluginurl = null; 31 var $plugindir = null;32 30 var $lastcheck = null; 33 31 var $defaulticon = null; 34 32 var $transparency = null; 33 var $debug = false; 35 34 36 35 … … 50 49 function __construct($init=true) { 51 50 52 $this->basename = plugin_basename(dirname(__FILE__));53 51 $this->initURLsAndDirs(); 54 52 … … 78 76 if (empty($revisit)) 79 77 $init && update_option('faviroll_revisit', 14); 78 79 // default is enabled background tranparency. 80 $this->debug = get_option('faviroll_debug'); 81 if (empty($this->debug)) 82 $init && update_option('faviroll_debug','off'); 83 84 $this->debug = (get_option('faviroll_debug') == 'on'); 80 85 81 86 // caretaker … … 186 191 187 192 $handle = @fopen($icopath,'wb'); 188 if ($handle ) {193 if ($handle !== false) { 189 194 fwrite($handle,$ico->rawdata); 190 195 fflush($handle); … … 402 407 403 408 echo'</p></div><script type="text/javascript">var t = document.getElementById("message"); if (t){ t.style.display = "none"; }</script>'; 409 404 410 flush(); 405 411 ob_flush(); … … 414 420 function initURLsAndDirs() { 415 421 416 $this->plugindir = $this->normalize(WP_PLUGIN_DIR.'/'.$this->basename); 417 $this->cachedir = $this->normalize($this->plugindir.'/cache'); 418 422 $this->cachedir = $this->normalize(plugin_dir_path(__FILE__).'/cache'); 419 423 420 424 // -------------- [Plugin URL ermitteln ] -------------- 421 $this->pluginurl = WP_PLUGIN_URL.'/'.$this->basename; 425 $this->pluginurl = plugin_dir_url(__FILE__); 426 422 427 $elems = parse_url($this->pluginurl); 423 428 … … 435 440 if (!isset($request['path'])) 436 441 return false; 442 437 443 438 444 $cURL = trim(rtrim($request['path'],'/')); … … 445 451 } 446 452 447 $this->cacheurl = $this->pluginurl.'/cache';453 $this->cacheurl = trim(rtrim($this->pluginurl,'/')).'/cache'; 448 454 return true; 449 455 } … … 459 465 $cElems = explode('/',$current_url); 460 466 $pElems = explode('/',$plugin_url); 467 461 468 462 469 // eleminate identically path elements from both arrays … … 474 481 } else { 475 482 483 // Wenn der Request Path nicht mit Slash endet, entferne den letzten Namen, 484 // da dann das Verzeichnis darüber gilt. Quasi der "dirname()" 476 485 if (substr($request_path,-1) != '/') 477 486 array_pop($cElems); … … 522 531 Use your ftp client, or the following command to fix it:<br /> 523 532 <br /> 524 <code># chmod 07 55 ".$this->cachedir."</code></p></div>";533 <code># chmod 0775 ".$this->cachedir."</code></p></div>"; 525 534 526 535 } … … 533 542 return $this->is__writable(rtrim($this->cachedir,'/').'/'); 534 543 } 544 535 545 536 546 /** … … 618 628 } 619 629 620 # debugging621 #echo "<p>$typeOfURL<br>$faviconURL</p>";622 623 630 if($this->validateURL($faviconURL)) 624 631 return $faviconURL; … … 664 671 } 665 672 673 674 /** 675 * TODO 676 */ 677 function patchPlugin($plugindir,$activate=false) { 678 679 $result = null; 680 681 foreach (get_plugins() as $path => $data) { 682 if (strpos($path,$plugindir) === 0) { 683 $pluginfile = $path; 684 break; 685 } 686 } 687 688 if (!isset($pluginfile)) 689 return true; 690 691 $pluginfile = WP_PLUGIN_DIR."/$pluginfile"; 692 if (!is_file($pluginfile) || !is_writable($pluginfile)) 693 return true; 694 695 switch ($plugindir) { 696 case 'wp-render-blogroll-links': 697 698 break; 699 default: 700 break; 701 } 702 703 return true; 704 } 705 706 707 708 709 710 711 666 712 // -----------------------Non - Admin Functions ----------------------------------------------------------------------- 667 713 … … 675 721 $default_favicon = get_option('faviroll_default_favicon'); 676 722 677 // get cached icon list723 // get list of cached icons 678 724 $cacheIcons = $this->getCacheIcons(); 679 725 … … 688 734 $line = trim($line); 689 735 690 if (! preg_match('/href=[\'"](.*)[\'"]/', $line, $matches) && !preg_match('/img/', $line)) {736 if (!(bool) @preg_match('/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a>/i', $line, $matches)) { 691 737 // overhead stuff 692 738 $newContent[] = $line; … … 694 740 } 695 741 696 if (count($matches) < 2) {742 if (count($matches) < 3) { 697 743 // overhead stuff 698 744 $newContent[] = $line; … … 700 746 } 701 747 702 extract($this->getURLinfo($matches[1]),EXTR_OVERWRITE); 748 $urlInfo = $this->getURLinfo($matches[1]); 749 extract($urlInfo,EXTR_OVERWRITE); 750 751 // Es konnte keine Checksumme ermittelt werden 752 // also einfach die Zeile as-is übernehmen 703 753 if (!isset($checksum)) { 704 // overhead stuff705 754 $newContent[] = $line; 706 755 continue; … … 717 766 $newContent[] = $line; 718 767 } 768 719 769 720 770 return "<!-- Begin:FaviRoll Plugin -->\n".implode("\n",$newContent)."\n<!-- End:FaviRoll Plugin -->"; -
faviroll/trunk/faviroll.php
r140233 r144083 5 5 Description: Locally caches all favicon.ico in PNG format and use this into the blogroll. Native ICO Images are not supported from all browsers/operating systems. <strong><a href="link-manager.php?page=faviroll.php">Settings » Faviroll</a></strong> 6 6 Author: grobator 7 Version: 0.4. 47 Version: 0.4.5 8 8 Author URI: http://www.grobator.de/ 9 9 ---------------------------------------------------------------------------------------- … … 26 26 27 27 // Debug only on localhost 28 if ($_SERVER['HTTP_HOST'] == 'localhost') error_reporting(E_ALL); 28 if ($_SERVER['HTTP_HOST'] == 'localhost') error_reporting(E_ALL); // |E_STRICT 29 29 30 30 require_once('Faviroll.class.php'); … … 39 39 } 40 40 add_filter('wp_list_bookmarks', 'faviroll_list_bookmarks'); 41 41 add_filter('wp_list_bookmarks_plus', 'faviroll_list_bookmarks'); 42 42 43 43 /** … … 76 76 function faviroll_options(){ 77 77 78 faviroll_activate(); 78 79 $message = null; 79 80 $removeSettings = isset($_REQUEST['faviroll_remove_settings']); … … 101 102 update_option('faviroll_revisit' , (int) trim($_REQUEST['faviroll_revisit'])); 102 103 update_option('faviroll_transparency', (isset($_REQUEST['faviroll_transparency']) ? 'on' : 'off') ); 104 update_option('faviroll_debug' , (isset($_REQUEST['faviroll_debug']) ? 'on' : 'off') ); 103 105 104 106 $message = 'Settings updated'; … … 113 115 114 116 $is_transparency = (get_option('faviroll_transparency') == 'on'); 115 117 $is_debugMode = (get_option('faviroll_debug') == 'on'); 116 118 117 119 if (!$removeSettings) { … … 130 132 131 133 echo ' 132 <div class="wrap"> 133 <h2>'.__('FAVIcons for blogROLL', 'faviroll').'</h2>'.$faviroll->get_message($message).' 134 <form id="faviroll" name="faviroll" method="post"> 135 <table class="form-table" summary=""> 134 <div class="wrap"> 135 136 <h2 style="display:inline;">'.__('FAVIcons for blogROLL', 'faviroll').'</h2>'.$faviroll->get_message($message).'<br /> 137 <h4 style="display:inline;">Currently [ '.$faviroll->cacheIconsCount().' ] icons in the cache directory.</h4> 138 139 <div style="float: right;"><form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 140 <input type="hidden" name="cmd" value="_s-xclick"> 141 <input type="hidden" name="hosted_button_id" value="7362367"> 142 <input type="image" src="https://www.paypalobjects.com/WEBSCR-580-20090807-1/de_DE/DE/i/btn/x-click-butcc-donate.gif" border="0" name="submit" alt="Make a donation" title="Make a donation"> 143 <img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1"> 144 </form></div> 145 146 <form id="faviroll" name="faviroll" method="post"> 147 <table class="form-table" summary=""> 148 <tr> 149 <td><strong>Settings</strong></td> 150 </tr> 151 <tr> 152 <td scope="row" valign="top">Default Favicon URL:</td> 153 <td><input type="text" name="faviroll_default_favicon" size="120" value="'.$default_favicon.'" /><br />(If the favicon on the link is missing this will be shown instead.)</td> 154 </tr> 155 <tr> 156 <td scope="row">Favions revisit after:</td> 157 <td><input type="text" name="faviroll_revisit" size="4" value="'.$revisit.'" /> days</td> 158 </tr> 159 <tr> 160 <td scope="row">Use transparent background:</td> 161 <td><input type="checkbox" name="faviroll_transparency" value="on"'.($is_transparency ? ' checked="checked"' : null).' /></td> 162 </tr> 163 <tr> 164 <td scope="row"> </td> 165 <td><a href="plugin-editor.php?file=faviroll/style.css&plugin=faviroll/faviroll.php" title="Edit the faviroll css-styles">Edit faviroll stylesheet</a></td> 166 </tr> 167 <tr> 168 <td colspan="2" width="98%"><hr size="1" /></td> 169 </tr> 170 <tr> 171 <td><strong>Actions</strong></td> 172 </tr> 173 <tr> 174 <td scope="row">(re)build FavIcons now:</td> 175 <td><input type="checkbox" name="faviroll_renew_icons" value="true"'.(($faviroll->cacheIconsCount() == 0) ? ' checked="checked"' : null).' /></td> 176 </tr> 177 <tr> 178 <td scope="row" title="This will remove plugin settings from database and drop the favicon cache">Remove settings:</td> 179 <td><input type="checkbox" name="faviroll_remove_settings" value="true" /> 180 </tr> 181 '; 182 /* 136 183 <tr> 137 <td><strong>Settings</strong></td> 184 <td scope="row" title="Write debug informations as comments into the HTML code">Debug mode:</td> 185 <td><input type="checkbox" name="faviroll_debug" value="true" '.($is_debugMode ? ' checked="checked"' : null).' /> ( just for Developers, normally switch off ) 138 186 </tr> 139 <tr> 140 <td scope="row" valign="top">Default Favicon URL:</td> 141 <td><input type="text" name="faviroll_default_favicon" size="120" value="'.$default_favicon.'" /><br />(If the favicon on the link is missing this will be shown instead.)</td> 142 </tr> 143 <tr> 144 <td scope="row">Favions revisit after:</td> 145 <td><input type="text" name="faviroll_revisit" size="4" value="'.$revisit.'" /> days</td> 146 </tr> 147 <tr> 148 <td scope="row">Use transparent background:</td> 149 <td><input type="checkbox" name="faviroll_transparency" value="on"'.($is_transparency ? ' checked="checked"' : null).' /> 150 <a href="plugin-editor.php?file=faviroll/style.css&plugin=faviroll/faviroll.php" title="Edit the faviroll css-styles">Edit faviroll stylesheet</a> 151 </td> 152 </tr> 153 <tr> 154 <td colspan="2" width="98%"><hr size="1" /></td> 155 </tr> 156 <tr> 157 <td><strong>Actions</strong></td> 158 </tr> 159 <tr> 160 <td scope="row">(re)build FavIcons now:</td> 161 <td><input type="checkbox" name="faviroll_renew_icons" value="true"'.(($faviroll->cacheIconsCount() == 0) ? ' checked="checked"' : null).' /></td> 162 </tr> 163 <tr> 164 <td scope="row" title="This will remove plugin settings from database and drop the favicon cache">Remove settings:</td> 165 <td><input type="checkbox" name="faviroll_remove_settings" value="true" /> 166 </tr> 167 <tr> 168 <td class="submit"><input type="submit" name="submit_button" value="Submit" /> 169 <input type="hidden" name="_wpnonce" value="'.$nonce.'" /> 170 </td> 171 </tr> 172 </table> 173 </form> 174 </div> 175 '; 187 */ 188 echo ' <tr> 189 <td class="submit"><input type="submit" name="submit_button" value="Submit" /><input type="hidden" name="_wpnonce" value="'.$nonce.'" /></td> 190 </tr> 191 </table> 192 </form> 193 </div> 194 '; 176 195 177 196 flush(); … … 198 217 add_action('wp_enqueue_scripts', 'faviroll_enqueue_scripts'); 199 218 219 220 /** 221 * Actions on plugin activation 222 */ 223 function faviroll_activate() { 224 $faviroll = new Faviroll(); 225 return $faviroll->patchPlugin('wp-render-blogroll-links',true); 226 } 227 register_activation_hook(__FILE__, 'faviroll_activate'); 228 229 230 /** 231 * Actions on plugin deactivation 232 */ 233 function faviroll_deactivate() { 234 $faviroll = new Faviroll(); 235 return $faviroll->patchPlugin('wp-render-blogroll-links',false); 236 } 237 register_deactivation_hook(__FILE__, 'faviroll_deactivate'); 238 200 239 /* eof */ 201 240 ?> -
faviroll/trunk/readme.txt
r140233 r144083 4 4 Requires at least: 2.7 5 5 Tested up to: 2.8 6 Stable tag: 0.4. 46 Stable tag: 0.4.5 7 7 8 8 Locally caches all favicon.ico in PNG format and use this into the blogroll. Native ICO Images are not supported from all browsers (f.e. IE). … … 20 20 2. Faviroll configuration panel 21 21 3. (re)build the local cache with the remote favicons 22 4. Remove the double slashes in WP-Render-Blogroll.php, if you want to have the faviroll icons in the blogroll of this plugin. 22 23 23 24 == Installation == … … 33 34 34 35 == Changelog == 36 = 0.4.5 = 37 * FIXED: Parser has not recognized Blogroll-Links with additional attributes like title="...", rel="...", etc. 38 Many many thanks for patient debugging support of: http://www.heiniger-net.ch/daniel 39 * prepared for the new version of http://wordpress.org/extend/plugins/wp-render-blogroll-links/ 40 * Unfortunately this plugin needs a little patch. See Screenshot-4. 41 * If possible, the patch will done by the faviroll plugin automatically. 35 42 = 0.4.4 = 43 * Settings panel now you can find under "Links". 36 44 * Image type recognition. Just the ICO image is converted into PNG. All other image formats are bypass direct into the local cache. This will maximize the usage of the foreign favicons. 37 45 = 0.4.3 =
Note: See TracChangeset
for help on using the changeset viewer.