Last active
February 27, 2017 07:09
-
-
Save BhargavBhandari90/b0df12e7515661b5b896a85741f59c5d to your computer and use it in GitHub Desktop.
Default sorting option
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* Sorts media on page load accoeging to perameters passed | |
* Use this function when rtmedia-sorting plugin is active | |
* | |
*/ | |
function rtmedia_custom_order_by( $order_by ) { | |
// if it's not json data | |
if ( ! isset( $_REQUEST['json'] ) ) { | |
// 'media_id ASC'; // for Upload Date (ASC) | |
// 'media_id DESC'; // for Upload Date (DESC) | |
// 'file_size ASC'; // for Size (ASC) | |
// 'file_size DESC'; // for Size (DESC) | |
// 'media_title ASC'; // for Title (ASC) | |
$order_by = 'media_title ASC'; | |
} | |
return $order_by; | |
} | |
add_filter( 'rtmedia_model_order_by', 'rtmedia_custom_order_by' ); | |
/** | |
* | |
* Sets parameter in hidden field for order by | |
* | |
*/ | |
function rtmedia_upload_hf_sort_by( $sort_by ) { | |
// if it's not json data | |
if ( ! isset( $_REQUEST['json'] ) ) { | |
// 'title': if Title (ASC OR DESC) | |
// 'date' : if Upload date (ASC OR DESC) | |
// 'size' : if file size (ASC OR DESC) | |
$sort_by = 'title'; | |
} | |
return $sort_by; | |
} | |
add_filter( 'rt_upload_hf_sort_by', 'rtmedia_upload_hf_sort_by' ); | |
/** | |
* | |
* Sets parameter in hidden field for sort order | |
* | |
*/ | |
function rtmedia_upload_hf_sort_order( $sort_order ) { | |
// if it's not json data | |
if ( ! isset( $_REQUEST['json'] ) ) { | |
// 'desc' : if title, size or date DESC | |
// 'asc' : if title, size or date ASC | |
$sort_order = 'asc'; | |
} | |
return $sort_order; | |
} | |
add_filter( 'rt_upload_hf_sort_order', 'rtmedia_upload_hf_sort_order' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment