Changeset 811631
- Timestamp:
- 11/27/2013 10:33:59 PM (12 years ago)
- Location:
- tailored-tools
- Files:
-
- 34 added
- 8 edited
-
tags/1.7.4 (added)
-
tags/1.7.4/embed-js.php (added)
-
tags/1.7.4/form.contact.php (added)
-
tags/1.7.4/form.sample.php (added)
-
tags/1.7.4/googlemaps.php (added)
-
tags/1.7.4/js (added)
-
tags/1.7.4/js/chosen.jquery.min.js (added)
-
tags/1.7.4/js/jquery.timepicker.js (added)
-
tags/1.7.4/js/loader.js (added)
-
tags/1.7.4/js/tinymce.js.php (added)
-
tags/1.7.4/lib (added)
-
tags/1.7.4/lib/class.akismet.php (added)
-
tags/1.7.4/lib/class.ayah.php (added)
-
tags/1.7.4/lib/class.forms.php (added)
-
tags/1.7.4/lib/class.recaptcha.php (added)
-
tags/1.7.4/lib/countries.php (added)
-
tags/1.7.4/lib/json.php (added)
-
tags/1.7.4/lib/lib.ayah.php (added)
-
tags/1.7.4/lib/recaptchalib.php (added)
-
tags/1.7.4/lib/tinymce.php (added)
-
tags/1.7.4/readme.txt (added)
-
tags/1.7.4/resource (added)
-
tags/1.7.4/resource/admin.css (added)
-
tags/1.7.4/resource/calendar.png (added)
-
tags/1.7.4/resource/chosen-sprite.png (added)
-
tags/1.7.4/resource/chosen-sprite@2x.png (added)
-
tags/1.7.4/resource/chosen.css (added)
-
tags/1.7.4/resource/custom.css (added)
-
tags/1.7.4/resource/exclaim.gif (added)
-
tags/1.7.4/resource/icons.png (added)
-
tags/1.7.4/resource/mce-icon.gif (added)
-
tags/1.7.4/resource/time.png (added)
-
tags/1.7.4/shortcodes.php (added)
-
tags/1.7.4/tools.php (added)
-
trunk/embed-js.php (modified) (2 diffs)
-
trunk/js/loader.js (modified) (3 diffs)
-
trunk/lib/class.akismet.php (modified) (1 diff)
-
trunk/lib/class.forms.php (modified) (18 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/resource/custom.css (modified) (3 diffs)
-
trunk/shortcodes.php (modified) (1 diff)
-
trunk/tools.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tailored-tools/trunk/embed-js.php
r752666 r811631 30 30 function output_embed_code() { 31 31 global $post; 32 if (!$post || !is_object($post)) return false; 32 33 $code = get_post_meta($post->ID, $this->meta_value_key, true); 33 34 if (empty($code)) return false; … … 38 39 function save_post( $post_id ) { 39 40 // Security check 41 if (empty($_POST) || !isset($_POST['embed_javascript'])) return; 40 42 if ($_POST['post_type'] == 'page' && !current_user_can('edit_page', $post_id)) return; 41 43 if ($_POST['post_type'] == 'post' && !current_user_can('edit_post', $post_id)) return; -
tailored-tools/trunk/js/loader.js
r802789 r811631 36 36 if (!$().datepicker) return; 37 37 $('form input.datepicker, form p.datepicker input').datepicker({ 38 dateFormat: 'dd -mm-yy',38 dateFormat: 'dd/mm/yy', 39 39 changeMonth: true, 40 40 changeYear: true … … 65 65 changeMonth: true, 66 66 changeYear: true, 67 dateFormat: 'dd -mm-yy',67 dateFormat: 'dd/mm/yy', 68 68 timeFormat: 'h:mm tt', 69 69 stepMinute: 15, … … 143 143 }); 144 144 $(ul).prependTo( $(tabset) ); 145 // alert( $(tabset).html() );146 145 $(tabset).tabs(); 147 148 146 }); 149 // alert('done');150 $('.ui-tabs').tabs('load', 2);151 147 }); 152 148 -
tailored-tools/trunk/lib/class.akismet.php
r715824 r811631 18 18 function __construct() { 19 19 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; 21 21 22 22 add_filter('ttools_map_akismet_fields', array(&$this,'map_form_fields'), 9, 2); -
tailored-tools/trunk/lib/class.forms.php
r802789 r811631 287 287 if (!$q['required']) return; 288 288 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']; 290 290 if ($q['type'] == 'email' && !empty($_POST[$key]) && !is_email($_POST[$key])) $this->error[] = '<em>'.$_POST[$key].'</em> does not look like an email address'; 291 291 } else … … 323 323 // Add words to existing array 324 324 $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', 327 327 )); 328 328 $badwords = array_unique($badwords); … … 398 398 399 399 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; 400 403 // Separator line? 401 404 if ($q['type'] == 'sep') { echo '<p class="sep"> </p>'."\n"; return; } … … 405 408 if ($q['type'] == 'note') { echo '<p class="note '.$q['class'].'">'.nl2br($q['label']).'</p>'."\n"; return; } 406 409 // 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']; 408 411 // Prepare element class 409 412 if (!is_array($q['class'])) $q['class'] = array($q['class']); … … 432 435 * Form Element Helpers 433 436 */ 434 function draw_input($key, $q) { 437 function draw_input($key, $q) { 435 438 // Allowed inputs 436 439 $allowed_types = array( 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'range', 'search', 'tel', 'time', 'url', 'week' ); … … 507 510 function draw_datepicker($key, $q) { 508 511 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"; 510 513 } 511 514 512 515 function draw_timepicker($key, $q) { 513 516 echo '<p'.$q['class'].'><label><span>'.$q['label'].'</span>'."\n"; 514 echo "\t".'<input type="t ext" 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"; 515 518 wp_enqueue_script('jquery-timepicker'); 516 519 } … … 518 521 function draw_datetimepicker($key, $q) { 519 522 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"; 521 524 wp_enqueue_script('jquery-timepicker'); 522 525 } … … 563 566 564 567 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 } 565 582 566 583 /** … … 569 586 function admin_menu() { 570 587 if (!$this->form_name) return false; 571 $menu_label = =$this->form_name;588 $menu_label = $this->form_name; 572 589 // Add a counter to menu name? 573 590 $counter = ''; 574 591 if ($this->log_type) { 575 $count = wp_count_posts( $this->log_type);592 $count = $this->count_logs(); 576 593 if ($count && $count->private>0) $counter = '<span class="update-plugins"><span class="update-count">'. $count->private .'</span></span>'; 577 594 } … … 605 622 )); 606 623 $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'] : ''), 610 627 )); 611 628 $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'] : ''), 614 631 )); 615 632 $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'] : ''), 619 636 )); 620 637 … … 658 675 <p><strong>Anti-Spam Services:</strong></p> 659 676 <?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 ?> 660 682 <fieldset class="antispam recaptcha"> 661 683 <legend>reCAPTCHA</legend> … … 671 693 <?php } ?> 672 694 <?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 ?> 673 699 <fieldset class="antispam akismet"> 674 700 <legend>Akismet Anti-Spam</legend> … … 682 708 <?php } ?> 683 709 <?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 ?> 684 716 <fieldset class="antispam recaptcha"> 685 717 <legend>Are You A Human?</legend> … … 717 749 wp_enqueue_style('ui-datepicker', '//ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css'); 718 750 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'] = ''; 719 754 720 755 if ($_REQUEST['date_from']) { $_REQUEST['date_from'] = date('M j, Y', strtotime( $_REQUEST['date_from'] )); } … … 813 848 $class_name = $this->log_type.'_Table'; 814 849 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'; 816 851 $table = new $class_name( $this->log_type, $per_page ); 817 852 $table->prepare_items(); … … 832 867 */ 833 868 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; 838 874 header("Content-type: application/csv"); 839 875 header("Content-Disposition: attachment; filename=log.csv"); … … 889 925 * Helper: format a timestamp 890 926 */ 891 function format_time_ago($timestamp) {927 public static function format_time_ago($timestamp) { 892 928 if (!is_numeric($timestamp)) $timestamp = strtotime($timestamp); 893 929 $t_diff = time() - $timestamp; … … 904 940 * Helper to fix the "Error at offset" issue 905 941 */ 906 function __unserialize($data) {942 public static function __unserialize($data) { 907 943 // First attempt json_decode 908 944 $decoded = json_decode($data); -
tailored-tools/trunk/readme.txt
r802789 r811631 4 4 Requires at least: 3.0 5 5 Tested up to: 3.7 6 Stable tag: 1.7. 36 Stable tag: 1.7.4 7 7 8 8 Contains some helper classes to help you build custom forms. … … 54 54 55 55 == 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 56 65 57 66 = 1.7.3 = -
tailored-tools/trunk/resource/custom.css
r726509 r811631 70 70 71 71 72 72 73 /** 73 74 * jQuery UI Datepicker 74 75 */ 75 76 .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:1 rem; }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; } 78 79 .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; } 80 81 .ui-datepicker .ui-datepicker-header .ui-datepicker-title { text-align:center; } 81 82 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; } 83 84 84 .ui-datepicker .ui-datepicker-calendar { }85 .ui-datepicker .ui-datepicker-calendar { margin:0; line-height:1.4; } 85 86 .ui-datepicker .ui-datepicker-calendar th, .ui-datepicker .ui-datepicker-calendar td { text-align:center; } 86 87 .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; } 88 89 .ui-datepicker .ui-datepicker-calendar a { display:block; padding:0.2em; text-decoration:none; } 89 90 .ui-datepicker .ui-datepicker-calendar a:hover { background:#c7dfef; } 90 91 .ui-datepicker .ui-datepicker-calendar a.ui-state-active { background:#c7efeb; } 92 93 94 91 95 92 96 /** … … 109 113 .ui-datepicker-buttonpane button { padding:0.5em 1em; margin:0 0.3em; border-radius:0.5em; } 110 114 115 116 111 117 /** 112 118 * jQuery UI Tabs … … 127 133 .ui-tabs .tab_panel:after { clear:both; content:"."; display:block; height:0; visibility:hidden; } 128 134 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 67 67 } 68 68 // Now go through and remove empty tags 69 $allowed_nodes = array( 'param', 'embed', 'iframe', 'div', 'object' ); 69 70 $xp = new DOMXPath($dom); 70 71 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 72 74 } 73 75 -
tailored-tools/trunk/tools.php
r802789 r811631 3 3 Plugin Name: Tailored Tools 4 4 Description: 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. 35 Version: 1.7.4 6 6 Author: Tailored Web Services 7 7 Author URI: http://www.tailored.com.au
Note: See TracChangeset
for help on using the changeset viewer.