Plugin Directory

Changeset 3139340


Ignore:
Timestamp:
08/22/2024 01:16:53 AM (19 months ago)
Author:
brandondove
Message:

Final release before closing this plugin. This plugin's functionality exists in WordPress Core and is no longer necessary. So long, and thanks for all the fish.

Location:
favicon-generator
Files:
18 deleted
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • favicon-generator/tags/2.1/pj-favicon-generator.php

    r588060 r3139340  
    11<?php
    2 /*
    3 Plugin Name: Favicon Generator
    4 Plugin URI: http://www.pixeljar.net/plugins/favicon-generator
    5 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3441397
    6 Description: This plugin will allow you to upload an image file of your choosing to be converted to a favicon for your WordPress site.
    7 Author: Brandon Dove, Jeffrey Zinn
    8 Version: 1.5
    9 Author URI: http://www.pixeljar.net
     2/**
     3 * Plugin Name: Favicon Generator (CLOSED)
     4 * Plugin URI: http://www.pixeljar.com
     5 * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3441397
     6 * Description: This plugin's functionality has been included in WordPress core for many years. It is no longer necessary to use this plugin. As such, this plugin can no longer be activated.
     7 * Author: Pixel Jar
     8 * Version: 2.1
     9 * Author URI: http://www.pixeljar.com
     10 * License: GPL2
     11 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
     12 * Text Domain: pjfavgen
     13 * Domain Path: /lang
     14 * Requires at least: 4.0
     15 * Tested up to: 6.6.1
     16 *
     17 * Copyright 2024  Pixel jar  (email : info@pixeljar.com)
     18 *
     19 * This program is free software; you can redistribute it and/or modify
     20 * it under the terms of the GNU General Public License as published by
     21 * the Free Software Foundation; either version 2 of the License, or
     22 * (at your option) any later version.
     23 *
     24 * This program is distributed in the hope that it will be useful,
     25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     27 * GNU General Public License for more details.
     28 *
     29 * You should have received a copy of the GNU General Public License
     30 * along with this program; if not, write to the Free Software
     31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     32 *
     33 * @package WordPress
     34 * @subpackage PJ_Favicon_Generator
     35 */
    1036
     37/**
     38 * Deactivate the plugin as the functionality is now in WordPress core.
     39 */
     40function pj_favicon_generator_deactivate() {
    1141
    12 Copyright 2009  Pixel jar  (email : info@pixeljar.net)
     42    $plugin = plugin_basename( __FILE__ );
     43    if ( is_plugin_active( $plugin ) ) {
    1344
    14 This program is free software; you can redistribute it and/or modify
    15 it under the terms of the GNU General Public License as published by
    16 the Free Software Foundation; either version 2 of the License, or
    17 (at your option) any later version.
     45        delete_option( 'pj_favicon_generator_options' );
     46        deactivate_plugins( $plugin, true );
    1847
    19 This program is distributed in the hope that it will be useful,
    20 but WITHOUT ANY WARRANTY; without even the implied warranty of
    21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    22 GNU General Public License for more details.
     48    }
    2349
    24 You should have received a copy of the GNU General Public License
    25 along with this program; if not, write to the Free Software
    26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    27 */
    28 
    29 if ( ! defined( 'PJFAV_URL' ) )
    30     define( 'PJFAV_URL', plugin_dir_url( __FILE__ ) );
    31 if ( ! defined( 'PJFAV_DIR' ) )
    32     define( 'PJFAV_DIR', plugin_dir_path( __FILE__ ) );
    33 
    34 load_plugin_textdomain( 'pj-favicon-generator', PJFAV_DIR );
    35 
    36 function pj_favicon_admin_scripts() {
    37     if ( isset($_GET['page']) && $_GET['page'] == "Favicon-Generator" )
    38         wp_enqueue_style( 'pjfav-admin-css', PJFAV_URL.'styles/styles.css' );
    3950}
    40 add_action( 'admin_init', 'pj_favicon_admin_scripts', 1 );
    41 register_activation_hook( __FILE__, array( &$pj_favicon_generator, 'activate' ) );
    42 add_action( 'admin_notices', array(&$pj_favicon_generator, 'check_installation') );
    43 
    44 
    45 if (!class_exists('pj_favicon_generator')) {
    46    
    47     include ('php/Directory.php');
    48     include ('php/Ico2_1.php');
    49     include ('php/Image.php');
    50    
    51     class pj_favicon_generator  {
    52        
    53         /**
    54         * @var string   The name the options are saved under in the database.
    55         */
    56         var $adminOptionsName = "pj_favicon_generator_options";
    57        
    58         /**
    59         * @var array   The options that are saved in the database.
    60         */
    61         var $adminOptions = array();
    62        
    63         /**
    64         * PHP 4 Compatible Constructor
    65         */
    66         function pj_favicon_generator(){$this->__construct();}
    67        
    68         /**
    69         * PHP 5 Constructor
    70         */     
    71         function __construct(){
    72             $this->adminOptions = $this->getAdminOptions();
    73             add_action("admin_menu", array(&$this,"add_admin_pages"));
    74             add_action('wp_head', array(&$this,'wp_head_intercept'));
    75         }
    76        
    77         /**
    78         * Retrieves the options from the database.
    79         * @return array
    80         */
    81         function getAdminOptions() {
    82             $adminOptions = array(
    83                 "favicon" => "<empty>",
    84                 "donated" => "no"
    85             );
    86             $savedOptions = get_option($this->adminOptionsName);
    87             if (!empty($savedOptions)) {
    88                 foreach ($savedOptions as $key => $option) {
    89                     $adminOptions[$key] = $option;
    90                 }
    91             }
    92             update_option($this->adminOptionsName, $adminOptions);
    93             return $adminOptions;
    94         }
    95        
    96         function saveAdminOptions(){
    97             update_option($this->adminOptionsName, $this->adminOptions);
    98         }
    99        
    100         /**
    101         * Runs on plugin activation
    102         */
    103         function activate () {
    104             $uploaddir = PJFAV_DIR.'uploads/';
    105             wp_mkdir_p( $uploaddir );
    106         }
    107         /**
    108         * Checks to make sure that all
    109         * required directories are set up properly
    110         */
    111         function check_installation() {
    112             if ( (stripos($_SERVER['REQUEST_URI'],'plugins.php') !== false) || (!empty($_GET['page']) && $_GET['page'] == "Favicon-Generator" ) ) :
    113                 $dir_list = "";
    114                 $dir_list2 = "";
    115    
    116                 $uploaddir = PJFAV_DIR.'uploads/';
    117                 wp_mkdir_p( $uploaddir );
    118    
    119                 if (!is_dir(PJFAV_DIR)){
    120                     $dir_list2.= "<li>".PJFAV_DIR . "</li>";
    121                 } elseif (!is_writable(PJFAV_DIR)){
    122                     $dir_list.= "<li>".PJFAV_DIR . "</li>";
    123                 }
    124    
    125                 if (!is_dir($uploaddir)){
    126                     $dir_list2.= "<li>".$uploaddir . "</li>";
    127                 } elseif (!is_writable($uploaddir)){
    128                     $dir_list.= "<li>".$uploaddir . "</li>";
    129                 }
    130        
    131                 if ($dir_list2 != ""){
    132                     echo "<div id='pj-favicon-install-error-message' class='error'><p><strong>".__('Favicon Generator is not ready yet.', 'pj-favicon-generator')."</strong> ".__('must create the following folders (and must chmod 777):', 'pj-favicon-generator')."</p><ul>";
    133                     echo $dir_list2;
    134                     echo "</ul></div>";
    135                 }
    136                 if ($dir_list != ""){
    137                     echo "<div id='pj-favicon-install-error-message-2' class='error'><p><strong>".__('Favicon Generator is not ready yet.', 'pj-favicon-generator')."</strong> ".__('The following folders must be writable (usually chmod 777 is neccesary):', 'pj-favicon-generator')."</p><ul>";
    138                     echo $dir_list;
    139                     echo "</ul></div>";
    140                 }
    141             endif;
    142         }
    143        
    144         /**
    145         * Creates the admin page.
    146         */
    147         function add_admin_pages(){
    148             add_menu_page("Favicon Generator", "Favicon Generator", 10, "Favicon-Generator", array(&$this,"output_sub_admin_page_0"), PJFAV_URL.'/menu-icon.png');
    149         }
    150        
    151         /**
    152         * Outputs the HTML for the admin sub page.
    153         */
    154         function output_sub_admin_page_0 () {
    155 
    156             // PATHS
    157             $uploaddir = PJFAV_DIR.'uploads/';
    158             $uploadurl = PJFAV_URL.'uploads/';
    159             $submiturl = preg_replace('/&[du]=[a-z0-9.%()_-]*\.(jpg|jpeg|gif|png)/is', '', $_SERVER['REQUEST_URI']);
    160            
    161             $msg = "";
    162 
    163             // USER UPLOADED A NEW IMAGE
    164             if (!empty($_FILES)) {
    165                 $userfile = preg_replace('/\\\\\'/', '', $_FILES['favicon']['name']);
    166                 $file_size = $_FILES['favicon']['size'];
    167                 $file_temp = $_FILES['favicon']['tmp_name'];
    168                 $file_err = $_FILES['favicon']['error'];
    169                 $file_name = explode('.', $userfile);
    170                 $file_type = strtolower($file_name[count($file_name) - 1]);
    171                 $uploadedfile = $uploaddir.$userfile;
    172                
    173                 if(!empty($userfile)) {
    174                     $file_type = strtolower($file_type);
    175                     $files = array('jpeg', 'jpg', 'gif', 'png');
    176                     $key = array_search($file_type, $files);
    177                
    178                     if(!$key) {
    179                         $msg .= __("ILLEGAL FILE TYPE. Only JPEG, JPG, GIF or PNG files are allowed.", 'pj-favicon-generator')."<br />";
    180                     }
    181                
    182                     // ERROR CHECKING
    183                     $error_count = count($file_error);
    184                     if($error_count > 0) {
    185                         for($i = 0; $i <= $error_count; ++$i) {
    186                             $msg .= $_FILES['favicon']['error'][$i]."<br />";
    187                         }
    188                     } else {
    189                         if (is_file(PJFAV_DIR.'favicon.ico')) {
    190                             if (!unlink(PJFAV_DIR.'favicon.ico')) {
    191                                 $msg .= __("There was an error deleting the old favicon.", 'pj-favicon-generator')."<br />";
    192                             }
    193                         }
    194                    
    195                         if(!move_uploaded_file($file_temp, $uploadedfile)) {
    196                             $msg .= __("There was an error when uploading your file.", 'pj-favicon-generator')."<br />";
    197                         }
    198                         if (!chmod($uploadedfile, 0777)) {
    199                             $msg .= __("There was an error when changing your favicon's permissions.", 'pj-favicon-generator')."<br />";
    200                         }
    201                    
    202                         $img =new Image($uploadedfile);
    203                         $img->resizeImage(16,16);
    204                         $img->saveImage($uploadedfile);
    205                    
    206                         switch ($file_type) {
    207                             case "jpeg":
    208                             case "jpg":
    209                                 $im = imagecreatefromjpeg($uploadedfile);
    210                                 break;
    211                             case "gif":
    212                                 $im = imagecreatefromgif($uploadedfile);
    213                                 break;
    214                             case "png":
    215                                 $im = imagecreatefrompng($uploadedfile);
    216                                 imagealphablending($im, true); // setting alpha blending on
    217                                 imagesavealpha($im, true); // save alphablending setting (important)
    218                                 break;
    219                         }
    220                         // ImageICO function provided by JPEXS.com <http://www.jpexs.com/php.html>
    221                         ImageIco($im, PJFAV_DIR.'favicon.ico');
    222                         $this->adminOptions['favicon'] = $userfile;
    223                         $this->saveAdminOptions();
    224                         $msg .= __("Your favicon has been updated.", 'pj-favicon-generator');
    225                     }
    226 
    227                 }
    228             }
    229            
    230             if (!empty($_POST['donated'])) :
    231            
    232                 $this->adminOptions['donated'] = $_POST['donated'];
    233                 $this->saveAdminOptions();
    234            
    235             endif;
    236 
    237             // USER HAS CHOSEN TO DELETE AN UPLOADED IMAGE
    238             if (!empty($_GET['d']) && is_file($uploaddir.$_GET['d'])) {
    239                 if (!unlink ($uploaddir.$_GET['d'])) {
    240                     $msg .= __("There was a problem deleting the selected image.", 'pj-favicon-generator');
    241                 } else {
    242                     $msg .= __("The selected image has been deleted.", 'pj-favicon-generator');
    243                 }
    244             }
    245            
    246             // USER HAS CHOSEN TO CHANGE HIS FAVICON TO A PREVIOUSLY UPLOADED IMAGE
    247             if (!empty($_GET['u'])) {
    248                 $file_name = explode('.', $_GET['u']);
    249                 $file_type = $file_name[count($file_name) - 1];
    250                 switch ($file_type) {
    251                     case "jpeg":
    252                     case "jpg":
    253                         $im = imagecreatefromjpeg($uploaddir.$_GET['u']);
    254                         break;
    255                     case "gif":
    256                         $im = imagecreatefromgif($uploaddir.$_GET['u']);
    257                         break;
    258                     case "png":
    259                         $im = imagecreatefrompng($uploaddir.$_GET['u']);
    260                         imagealphablending($im, true); // setting alpha blending on
    261                         imagesavealpha($im, true); // save alphablending setting (important)
    262                         break;
    263                 }
    264                
    265                 // ImageICO function provided by JPEXS.com <http://www.jpexs.com/php.html>
    266                 ImageIco($im, PJFAV_DIR.'favicon.ico');
    267                 $this->adminOptions['favicon'] = $_GET['u'];
    268                 $this->saveAdminOptions();
    269                 $msg .= __("Your favicon has been updated.", 'pj-favicon-generator');
    270             }
    271             ?>
    272 <div class="wrap favicon-generator">
    273     <div id="favicon-options" class="icon32" style="background: transparent url('<?php echo PJFAV_URL; ?>large-menu-icon.png') no-repeat;"><br /></div>
    274     <h2>Favicon Generator</h2>
    275    
    276     <?php
    277         $ads = '<script type="text/javascript">';
    278         $ads.= 'var psHost = (("https:" == document.location.protocol) ? "https://" : "http://");';
    279         $ads.= 'document.write(unescape("%3Cscript src=\'" + psHost + "pluginsponsors.com/direct/spsn/display.php?client=pj-favicon-generator&spot=\' type=\'text/javascript\'%3E%3C/script%3E"));';
    280         $ads.= '</script>';
    281         if ($this->adminOptions['donated'] == 'no')
    282             echo $ads;
    283     ?>
    284    
    285     <form method="post" action="<?php echo $submiturl; ?>" enctype="multipart/form-data">
    286         <?php wp_nonce_field('update-options'); ?>
    287        
    288        
    289         <h3><?php _e('Upload a New Image', 'pj-favicon-generator'); ?></h3>
    290         <p><?php _e('Acceptable file types are JPG, JPEG, GIF and PNG. Note that for this to work, you\'re going to need to have PHP configured with the GD2 library.', 'pj-favicon-generator'); ?></p>
    291            
    292         <table class="form-table">
    293         <?php if ($this->adminOptions['donated'] == 'no') : ?>
    294         <tr valign="top">
    295             <th scope="row"><?php _e('Donations', 'pj-favicon-generator'); ?></th>
    296             <td>
    297                 <input type="radio" name="donated" value="no"<?php echo ($this->adminOptions['donated'] == 'no') ? ' checked="checked"' : '' ?> />  <?php _e('I haven\'t donated to this plugin yet. <small>(<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3441397" target="_blank">What are you waiting for?</a>)</small>', 'pj-favicon-generator'); ?><br />
    298                 <input type="radio" name="donated" value="yes" /> <?php _e('I\'ve donated to this plugin because I love it. Turn off the ads.', 'pj-favicon-generator'); ?><br />
    299                 <input type="submit" class="button-primary" name="save-donations" value="Save Changes" />
    300             </td>
    301         </tr>
    302         <?php endif; ?>
    303         <tr valign="top">
    304             <th scope="row"><?php _e('Favicon Source', 'pj-favicon-generator'); ?></th>
    305             <td>
    306                 <input type="file" name="favicon" id="favicon" />
    307                 <input type="submit" class="button" name="html-upload" value="Upload" />
    308             </td>
    309         </tr>
    310         </table>
    311        
    312         <h3><?php _e('Select a Previously Uploaded File', 'pj-favicon-generator'); ?></h3>
    313         <p><?php _e('Since this plugin stores every image you upload, you can upload as many images as you like. You can then come back from time to time and change your favicon. Select from the choices below.', 'pj-favicon-generator'); ?></p>
    314         <p><em><strong><?php _e('Note:', 'pj-favicon-generator') ?></strong> <?php _e('Some browsers hang on to old favicon images in their cache. This is an unfortunate side effect of caching. If you make a change to your favicon and don\'t immediately see the change, don\'t start banging your head against the wall. This is not an indication that this plugin is not working. Try <a href="http://en.wikipedia.org/wiki/Bypass_your_cache" target="_blank">emptying your cache</a> and quitting the browser.', 'pj-favicon-generator'); ?></em></p>
    315         <?php
    316             $files = dirList($uploaddir);
    317             for ($i = 0; $i < count($files); $i++) :
    318                 $active = ($files[$i] == $this->adminOptions['favicon']) ? true : false;
    319                 echo '<div style="float: left; margin-top: 20px; padding: 10px; text-align: center;'.(($active) ? ' background-color: #dddddd' : '').'">';
    320                 echo '  <div class="choice-block" style="position: relative; width: 36px; height: 36px; border: 1px solid '.(($active) ? '#ff6666' : '#cccccc').';">';
    321                 echo '      <img src="'.$uploadurl.$files[$i].'" title="'.$files[$i].'" alt="'.$files[$i].'" class="favicon-choices" style="position: absolute; top: 10px; left: 10px; width: 16px; height: 16px;" />';
    322                 echo '  </div>';
    323                 echo '  <div>';
    324                 echo ($active) ? __('Active', 'pj-favicon-generator').'<br />' : '      <a href="'.$submiturl.'&d='.$files[$i].'">'.__('Delete', 'pj-favicon-generator').'</a><br />';
    325                 echo ($active) ? __('Icon', 'pj-favicon-generator') : '     <a href="'.$submiturl.'&u='.$files[$i].'">'.__('Use', 'pj-favicon-generator').'</a>';
    326                 echo '  </div>';
    327                 echo '</div>';
    328                
    329             endfor;
    330             echo '<div class="clear"></div>'
    331         ?>
    332     </form>
    333 </div>
    334             <?php
    335         }
    336        
    337        
    338         /**
    339         * Called by the action wp_head
    340         */
    341         function wp_head_intercept() {
    342             //this is a sample function that includes additional styles within the head of your template.
    343             echo '<link rel="shortcut icon" href="'.PJFAV_URL.'favicon.ico" />';
    344             // echo '<link rel="apple-touch-icon" href="'.PJFAV_URL.'touchicon.png" />'; // coming soon!
    345             echo '<meta name="generator" content="Think-Press Favicon Generator v1.5" />';
    346         }
    347        
    348     }
    349 }
    350 
    351 //instantiate the class
    352 if (class_exists('pj_favicon_generator')) {
    353     $pj_favicon_generator = new pj_favicon_generator();
    354 }
     51add_action( 'admin_init', 'pj_favicon_generator_deactivate' );
  • favicon-generator/tags/2.1/readme.txt

    r588060 r3139340  
    11=== Plugin Name ===
    2 Contributors: brandondove, jeffreyzinn
     2Contributors: brandondove, lordleiter
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3441397
    44Tags: favicon
    5 Requires at least: 2.8
    6 Tested up to: 2.9.2
    7 Stable tag: 1.5
     5Requires at least: 4.0
     6Tested up to: 6.6.1
     7Stable tag: 2.1
    88
    99== Description ==
    1010
    11 This plugin will allow you to upload an image in the format of a jpeg, gif or png and will convert the image into a <a href="http://en.wikipedia.org/wiki/Favicon" target="_blank">favicon</a> formatted file. This file will be placed in your WordPress root directory and a link tag will then be added to your html output.
    12 
    13 == Installation ==
    14 
    15 1. Upload the `favicon-generator` folder to your `/wp-content/plugins/` directory.
    16 2. Make sure that the `favicon-generator` folder and the `favicon-generator/uploads` folder have their permissions set to 777.
    17 3. Activate the plugin through the 'Plugins' menu in WordPress.
    18 
    19 == Frequently Asked Questions ==
    20 
    21 = What file types do you support? =
    22 
    23 We support JPEG, GIF and PNG. Note: In order for this plugin to properly generate images, your server must have PHP configured with the GD2 library.
    24 
    25 = How do I make this work? =
    26 
    27 1. Find the Favicon Generator section in WordPress.
    28 2. Upload an image. Generally speaking this would be your logo or something of that nature.
    29 3. That's it! Your website now has an awesome favicon.
    30 
    31 = Why isn't my favicon showing up? =
    32 
    33 Some browsers hang on to old favicon images in their cache. This is an unfortunate side effect of caching. If you make a change to your favicon and don't immediately see the change, don't start banging your head against the wall. This is not an indication that this plugin is not working. Try <a href="http://en.wikipedia.org/wiki/Bypass_your_cache" target="_blank">emptying your cache</a> and quitting the browser.
    34 
    35 If that doesn't work, it could also be because your theme doesn't make use of WordPress' wp_head() function. If this is the case, sadly you'll have to edit your theme. This function is what allows us to automagically insert the favicon code. Most modern themes comply with this WordPress standard, so this really shouldn't be the problem unless you built your own custom theme or are using a really old theme.
    36 
    37 == Version History ==
    38 
    39 = Version 1.1 =
    40 
    41 1. Added PHP 4 Compatibility
    42 2. Updated the ImageIco library from <http://www.jpexs.com/php.html>
    43 3. Cannot delete active favicon
    44 4. Added highlight to active favicon
    45 
    46 = Version 1.2 =
    47 
    48 1. Forgot to add the new ImageIco library via SVN. This version has it. Sorry about the mixup.
    49 
    50 = Version 1.3 =
    51 
    52 1. AAAARGH! Include error was happening because I forgot about case sensitivity in Linux filesystems. Sorry, I'm on a mac.
    53 
    54 = Version 1.4 =
    55 
    56 1. Supressed errors that appeared if the upload directory wasn't created. Added in creation of the upload directory to the init routines.
    57 
    58 = Version 1.5 =
    59 
    60 1. Added support for ads from pluginsponsors.com to be placed on the admin page. A guy's gotta earn a living, right?
    61 2. Tested functionality against WordPress version 2.9.2
    62 3. Increased the minimum WordPress version to 2.8 because, come on...who's still running WordPress 2.1?
    63 4. Added checks to make sure certain necessary directories and permissions were set properly.
    64 5. Suppressed ugly warnings that were displayed when the upload directories weren't set properly.
    65 6. Added support for l10n.
    66 
    67 == Screenshots ==
    68 
    69 1. Favicon Generator configuration screen
    70 2. Shows the favicon in place
     11This plugin's functionality has been included in WordPress core for many years. It is no longer necessary to use this plugin. As such, this plugin can no longer be activated.
  • favicon-generator/trunk/pj-favicon-generator.php

    r588060 r3139340  
    11<?php
    2 /*
    3 Plugin Name: Favicon Generator
    4 Plugin URI: http://www.pixeljar.net/plugins/favicon-generator
    5 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3441397
    6 Description: This plugin will allow you to upload an image file of your choosing to be converted to a favicon for your WordPress site.
    7 Author: Brandon Dove, Jeffrey Zinn
    8 Version: 1.5
    9 Author URI: http://www.pixeljar.net
     2/**
     3 * Plugin Name: Favicon Generator (CLOSED)
     4 * Plugin URI: http://www.pixeljar.com
     5 * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3441397
     6 * Description: This plugin's functionality has been included in WordPress core for many years. It is no longer necessary to use this plugin. As such, this plugin can no longer be activated.
     7 * Author: Pixel Jar
     8 * Version: 2.1
     9 * Author URI: http://www.pixeljar.com
     10 * License: GPL2
     11 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
     12 * Text Domain: pjfavgen
     13 * Domain Path: /lang
     14 * Requires at least: 4.0
     15 * Tested up to: 6.6.1
     16 *
     17 * Copyright 2024  Pixel jar  (email : info@pixeljar.com)
     18 *
     19 * This program is free software; you can redistribute it and/or modify
     20 * it under the terms of the GNU General Public License as published by
     21 * the Free Software Foundation; either version 2 of the License, or
     22 * (at your option) any later version.
     23 *
     24 * This program is distributed in the hope that it will be useful,
     25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     27 * GNU General Public License for more details.
     28 *
     29 * You should have received a copy of the GNU General Public License
     30 * along with this program; if not, write to the Free Software
     31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     32 *
     33 * @package WordPress
     34 * @subpackage PJ_Favicon_Generator
     35 */
    1036
     37/**
     38 * Deactivate the plugin as the functionality is now in WordPress core.
     39 */
     40function pj_favicon_generator_deactivate() {
    1141
    12 Copyright 2009  Pixel jar  (email : info@pixeljar.net)
     42    $plugin = plugin_basename( __FILE__ );
     43    if ( is_plugin_active( $plugin ) ) {
    1344
    14 This program is free software; you can redistribute it and/or modify
    15 it under the terms of the GNU General Public License as published by
    16 the Free Software Foundation; either version 2 of the License, or
    17 (at your option) any later version.
     45        delete_option( 'pj_favicon_generator_options' );
     46        deactivate_plugins( $plugin, true );
    1847
    19 This program is distributed in the hope that it will be useful,
    20 but WITHOUT ANY WARRANTY; without even the implied warranty of
    21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    22 GNU General Public License for more details.
     48    }
    2349
    24 You should have received a copy of the GNU General Public License
    25 along with this program; if not, write to the Free Software
    26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    27 */
    28 
    29 if ( ! defined( 'PJFAV_URL' ) )
    30     define( 'PJFAV_URL', plugin_dir_url( __FILE__ ) );
    31 if ( ! defined( 'PJFAV_DIR' ) )
    32     define( 'PJFAV_DIR', plugin_dir_path( __FILE__ ) );
    33 
    34 load_plugin_textdomain( 'pj-favicon-generator', PJFAV_DIR );
    35 
    36 function pj_favicon_admin_scripts() {
    37     if ( isset($_GET['page']) && $_GET['page'] == "Favicon-Generator" )
    38         wp_enqueue_style( 'pjfav-admin-css', PJFAV_URL.'styles/styles.css' );
    3950}
    40 add_action( 'admin_init', 'pj_favicon_admin_scripts', 1 );
    41 register_activation_hook( __FILE__, array( &$pj_favicon_generator, 'activate' ) );
    42 add_action( 'admin_notices', array(&$pj_favicon_generator, 'check_installation') );
    43 
    44 
    45 if (!class_exists('pj_favicon_generator')) {
    46    
    47     include ('php/Directory.php');
    48     include ('php/Ico2_1.php');
    49     include ('php/Image.php');
    50    
    51     class pj_favicon_generator  {
    52        
    53         /**
    54         * @var string   The name the options are saved under in the database.
    55         */
    56         var $adminOptionsName = "pj_favicon_generator_options";
    57        
    58         /**
    59         * @var array   The options that are saved in the database.
    60         */
    61         var $adminOptions = array();
    62        
    63         /**
    64         * PHP 4 Compatible Constructor
    65         */
    66         function pj_favicon_generator(){$this->__construct();}
    67        
    68         /**
    69         * PHP 5 Constructor
    70         */     
    71         function __construct(){
    72             $this->adminOptions = $this->getAdminOptions();
    73             add_action("admin_menu", array(&$this,"add_admin_pages"));
    74             add_action('wp_head', array(&$this,'wp_head_intercept'));
    75         }
    76        
    77         /**
    78         * Retrieves the options from the database.
    79         * @return array
    80         */
    81         function getAdminOptions() {
    82             $adminOptions = array(
    83                 "favicon" => "<empty>",
    84                 "donated" => "no"
    85             );
    86             $savedOptions = get_option($this->adminOptionsName);
    87             if (!empty($savedOptions)) {
    88                 foreach ($savedOptions as $key => $option) {
    89                     $adminOptions[$key] = $option;
    90                 }
    91             }
    92             update_option($this->adminOptionsName, $adminOptions);
    93             return $adminOptions;
    94         }
    95        
    96         function saveAdminOptions(){
    97             update_option($this->adminOptionsName, $this->adminOptions);
    98         }
    99        
    100         /**
    101         * Runs on plugin activation
    102         */
    103         function activate () {
    104             $uploaddir = PJFAV_DIR.'uploads/';
    105             wp_mkdir_p( $uploaddir );
    106         }
    107         /**
    108         * Checks to make sure that all
    109         * required directories are set up properly
    110         */
    111         function check_installation() {
    112             if ( (stripos($_SERVER['REQUEST_URI'],'plugins.php') !== false) || (!empty($_GET['page']) && $_GET['page'] == "Favicon-Generator" ) ) :
    113                 $dir_list = "";
    114                 $dir_list2 = "";
    115    
    116                 $uploaddir = PJFAV_DIR.'uploads/';
    117                 wp_mkdir_p( $uploaddir );
    118    
    119                 if (!is_dir(PJFAV_DIR)){
    120                     $dir_list2.= "<li>".PJFAV_DIR . "</li>";
    121                 } elseif (!is_writable(PJFAV_DIR)){
    122                     $dir_list.= "<li>".PJFAV_DIR . "</li>";
    123                 }
    124    
    125                 if (!is_dir($uploaddir)){
    126                     $dir_list2.= "<li>".$uploaddir . "</li>";
    127                 } elseif (!is_writable($uploaddir)){
    128                     $dir_list.= "<li>".$uploaddir . "</li>";
    129                 }
    130        
    131                 if ($dir_list2 != ""){
    132                     echo "<div id='pj-favicon-install-error-message' class='error'><p><strong>".__('Favicon Generator is not ready yet.', 'pj-favicon-generator')."</strong> ".__('must create the following folders (and must chmod 777):', 'pj-favicon-generator')."</p><ul>";
    133                     echo $dir_list2;
    134                     echo "</ul></div>";
    135                 }
    136                 if ($dir_list != ""){
    137                     echo "<div id='pj-favicon-install-error-message-2' class='error'><p><strong>".__('Favicon Generator is not ready yet.', 'pj-favicon-generator')."</strong> ".__('The following folders must be writable (usually chmod 777 is neccesary):', 'pj-favicon-generator')."</p><ul>";
    138                     echo $dir_list;
    139                     echo "</ul></div>";
    140                 }
    141             endif;
    142         }
    143        
    144         /**
    145         * Creates the admin page.
    146         */
    147         function add_admin_pages(){
    148             add_menu_page("Favicon Generator", "Favicon Generator", 10, "Favicon-Generator", array(&$this,"output_sub_admin_page_0"), PJFAV_URL.'/menu-icon.png');
    149         }
    150        
    151         /**
    152         * Outputs the HTML for the admin sub page.
    153         */
    154         function output_sub_admin_page_0 () {
    155 
    156             // PATHS
    157             $uploaddir = PJFAV_DIR.'uploads/';
    158             $uploadurl = PJFAV_URL.'uploads/';
    159             $submiturl = preg_replace('/&[du]=[a-z0-9.%()_-]*\.(jpg|jpeg|gif|png)/is', '', $_SERVER['REQUEST_URI']);
    160            
    161             $msg = "";
    162 
    163             // USER UPLOADED A NEW IMAGE
    164             if (!empty($_FILES)) {
    165                 $userfile = preg_replace('/\\\\\'/', '', $_FILES['favicon']['name']);
    166                 $file_size = $_FILES['favicon']['size'];
    167                 $file_temp = $_FILES['favicon']['tmp_name'];
    168                 $file_err = $_FILES['favicon']['error'];
    169                 $file_name = explode('.', $userfile);
    170                 $file_type = strtolower($file_name[count($file_name) - 1]);
    171                 $uploadedfile = $uploaddir.$userfile;
    172                
    173                 if(!empty($userfile)) {
    174                     $file_type = strtolower($file_type);
    175                     $files = array('jpeg', 'jpg', 'gif', 'png');
    176                     $key = array_search($file_type, $files);
    177                
    178                     if(!$key) {
    179                         $msg .= __("ILLEGAL FILE TYPE. Only JPEG, JPG, GIF or PNG files are allowed.", 'pj-favicon-generator')."<br />";
    180                     }
    181                
    182                     // ERROR CHECKING
    183                     $error_count = count($file_error);
    184                     if($error_count > 0) {
    185                         for($i = 0; $i <= $error_count; ++$i) {
    186                             $msg .= $_FILES['favicon']['error'][$i]."<br />";
    187                         }
    188                     } else {
    189                         if (is_file(PJFAV_DIR.'favicon.ico')) {
    190                             if (!unlink(PJFAV_DIR.'favicon.ico')) {
    191                                 $msg .= __("There was an error deleting the old favicon.", 'pj-favicon-generator')."<br />";
    192                             }
    193                         }
    194                    
    195                         if(!move_uploaded_file($file_temp, $uploadedfile)) {
    196                             $msg .= __("There was an error when uploading your file.", 'pj-favicon-generator')."<br />";
    197                         }
    198                         if (!chmod($uploadedfile, 0777)) {
    199                             $msg .= __("There was an error when changing your favicon's permissions.", 'pj-favicon-generator')."<br />";
    200                         }
    201                    
    202                         $img =new Image($uploadedfile);
    203                         $img->resizeImage(16,16);
    204                         $img->saveImage($uploadedfile);
    205                    
    206                         switch ($file_type) {
    207                             case "jpeg":
    208                             case "jpg":
    209                                 $im = imagecreatefromjpeg($uploadedfile);
    210                                 break;
    211                             case "gif":
    212                                 $im = imagecreatefromgif($uploadedfile);
    213                                 break;
    214                             case "png":
    215                                 $im = imagecreatefrompng($uploadedfile);
    216                                 imagealphablending($im, true); // setting alpha blending on
    217                                 imagesavealpha($im, true); // save alphablending setting (important)
    218                                 break;
    219                         }
    220                         // ImageICO function provided by JPEXS.com <http://www.jpexs.com/php.html>
    221                         ImageIco($im, PJFAV_DIR.'favicon.ico');
    222                         $this->adminOptions['favicon'] = $userfile;
    223                         $this->saveAdminOptions();
    224                         $msg .= __("Your favicon has been updated.", 'pj-favicon-generator');
    225                     }
    226 
    227                 }
    228             }
    229            
    230             if (!empty($_POST['donated'])) :
    231            
    232                 $this->adminOptions['donated'] = $_POST['donated'];
    233                 $this->saveAdminOptions();
    234            
    235             endif;
    236 
    237             // USER HAS CHOSEN TO DELETE AN UPLOADED IMAGE
    238             if (!empty($_GET['d']) && is_file($uploaddir.$_GET['d'])) {
    239                 if (!unlink ($uploaddir.$_GET['d'])) {
    240                     $msg .= __("There was a problem deleting the selected image.", 'pj-favicon-generator');
    241                 } else {
    242                     $msg .= __("The selected image has been deleted.", 'pj-favicon-generator');
    243                 }
    244             }
    245            
    246             // USER HAS CHOSEN TO CHANGE HIS FAVICON TO A PREVIOUSLY UPLOADED IMAGE
    247             if (!empty($_GET['u'])) {
    248                 $file_name = explode('.', $_GET['u']);
    249                 $file_type = $file_name[count($file_name) - 1];
    250                 switch ($file_type) {
    251                     case "jpeg":
    252                     case "jpg":
    253                         $im = imagecreatefromjpeg($uploaddir.$_GET['u']);
    254                         break;
    255                     case "gif":
    256                         $im = imagecreatefromgif($uploaddir.$_GET['u']);
    257                         break;
    258                     case "png":
    259                         $im = imagecreatefrompng($uploaddir.$_GET['u']);
    260                         imagealphablending($im, true); // setting alpha blending on
    261                         imagesavealpha($im, true); // save alphablending setting (important)
    262                         break;
    263                 }
    264                
    265                 // ImageICO function provided by JPEXS.com <http://www.jpexs.com/php.html>
    266                 ImageIco($im, PJFAV_DIR.'favicon.ico');
    267                 $this->adminOptions['favicon'] = $_GET['u'];
    268                 $this->saveAdminOptions();
    269                 $msg .= __("Your favicon has been updated.", 'pj-favicon-generator');
    270             }
    271             ?>
    272 <div class="wrap favicon-generator">
    273     <div id="favicon-options" class="icon32" style="background: transparent url('<?php echo PJFAV_URL; ?>large-menu-icon.png') no-repeat;"><br /></div>
    274     <h2>Favicon Generator</h2>
    275    
    276     <?php
    277         $ads = '<script type="text/javascript">';
    278         $ads.= 'var psHost = (("https:" == document.location.protocol) ? "https://" : "http://");';
    279         $ads.= 'document.write(unescape("%3Cscript src=\'" + psHost + "pluginsponsors.com/direct/spsn/display.php?client=pj-favicon-generator&spot=\' type=\'text/javascript\'%3E%3C/script%3E"));';
    280         $ads.= '</script>';
    281         if ($this->adminOptions['donated'] == 'no')
    282             echo $ads;
    283     ?>
    284    
    285     <form method="post" action="<?php echo $submiturl; ?>" enctype="multipart/form-data">
    286         <?php wp_nonce_field('update-options'); ?>
    287        
    288        
    289         <h3><?php _e('Upload a New Image', 'pj-favicon-generator'); ?></h3>
    290         <p><?php _e('Acceptable file types are JPG, JPEG, GIF and PNG. Note that for this to work, you\'re going to need to have PHP configured with the GD2 library.', 'pj-favicon-generator'); ?></p>
    291            
    292         <table class="form-table">
    293         <?php if ($this->adminOptions['donated'] == 'no') : ?>
    294         <tr valign="top">
    295             <th scope="row"><?php _e('Donations', 'pj-favicon-generator'); ?></th>
    296             <td>
    297                 <input type="radio" name="donated" value="no"<?php echo ($this->adminOptions['donated'] == 'no') ? ' checked="checked"' : '' ?> />  <?php _e('I haven\'t donated to this plugin yet. <small>(<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3441397" target="_blank">What are you waiting for?</a>)</small>', 'pj-favicon-generator'); ?><br />
    298                 <input type="radio" name="donated" value="yes" /> <?php _e('I\'ve donated to this plugin because I love it. Turn off the ads.', 'pj-favicon-generator'); ?><br />
    299                 <input type="submit" class="button-primary" name="save-donations" value="Save Changes" />
    300             </td>
    301         </tr>
    302         <?php endif; ?>
    303         <tr valign="top">
    304             <th scope="row"><?php _e('Favicon Source', 'pj-favicon-generator'); ?></th>
    305             <td>
    306                 <input type="file" name="favicon" id="favicon" />
    307                 <input type="submit" class="button" name="html-upload" value="Upload" />
    308             </td>
    309         </tr>
    310         </table>
    311        
    312         <h3><?php _e('Select a Previously Uploaded File', 'pj-favicon-generator'); ?></h3>
    313         <p><?php _e('Since this plugin stores every image you upload, you can upload as many images as you like. You can then come back from time to time and change your favicon. Select from the choices below.', 'pj-favicon-generator'); ?></p>
    314         <p><em><strong><?php _e('Note:', 'pj-favicon-generator') ?></strong> <?php _e('Some browsers hang on to old favicon images in their cache. This is an unfortunate side effect of caching. If you make a change to your favicon and don\'t immediately see the change, don\'t start banging your head against the wall. This is not an indication that this plugin is not working. Try <a href="http://en.wikipedia.org/wiki/Bypass_your_cache" target="_blank">emptying your cache</a> and quitting the browser.', 'pj-favicon-generator'); ?></em></p>
    315         <?php
    316             $files = dirList($uploaddir);
    317             for ($i = 0; $i < count($files); $i++) :
    318                 $active = ($files[$i] == $this->adminOptions['favicon']) ? true : false;
    319                 echo '<div style="float: left; margin-top: 20px; padding: 10px; text-align: center;'.(($active) ? ' background-color: #dddddd' : '').'">';
    320                 echo '  <div class="choice-block" style="position: relative; width: 36px; height: 36px; border: 1px solid '.(($active) ? '#ff6666' : '#cccccc').';">';
    321                 echo '      <img src="'.$uploadurl.$files[$i].'" title="'.$files[$i].'" alt="'.$files[$i].'" class="favicon-choices" style="position: absolute; top: 10px; left: 10px; width: 16px; height: 16px;" />';
    322                 echo '  </div>';
    323                 echo '  <div>';
    324                 echo ($active) ? __('Active', 'pj-favicon-generator').'<br />' : '      <a href="'.$submiturl.'&d='.$files[$i].'">'.__('Delete', 'pj-favicon-generator').'</a><br />';
    325                 echo ($active) ? __('Icon', 'pj-favicon-generator') : '     <a href="'.$submiturl.'&u='.$files[$i].'">'.__('Use', 'pj-favicon-generator').'</a>';
    326                 echo '  </div>';
    327                 echo '</div>';
    328                
    329             endfor;
    330             echo '<div class="clear"></div>'
    331         ?>
    332     </form>
    333 </div>
    334             <?php
    335         }
    336        
    337        
    338         /**
    339         * Called by the action wp_head
    340         */
    341         function wp_head_intercept() {
    342             //this is a sample function that includes additional styles within the head of your template.
    343             echo '<link rel="shortcut icon" href="'.PJFAV_URL.'favicon.ico" />';
    344             // echo '<link rel="apple-touch-icon" href="'.PJFAV_URL.'touchicon.png" />'; // coming soon!
    345             echo '<meta name="generator" content="Think-Press Favicon Generator v1.5" />';
    346         }
    347        
    348     }
    349 }
    350 
    351 //instantiate the class
    352 if (class_exists('pj_favicon_generator')) {
    353     $pj_favicon_generator = new pj_favicon_generator();
    354 }
     51add_action( 'admin_init', 'pj_favicon_generator_deactivate' );
  • favicon-generator/trunk/readme.txt

    r588060 r3139340  
    11=== Plugin Name ===
    2 Contributors: brandondove, jeffreyzinn
     2Contributors: brandondove, lordleiter
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3441397
    44Tags: favicon
    5 Requires at least: 2.8
    6 Tested up to: 2.9.2
    7 Stable tag: 1.5
     5Requires at least: 4.0
     6Tested up to: 6.6.1
     7Stable tag: 2.1
    88
    99== Description ==
    1010
    11 This plugin will allow you to upload an image in the format of a jpeg, gif or png and will convert the image into a <a href="http://en.wikipedia.org/wiki/Favicon" target="_blank">favicon</a> formatted file. This file will be placed in your WordPress root directory and a link tag will then be added to your html output.
    12 
    13 == Installation ==
    14 
    15 1. Upload the `favicon-generator` folder to your `/wp-content/plugins/` directory.
    16 2. Make sure that the `favicon-generator` folder and the `favicon-generator/uploads` folder have their permissions set to 777.
    17 3. Activate the plugin through the 'Plugins' menu in WordPress.
    18 
    19 == Frequently Asked Questions ==
    20 
    21 = What file types do you support? =
    22 
    23 We support JPEG, GIF and PNG. Note: In order for this plugin to properly generate images, your server must have PHP configured with the GD2 library.
    24 
    25 = How do I make this work? =
    26 
    27 1. Find the Favicon Generator section in WordPress.
    28 2. Upload an image. Generally speaking this would be your logo or something of that nature.
    29 3. That's it! Your website now has an awesome favicon.
    30 
    31 = Why isn't my favicon showing up? =
    32 
    33 Some browsers hang on to old favicon images in their cache. This is an unfortunate side effect of caching. If you make a change to your favicon and don't immediately see the change, don't start banging your head against the wall. This is not an indication that this plugin is not working. Try <a href="http://en.wikipedia.org/wiki/Bypass_your_cache" target="_blank">emptying your cache</a> and quitting the browser.
    34 
    35 If that doesn't work, it could also be because your theme doesn't make use of WordPress' wp_head() function. If this is the case, sadly you'll have to edit your theme. This function is what allows us to automagically insert the favicon code. Most modern themes comply with this WordPress standard, so this really shouldn't be the problem unless you built your own custom theme or are using a really old theme.
    36 
    37 == Version History ==
    38 
    39 = Version 1.1 =
    40 
    41 1. Added PHP 4 Compatibility
    42 2. Updated the ImageIco library from <http://www.jpexs.com/php.html>
    43 3. Cannot delete active favicon
    44 4. Added highlight to active favicon
    45 
    46 = Version 1.2 =
    47 
    48 1. Forgot to add the new ImageIco library via SVN. This version has it. Sorry about the mixup.
    49 
    50 = Version 1.3 =
    51 
    52 1. AAAARGH! Include error was happening because I forgot about case sensitivity in Linux filesystems. Sorry, I'm on a mac.
    53 
    54 = Version 1.4 =
    55 
    56 1. Supressed errors that appeared if the upload directory wasn't created. Added in creation of the upload directory to the init routines.
    57 
    58 = Version 1.5 =
    59 
    60 1. Added support for ads from pluginsponsors.com to be placed on the admin page. A guy's gotta earn a living, right?
    61 2. Tested functionality against WordPress version 2.9.2
    62 3. Increased the minimum WordPress version to 2.8 because, come on...who's still running WordPress 2.1?
    63 4. Added checks to make sure certain necessary directories and permissions were set properly.
    64 5. Suppressed ugly warnings that were displayed when the upload directories weren't set properly.
    65 6. Added support for l10n.
    66 
    67 == Screenshots ==
    68 
    69 1. Favicon Generator configuration screen
    70 2. Shows the favicon in place
     11This plugin's functionality has been included in WordPress core for many years. It is no longer necessary to use this plugin. As such, this plugin can no longer be activated.
Note: See TracChangeset for help on using the changeset viewer.