WordPress.org

Plugin Directory

Changeset 207528


Ignore:
Timestamp:
02/18/10 10:15:08 (4 years ago)
Author:
brandondove
Message:

ps.com, 2.9.2, min-req, perm, err, l10n

Location:
favicon-generator/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • favicon-generator/trunk/php/Directory.php

    r96891 r207528  
    77 
    88        // create a handler for the directory 
    9         $handler = opendir($directory); 
     9        $handler = @opendir($directory); 
    1010 
    1111        // keep going until all files in directory have been read 
    12         while ($file = readdir($handler)) { 
     12        while ($file = @readdir($handler)) { 
    1313 
    1414            // if $file isn't this directory or its parent,  
    1515            // add it to the results array 
    16             if ($file != '.' && $file != '..' && $file != '.DS_Store') 
     16            if ($file != '.' && $file != '..' && $file != '.DS_Store' && $file != '.svn') 
    1717                $results[] = $file; 
    1818        } 
    1919 
    2020        // tidy up: close the handler 
    21         closedir($handler); 
     21        @closedir($handler); 
    2222 
    2323        // done! 
  • favicon-generator/trunk/pj-favicon-generator.php

    r127248 r207528  
    66Description: This plugin will allow you to upload an image file of your choosing to be converted to a favicon for your WordPress site. 
    77Author: Brandon Dove, Jeffrey Zinn 
    8 Version: 1.4 
     8Version: 1.5 
    99Author URI: http://www.think-press.com 
    1010 
     
    2727*/ 
    2828 
     29if ( ! defined( 'PJFAV_URL' ) ) 
     30    define( 'PJFAV_URL', plugin_dir_url( __FILE__ ) ); 
     31if ( ! defined( 'PJFAV_DIR' ) ) 
     32    define( 'PJFAV_DIR', plugin_dir_path( __FILE__ ) ); 
     33 
     34load_plugin_textdomain( 'pj-favicon-generator', PJFAV_DIR ); 
     35 
     36function 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' ); 
     39} 
     40add_action( 'admin_init', 'pj_favicon_admin_scripts', 1 ); 
     41register_activation_hook( __FILE__, array( &$pj_favicon_generator, 'activate' ) ); 
     42add_action( 'admin_notices', array(&$pj_favicon_generator, 'check_installation') ); 
     43 
     44 
    2945if (!class_exists('pj_favicon_generator')) { 
    3046     
     
    4157         
    4258        /** 
     59        * @var array   The options that are saved in the database. 
     60        */ 
     61        var $adminOptions = array(); 
     62         
     63        /** 
    4364        * PHP 4 Compatible Constructor 
    4465        */ 
     
    4970        */       
    5071        function __construct(){ 
     72            $this->adminOptions = $this->getAdminOptions(); 
    5173            add_action("admin_menu", array(&$this,"add_admin_pages")); 
    5274            add_action('wp_head', array(&$this,'wp_head_intercept')); 
    53             $this->adminOptions = $this->getAdminOptions(); 
    54             if ( ! defined( 'WP_CONTENT_URL' ) ) 
    55                   define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); 
    56             if ( ! defined( 'WP_CONTENT_DIR' ) ) 
    57                   define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); 
    58             if ( ! defined( 'WP_PLUGIN_URL' ) ) 
    59                   define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' ); 
    60             if ( ! defined( 'WP_PLUGIN_DIR' ) ) 
    61                   define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); 
    6275        } 
    6376         
     
    6881        function getAdminOptions() { 
    6982            $adminOptions = array( 
    70                 "favicon" => "<empty>" 
     83                "favicon" => "<empty>", 
     84                "donated" => "no" 
    7185            ); 
    7286            $savedOptions = get_option($this->adminOptionsName); 
     
    8599         
    86100        /** 
     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        /** 
    87145        * Creates the admin page. 
    88146        */ 
    89147        function add_admin_pages(){ 
    90             add_menu_page("Favicon Generator", "Favicon Generator", 10, "Favicon-Generator", array(&$this,"output_sub_admin_page_0"), WP_PLUGIN_URL.'/favicon-generator/menu-icon.png'); 
     148            add_menu_page("Favicon Generator", "Favicon Generator", 10, "Favicon-Generator", array(&$this,"output_sub_admin_page_0"), PJFAV_URL.'/menu-icon.png'); 
    91149        } 
    92150         
     
    97155 
    98156            // PATHS 
    99             $uploaddir = WP_PLUGIN_DIR.'/favicon-generator/uploads/'; 
    100             if (!is_dir($uploaddir)) { @mkdir($uploaddir, 0777); } 
    101             $uploadurl = WP_PLUGIN_URL.'/favicon-generator/uploads/'; 
    102             $favicondir = WP_PLUGIN_DIR.'/favicon-generator/'; 
    103             $faviconurl = WP_PLUGIN_URL.'/favicon-generator/'; 
     157            $uploaddir = PJFAV_DIR.'uploads/'; 
     158            $uploadurl = PJFAV_URL.'uploads/'; 
    104159            $submiturl = preg_replace('/&[du]=[a-z0-9.%()_-]*\.(jpg|jpeg|gif|png)/is', '', $_SERVER['REQUEST_URI']); 
    105160             
     
    122177                 
    123178                    if(!$key) { 
    124                         $msg .= "ILLEGAL FILE TYPE. Only JPEG, JPG, GIF or PNG files are allowed.<br />"; 
     179                        $msg .= __("ILLEGAL FILE TYPE. Only JPEG, JPG, GIF or PNG files are allowed.", 'pj-favicon-generator')."<br />"; 
    125180                    } 
    126181                 
     
    132187                        } 
    133188                    } else { 
    134                         if (is_file($favicondir.'/favicon.ico')) { 
    135                             if (!unlink($favicondir.'/favicon.ico')) { 
    136                                 $msg .= "There was an error deleting the old favicon.<br />"; 
     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 />"; 
    137192                            } 
    138193                        } 
    139194                     
    140195                        if(!move_uploaded_file($file_temp, $uploadedfile)) { 
    141                             $msg .= "There was an error when uploading your file.<br />"; 
     196                            $msg .= __("There was an error when uploading your file.", 'pj-favicon-generator')."<br />"; 
    142197                        } 
    143198                        if (!chmod($uploadedfile, 0777)) { 
    144                             $msg .= "There was an error when changing your favicon's permissions.<br />"; 
     199                            $msg .= __("There was an error when changing your favicon's permissions.", 'pj-favicon-generator')."<br />"; 
    145200                        } 
    146201                     
     
    164219                        } 
    165220                        // ImageICO function provided by JPEXS.com <http://www.jpexs.com/php.html> 
    166                         ImageIco($im, $favicondir.'/favicon.ico'); 
     221                        ImageIco($im, PJFAV_DIR.'favicon.ico'); 
    167222                        $this->adminOptions['favicon'] = $userfile; 
    168223                        $this->saveAdminOptions(); 
    169                         $msg .= "Your favicon has been updated."; 
     224                        $msg .= __("Your favicon has been updated.", 'pj-favicon-generator'); 
    170225                    } 
    171226 
    172227                } 
    173228            } 
     229             
     230            if (!empty($_POST['donated'])) : 
     231             
     232                $this->adminOptions['donated'] = $_POST['donated']; 
     233                $this->saveAdminOptions(); 
     234             
     235            endif; 
    174236 
    175237            // USER HAS CHOSEN TO DELETE AN UPLOADED IMAGE 
    176238            if (!empty($_GET['d']) && is_file($uploaddir.$_GET['d'])) { 
    177239                if (!unlink ($uploaddir.$_GET['d'])) { 
    178                     $msg .= "There was a problem deleting the selected image."; 
     240                    $msg .= __("There was a problem deleting the selected image.", 'pj-favicon-generator'); 
    179241                } else { 
    180                     $msg .= "The selected image has been deleted."; 
     242                    $msg .= __("The selected image has been deleted.", 'pj-favicon-generator'); 
    181243                } 
    182244            } 
     
    202264                 
    203265                // ImageICO function provided by JPEXS.com <http://www.jpexs.com/php.html> 
    204                 ImageIco($im, $favicondir.'/favicon.ico'); 
     266                ImageIco($im, PJFAV_DIR.'favicon.ico'); 
    205267                $this->adminOptions['favicon'] = $_GET['u']; 
    206268                $this->saveAdminOptions(); 
    207                 $msg .= "Your favicon has been updated."; 
     269                $msg .= __("Your favicon has been updated.", 'pj-favicon-generator'); 
    208270            } 
    209271            ?> 
    210 <div class="wrap"> 
    211     <div id="icon-options-general" class="icon32"><br /></div> 
     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> 
    212274    <h2>Favicon Generator</h2> 
    213  
     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     
    214285    <form method="post" action="<?php echo $submiturl; ?>" enctype="multipart/form-data"> 
    215286        <?php wp_nonce_field('update-options'); ?> 
    216287         
    217288         
    218         <h3>Upload a New Image</h3> 
    219         <p>Acceptable file types are JPG, JPEG, GIF and PNG. Note that for this to work, 
    220             you're going to need to have PHP configured with the GD2 library.</p> 
     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> 
    221291             
    222292        <table class="form-table"> 
     293        <?php if ($this->adminOptions['donated'] == 'no') : ?> 
    223294        <tr valign="top"> 
    224             <th scope="row">Favicon Source</th> 
     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> 
    225305            <td> 
    226306                <input type="file" name="favicon" id="favicon" /> 
     
    230310        </table> 
    231311         
    232         <h3>Select a Previously Uploaded File</h3> 
    233         <p>Since this plugin stores every image you upload, you can upload as many images as you like. 
    234             You can then come back from time to time and change your favicon. Select from the 
    235             choices below.</p> 
    236         <p><em><strong>Note:</strong> Some browsers hang on to old favicon images in their cache. This is 
    237             an unfortunate side effect of caching. If you make a change to your favicon and don't 
    238             immediately see the change, don't start banging your head against the wall. This is not an 
    239             indication that this plugin is not working. Try 
    240             <a href="http://en.wikipedia.org/wiki/Bypass_your_cache" target="_blank">emptying your cache</a> 
    241             and quitting the browser.</em></p> 
     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> 
    242315        <?php 
    243316            $files = dirList($uploaddir); 
     
    249322                echo '  </div>'; 
    250323                echo '  <div>'; 
    251                 echo ($active) ? 'Active<br />' : '     <a href="'.$submiturl.'&d='.$files[$i].'">Delete</a><br />'; 
    252                 echo ($active) ? 'Icon' : '     <a href="'.$submiturl.'&u='.$files[$i].'">Use</a>'; 
     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>'; 
    253326                echo '  </div>'; 
    254327                echo '</div>'; 
     
    268341        function wp_head_intercept() { 
    269342            //this is a sample function that includes additional styles within the head of your template. 
    270             echo '<link rel="shortcut icon" href="'.WP_PLUGIN_URL.'/favicon-generator/favicon.ico" />'; 
    271             echo '<meta name="generator" content="Think-Press Favicon Generator v1.4" />'; 
     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" />'; 
    272346        } 
    273347         
     
    279353    $pj_favicon_generator = new pj_favicon_generator(); 
    280354} 
    281 ?> 
  • favicon-generator/trunk/readme.txt

    r127244 r207528  
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3441397 
    44Tags: favicon 
    5 Requires at least: 2.1 
    6 Tested up to: 2.8 
    7 Stable tag: 1.4 
     5Requires at least: 2.8 
     6Tested up to: 2.9.2 
     7Stable tag: 1.5 
    88 
    99== Description == 
     
    56561. Supressed errors that appeared if the upload directory wasn't created. Added in creation of the upload directory to the init routines. 
    5757 
     58= Version 1.5 = 
     59 
     601. Added support for ads from pluginsponsors.com to be placed on the admin page. A guy's gotta earn a living, right? 
     612. Tested functionality against WordPress version 2.9.2 
     623. Increased the minimum WordPress version to 2.8 because, come on...who's still running WordPress 2.1? 
     634. Added checks to make sure certain necessary directories and permissions were set properly. 
     645. Suppressed ugly warnings that were displayed when the upload directories weren't set properly. 
     656. Added support for l10n. 
     66 
    5867== Screenshots == 
    5968 
Note: See TracChangeset for help on using the changeset viewer.