Plugin Directory

Changeset 1937055


Ignore:
Timestamp:
09/06/2018 07:11:15 PM (8 years ago)
Author:
godsgood33
Message:

Updates for v1.4

Location:
point-tracker
Files:
10 edited
21 copied

Legend:

Unmodified
Added
Removed
  • point-tracker/tags/1.4/README.txt

    r1930326 r1937055  
    66Requires PHP: 5.6
    77Tested up to: 4.9.8
    8 Stable tag: 1.3.1
     8Stable tag: 1.4
    99License: Apache-2.0
    1010License URI: https://www.apache.org/licenses/LICENSE-2.0
     
    5454= How can I create a custom page =
    5555
    56 After you've created a challenge copy the unique code for that challenge.  Create a new page at Page -> Add New.  Give it a name and whatever content you'd like.  Then where you'd like to put the challenge form simply type [challenge chal={challenge code you copied}][/challenge], then publish the page.  That is all.
     56After you've created a challenge, copy the unique code for that challenge.  Create a new page at Pages -> Add New.  Give it a name and whatever content you'd like.  Then where you'd like to put the challenge form simply type `[challenge chal={challenge code you copied}][/challenge]`, then publish the page.  That is all.  You can also create an activity page using the shortcode `[my_activity chal={code}][/my_activity]`.
    5757
    5858= I'd like a leader board =
     
    9292* Fixed bug in showing challenge list
    9393
     94= 1.4 =
     95* Fix bug in admin with start and end date formats
     96* Add documentation for creating custom challenge and activity pages
     97* Add Upgrade admin submenu (not linked right now)
     98* Extended the size of the label for radio buttons and checkboxes and answer
     99* Added a span below text fields to show character count
     100
    94101== Upgrade Notice ==
    95102
  • point-tracker/tags/1.4/admin/class-point-tracker-admin.php

    r1929974 r1937055  
    173173        ));
    174174
     175        add_submenu_page('point-tracker-menu', 'Upgrade!', 'Upgrade!', 'manage_options', 'point-tracker-upgrade', [
     176            $this,
     177            'display_upgrade_page'
     178        ]);
     179
    175180        add_options_page("Point Tracker Settings", "PT Settings", "manage_options", "pt-settings", array(
    176181            $this,
     
    191196            "m/d/Y" => "mm/dd/yy",
    192197            "M j, Y" => "M d, yy",
    193             "F j, Y" => "MMMM d, yy",
     198            "F j, Y" => "MM d, yy",
    194199            "d/m/Y" => "dd/mm/yy"
    195200        ];
     
    231236    }
    232237
     238
     239    public function display_upgrade_page()
     240    {
     241        print <<<EOL
     242<h2>Upgrade to Point Tracker Pro</h2>
     243<p>Take your challenges to the next level with <a href='' target='_blank'>Point Tracker Pro</a></p>
     244EOL;
     245    }
     246
    233247    /**
    234248     * Render the admin options page
  • point-tracker/tags/1.4/includes/ajax/entry-ajax.php

    r1929974 r1937055  
    133133    $member_id = filter_input(INPUT_POST, 'member-id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
    134134    $user_name = sanitize_text_field(filter_input(INPUT_POST, 'user-name', FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE));
    135     $user_email = sanitize_email(filter_input(INPUT_POST, 'user-email', FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE));
     135    $user_email = strtolower(sanitize_email(filter_input(INPUT_POST, 'user-email', FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE)));
    136136
    137137    if (! $member_id) {
     
    380380    $tp = 0;
    381381    $member_id = filter_input(INPUT_POST, 'member-id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
    382     $email = sanitize_email(filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL, FILTER_NULL_ON_FAILURE));
     382    $email = strtolower(sanitize_email(filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL, FILTER_NULL_ON_FAILURE)));
    383383    $chal_id = filter_input(INPUT_POST, 'chal-id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
    384384
  • point-tracker/tags/1.4/includes/ajax/participant-ajax.php

    r1929974 r1937055  
    226226    $member_id = filter_input(INPUT_POST, 'member-id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
    227227    $name = sanitize_text_field(filter_input(INPUT_POST, 'user-name', FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE));
    228     $email = sanitize_email(filter_input(INPUT_POST, 'user-email', FILTER_SANITIZE_EMAIL, FILTER_NULL_ON_FAILURE));
     228    $email = strtolower(sanitize_email(filter_input(INPUT_POST, 'user-email', FILTER_SANITIZE_EMAIL, FILTER_NULL_ON_FAILURE)));
    229229    $now = new DateTime("now", new DateTimeZone(get_option("timezone_string")));
    230230
     
    319319
    320320    $name = sanitize_text_field(filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE));
    321     $email = sanitize_email(filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE));
     321    $email = strtolower(sanitize_email(filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE)));
    322322
    323323    $now = new DateTime("now", new DateTimeZone(get_option("timezone_string")));
  • point-tracker/tags/1.4/includes/class-point-tracker-activator.php

    r1929974 r1937055  
    130130        $res = $wpdb->get_row("SHOW TABLES LIKE '{$wpdb->prefix}pt_challenges'", ARRAY_N);
    131131        if (! is_array($res) || ! count($res)) {
    132             return new WP_Error('db_failure', "Failed to create table '{$wpdb->prefix}pt_challenges");
     132            return new WP_Error('db_failure', "Failed to create table {$wpdb->prefix}pt_challenges");
    133133        }
    134134
     
    139139      `points` decimal(4,1) DEFAULT NULL,
    140140      `type` enum('checkbox','radio','text','number') NOT NULL,
    141       `label` varchar(45) DEFAULT NULL,
     141      `label` mediumtext DEFAULT NULL,
    142142      `question` varchar(100) DEFAULT NULL,
    143143      `min` int(11) DEFAULT '0',
     
    151151        $res = $wpdb->get_row("SHOW TABLES LIKE '{$wpdb->prefix}pt_activities'", ARRAY_N);
    152152        if (! is_array($res) || ! count($res)) {
    153             return new WP_Error('db_failure', "Failed to create table '{$wpdb->prefix}pt_activities");
     153            return new WP_Error('db_failure', "Failed to create table {$wpdb->prefix}pt_activities");
    154154        }
    155155
     
    168168        $res = $wpdb->get_row("SHOW TABLES LIKE '{$wpdb->prefix}pt_participants'", ARRAY_N);
    169169        if (! is_array($res) || ! count($res)) {
    170             return new WP_Error('db_failure', "Failed to create table '{$wpdb->prefix}pt_participants");
     170            return new WP_Error('db_failure', "Failed to create table {$wpdb->prefix}pt_participants");
    171171        }
    172172
     
    176176      `log_date` date NOT NULL,
    177177      `log_time` time NOT NULL,
    178       `value` varchar(255) NOT NULL DEFAULT '',
     178      `value` text NOT NULL DEFAULT '',
    179179      PRIMARY KEY (`user_id`,`activity_id`,`log_date`)
    180180    )";
     
    182182        $res = $wpdb->get_row("SHOW TABLES LIKE '{$wpdb->prefix}pt_log'", ARRAY_N);
    183183        if (! is_array($res) || ! count($res)) {
    184             return new WP_Error('db_failure', "Failed to create table '{$wpdb->prefix}pt_log");
     184            return new WP_Error('db_failure', "Failed to create table {$wpdb->prefix}pt_log");
    185185        }
    186186    }
  • point-tracker/tags/1.4/includes/class-point-tracker.php

    r1930304 r1937055  
    7070    public function __construct()
    7171    {
    72         if (defined('PT_PLUGIN_NAME_VERSION')) {
    73             $this->version = PT_PLUGIN_NAME_VERSION;
     72        if (defined('PT_VERSION')) {
     73            $this->version = PT_VERSION;
    7474        } else {
    75             $this->version = '1.3.1';
     75            $this->version = '1.4';
    7676        }
    7777        $this->plugin_name = 'point-tracker';
  • point-tracker/tags/1.4/point-tracker.php

    r1930304 r1937055  
    1616 * Plugin Name:       Point Tracker
    1717 * Plugin URI:        https://github.com/godsgood33/point-tracker
    18  * Description:       Allow network marketing leaders to create challenges and let people track their points.
    19  * Version:           1.3.1
     18 * Description:       Allow leaders to create challenges and let people track their points.
     19 * Version:           1.4
    2020 * Author:            Ryan Prather
    2121 * Author URI:        https://github.com/godsgood33
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define('PT_PLUGIN_NAME_VERSION', '1.3.1');
     38define('PT_VERSION', '1.4');
    3939
    4040/**
  • point-tracker/tags/1.4/public/class-point-tracker-public.php

    r1929974 r1937055  
    172172            "m/d/Y" => "mm/dd/yy",
    173173            "M j, Y" => "M d, yy",
    174             "F j, Y" => "MMMM d, yy",
     174            "F j, Y" => "MM d, yy",
    175175            "d/m/Y" => "dd/mm/yy"
    176176        ];
  • point-tracker/tags/1.4/public/js/point-tracker-public.min.js

    r1929974 r1937055  
    33return false;}else{if(!$("#email").val()){$("#msg").append("<div>Please enter your email</div>");$("#msg").slideToggle(300);$("#msg").addClass("warn-msg");setTimeout(function(){$("#msg").slideToggle(300);},5000);return false;}}$.ajax(ajax_object.ajax_url,{data:{action:"get-my-activity","member-id":$("#member-id").val(),"email":$("#email").val(),"chal-id":$("#chal-id").val()},beforeSend:beforeAjaxSend,complete:ajaxComplete,success:function(data){if(!check_for_error(data)){return;}$("#total-points").html(data.total_points);
    44if($.fn.DataTable.isDataTable("#my-activity-table")){table.destroy();$("#my-activity-table").empty();}table=$("#my-activity-table").DataTable({data:data.data.slice(0),columns:data.columns.slice(0),paging:false,buttons:["copyHtml5","csv","excel","pdf","print"],dom:"Bfrtip",searching:false});$(".fa-trash-alt").click(delete_activity);},error:function(xhr,status,error){console.error(error);},method:"post",dataType:"json"});}function save_activity(){var start=$(this).parent().parent();var type=$(start).find(".type").val();
    5 var value="";if(!validate_entry(start)){return;}if(type=="checkbox"){var length=$(start).find("input[type='checkbox']:checked").length;if(length>1){value=[];for(var x=0;x<length;x++){value.push($(start).find("input[type='checkbox']:checked").eq(x).val());}}else{value=$(start).find("input[type='checkbox']:checked").val();}}else{if(type=="radio"){value=$(start).find("input[type='radio']:checked").val();}else{value=$(start).find("input.value").val();}}$.ajax(ajax_object.ajax_url,{data:{"action":"save-entry","chal-link":$("#chal-link").val(),"act-id":$(start).find(".id").val(),"type":type,"value":value,"member-id":$("#member-id").val(),"user-name":$("#user-name").val(),"user-email":$("#user-email").val()},beforeSend:beforeAjaxSend,complete:ajaxComplete,success:function(data){$("#msg").html("");
     5var value="";if(!validate_entry(start)){return;}if(type=="checkbox"){var length=$(start).find("input[type='checkbox']:checked").length;if(length>1){value=[];for(var x=0;x<length;x++){value.push($(start).find("input[type='checkbox']:checked").eq(x).val());}}else{value=$(start).find("input[type='checkbox']:checked").val();}}else{if(type=="radio"){value=$(start).find("input[type='radio']:checked").val();}else{value=$(start).find("input.value").val();}}$.ajax(ajax_object.ajax_url,{data:{"action":"save-entry","chal-link":$("#chal-link").val(),"act-id":$(start).find(".id").val(),"type":type,"value":value,"member-id":$("#member-id").val(),"user-name":$("#user-name").val(),"user-email":$("#user-email").val()},beforeSend:beforeAjaxSend,complete:ajaxComplete,success:function(data){$("#msg").empty();
    66$("#msg").removeClass("err-msg,warn-msg");var duration=1500;if(data.error){$("#msg").html("<p>"+data.error+"</p>");$("#msg").addClass("err-msg");duration=5000;}else{if(data.warning){$("#msg").html("<p>"+data.warning+"</p>");$("#msg").addClass("warn-msg");duration=3000;}else{$("#msg").html("<p>Activity saved</p>");}}$("#msg").css("top",$(start).position().top+5);$("#msg").height($(start).height()+2);$("#msg").slideToggle(300);setTimeout(function(){$("#msg").slideToggle(300);},duration);},error:function(xhr,status,error){console.error(error);
    77},dataType:"json",method:"post"});}function delete_activity(){var button=$(this);$.ajax(ajax_object.ajax_url,{data:{"action":"delete-participant-activity","act-id":$(this).data("act-id"),"user-id":$(this).data("user-id"),"log-date":$(this).data("log-date"),"security":$("#_wpnonce").val()},beforeSend:beforeAjaxSend,complete:ajaxComplete,success:function(data){if(!check_for_error(data)){return;}table.row($(button).closest("tr").index()).remove().draw();},error:function(xhr,status,error){console.error(error);},dataType:"json",method:"post"});
    8 }function validate_entry(act){var numeric=/^\d+$/;var ret=true;var type=$(act).find("input.type").val();$("#msg div").remove();$("#msg").removeClass("err-msg");$("#msg").removeClass("warn-msg");if(!$("#member-id").val()||!$("#member-id").val().match(numeric)){$("#msg").append("<div>That is an invalid member ID</div>");ret=false;}if(!$("#user-name").val()){$("#msg").append("<div>You need to put your name in the form</div>");ret=false;}if(!$("#user-email").val()){$("#msg").append("<div>You need to enter your e-mail address</div>");
    9 ret=false;}if(type=="checkbox"||type=="radio"){if(!$(act).find("input[type="+type+"]:checked").length){$("#msg").append("<div>You must select one of the options</div>");ret=false;}}else{if(type=="text"){if(!$(act).find('input[type="text"]').val().length){$("#msg").append("<div>Invalid entry for this activity</div>");ret=false;}}else{if(type=="number"){var num=$(act).find('input[type="number"]').val();if(!num.match(numeric)){$("#msg").append("<div>Invalid entry for this activity</div>");ret=false;}else{if(parseInt(num)<1){$("#msg").append("<div>Invalid entry for this activity, positive numbers only</div>");
    10 ret=false;}}}}}if(!ret){$("#msg").slideToggle(300);$("#msg").addClass("warn-msg");setTimeout(function(){$("#msg").slideToggle(300);},5000);}return ret;}function check_for_error(data){$("#msg div").remove();$("#msg").removeClass("err-msg,warn-msg");var err=false;if(data=="0"){$("#msg").html("<div>There was an error</div>");$("#msg").addClass("err-msg");err=true;}else{if(data.error){$("#msg").html("<div>"+data.error+"</div>");$("#msg").addClass("err-msg");err=true;}else{if(data.warning){$("#msg").html("<div>"+data.warning+"</div>");
    11 $("#msg").addClass("warn-msg");err=true;}else{if(data.success){$("#msg").html("<div>"+data.success+"</div>");}}}}if($("#msg").html()){$("#msg").show(300);}if(err){setTimeout(function(){$("#msg").hide(300);$("#msg").html("");},3000);}else{setTimeout(function(){$("#msg").hide(300);$("#msg").html("");},1500);}return !err;}function beforeAjaxSend(){$("#loading,#waiting").show();$("#waiting").animate({"opacity":"0.5"},300,"linear");}function ajaxComplete(){$("#loading,#waiting").hide();$("#waiting").animate({"opacity":"0"},300,"linear");
    12 }var opts={lines:25,length:25,width:5,radius:50,scale:1,corners:1,color:"#000",opacity:0.25,rotate:0,direction:1,speed:0.5,trail:60,fps:20,zIndex:2000000000,className:"spinner",top:"50%",left:"50%",shadow:false,hwaccel:false,position:"absolute"};var target,spinner,table;$("#registered-challenges,#upcoming-challenges,#past-challenges").DataTable({paging:false,searching:false});$(".tooltip-field").tooltip({show:{effect:"slideDown",delay:100},hide:{effect:"slideUp",delay:250}});dialog=$("#dialog-form").dialog({autoOpen:false,height:500,width:350,modal:true,buttons:{"Join Challenge":join_challenge,Cancel:function(){dialog.dialog("close");
    13 }},close:function(){form[0].reset();}});form=dialog.find("form").on("submit",function(event){event.preventDefault();join_challenge();});$("#join-challenge").button().on("click",function(){dialog.dialog("open");});$(".save").click(save_activity);$("#get-activity").click(get_my_activity);$("#msg").hide();if($("#loading")){target=document.getElementById("loading");spinner=new Spinner(opts).spin(target);}if($("#my-activity-body tr").length){table=$("#my-activity-table").DataTable({paging:false,buttons:["copyHtml5","csv","excel","pdf","print"],dom:"Bfrtip",searching:false,stripClasses:["odd-row","even-row"],order:[[0,"asc"],[2,"asc"]]});
    14 $(".fa-trash-alt").click(delete_activity);}});
     8}function validate_entry(act){var numeric=/^\d+$/;var ret=true;var start=$(act);var type=$(act).find("input.type").val();$("#msg").empty();$("#msg").removeClass("err-msg");$("#msg").removeClass("warn-msg");$("#msg").css("top",$(start).position().top+5);$("#msg").height($(start).height()+2);if(!$("#member-id").val()||!$("#member-id").val().match(numeric)){$("#msg").append("<p>That is an invalid member ID</p>");ret=false;}if(!$("#user-name").val()){$("#msg").append("<p>You need to put your name in the form</p>");
     9ret=false;}if(!$("#user-email").val()){$("#msg").append("<p>You need to enter your e-mail address</p>");ret=false;}if(type=="checkbox"||type=="radio"){if(!$(act).find("input[type="+type+"]:checked").length){$("#msg").append("<p>You must select one of the options</p>");ret=false;}}else{if(type=="text"){if(!$(act).find('input[type="text"]').val().length){$("#msg").append("<p>Invalid entry for this activity</p>");ret=false;}}else{if(type=="number"){var field=$(act).find('input[type="number"]');var num=$(field).val();
     10var min=($(field).attr("min")?$(field).attr("min"):0);var max=($(field).attr("max")?$(field).attr("max"):0);if(!num.match(numeric)){$("#msg").append("<p>Invalid entry for this activity</p>");ret=false;}else{if(parseInt(num)<1){$("#msg").append("<p>Invalid entry for this activity, positive numbers only</p>");ret=false;}else{if(parseInt(num)<min){$("#msg").append("<p>Invalid entry for this activity, number must be greater than or equal to "+min+"</p>");ret=false;}else{if(parseInt(num)>max){$("#msg").append("<p>Invalid entry for this activity, number must be lesser than or equal to "+max+"</p>");
     11ret=false;}}}}}}}if(!ret){$("#msg").slideToggle(300);$("#msg").addClass("warn-msg");setTimeout(function(){$("#msg").slideToggle(300);$("#msg").empty();},5000);}return ret;}function check_for_error(data){$("#msg").empty();$("#msg").removeClass("err-msg,warn-msg");var err=false;if(data=="0"){$("#msg").html("<p>There was an error</p>");$("#msg").addClass("err-msg");err=true;}else{if(data.error){$("#msg").html("<p>"+data.error+"</p>");$("#msg").addClass("err-msg");err=true;}else{if(data.warning){$("#msg").html("<p>"+data.warning+"</p>");
     12$("#msg").addClass("warn-msg");err=true;}else{if(data.success){$("#msg").html("<p>"+data.success+"</p>");}}}}if($("#msg").html()){$("#msg").show(300);}if(err){setTimeout(function(){$("#msg").hide(300);$("#msg").empty();},3000);}else{setTimeout(function(){$("#msg").hide(300);$("#msg").empty();},1500);}return !err;}function beforeAjaxSend(){$("#loading,#waiting").show();$("#waiting").animate({"opacity":"0.5"},300,"linear");}function ajaxComplete(){$("#loading,#waiting").hide();$("#waiting").animate({"opacity":"0"},300,"linear");
     13}var opts={lines:25,length:25,width:5,radius:50,scale:1,corners:1,color:"#000",opacity:0.25,rotate:0,direction:1,speed:0.5,trail:60,fps:20,zIndex:2000000000,className:"spinner",top:"50%",left:"50%",shadow:false,hwaccel:false,position:"absolute"};var target,spinner,table;$(".text-max").keyup(function(){$("#text-len-"+$(this).attr("id")).text($(this).val().length);});$("#registered-challenges,#upcoming-challenges,#past-challenges").DataTable({paging:false,searching:false});$(".tooltip-field").tooltip({show:{effect:"slideDown",delay:100},hide:{effect:"slideUp",delay:250}});
     14dialog=$("#dialog-form").dialog({autoOpen:false,height:500,width:350,modal:true,buttons:{"Join Challenge":join_challenge,Cancel:function(){dialog.dialog("close");}},close:function(){form[0].reset();}});form=dialog.find("form").on("submit",function(event){event.preventDefault();join_challenge();});$("#join-challenge").button().on("click",function(){dialog.dialog("open");});$(".save").click(save_activity);$("#get-activity").click(get_my_activity);$("#msg").hide();if($("#loading")){target=document.getElementById("loading");
     15spinner=new Spinner(opts).spin(target);}if($("#my-activity-body tr").length){table=$("#my-activity-table").DataTable({paging:false,buttons:["copyHtml5","csv","excel","pdf","print"],dom:"Bfrtip",searching:false,stripClasses:["odd-row","even-row"],order:[[0,"asc"],[2,"asc"]]});$(".fa-trash-alt").click(delete_activity);}});
  • point-tracker/tags/1.4/public/partials/point-tracker-challenge-pg.php

    r1929974 r1937055  
    126126
    127127                print <<<EOR
    128 <label for='$id'>$label</label>&nbsp;&nbsp;
    129 <input type='{$act->type}' class='value' id='$id' value='$label' /><br />
     128<input type='{$act->type}' class='value' id='$id' value='$label' />&nbsp;&nbsp;
     129<label for='$id'>$label</label><br />
    130130EOR;
    131131            }
     
    138138
    139139            $inputmode = ($act->type == 'number' ? " inputmode='numeric' pattern='[0-9]*'" : null);
    140 
    141             print "<input type='{$act->type}' class='value' id='$id'$inputmode $min $max $val />&nbsp;&nbsp;";
     140            $text_max = ($act->type == 'text' && $act->max ? " text-max" : null);
     141
     142            print "<input type='{$act->type}' class='value$text_max' id='$id'$inputmode $min $max $val />&nbsp;&nbsp;";
     143            print ($act->type == 'text' && $act->max ? "<br />(<span id='text-len-{$id}'>0</span> / {$act->max})" : null);
    142144        }
    143145
     
    220222
    221223                print <<<EOR
    222 <label for='$id'>$label</label>&nbsp;&nbsp;
    223 <input type='{$act->type}' class='value' id='$id' value='$label' /><br />
     224<input type='{$act->type}' class='value' id='$id' value='$label' />&nbsp;&nbsp;
     225<label for='$id'>$label</label><br />
    224226EOR;
    225227            }
     
    232234
    233235            $inputmode = ($act->type == 'number' ? " inputmode='numeric' pattern='[0-9]*'" : null);
    234 
    235             print "<input type='{$act->type}' class='value' id='$id'$inputmode $min $max $val />&nbsp;&nbsp;";
     236            $text_max = ($act->type == 'text' && $act->max ? " text-max" : null);
     237
     238            print "<input type='{$act->type}' class='value$text_max' id='$id'$inputmode $min $max $val />&nbsp;&nbsp;";
     239            print ($act->type == 'text' && $act->max ? "<br />(<span id='text-len-{$id}'>0</span> / {$act->max})" : null);
    236240        }
    237241
  • point-tracker/trunk/README.txt

    r1930326 r1937055  
    66Requires PHP: 5.6
    77Tested up to: 4.9.8
    8 Stable tag: 1.3.1
     8Stable tag: 1.4
    99License: Apache-2.0
    1010License URI: https://www.apache.org/licenses/LICENSE-2.0
     
    5454= How can I create a custom page =
    5555
    56 After you've created a challenge copy the unique code for that challenge.  Create a new page at Page -> Add New.  Give it a name and whatever content you'd like.  Then where you'd like to put the challenge form simply type [challenge chal={challenge code you copied}][/challenge], then publish the page.  That is all.
     56After you've created a challenge, copy the unique code for that challenge.  Create a new page at Pages -> Add New.  Give it a name and whatever content you'd like.  Then where you'd like to put the challenge form simply type `[challenge chal={challenge code you copied}][/challenge]`, then publish the page.  That is all.  You can also create an activity page using the shortcode `[my_activity chal={code}][/my_activity]`.
    5757
    5858= I'd like a leader board =
     
    9292* Fixed bug in showing challenge list
    9393
     94= 1.4 =
     95* Fix bug in admin with start and end date formats
     96* Add documentation for creating custom challenge and activity pages
     97* Add Upgrade admin submenu (not linked right now)
     98* Extended the size of the label for radio buttons and checkboxes and answer
     99* Added a span below text fields to show character count
     100
    94101== Upgrade Notice ==
    95102
  • point-tracker/trunk/admin/class-point-tracker-admin.php

    r1929974 r1937055  
    173173        ));
    174174
     175        add_submenu_page('point-tracker-menu', 'Upgrade!', 'Upgrade!', 'manage_options', 'point-tracker-upgrade', [
     176            $this,
     177            'display_upgrade_page'
     178        ]);
     179
    175180        add_options_page("Point Tracker Settings", "PT Settings", "manage_options", "pt-settings", array(
    176181            $this,
     
    191196            "m/d/Y" => "mm/dd/yy",
    192197            "M j, Y" => "M d, yy",
    193             "F j, Y" => "MMMM d, yy",
     198            "F j, Y" => "MM d, yy",
    194199            "d/m/Y" => "dd/mm/yy"
    195200        ];
     
    231236    }
    232237
     238
     239    public function display_upgrade_page()
     240    {
     241        print <<<EOL
     242<h2>Upgrade to Point Tracker Pro</h2>
     243<p>Take your challenges to the next level with <a href='' target='_blank'>Point Tracker Pro</a></p>
     244EOL;
     245    }
     246
    233247    /**
    234248     * Render the admin options page
  • point-tracker/trunk/includes/ajax/entry-ajax.php

    r1929974 r1937055  
    133133    $member_id = filter_input(INPUT_POST, 'member-id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
    134134    $user_name = sanitize_text_field(filter_input(INPUT_POST, 'user-name', FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE));
    135     $user_email = sanitize_email(filter_input(INPUT_POST, 'user-email', FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE));
     135    $user_email = strtolower(sanitize_email(filter_input(INPUT_POST, 'user-email', FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE)));
    136136
    137137    if (! $member_id) {
     
    380380    $tp = 0;
    381381    $member_id = filter_input(INPUT_POST, 'member-id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
    382     $email = sanitize_email(filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL, FILTER_NULL_ON_FAILURE));
     382    $email = strtolower(sanitize_email(filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL, FILTER_NULL_ON_FAILURE)));
    383383    $chal_id = filter_input(INPUT_POST, 'chal-id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
    384384
  • point-tracker/trunk/includes/ajax/participant-ajax.php

    r1929974 r1937055  
    226226    $member_id = filter_input(INPUT_POST, 'member-id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
    227227    $name = sanitize_text_field(filter_input(INPUT_POST, 'user-name', FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE));
    228     $email = sanitize_email(filter_input(INPUT_POST, 'user-email', FILTER_SANITIZE_EMAIL, FILTER_NULL_ON_FAILURE));
     228    $email = strtolower(sanitize_email(filter_input(INPUT_POST, 'user-email', FILTER_SANITIZE_EMAIL, FILTER_NULL_ON_FAILURE)));
    229229    $now = new DateTime("now", new DateTimeZone(get_option("timezone_string")));
    230230
     
    319319
    320320    $name = sanitize_text_field(filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE));
    321     $email = sanitize_email(filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE));
     321    $email = strtolower(sanitize_email(filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE)));
    322322
    323323    $now = new DateTime("now", new DateTimeZone(get_option("timezone_string")));
  • point-tracker/trunk/includes/class-point-tracker-activator.php

    r1929974 r1937055  
    130130        $res = $wpdb->get_row("SHOW TABLES LIKE '{$wpdb->prefix}pt_challenges'", ARRAY_N);
    131131        if (! is_array($res) || ! count($res)) {
    132             return new WP_Error('db_failure', "Failed to create table '{$wpdb->prefix}pt_challenges");
     132            return new WP_Error('db_failure', "Failed to create table {$wpdb->prefix}pt_challenges");
    133133        }
    134134
     
    139139      `points` decimal(4,1) DEFAULT NULL,
    140140      `type` enum('checkbox','radio','text','number') NOT NULL,
    141       `label` varchar(45) DEFAULT NULL,
     141      `label` mediumtext DEFAULT NULL,
    142142      `question` varchar(100) DEFAULT NULL,
    143143      `min` int(11) DEFAULT '0',
     
    151151        $res = $wpdb->get_row("SHOW TABLES LIKE '{$wpdb->prefix}pt_activities'", ARRAY_N);
    152152        if (! is_array($res) || ! count($res)) {
    153             return new WP_Error('db_failure', "Failed to create table '{$wpdb->prefix}pt_activities");
     153            return new WP_Error('db_failure', "Failed to create table {$wpdb->prefix}pt_activities");
    154154        }
    155155
     
    168168        $res = $wpdb->get_row("SHOW TABLES LIKE '{$wpdb->prefix}pt_participants'", ARRAY_N);
    169169        if (! is_array($res) || ! count($res)) {
    170             return new WP_Error('db_failure', "Failed to create table '{$wpdb->prefix}pt_participants");
     170            return new WP_Error('db_failure', "Failed to create table {$wpdb->prefix}pt_participants");
    171171        }
    172172
     
    176176      `log_date` date NOT NULL,
    177177      `log_time` time NOT NULL,
    178       `value` varchar(255) NOT NULL DEFAULT '',
     178      `value` text NOT NULL DEFAULT '',
    179179      PRIMARY KEY (`user_id`,`activity_id`,`log_date`)
    180180    )";
     
    182182        $res = $wpdb->get_row("SHOW TABLES LIKE '{$wpdb->prefix}pt_log'", ARRAY_N);
    183183        if (! is_array($res) || ! count($res)) {
    184             return new WP_Error('db_failure', "Failed to create table '{$wpdb->prefix}pt_log");
     184            return new WP_Error('db_failure', "Failed to create table {$wpdb->prefix}pt_log");
    185185        }
    186186    }
  • point-tracker/trunk/includes/class-point-tracker.php

    r1930304 r1937055  
    7070    public function __construct()
    7171    {
    72         if (defined('PT_PLUGIN_NAME_VERSION')) {
    73             $this->version = PT_PLUGIN_NAME_VERSION;
     72        if (defined('PT_VERSION')) {
     73            $this->version = PT_VERSION;
    7474        } else {
    75             $this->version = '1.3.1';
     75            $this->version = '1.4';
    7676        }
    7777        $this->plugin_name = 'point-tracker';
  • point-tracker/trunk/point-tracker.php

    r1930304 r1937055  
    1616 * Plugin Name:       Point Tracker
    1717 * Plugin URI:        https://github.com/godsgood33/point-tracker
    18  * Description:       Allow network marketing leaders to create challenges and let people track their points.
    19  * Version:           1.3.1
     18 * Description:       Allow leaders to create challenges and let people track their points.
     19 * Version:           1.4
    2020 * Author:            Ryan Prather
    2121 * Author URI:        https://github.com/godsgood33
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define('PT_PLUGIN_NAME_VERSION', '1.3.1');
     38define('PT_VERSION', '1.4');
    3939
    4040/**
  • point-tracker/trunk/public/class-point-tracker-public.php

    r1929974 r1937055  
    172172            "m/d/Y" => "mm/dd/yy",
    173173            "M j, Y" => "M d, yy",
    174             "F j, Y" => "MMMM d, yy",
     174            "F j, Y" => "MM d, yy",
    175175            "d/m/Y" => "dd/mm/yy"
    176176        ];
  • point-tracker/trunk/public/js/point-tracker-public.min.js

    r1929974 r1937055  
    33return false;}else{if(!$("#email").val()){$("#msg").append("<div>Please enter your email</div>");$("#msg").slideToggle(300);$("#msg").addClass("warn-msg");setTimeout(function(){$("#msg").slideToggle(300);},5000);return false;}}$.ajax(ajax_object.ajax_url,{data:{action:"get-my-activity","member-id":$("#member-id").val(),"email":$("#email").val(),"chal-id":$("#chal-id").val()},beforeSend:beforeAjaxSend,complete:ajaxComplete,success:function(data){if(!check_for_error(data)){return;}$("#total-points").html(data.total_points);
    44if($.fn.DataTable.isDataTable("#my-activity-table")){table.destroy();$("#my-activity-table").empty();}table=$("#my-activity-table").DataTable({data:data.data.slice(0),columns:data.columns.slice(0),paging:false,buttons:["copyHtml5","csv","excel","pdf","print"],dom:"Bfrtip",searching:false});$(".fa-trash-alt").click(delete_activity);},error:function(xhr,status,error){console.error(error);},method:"post",dataType:"json"});}function save_activity(){var start=$(this).parent().parent();var type=$(start).find(".type").val();
    5 var value="";if(!validate_entry(start)){return;}if(type=="checkbox"){var length=$(start).find("input[type='checkbox']:checked").length;if(length>1){value=[];for(var x=0;x<length;x++){value.push($(start).find("input[type='checkbox']:checked").eq(x).val());}}else{value=$(start).find("input[type='checkbox']:checked").val();}}else{if(type=="radio"){value=$(start).find("input[type='radio']:checked").val();}else{value=$(start).find("input.value").val();}}$.ajax(ajax_object.ajax_url,{data:{"action":"save-entry","chal-link":$("#chal-link").val(),"act-id":$(start).find(".id").val(),"type":type,"value":value,"member-id":$("#member-id").val(),"user-name":$("#user-name").val(),"user-email":$("#user-email").val()},beforeSend:beforeAjaxSend,complete:ajaxComplete,success:function(data){$("#msg").html("");
     5var value="";if(!validate_entry(start)){return;}if(type=="checkbox"){var length=$(start).find("input[type='checkbox']:checked").length;if(length>1){value=[];for(var x=0;x<length;x++){value.push($(start).find("input[type='checkbox']:checked").eq(x).val());}}else{value=$(start).find("input[type='checkbox']:checked").val();}}else{if(type=="radio"){value=$(start).find("input[type='radio']:checked").val();}else{value=$(start).find("input.value").val();}}$.ajax(ajax_object.ajax_url,{data:{"action":"save-entry","chal-link":$("#chal-link").val(),"act-id":$(start).find(".id").val(),"type":type,"value":value,"member-id":$("#member-id").val(),"user-name":$("#user-name").val(),"user-email":$("#user-email").val()},beforeSend:beforeAjaxSend,complete:ajaxComplete,success:function(data){$("#msg").empty();
    66$("#msg").removeClass("err-msg,warn-msg");var duration=1500;if(data.error){$("#msg").html("<p>"+data.error+"</p>");$("#msg").addClass("err-msg");duration=5000;}else{if(data.warning){$("#msg").html("<p>"+data.warning+"</p>");$("#msg").addClass("warn-msg");duration=3000;}else{$("#msg").html("<p>Activity saved</p>");}}$("#msg").css("top",$(start).position().top+5);$("#msg").height($(start).height()+2);$("#msg").slideToggle(300);setTimeout(function(){$("#msg").slideToggle(300);},duration);},error:function(xhr,status,error){console.error(error);
    77},dataType:"json",method:"post"});}function delete_activity(){var button=$(this);$.ajax(ajax_object.ajax_url,{data:{"action":"delete-participant-activity","act-id":$(this).data("act-id"),"user-id":$(this).data("user-id"),"log-date":$(this).data("log-date"),"security":$("#_wpnonce").val()},beforeSend:beforeAjaxSend,complete:ajaxComplete,success:function(data){if(!check_for_error(data)){return;}table.row($(button).closest("tr").index()).remove().draw();},error:function(xhr,status,error){console.error(error);},dataType:"json",method:"post"});
    8 }function validate_entry(act){var numeric=/^\d+$/;var ret=true;var type=$(act).find("input.type").val();$("#msg div").remove();$("#msg").removeClass("err-msg");$("#msg").removeClass("warn-msg");if(!$("#member-id").val()||!$("#member-id").val().match(numeric)){$("#msg").append("<div>That is an invalid member ID</div>");ret=false;}if(!$("#user-name").val()){$("#msg").append("<div>You need to put your name in the form</div>");ret=false;}if(!$("#user-email").val()){$("#msg").append("<div>You need to enter your e-mail address</div>");
    9 ret=false;}if(type=="checkbox"||type=="radio"){if(!$(act).find("input[type="+type+"]:checked").length){$("#msg").append("<div>You must select one of the options</div>");ret=false;}}else{if(type=="text"){if(!$(act).find('input[type="text"]').val().length){$("#msg").append("<div>Invalid entry for this activity</div>");ret=false;}}else{if(type=="number"){var num=$(act).find('input[type="number"]').val();if(!num.match(numeric)){$("#msg").append("<div>Invalid entry for this activity</div>");ret=false;}else{if(parseInt(num)<1){$("#msg").append("<div>Invalid entry for this activity, positive numbers only</div>");
    10 ret=false;}}}}}if(!ret){$("#msg").slideToggle(300);$("#msg").addClass("warn-msg");setTimeout(function(){$("#msg").slideToggle(300);},5000);}return ret;}function check_for_error(data){$("#msg div").remove();$("#msg").removeClass("err-msg,warn-msg");var err=false;if(data=="0"){$("#msg").html("<div>There was an error</div>");$("#msg").addClass("err-msg");err=true;}else{if(data.error){$("#msg").html("<div>"+data.error+"</div>");$("#msg").addClass("err-msg");err=true;}else{if(data.warning){$("#msg").html("<div>"+data.warning+"</div>");
    11 $("#msg").addClass("warn-msg");err=true;}else{if(data.success){$("#msg").html("<div>"+data.success+"</div>");}}}}if($("#msg").html()){$("#msg").show(300);}if(err){setTimeout(function(){$("#msg").hide(300);$("#msg").html("");},3000);}else{setTimeout(function(){$("#msg").hide(300);$("#msg").html("");},1500);}return !err;}function beforeAjaxSend(){$("#loading,#waiting").show();$("#waiting").animate({"opacity":"0.5"},300,"linear");}function ajaxComplete(){$("#loading,#waiting").hide();$("#waiting").animate({"opacity":"0"},300,"linear");
    12 }var opts={lines:25,length:25,width:5,radius:50,scale:1,corners:1,color:"#000",opacity:0.25,rotate:0,direction:1,speed:0.5,trail:60,fps:20,zIndex:2000000000,className:"spinner",top:"50%",left:"50%",shadow:false,hwaccel:false,position:"absolute"};var target,spinner,table;$("#registered-challenges,#upcoming-challenges,#past-challenges").DataTable({paging:false,searching:false});$(".tooltip-field").tooltip({show:{effect:"slideDown",delay:100},hide:{effect:"slideUp",delay:250}});dialog=$("#dialog-form").dialog({autoOpen:false,height:500,width:350,modal:true,buttons:{"Join Challenge":join_challenge,Cancel:function(){dialog.dialog("close");
    13 }},close:function(){form[0].reset();}});form=dialog.find("form").on("submit",function(event){event.preventDefault();join_challenge();});$("#join-challenge").button().on("click",function(){dialog.dialog("open");});$(".save").click(save_activity);$("#get-activity").click(get_my_activity);$("#msg").hide();if($("#loading")){target=document.getElementById("loading");spinner=new Spinner(opts).spin(target);}if($("#my-activity-body tr").length){table=$("#my-activity-table").DataTable({paging:false,buttons:["copyHtml5","csv","excel","pdf","print"],dom:"Bfrtip",searching:false,stripClasses:["odd-row","even-row"],order:[[0,"asc"],[2,"asc"]]});
    14 $(".fa-trash-alt").click(delete_activity);}});
     8}function validate_entry(act){var numeric=/^\d+$/;var ret=true;var start=$(act);var type=$(act).find("input.type").val();$("#msg").empty();$("#msg").removeClass("err-msg");$("#msg").removeClass("warn-msg");$("#msg").css("top",$(start).position().top+5);$("#msg").height($(start).height()+2);if(!$("#member-id").val()||!$("#member-id").val().match(numeric)){$("#msg").append("<p>That is an invalid member ID</p>");ret=false;}if(!$("#user-name").val()){$("#msg").append("<p>You need to put your name in the form</p>");
     9ret=false;}if(!$("#user-email").val()){$("#msg").append("<p>You need to enter your e-mail address</p>");ret=false;}if(type=="checkbox"||type=="radio"){if(!$(act).find("input[type="+type+"]:checked").length){$("#msg").append("<p>You must select one of the options</p>");ret=false;}}else{if(type=="text"){if(!$(act).find('input[type="text"]').val().length){$("#msg").append("<p>Invalid entry for this activity</p>");ret=false;}}else{if(type=="number"){var field=$(act).find('input[type="number"]');var num=$(field).val();
     10var min=($(field).attr("min")?$(field).attr("min"):0);var max=($(field).attr("max")?$(field).attr("max"):0);if(!num.match(numeric)){$("#msg").append("<p>Invalid entry for this activity</p>");ret=false;}else{if(parseInt(num)<1){$("#msg").append("<p>Invalid entry for this activity, positive numbers only</p>");ret=false;}else{if(parseInt(num)<min){$("#msg").append("<p>Invalid entry for this activity, number must be greater than or equal to "+min+"</p>");ret=false;}else{if(parseInt(num)>max){$("#msg").append("<p>Invalid entry for this activity, number must be lesser than or equal to "+max+"</p>");
     11ret=false;}}}}}}}if(!ret){$("#msg").slideToggle(300);$("#msg").addClass("warn-msg");setTimeout(function(){$("#msg").slideToggle(300);$("#msg").empty();},5000);}return ret;}function check_for_error(data){$("#msg").empty();$("#msg").removeClass("err-msg,warn-msg");var err=false;if(data=="0"){$("#msg").html("<p>There was an error</p>");$("#msg").addClass("err-msg");err=true;}else{if(data.error){$("#msg").html("<p>"+data.error+"</p>");$("#msg").addClass("err-msg");err=true;}else{if(data.warning){$("#msg").html("<p>"+data.warning+"</p>");
     12$("#msg").addClass("warn-msg");err=true;}else{if(data.success){$("#msg").html("<p>"+data.success+"</p>");}}}}if($("#msg").html()){$("#msg").show(300);}if(err){setTimeout(function(){$("#msg").hide(300);$("#msg").empty();},3000);}else{setTimeout(function(){$("#msg").hide(300);$("#msg").empty();},1500);}return !err;}function beforeAjaxSend(){$("#loading,#waiting").show();$("#waiting").animate({"opacity":"0.5"},300,"linear");}function ajaxComplete(){$("#loading,#waiting").hide();$("#waiting").animate({"opacity":"0"},300,"linear");
     13}var opts={lines:25,length:25,width:5,radius:50,scale:1,corners:1,color:"#000",opacity:0.25,rotate:0,direction:1,speed:0.5,trail:60,fps:20,zIndex:2000000000,className:"spinner",top:"50%",left:"50%",shadow:false,hwaccel:false,position:"absolute"};var target,spinner,table;$(".text-max").keyup(function(){$("#text-len-"+$(this).attr("id")).text($(this).val().length);});$("#registered-challenges,#upcoming-challenges,#past-challenges").DataTable({paging:false,searching:false});$(".tooltip-field").tooltip({show:{effect:"slideDown",delay:100},hide:{effect:"slideUp",delay:250}});
     14dialog=$("#dialog-form").dialog({autoOpen:false,height:500,width:350,modal:true,buttons:{"Join Challenge":join_challenge,Cancel:function(){dialog.dialog("close");}},close:function(){form[0].reset();}});form=dialog.find("form").on("submit",function(event){event.preventDefault();join_challenge();});$("#join-challenge").button().on("click",function(){dialog.dialog("open");});$(".save").click(save_activity);$("#get-activity").click(get_my_activity);$("#msg").hide();if($("#loading")){target=document.getElementById("loading");
     15spinner=new Spinner(opts).spin(target);}if($("#my-activity-body tr").length){table=$("#my-activity-table").DataTable({paging:false,buttons:["copyHtml5","csv","excel","pdf","print"],dom:"Bfrtip",searching:false,stripClasses:["odd-row","even-row"],order:[[0,"asc"],[2,"asc"]]});$(".fa-trash-alt").click(delete_activity);}});
  • point-tracker/trunk/public/partials/point-tracker-challenge-pg.php

    r1929974 r1937055  
    126126
    127127                print <<<EOR
    128 <label for='$id'>$label</label>&nbsp;&nbsp;
    129 <input type='{$act->type}' class='value' id='$id' value='$label' /><br />
     128<input type='{$act->type}' class='value' id='$id' value='$label' />&nbsp;&nbsp;
     129<label for='$id'>$label</label><br />
    130130EOR;
    131131            }
     
    138138
    139139            $inputmode = ($act->type == 'number' ? " inputmode='numeric' pattern='[0-9]*'" : null);
    140 
    141             print "<input type='{$act->type}' class='value' id='$id'$inputmode $min $max $val />&nbsp;&nbsp;";
     140            $text_max = ($act->type == 'text' && $act->max ? " text-max" : null);
     141
     142            print "<input type='{$act->type}' class='value$text_max' id='$id'$inputmode $min $max $val />&nbsp;&nbsp;";
     143            print ($act->type == 'text' && $act->max ? "<br />(<span id='text-len-{$id}'>0</span> / {$act->max})" : null);
    142144        }
    143145
     
    220222
    221223                print <<<EOR
    222 <label for='$id'>$label</label>&nbsp;&nbsp;
    223 <input type='{$act->type}' class='value' id='$id' value='$label' /><br />
     224<input type='{$act->type}' class='value' id='$id' value='$label' />&nbsp;&nbsp;
     225<label for='$id'>$label</label><br />
    224226EOR;
    225227            }
     
    232234
    233235            $inputmode = ($act->type == 'number' ? " inputmode='numeric' pattern='[0-9]*'" : null);
    234 
    235             print "<input type='{$act->type}' class='value' id='$id'$inputmode $min $max $val />&nbsp;&nbsp;";
     236            $text_max = ($act->type == 'text' && $act->max ? " text-max" : null);
     237
     238            print "<input type='{$act->type}' class='value$text_max' id='$id'$inputmode $min $max $val />&nbsp;&nbsp;";
     239            print ($act->type == 'text' && $act->max ? "<br />(<span id='text-len-{$id}'>0</span> / {$act->max})" : null);
    236240        }
    237241
Note: See TracChangeset for help on using the changeset viewer.