Well, here's some small changes made to the code to improve the shortcodes available for users. This essentially allows you to use shortcodes to determine a gallery's sorting order and type. The changes are very minimal, however, and could well be improved upon: this is purely to get a working version out, for Byron to adapt (should he so wish).
Anyways...
bwbps-layout.php:
Line 2702: Change to
$sortorder = $g['sort_order']>0 || strtolower($g['sort_order']) == 'asc' ? "ASC" : "DESC";
- Sets the order to the correct string, allowing either numerical or string-based parameters. Defaults to 'DESC'.
Line 2711: Change to
if( (int)$g['sort_field'] == 4 || $g['sort_field'] == "rank"){
- Allows correct generation of ranking SQL if sort_field is set to 'rank'. It should really be checking against a value defined elsewhere, to allow you to change the short_code strings independently of the rest of your code.
Lines 3050: Change to
switch ( (string)$g['sort_field'] ){
case "sequence" :
case "1" : // Custom Sort
$sortby = PSIMAGESTABLE.'.seq, '.PSIMAGESTABLE.'.created_date '. $sortorder;
break;
/* -- Not implemented --
case "custom" :
case "2" :
*/
case "user" :
case "3" : // User IDs
$sortby = PSIMAGESTABLE.'.user_id ' . $sortorder . ', '.PSIMAGESTABLE.'.seq';
break;
case "user_name" :
case "6" : // User Name
$sortby = $wpdb->users.'.user_nicename ' . $sortorder . ', ' . $wpdb->users.'.user_login ' . $sortorder . ', '.PSIMAGESTABLE.'.seq';
break;
case "user_login" :
case "7" : // User Login
$sortby = $wpdb->users.'.user_login ' . $sortorder . ', ' . $wpdb->users.'.user_nicename ' . $sortorder . ', '.PSIMAGESTABLE.'.seq';
break;
case "rank" :
case "4" : // Rating
switch ((int)$g['poll_id'] ) {
case -2 : // Vote up /vote down
$sortby = 'bwbps_br_rating '. $sortorder . ', '.PSIMAGESTABLE.'.votes_cnt DESC ';
break;
case -3 : // Vote up
$sortby = 'votes_sum '
. $sortorder . ', '.PSIMAGESTABLE.'.votes_cnt ASC, '.PSIMAGESTABLE.'.seq';
break;
// Default to Bayesian sorting
default :
$sortby = 'bwbps_br_rating '
. $sortorder . ', '.PSIMAGESTABLE.'.seq';
break;
}
break;
case "favourites" :
case "5" : // Favorites Count
$sortby = PSIMAGESTABLE.'.favorites_cnt ' . $sortorder . ', '.PSIMAGESTABLE.'.seq';
break;
// Default to created date
default : // When Uploaded
$sortby = PSIMAGESTABLE.'.created_date '
. $sortorder . ', '.PSIMAGESTABLE.'.seq';
break;
}
- Essentially creates string aliases for each of case conditions. Removed those that are the same as the default conditions, and commented out the custom search, given that that isn't implemented in the latest release version.
bwb-photosmash.php:
Line 862: Append with
'sort_field' => false, // Custom - allows sorting
'sort_order' => 0 // Same as above
- Fairly obviously adds to array of tags to extract from shortcode. Ensure that the 'piclens_class' value is followed with a comma.
Line 1021: Add
// Custom - allow specification of sorting
if(isset($sort_order)) $galparams['sort_order'] = $sort_order;
if(isset($sort_field)) $galparams['sort_field'] = $sort_field;
- Once you've done all the default Photosmash behaviour, check to see if we've set the two custom variables, and override any default values generated.
Lines 1607 & 1609: Replace with
$data['sort_field'] = isset($data['sort_field']) ? $data['sort_field'] : $this->psOptions['sort_field'];
$data['sort_order'] = isset($data['sort_order']) ? $data['sort_order'] : $this->psOptions['sort_order'];
- Ensures that we're not typecasting these variables as integers
...And that should be that! Try it out yourself by using the shortcode. For instance, "[photosmash id=2 sort_field=rank sort_order=ASC]".
Hope this proves useful!