Plugin Directory

Changeset 2798476


Ignore:
Timestamp:
10/13/2022 06:42:43 PM (3 years ago)
Author:
era404
Message:

Added a new shortcode attribute , where n is the column to be use for sorting when StaffList is first rendered (Your website visitors may still change the sort as they please afterward). Hover the column names in the admin page to reference column numbers that can be used. Per request by @jorniel1 (Thank you);

Location:
stafflist/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • stafflist/trunk/readme.txt

    r2718709 r2798476  
    103103
    104104== Changelog ==
     105= 3.1.9 =
     106* Added a new shortcode attribute `sort=n`, where n is the column to be use for sorting when StaffList is first rendered (Your website visitors may still change the sort as they please afterward). Hover the column names in the admin page to reference column numbers that can be used. Per request by @jorniel1 (Thank you);
     107
     108= 3.1.8 =
     109* Rewrote a $wpdb->prepare statement that was producing a WP deprecated warning;
    105110
    106111= 3.1.7 =
  • stafflist/trunk/stafflist.js

    r2458455 r2798476  
    6363        var data = {    action: 'ajax_build',
    6464                        wait:   wait,
     65                        sort:   form.find("input[rel='sl_sort']").val(),
    6566                        rows:   form.find("input[rel='sl_rows']").val() }
    6667       
  • stafflist/trunk/stafflist.php

    r2718709 r2798476  
    44Plugin URI: http://wordpress.org/plugins/stafflist/
    55Description: A super simplified staff directory tool
    6 Version: 3.1.7
     6Version: 3.1.9
    77Author: era404
    88Author URI: http://www.era404.com
     
    233233    } else {
    234234        $w = false;
    235         $where = "";
    236         $params = array();
     235        $where = "WHERE 1=%d";
     236        $params = array(1);
    237237    }
    238238   
     
    263263                You can insert the StaffList directory into any WordPress page or post using the shortcode:<br />
    264264                    <tt>[stafflist]</tt><br />
    265                 If you wish to change the default number of rows from {$rows} per page, use the shortcode attribute:<br />
    266                     <tt style='color:#0073AA; font-weight:bold;'>[stafflist <span>rows=50</span>]</tt><br /> 
    267                 If you wish to use just a subset of records, use the shortcode attribute:<br />
     265                If you wish to change the default number of rows from {$rows} per page, use the shortcode <strong>rows</strong> attribute:<br />
     266                    <tt style='color:#0073AA; font-weight:bold;'>[stafflist <span>rows=50</span>]</tt><br />
     267                To specify the initial sort column, hover the column names below to find its number, and use it in the shortcode <strong>sort</strong> attribute:<br />
     268                    <tt style='color:#0073AA; font-weight:bold;'>[stafflist <span>sort=4</span>]</tt><br />
     269                If you wish to use just a subset of records, use the shortcode <strong>subset</strong> attribute:<br />
    268270                    <tt style='color:#0073AA; font-weight:bold;'>[stafflist <span>subset=&quot;department:marketing&quot;</span>]</tt><br />
    269                 If you have a column in your StaffList called &quot;Building&quot; and wish to show records from Building A and Building B, use:<br />
     271                If you have a column in your StaffList called &quot;Building&quot; and wish to show only records from Building A and Building B, use:<br />
    270272                    <tt style='color:#0073AA; font-weight:bold;'>[stafflist <span>subset=&quot;building:a|b&quot;</span>]</tt><br />
    271273                Searches are performed as you type and when the enter key is pressed.
    272                 If you wish to limit this function to just enter (or just type), use:<br />
     274                To limit this function to just enter (or just type), use:<br />
    273275                    <tt style='color:#0073AA; font-weight:bold;'>[stafflist <span>on=&quot;enter&quot;</span>]</tt> or
    274276                    <tt style='color:#0073AA; font-weight:bold;'>[stafflist <span>on=&quot;type&quot;</span>]</tt><br />
     
    295297          <table id='stafflists' style='border:1px solid #E8E8E8;'>";
    296298    echo "<thead id='stafflisthead'><tr>
    297             <th><a href='{$stafflisturl}&s=last' title='Sort by Last Name A-Z' class='sort_a ".($s=='last'?'selected':'')."'><span>Ascending</span></a> Last Name
     299            <th><a href='{$stafflisturl}&s=last' title='Sort by Last Name A-Z' class='sort_a ".($s=='last'?'selected':'')."'><span>Ascending</span></a>
     300                <a title='For initial sort by Last Name, use &quot;sort=1&quot; in your shortcode.'>Last Name</a>
    298301                <a href='{$stafflisturl}&s=last-' title='Sort by Last Name Z-A' class='sort_d ".($s=='last-'?'selected':'')."'><span>Descending</span></a>
    299302            </th><th>&nbsp;</th>
    300             <th><a href='{$stafflisturl}&s=first' title='Sort by First Name Ascending' class='sort_a ".($s=='first'?'selected':'')."'><span>Ascending</span></a> First Name
     303            <th><a href='{$stafflisturl}&s=first' title='Sort by First Name Ascending' class='sort_a ".($s=='first'?'selected':'')."'><span>Ascending</span></a>
     304                <a title='For initial sort by First Name, use &quot;sort=2&quot; in your shortcode.'>First Name</a>
    301305                <a href='{$stafflisturl}&s=first-' title='Sort by First Name Descending' class='sort_d ".($s=='first-'?'selected':'')."'><span>Descending</span></a>
    302306            </th><th>&nbsp;</th>
    303             <th><a href='{$stafflisturl}&s=dept' title='Sort by Department Ascending' class='sort_a ".($s=='dept'?'selected':'')."'><span>Ascending</span></a> Department
     307            <th><a href='{$stafflisturl}&s=dept' title='Sort by Department Ascending' class='sort_a ".($s=='dept'?'selected':'')."'><span>Ascending</span></a>
     308                <a title='For initial sort by Department, use &quot;sort=3&quot; in your shortcode.'>Department</a>
    304309                <a href='{$stafflisturl}&s=dept-' title='Sort by Department Descending' class='sort_d ".($s=='dept-'?'selected':'')."'><span>Descending</span></a>
    305310            </th><th>&nbsp;</th>
    306             <th><a href='{$stafflisturl}&s=email' title='Sort by Email Address Ascending' class='sort_a ".($s=='email'?'selected':'')."'><span>Ascending</span></a> Email Address
     311            <th><a href='{$stafflisturl}&s=email' title='Sort by Email Address Ascending' class='sort_a ".($s=='email'?'selected':'')."'><span>Ascending</span></a>
     312                <a title='For initial sort by Email Address, use &quot;sort=4&quot; in your shortcode.'>Email Address
    307313                <a href='{$stafflisturl}&s=email-' title='Sort by Email Address Descending' class='sort_d ".($s=='email-'?'selected':'')."'><span>Descending</span></a>
    308314            </th><th>&nbsp;</th>
     
    315321        $del = "<a href='".wp_nonce_url("{$stafflisturl}&remove={$v['id']}&p={$p}&s={$s}")."' class='remove'
    316322                   onclick='javascript:if(!confirm(\"Are you sure you want to delete this staff record?\")) return false;'
    317                    title='Permanently Delete This Staff Record' target='_self'
    318                 /></a>";
     323                   title='Permanently Delete This Staff Record' target='_self'></a>";
    319324        $i++;
    320325       
     
    950955        $active = 0;
    951956        foreach($nonstd as $k=>$col) {
    952             echo "<th>{$col['name']}</th><th>&nbsp;</th>";
     957            echo "\n\t\t\t<th>\n".
     958                 "\t\t\t\t<a title='For initial sort by ".esc_attr($col['name']).", use &quot;sort={$col['id']}&quot; in your shortcode.'>{$col['name']}</a>\n".
     959                 "\t\t\t</th>\n\t\t\t<th>&nbsp;</th>";
    953960            $active++;
    954961        }
     
    12181225
    12191226    //default sort
    1220     if(!$sort = $wpdb->get_var("SELECT id FROM {$staffmetadb} WHERE active>0 ORDER BY colpos ASC LIMIT 1")) $sort = 1;
     1227    if(isset($atts['sort']) &&
     1228        is_numeric($atts['sort']) &&
     1229        $wpdb->get_var($wpdb->prepare("SELECT active FROM {$staffmetadb} WHERE id=%d", (int) $atts['sort']))==1){
     1230            $sort = (int) $atts['sort']; //shortcode sort=#
     1231    } elseif(!$sort = $wpdb->get_var("SELECT id FROM {$staffmetadb} WHERE active>0 ORDER BY colpos ASC LIMIT 1")){
     1232        $sort = 1;
     1233    }
    12211234    //number of results rows
    12221235    if(isset($atts['rows']) && is_numeric($atts['rows']) && $atts['rows'] > 0 && $atts['rows'] <= 100) $rows = $atts['rows'];
     
    12251238    //search on
    12261239    if(isset($atts['on']) && in_array($atts['on'],array("enter","type","wait"))) $on=$atts['on'];
     1240
    12271241    //custom messaging
    12281242    $searchdir = get_option("stafflist_rename_searchdir"); //use custom message, if set
  • stafflist/trunk/stafflist_admin.css

    r2550014 r2798476  
    103103    background-color: #cfcfcf;
    104104    font-weight: bold;
     105    cursor: pointer;
     106}
     107#stafflisthead tr th a {
     108    cursor: pointer;
    105109}
    106110tr.row {
Note: See TracChangeset for help on using the changeset viewer.