Plugin Directory

Changeset 212172


Ignore:
Timestamp:
03/02/2010 03:29:06 PM (16 years ago)
Author:
geraint
Message:
 
Location:
file-proxy/trunk/com/twothirdsdesign
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • file-proxy/trunk/com/twothirdsdesign/core/gcp_options.php

    r211980 r212172  
    44 *
    55 * @author      Geraint Palmer
    6  * @version     1.0.2     
     6 * @version     1.0.3     
    77 */
    88class GcpOptions
    99{
    10     const VERSION = '1.0.2';
     10    const VERSION = '1.0.3';
    1111    protected $options_key = 'ttd_plugin_options';
    1212    protected $_options = array(
     
    2727            // tries to create a cache from wordpress DB options table.// uses plugin preset options not in db
    2828            $this->_optioncache = unserialize( get_option( $this->options_key , false ));
    29             if (!$this->_optioncache) $this->_optioncache = $this->_options;
     29            if (!$this->_optioncache)
     30                $this->_optioncache = $this->_options;
    3031        }
    3132    }
    3233   
     34    /**
     35     * Clears the option cache
     36     */
     37    public function flush_options()
     38    {
     39        unset($this->_optioncache);
     40    }
    3341   
    3442    /**
  • file-proxy/trunk/com/twothirdsdesign/core/ttd_plugin_class.php

    r210557 r212172  
    44 *
    55 * @author      Geraint Palmer
    6  * @version     1.0.0     
     6 * @version     1.0.1     
    77 */
    88    class TtdPluginClass
    99    {
    10         const VERSION = '1.0.0';
     10        const VERSION = '1.0.1';
    1111        // variable
    1212        protected $options;
     
    9191       
    9292        /**
     93         * Clears the option cache
     94         */
     95        public function flush_options()
     96        {
     97            $this->options->flush_options();
     98        }
     99       
     100        /**
    93101         * Executes a MySQL query with exception handling.
    94102         */
  • file-proxy/trunk/com/twothirdsdesign/file-proxy/admin/admin.php

    r212141 r212172  
    162162            if( "Y" == esc_attr( $_POST['ttd_file_proxy_submit_hidden'] )){
    163163                    //echo "<pre>"; print_r( $_POST ); echo "</pre>";
    164                     $this->m->update_option( "permalinks", isset( $_POST[ 'permalinks' ] ) ? 'on' : 'off' );
    165                     $this->m->update_option( "cache", isset( $_POST[ 'cache' ] ) ? 'on' : 'off' );
     164                   
     165                    if( $this->m->get_option( "permalinks" != "disabled" ) )
     166                        $this->m->update_option( "permalinks", isset( $_POST[ 'permalinks' ] ) ? 'on' : 'off' );
     167   
     168                    if( $this->m->get_option( "cache" != "disabled" ) )
     169                        $this->m->update_option( "cache", isset( $_POST[ 'cache' ] ) ? 'on' : 'off' );
     170                   
    166171                    $this->m->update_option( "uninstall", isset( $_POST[ 'uninstall' ] ) ? true : false );
    167172                    $this->m->update_option( "url-key", esc_attr( $_POST['url-key']) );
     
    171176            else if( $_GET['opt'] == "reset" ){
    172177                delete_option( $this->m->get_options_key() );
     178                $this->m->flush_options();
     179                $this->m->update_option("version", TTDPF_VERSION);
    173180                wp_redirect( $this->get_settings_link() );
    174181            }
     
    237244            <tr>
    238245                <th><?php _e( 'Version:', $this->domain ); ?></th>
    239                 <td><?php echo TTDPF_VERSION; ?></td>
     246                <td><?php echo $this->m->get_option("version", 0 );?></td>
    240247            </tr>
    241248        </table><!-- .form-table --><?php
     
    259266
    260267    <table class="form-table">
    261 
     268        <?php if($this->m->get_option('permalinks') != "disabled"): ?>
    262269        <tr>
    263270            <th><label for="permalinks"><?php _e( 'Use Permalinks:', $this->domain ); ?></label></th>
     
    275282            </td>
    276283        </tr>
     284        <?php endif; ?>
    277285        <tr>
    278286            <th><label for="url-key"><?php _e( 'Url Key:', $this->domain ); ?></label></th>
     
    285293            </td>
    286294        </tr>
    287        
     295        <?php if($this->m->get_option('cache') != "disabled"): ?>
    288296        <tr>
    289297            <th><label for="cache"><?php _e( 'Caching:', $this->domain ); ?></label></th>
     
    299307            </td>
    300308        </tr>
     309        <?php endif; ?>
    301310        <tr>
    302311            <th><label for="uninstall"><?php _e( 'Uninstall:', $this->domain ); ?></label></th>
  • file-proxy/trunk/com/twothirdsdesign/file-proxy/ttd_file_proxy.php

    r212141 r212172  
    1919        'uninstall'     => true,
    2020        'url-key'       => 'file',
    21         'cache'         => 'off',
    22         'permalinks'    => 'off',
     21        'cache'         => 'disabled',
     22        'permalinks'    => 'disabled',
    2323    );
    2424   
     
    137137    {
    138138        $this->flush_rules();
    139        
    140         $this->update_option("version", TTDPF_VERSION );
    141        
     139        $this->install();       
     140    }
     141   
     142    public function install(){
     143        switch ( $this->get_option("version", "0") )
     144        {
     145            case '0.1':
     146            case '0.2':
     147            case '0.3':
     148            case '0.4':
     149                // Clears options for previous version
     150                delete_option( $this->options_key );
     151                break;
     152            default:
     153                break;
     154        }
     155        if( $this->get_option("cache") != "disabled" )
     156            $this->build_cache_dir();
     157           
     158        $this->update_option("version", TTDFP_VERSION );
     159    }
     160   
     161    public function build_cache_dir()
     162    {
    142163        if( defined('WP_CONTENT_DIR') ){
    143164            if(!is_dir( WP_CONTENT_DIR.DS.'cache' ) && is_writable( WP_CONTENT_DIR )){
Note: See TracChangeset for help on using the changeset viewer.