Changeset 795003
- Timestamp:
- 10/28/2013 09:04:18 PM (12 years ago)
- Location:
- tailored-tools
- Files:
-
- 34 added
- 4 edited
-
tags/1.7.0 (added)
-
tags/1.7.0/embed-js.php (added)
-
tags/1.7.0/form.contact.php (added)
-
tags/1.7.0/form.sample.php (added)
-
tags/1.7.0/googlemaps.php (added)
-
tags/1.7.0/js (added)
-
tags/1.7.0/js/chosen.jquery.min.js (added)
-
tags/1.7.0/js/jquery.timepicker.js (added)
-
tags/1.7.0/js/loader.js (added)
-
tags/1.7.0/js/tinymce.js.php (added)
-
tags/1.7.0/lib (added)
-
tags/1.7.0/lib/class.akismet.php (added)
-
tags/1.7.0/lib/class.ayah.php (added)
-
tags/1.7.0/lib/class.forms.php (added)
-
tags/1.7.0/lib/class.recaptcha.php (added)
-
tags/1.7.0/lib/countries.php (added)
-
tags/1.7.0/lib/json.php (added)
-
tags/1.7.0/lib/lib.ayah.php (added)
-
tags/1.7.0/lib/recaptchalib.php (added)
-
tags/1.7.0/lib/tinymce.php (added)
-
tags/1.7.0/readme.txt (added)
-
tags/1.7.0/resource (added)
-
tags/1.7.0/resource/admin.css (added)
-
tags/1.7.0/resource/calendar.png (added)
-
tags/1.7.0/resource/chosen-sprite.png (added)
-
tags/1.7.0/resource/chosen-sprite@2x.png (added)
-
tags/1.7.0/resource/chosen.css (added)
-
tags/1.7.0/resource/custom.css (added)
-
tags/1.7.0/resource/exclaim.gif (added)
-
tags/1.7.0/resource/icons.png (added)
-
tags/1.7.0/resource/mce-icon.gif (added)
-
tags/1.7.0/resource/time.png (added)
-
tags/1.7.0/shortcodes.php (added)
-
tags/1.7.0/tools.php (added)
-
trunk/form.contact.php (modified) (1 diff)
-
trunk/lib/class.forms.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/tools.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tailored-tools/trunk/form.contact.php
r752666 r795003 23 23 public $avail_ayah = true; 24 24 public $check_bad_words= true; 25 26 public $show_graph = true; 25 27 26 28 -
tailored-tools/trunk/lib/class.forms.php
r752666 r795003 26 26 public $shortcode = 'FormShortcode'; 27 27 public $log_type = false; // False to disable logging, or post-type 28 public $show_graph = false; // Embed a graph before results to show leads over time 28 29 public $submit_key = 'submit_form'; // submit button key - for processing. 29 30 public $submit_label = 'Submit Form'; … … 621 622 echo '<div class="updated"><p>Settings have been saved.</p></div>'."\n"; 622 623 } 624 // Show graph 625 if ($this->log_type) $this->admin_graph_logs(); 623 626 // Show & Save logged submissions 624 627 if ($this->log_type) $this->admin_list_logs(); … … 704 707 705 708 709 710 /** 711 * Graph our enquiries over time. 712 */ 713 function admin_graph_logs() { 714 if (!$this->show_graph || !$this->log_type) return false; 715 wp_enqueue_script('google-jsapi', '//www.google.com/jsapi', false, false, true); 716 wp_enqueue_script('jquery-ui-datepicker'); 717 wp_enqueue_style('ui-datepicker', '//ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css'); 718 add_action('admin_print_footer_scripts', array($this,'admin_graph_js')); 719 720 if ($_REQUEST['date_from']) { $_REQUEST['date_from'] = date('M j, Y', strtotime( $_REQUEST['date_from'] )); } 721 if ($_REQUEST['date_to']) { $_REQUEST['date_to'] = date('M j, Y', strtotime( $_REQUEST['date_to'] )); } 722 723 724 if (empty($_REQUEST['date_from'])) $_REQUEST['date_from'] = date('M j, Y', strtotime("-30 days")); 725 if (empty($_REQUEST['date_to'])) $_REQUEST['date_to'] = date('M j, Y'); 726 727 global $wpdb; 728 $total_leads = $wpdb->get_var(" 729 SELECT COUNT( * ) AS `num_leads` 730 FROM `{$wpdb->posts}` 731 WHERE `post_type` = '{$this->log_type}' 732 AND DATE(`post_date`) BETWEEN '".date('Y-m-d',strtotime($_REQUEST['date_from']))."' AND '".date('Y-m-d',strtotime($_REQUEST['date_to']))."' 733 "); 734 ?> 735 <div id="graph"> 736 <p class="total_leads">Number of leads for selected time period: <?php echo $total_leads; ?></p> 737 <div class="ranges"> 738 <form method="POST"> 739 <p><label><span>From:</span> <input type="text" name="date_from" value="<?php echo $_REQUEST['date_from']; ?>" /></label></p> 740 <p><label><span>To:</span> <input type="text" name="date_to" value="<?php echo $_REQUEST['date_to']; ?>" /></label></p> 741 <p class="submit"><input class="button-primary" type="submit" value="Go" /></p> 742 </form> 743 </div> 744 <div id="chart"></div> 745 </div> 746 <style><!-- 747 #graph { background:#FFF; margin:1em 0.5em 2em; padding:0.5em; border:1px solid #DFDFDF; border-radius:0.3em; } 748 #graph p.total_leads { float:left; margin:0; padding:0.5em 0 0; } 749 #graph .ranges { text-align:right; } 750 #graph .ranges p { display:inline-block; margin:0 1em 0; padding:0; } 751 #graph .ranges p input { cursor:pointer; } 752 --></style> 753 <?php 754 } 755 756 function admin_graph_js() { 757 global $wpdb; 758 $data = array(); 759 $date = $_REQUEST['date_from']; 760 $loop = 0; 761 while (strtotime($date) <= strtotime($_REQUEST['date_to'])) { 762 $result = $wpdb->get_results(" 763 SELECT COUNT( * ) AS `num_leads`, DATE(`post_date`) AS `date` 764 FROM `{$wpdb->posts}` 765 WHERE `post_type` = '{$this->log_type}' 766 AND DATE(`post_date`) = '".date('Y-m-d',strtotime($date))."'; 767 "); 768 $data[] = array( 769 'Date' => date('jS M Y', strtotime($date)), 770 'Leads' => $result[0]->num_leads, 771 ); 772 $date = date('Y-m-d', strtotime("+1 day", strtotime($date))); 773 774 } 775 ?> 776 <script type="text/javascript"><!-- 777 jQuery(document).ready(function($){ 778 $('#graph .ranges label input').datepicker({ numberOfMonths:3, showButtonPanel:true, dateFormat:'M d, yy' }); 779 }); 780 781 google.load('visualization', '1.0', {'packages':['corechart']}); 782 google.setOnLoadCallback(drawChart); 783 function drawChart() { 784 785 var data = google.visualization.arrayToDataTable([ 786 ['Day', 'Leads'], 787 <?php 788 foreach ($data as $row) { 789 echo "['".$row['Date']."', ".$row['Leads']." ],"; 790 } 791 ?> 792 793 ]); 794 795 var options = { 796 title: "Leads per day", 797 }; 798 799 var chart = new google.visualization.LineChart(document.getElementById('chart')); 800 chart.draw(data, options); 801 } 802 --></script> 803 <?php 804 } 805 806 706 807 /** 707 808 * Extend this if you want to list logged submissions … … 722 823 <?php 723 824 } 825 826 827 724 828 725 829 … … 811 915 812 916 813 814 815 816 817 917 ?> -
tailored-tools/trunk/readme.txt
r752666 r795003 3 3 Tags: 4 4 Requires at least: 3.0 5 Tested up to: 3. 66 Stable tag: 1. 65 Tested up to: 3.7 6 Stable tag: 1.7 7 7 8 8 Contains some helper classes to help you build custom forms. … … 54 54 55 55 == Changelog == 56 = 1.7 = 57 * Now including a graph before displaying logs in admin area, to show leads over time. 56 58 57 59 = 1.6 = -
tailored-tools/trunk/tools.php
r752666 r795003 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. 65 Version: 1.7 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.