Plugin Directory

Changeset 811631


Ignore:
Timestamp:
11/27/2013 10:33:59 PM (12 years ago)
Author:
ajferg
Message:

2.7.4 Update.

  • New shortcode handler for [tabs] had an issue with iframes and other elements. Now corrected.
  • Change input type for date,time,datetime elements
  • Fix some code that was causing PHP warnings
  • Add some CSS for responsive map embed
  • Add some CSS for better ui-datepicker default apperance
  • Change dateformat from dd-mm-yy to dd/mm/yy (was a problem with validation format)
  • Allow a default of 0 on form inputs, and allow a supplied "0" value to pass server-side validation
Location:
tailored-tools
Files:
34 added
8 edited

Legend:

Unmodified
Added
Removed
  • tailored-tools/trunk/embed-js.php

    r752666 r811631  
    3030    function output_embed_code() {
    3131        global $post;
     32        if (!$post || !is_object($post))    return false;
    3233        $code = get_post_meta($post->ID, $this->meta_value_key, true);
    3334        if (empty($code))   return false;
     
    3839    function save_post( $post_id ) {
    3940        // Security check
     41        if (empty($_POST) || !isset($_POST['embed_javascript']))                        return;
    4042        if ($_POST['post_type'] == 'page' && !current_user_can('edit_page', $post_id))  return;
    4143        if ($_POST['post_type'] == 'post' && !current_user_can('edit_post', $post_id))  return;
  • tailored-tools/trunk/js/loader.js

    r802789 r811631  
    3636    if (!$().datepicker)                    return;
    3737    $('form input.datepicker, form p.datepicker input').datepicker({
    38         dateFormat:     'dd-mm-yy',
     38        dateFormat:     'dd/mm/yy',
    3939        changeMonth:    true,
    4040        changeYear:     true
     
    6565        changeMonth:    true,
    6666        changeYear:     true,
    67         dateFormat:     'dd-mm-yy',
     67        dateFormat:     'dd/mm/yy',
    6868        timeFormat:     'h:mm tt',
    6969        stepMinute:     15,
     
    143143        });
    144144        $(ul).prependTo( $(tabset) );
    145 //      alert( $(tabset).html() );
    146145        $(tabset).tabs();
    147        
    148146    });
    149 //  alert('done');
    150     $('.ui-tabs').tabs('load', 2);
    151147});
    152148
  • tailored-tools/trunk/lib/class.akismet.php

    r715824 r811631  
    1818    function __construct() {
    1919        global $wp_version;
    20         $this->user_agent = 'WordPress/'.$wp_version.' | Akismet/'.$this->class-version;
     20        $this->user_agent = 'WordPress/'.$wp_version.' | Akismet/'.$this->class_version;
    2121       
    2222        add_filter('ttools_map_akismet_fields', array(&$this,'map_form_fields'), 9, 2);
  • tailored-tools/trunk/lib/class.forms.php

    r802789 r811631  
    287287        if (!$q['required'])        return;
    288288        if ($q['type'] != 'file') {
    289             if (!isset($_POST[$key]) || empty($_POST[$key]))                                $this->error[] = $q['error'];
     289            if (!isset($_POST[$key]) || trim($_POST[$key])=='')                             $this->error[] = $q['error'];
    290290            if ($q['type'] == 'email' && !empty($_POST[$key]) && !is_email($_POST[$key]))   $this->error[] = '<em>'.$_POST[$key].'</em> does not look like an email address';
    291291        } else
     
    323323        // Add words to existing array
    324324        $badwords = array_merge($badwords, array(
    325             'ambien', 'cialis', 'buycialis', 'hydrocodone', 'viagraonline', 'cialisonline', 'phentermine', 'viagrabuy', 'percocet', 'tramadol',
    326             'propecia', 'xenical', 'meridia', 'levitra', 'vicodin', 'viagra', 'valium', 'porno', 'xanax', 'href=', // 'sex', 'soma'
     325            'buycialis', 'hydrocodone', 'viagraonline', 'cialisonline', 'phentermine', 'viagrabuy', 'percocet', 'tramadol', // 'ambien',
     326            'propecia', 'xenical', 'meridia', 'levitra', 'vicodin', 'viagra', 'valium', 'porno', 'xanax', 'href=', // 'sex', 'soma', 'cialis',
    327327        ));
    328328        $badwords = array_unique($badwords);
     
    398398   
    399399    function draw_element($key, $q) {
     400        if (!isset($_POST[$key]))       $_POST[$key] = '';
     401        if (!isset($q['required']))     $q['required'] = false;
     402        if (!isset($q['class']))        $q['class'] = false;
    400403        // Separator line?
    401404        if ($q['type'] == 'sep') { echo '<p class="sep">&nbsp;</p>'."\n"; return; }
     
    405408        if ($q['type'] == 'note') { echo '<p class="note '.$q['class'].'">'.nl2br($q['label']).'</p>'."\n"; return; }
    406409        // Prepare default value
    407         if (!isset($_POST[$key]) && !empty($q['default']))  $_POST[$key] = $q['default'];
     410        if (!isset($_POST[$key]) && isset($q['default']))   $_POST[$key] = $q['default'];
    408411        // Prepare element class
    409412        if (!is_array($q['class']))     $q['class'] = array($q['class']);
     
    432435     *  Form Element Helpers
    433436     */
    434     function draw_input($key, $q) {
     437    function draw_input($key, $q) {     
    435438        // Allowed inputs
    436439        $allowed_types = array( 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'range', 'search', 'tel', 'time', 'url', 'week' );
     
    507510    function draw_datepicker($key, $q) {
    508511        echo '<p'.$q['class'].'><label><span>'.$q['label'].'</span>'."\n";
    509         echo "\t".'<input type="text" name="'.$key.'" id="'.$key.'" class="txt datepicker" value="'.esc_attr($_POST[$key]).'" /></label></p>'."\n";
     512        echo "\t".'<input type="date" name="'.$key.'" id="'.$key.'" class="txt datepicker" value="'.esc_attr($_POST[$key]).'" /></label></p>'."\n";
    510513    }
    511514   
    512515    function draw_timepicker($key, $q) {
    513516        echo '<p'.$q['class'].'><label><span>'.$q['label'].'</span>'."\n";
    514         echo "\t".'<input type="text" name="'.$key.'" id="'.$key.'" class="txt timepicker" value="'.esc_attr($_POST[$key]).'" /></label></p>'."\n";
     517        echo "\t".'<input type="time" name="'.$key.'" id="'.$key.'" class="txt timepicker" value="'.esc_attr($_POST[$key]).'" /></label></p>'."\n";
    515518        wp_enqueue_script('jquery-timepicker');
    516519    }
     
    518521    function draw_datetimepicker($key, $q) {
    519522        echo '<p'.$q['class'].'><label><span>'.$q['label'].'</span>'."\n";
    520         echo "\t".'<input type="text" name="'.$key.'" id="'.$key.'" class="txt datetimepicker" value="'.esc_attr($_POST[$key]).'" /></label></p>'."\n";
     523        echo "\t".'<input type="datetime" name="'.$key.'" id="'.$key.'" class="txt datetimepicker" value="'.esc_attr($_POST[$key]).'" /></label></p>'."\n";
    521524        wp_enqueue_script('jquery-timepicker');
    522525    }
     
    563566   
    564567   
     568    function count_logs() {
     569        // Used cached variable if available
     570        $counts = wp_cache_get( 'count_'.$this->log_type, 'counts' );
     571        // Query database to get recent count
     572        global $wpdb;
     573        $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = '{$this->log_type}' GROUP BY post_status";
     574        $results = (array) $wpdb->get_results( $query, ARRAY_A );
     575        $counts = array_fill_keys( get_post_stati(), 0 );
     576        foreach ( $results as $row )    $counts[ $row['post_status'] ] = $row['num_posts'];
     577        $counts = (object) $counts;
     578        // Set cache for next time, and return value
     579        wp_cache_set( 'count_'.$this->log_type, $counts, 'counts' );
     580        return $counts;
     581    }
    565582   
    566583    /**
     
    569586    function admin_menu() {
    570587        if (!$this->form_name)      return false;
    571         $menu_label == $this->form_name;
     588        $menu_label = $this->form_name;
    572589        // Add a counter to menu name?
    573590        $counter = '';
    574591        if ($this->log_type) {
    575             $count = wp_count_posts( $this->log_type );
     592            $count = $this->count_logs();
    576593            if ($count && $count->private>0)    $counter = '<span class="update-plugins"><span class="update-count">'. $count->private .'</span></span>';
    577594        }
     
    605622            ));
    606623            $this->opts['recaptcha'] = array_merge((array)$this->opts['recaptcha'], array(
    607                 'use'       => (($_POST['recaptcha']['use'] == 'yes') ? true : false),
    608                 'public'    => $_POST['recaptcha']['public'],
    609                 'private'   => $_POST['recaptcha']['private'],
     624                'use'       => ((isset($_POST['recaptcha']['use']) && $_POST['recaptcha']['use'] == 'yes') ? true : false),
     625                'public'    => ((isset($_POST['recaptcha']['public'])) ? $_POST['recaptcha']['public'] : ''),
     626                'private'   => ((isset($_POST['recaptcha']['private'])) ? $_POST['recaptcha']['private'] : ''),
    610627            ));
    611628            $this->opts['akismet'] = array_merge((array)$this->opts['akismet'], array(
    612                 'use'       => (($_POST['akismet']['use'] == 'yes') ? true : false),
    613                 'api_key'   => $_POST['akismet']['api_key'],
     629                'use'       => ((isset($_POST['akismet']['use']) && $_POST['akismet']['use'] == 'yes') ? true : false),
     630                'api_key'   => ((isset($_POST['akismet']['api_key'])) ? $_POST['akismet']['api_key'] : ''),
    614631            ));
    615632            $this->opts['ayah'] = array_merge((array)$this->opts['recaptcha'], array(
    616                 'use'       => (($_POST['ayah']['use'] == 'yes') ? true : false),
    617                 'publisher_key' => $_POST['ayah']['publisher_key'],
    618                 'scoring_key'   => $_POST['ayah']['scoring_key'],
     633                'use'           => ((isset($_POST['ayah']['use']) && $_POST['ayah']['use'] == 'yes') ? true : false),
     634                'publisher_key' => ((isset($_POST['ayah']['publisher_key'])) ? $_POST['ayah']['publisher_key'] : ''),
     635                'scoring_key'   => ((isset($_POST['ayah']['scoring_key'])) ? $_POST['ayah']['scoring_key'] : ''),
    619636            ));
    620637           
     
    658675        <p><strong>Anti-Spam Services:</strong></p>
    659676        <?php   if ($this->avail_recaptcha) {   ?>
     677        <?php
     678        if (!isset($this->opts['recaptcha']['use']))    $this->opts['recaptcha']['use'] = false;
     679        if (!isset($this->opts['recaptcha']['public'])) $this->opts['recaptcha']['public'] = '';
     680        if (!isset($this->opts['recaptcha']['private']))    $this->opts['recaptcha']['private'] = '';
     681        ?>
    660682        <fieldset class="antispam recaptcha">
    661683          <legend>reCAPTCHA</legend>
     
    671693        <?php   }                               ?>
    672694        <?php   if ($this->avail_akismet) {     ?>
     695        <?php
     696        if (!isset($this->opts['akismet']['use']))      $this->opts['akismet']['use'] = false;
     697        if (!isset($this->opts['akismet']['api_key']))  $this->opts['akismet']['api_key'] = '';
     698        ?>
    673699        <fieldset class="antispam akismet">
    674700            <legend>Akismet Anti-Spam</legend>
     
    682708        <?php   }                               ?>
    683709        <?php   if ($this->avail_ayah) {        ?>
     710        <?php
     711        if (!isset($this->opts['ayah']['use']))             $this->opts['ayah']['use'] = false;
     712        if (!isset($this->opts['ayah']['publisher_key']))   $this->opts['ayah']['publisher_key'] = '';
     713        if (!isset($this->opts['ayah']['scoring_key']))     $this->opts['ayah']['scoring_key'] = '';
     714       
     715        ?>
    684716        <fieldset class="antispam recaptcha">
    685717          <legend>Are You A Human?</legend>
     
    717749        wp_enqueue_style('ui-datepicker', '//ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css');
    718750        add_action('admin_print_footer_scripts', array($this,'admin_graph_js'));
     751       
     752        if (!isset($_REQUEST['date_from']))     $_REQUEST['date_from'] = '';
     753        if (!isset($_REQUEST['date_to']))       $_REQUEST['date_to'] = '';
    719754       
    720755        if ($_REQUEST['date_from']) {   $_REQUEST['date_from'] = date('M j, Y', strtotime( $_REQUEST['date_from'] ));   }
     
    813848        $class_name = $this->log_type.'_Table';
    814849        if (!class_exists($class_name)) return;
    815         $per_page = (is_numeric($_GET['per_page'])) ? $_GET['per_page'] : '20';
     850        $per_page = (isset($_GET['per_page']) && is_numeric($_GET['per_page'])) ? $_GET['per_page'] : '20';
    816851        $table = new $class_name( $this->log_type, $per_page );
    817852        $table->prepare_items();
     
    832867     */
    833868    function output_csv_logs() {
    834         if (!$this->log_type)               return false;
    835         if (!$_GET['download'] == 'csv')    return false;
    836             $logs = $this->admin_csv_logs();
    837             if (!$logs)                     return false;
     869        if (!$this->log_type)                                           return false;
     870        if (!isset($_GET['download']) || !$_GET['download'] == 'csv')   return false;
     871        if (!$this->questions)                                          return false;
     872        $logs = $this->admin_csv_logs();
     873        if (!$logs)                                                     return false;
    838874        header("Content-type: application/csv");
    839875        header("Content-Disposition: attachment; filename=log.csv");
     
    889925     *  Helper: format a timestamp
    890926     */
    891     function format_time_ago($timestamp) {
     927    public static function format_time_ago($timestamp) {
    892928        if (!is_numeric($timestamp)) $timestamp = strtotime($timestamp);
    893929        $t_diff = time() - $timestamp;
     
    904940     *  Helper to fix the "Error at offset" issue
    905941     */
    906     function __unserialize($data) {
     942    public static function __unserialize($data) {
    907943        // First attempt json_decode
    908944        $decoded = json_decode($data);
  • tailored-tools/trunk/readme.txt

    r802789 r811631  
    44Requires at least:  3.0
    55Tested up to:       3.7
    6 Stable tag:         1.7.3
     6Stable tag:         1.7.4
    77
    88Contains some helper classes to help you build custom forms.
     
    5454
    5555== Changelog ==
     56
     57= 1.7.4 =
     58* New shortcode handler for [tabs] had an issue with iframes and other elements. Now corrected.
     59* Change input type for date,time,datetime elements
     60* Fix some code that was causing PHP warnings
     61* Add some CSS for responsive map embed
     62* Add some CSS for better ui-datepicker default apperance
     63* Change dateformat from dd-mm-yy to dd/mm/yy (was a problem with validation format)
     64* Allow a default of 0 on form inputs, and allow a supplied "0" value to pass server-side validation
    5665
    5766= 1.7.3 =
  • tailored-tools/trunk/resource/custom.css

    r726509 r811631  
    7070
    7171
     72
    7273/**
    7374 *  jQuery UI Datepicker
    7475 */
    7576.ui-datepicker { display:none; }
    76 .ui-datepicker { background:#FFF; border:1px solid #CCC; padding:0.5em; box-shadow:2px 2px 4px #CCC; border-radius:0.3em; font-size:1rem; }
    77 .ui-datepicker .ui-datepicker-header a { float:left; display:block; width:16px; height:16px; background:url(icons.png) top right no-repeat; text-decoration:none; cursor:pointer; }
     77.ui-datepicker { background:#FFF; border:1px solid #CCC; padding:0.5em; box-shadow:2px 2px 4px #CCC; border-radius:0.3em; font-size:1em; }
     78.ui-datepicker .ui-datepicker-header a { float:left; display:block; width:16px; height:16px; background:url(icons.png) top right no-repeat; text-decoration:none; cursor:pointer; margin-top:0.3em; }
    7879.ui-datepicker .ui-datepicker-header a.ui-datepicker-next { float:right; background-position:top left; }
    79 .ui-datepicker .ui-datepicker-header a span { display:block; font-size:1px; text-indent:-2999px; }
     80.ui-datepicker .ui-datepicker-header a span { display:block; font-size:1px; text-indent:-2999px;  }
    8081.ui-datepicker .ui-datepicker-header .ui-datepicker-title { text-align:center; }
    8182
    82 .ui-datepicker .ui-datepicker-header select { width:auto; padding:0; box-shadow:none; border:1px solid #DDD; color:#333; cursor:pointer; }
     83.ui-datepicker .ui-datepicker-header select { width:auto; padding:0; box-shadow:none; border:1px solid #DDD; color:#333; cursor:pointer; margin:0 0.1em; }
    8384
    84 .ui-datepicker .ui-datepicker-calendar { }
     85.ui-datepicker .ui-datepicker-calendar { margin:0; line-height:1.4; }
    8586.ui-datepicker .ui-datepicker-calendar th, .ui-datepicker .ui-datepicker-calendar td { text-align:center; }
    8687.ui-datepicker .ui-datepicker-calendar th { padding:0.2em; }
    87 .ui-datepicker .ui-datepicker-calendar td { }
     88.ui-datepicker .ui-datepicker-calendar td { padding:0; }
    8889.ui-datepicker .ui-datepicker-calendar a { display:block; padding:0.2em; text-decoration:none; }
    8990.ui-datepicker .ui-datepicker-calendar a:hover { background:#c7dfef; }
    9091.ui-datepicker .ui-datepicker-calendar a.ui-state-active { background:#c7efeb; }
     92
     93
     94
    9195
    9296/**
     
    109113.ui-datepicker-buttonpane button { padding:0.5em 1em; margin:0 0.3em; border-radius:0.5em; }
    110114
     115
     116
    111117/**
    112118 *  jQuery UI Tabs
     
    127133.ui-tabs .tab_panel:after { clear:both; content:"."; display:block; height:0; visibility:hidden; }
    128134
     135
     136
     137/**
     138 *  Responsive map embed
     139 */
     140.googlemap img,
     141.googlemap iframe { background:#FFF; border:1px solid #DDD; padding:2px; border-radius:10px; box-shadow:1px 1px 2px #DDD; margin:10px auto 15px; max-width:100%;  }
     142.googlemap img { max-width:95%; height:auto; display:block; }
     143.googlemap iframe { display:none; }
     144@media only screen and (min-width:500px) {
     145    .googlemap img { display:none; }
     146    .googlemap iframe { display:block; max-width:97%; }
     147}
  • tailored-tools/trunk/shortcodes.php

    r802789 r811631  
    6767        }
    6868        // Now go through and remove empty tags
     69        $allowed_nodes = array( 'param', 'embed', 'iframe', 'div', 'object' );
    6970        $xp = new DOMXPath($dom);
    7071        foreach($xp->query('//*[not(node() or self::br) or normalize-space() = ""]') as $node) {
    71             $node->parentNode->removeChild($node);
     72            if (in_array($node->tagName, $allowed_nodes))   continue;
     73            $node->parentNode->removeChild($node);  // For some reason, this breaks on iFrames and some other elements.  Dodge by $allowed_nodes
    7274        }
    7375       
  • tailored-tools/trunk/tools.php

    r802789 r811631  
    33Plugin Name:    Tailored Tools
    44Description:    Adds some functionality to WordPress that you'll need.  (Version 1.5+ has different style rules. Do not upgrade without checking these.)
    5 Version:        1.7.3
     5Version:        1.7.4
    66Author:         Tailored Web Services
    77Author URI:     http://www.tailored.com.au
Note: See TracChangeset for help on using the changeset viewer.