Advertisement
businessdad

EDD Currency Switcher - Sort the list of currencies

Apr 23rd, 2018
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.77 KB | None | 0 0
  1. /**
  2.  * Sorts the list of currencies displayed on the currency selector widget.
  3.  *
  4.  * HOW TO USE THIS CODE
  5.  * Add the code to the bottom of your theme's functions.php file, and it
  6.  * will run automatically. For more information: https://www.skyverge.com/blog/add-custom-code-to-wordpress/
  7.  *
  8.  * GPL DISCLAIMER
  9.  * Because this code program is free of charge, there is no warranty for it, to the extent permitted by applicable law.
  10.  * Except when otherwise stated in writing the copyright holders and/or other parties provide the program "as is"
  11.  * without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of
  12.  * merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program
  13.  * is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
  14.  *
  15.  * Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us
  16.  *
  17.  * @param array currencies An array of currencies passed by the widget.
  18.  * @param string widget_type The type of widget beind displayed (e.g. 'dropdown' or 'buttons').
  19.  * @param string widget_title The widget title
  20.  * @param string widget_template_name The template file that is going to be used to render the widget.
  21.  * @return array
  22.  */
  23. function custom_sort_currencies($currencies, $widget_type, $widget_title, $widget_template_name) {
  24.   // Sort the list of currencies before returning it
  25.   $sorted_currencies = array(
  26.     'USD' => $currencies['USD'],
  27.     'GBP' => $currencies['GBP'],
  28.     'EUR' => $currencies['EUR'],
  29.   );
  30.  
  31.   return $sorted_currencies;
  32. }
  33. add_filter('edd_aelia_currencyswitcher_widget_currency_options', 'custom_sort_currencies', 10, 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement