Plugin Directory

Changeset 197768


Ignore:
Timestamp:
01/25/2010 03:46:55 AM (16 years ago)
Author:
aradke
Message:

Improved handling and checking of units on options page; Changed submit behaviour to be compatible with WPMU.

Location:
shadows/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • shadows/trunk/options.php

    r132095 r197768  
    22
    33function shadows_plugin_options() {
     4
     5    if( $_POST['action'] == 'update' ) {
     6        $curl_shadow_height = preg_replace ('/[^0-9]*/', '', $_POST['curl_shadow_height'] );        # strip any non digits
     7        $curl_shadow_height = $curl_shadow_height ? $curl_shadow_height : '10';             # default to 10 if empty
     8        $curl_shadow_opacity = preg_replace ('/[^0-9]*/', '', $_POST['curl_shadow_opacity'] );      # strip any non digits
     9        $curl_shadow_opacity = $curl_shadow_opacity ? $curl_shadow_opacity : '100';         # default to 100 if empty
     10        $curl_shadow_height_unit = preg_replace ('/.*(px|em)$/i', '\\1', $_POST['curl_shadow_height'] );    # grab either px or em
     11        $curl_shadow_height_unit = strtolower($curl_shadow_height_unit);
     12        if (! ($curl_shadow_height_unit == 'px' || $curl_shadow_height_unit == 'em')) {
     13            $curl_shadow_height_unit = 'px';
     14        }
     15
     16        update_option( 'curl_shadow_height', $curl_shadow_height . $curl_shadow_height_unit );
     17        update_option( 'curl_shadow_opacity', $curl_shadow_opacity );
     18
     19        $flat_shadow_height = preg_replace ('/[^0-9]*/', '', $_POST['flat_shadow_height'] );        # strip any non digits
     20        $flat_shadow_height = $flat_shadow_height ? $flat_shadow_height : '10';             # default to 10 if empty
     21        $flat_shadow_opacity = preg_replace ('/[^0-9]*/', '', $_POST['flat_shadow_opacity'] );      # strip any non digits
     22        $flat_shadow_opacity = $flat_shadow_opacity ? $flat_shadow_opacity : '100';         # default to 100 if empty
     23        $flat_shadow_height_unit = preg_replace ('/.*(px|em)$/', '\\1', $_POST['flat_shadow_height'] ); # grab either px or em
     24        $flat_shadow_height_unit = strtolower($flat_shadow_height_unit);
     25        if (! ($flat_shadow_height_unit == 'px' || $flat_shadow_height_unit == 'em')) {
     26            $flat_shadow_height_unit = 'px';
     27        }
     28
     29        update_option( 'flat_shadow_height', $flat_shadow_height . $flat_shadow_height_unit );
     30        update_option( 'flat_shadow_opacity', $flat_shadow_opacity );
     31?>
     32<div class="updated"><p><strong><?php _e('Options saved.', 'mt_trans_domain' ); ?></strong></p></div>
     33<?php
     34    }
     35
    436    $curl_shadow_height = get_option('curl_shadow_height');
    537    $curl_shadow_height = $curl_shadow_height ? $curl_shadow_height : '10px';
     38    $curl_shadow_opacity = get_option('curl_shadow_opacity');
     39    $curl_shadow_opacity = $curl_shadow_opacity ? $curl_shadow_opacity : '100%';
    640
    741    $flat_shadow_height = get_option('flat_shadow_height');
    842    $flat_shadow_height = $flat_shadow_height ? $flat_shadow_height : '10px';
     43    $flat_shadow_opacity = get_option('flat_shadow_opacity');
     44    $flat_shadow_opacity = $flat_shadow_opacity ? $flat_shadow_opacity : '100%';
     45
     46    # opacities must be a number ONLY but are better displayed with a trailing %
     47    $curl_shadow_opacity = preg_replace ('/[^0-9]*/', '', $curl_shadow_opacity) . '%';
     48    $flat_shadow_opacity = preg_replace ('/[^0-9]*/', '', $flat_shadow_opacity) . '%';
     49
    950?>
    1051<div class="wrap">
    1152<h2>Shadows Options</h2>
    12 <form method="post" action="options.php">
     53<form method="post" action="">
    1354
    1455<?php wp_nonce_field('update-options'); ?>
     
    1657<p>It is recommended that you leave the height of the shadows at the default of 10px for best results.</p>
    1758
    18 <p>Heights must include units such as px or em.</p>
     59<p>Heights can be specified in px or em. They will default to px if the units are unspecified or invalid.</p>
    1960
    2061<table class="form-table">
    2162<tr valign="top">
    22 <th scope="row">Curl shadow height</th>
     63<th scope="row"><strong>Curl</strong> shadow height</th>
    2364<td><input type="text" name="curl_shadow_height" value="<?php echo $curl_shadow_height; ?>" /></td>
    2465</tr>
    2566<tr valign="top">
    26 <th scope="row">Curl shadow opacity<br/> (<strong>do not include %</strong>)</th>
    27 <td><input type="text" name="curl_shadow_opacity" value="<?php echo get_option('curl_shadow_opacity'); ?>" /></td>
     67<th scope="row"><strong>Curl</strong> shadow opacity</th>
     68<td><input type="text" name="curl_shadow_opacity" value="<?php echo $curl_shadow_opacity; ?>" /></td>
    2869</tr>
    2970<tr valign="top">
    30 <th scope="row">Flat shadow height</th>
     71<th scope="row"><strong>Flat</strong> shadow height</th>
    3172<td><input type="text" name="flat_shadow_height" value="<?php echo $flat_shadow_height; ?>" /></td>
    3273</tr>
    3374<tr valign="top">
    34 <th scope="row">Flat shadow opacity<br/> (<strong>do not include %</strong>)</th>
    35 <td><input type="text" name="flat_shadow_opacity" value="<?php echo get_option('flat_shadow_opacity'); ?>" /></td>
     75<th scope="row"><strong>Flat</strong> shadow opacity</th>
     76<td><input type="text" name="flat_shadow_opacity" value="<?php echo $flat_shadow_opacity; ?>" /></td>
    3677</tr>
    3778</table>
     
    4182
    4283<p class="submit">
    43 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
     84<input type="submit" class="button-primary" value="<?php _e('Save Changes', 'mt_trans_domain' ); ?>" />
    4485</p>
    4586</form>
  • shadows/trunk/readme.txt

    r197287 r197768  
    55Requires at least: 2.5
    66Tested up to: 2.9
    7 Stable Tag: 0.3.4
     7Stable Tag: 0.3.5
    88
    99This is a plugin to add a range of shadow types to a range of objects. Currently supported are images, divs and blockquotes.
     
    7979== Changelog ==
    8080
     81= 0.3.5 =
     82* Improved handling and checking of units on options page
     83* Changed submit behaviour to be compatible with WPMU
     84
    8185= 0.3.4 =
    8286* Added "overflow:hidden;" to avoid problems with other objects with clear's on them
  • shadows/trunk/shadows.php

    r197287 r197768  
    44Plugin URI: http://deepport.net/computing/wordpress-shadows-plugin/
    55Description: Adds a range of shadow types to images, divs and blockquotes
    6 Version: 0.3.4
     6Version: 0.3.5
    77Author: Andrew Radke
    88Author URI: http://deepport.net/
Note: See TracChangeset for help on using the changeset viewer.