Ejemplo n.º 1
0
 /**
  * Mange column data
  *
  * Default Column for listing table
  * 
  * @package Easy Digital Downloads - Currency Converter
  * @since 1.0.0
  */
 function column_default($item, $column_name)
 {
     global $edd_options;
     switch ($column_name) {
         case 'post_content':
             return $item[$column_name] . '<input type="hidden" name="edd_currency_sort_order[]" value="' . $item['ID'] . '" />';
         case 'post_drag':
         case 'post_title':
         case 'symbol':
         case 'custom_rate':
         case 'post_date':
             return $item[$column_name];
         case 'open_ex_rate':
             if (isset($edd_options['exchange_rates_method']) && $edd_options['exchange_rates_method'] != 'custom_rates') {
                 $open_exchange_rates = edd_currency_get_open_exchange_rates();
                 if (isset($open_exchange_rates['rates'][$item['post_title']])) {
                     return $open_exchange_rates['rates'][$item['post_title']];
                 }
             }
             return __('N/A', 'eddcurrency');
         default:
             return print_r($item, true);
             //Show the whole array for troubleshooting purposes
     }
 }
/**
 * Get Open Exchange Rate based on code
 * 
 * Handles to get open exchange rate based on code
 * 
 * @package Easy Digital Downloads - Currency Converter
 * @since 1.0.0
 **/
function edd_currency_get_open_exchange_rate_by_code($currency_code)
{
    global $edd_options;
    //check exchange method is open exchange or not
    if (!empty($currency_code) && isset($edd_options['exchange_rates_method']) && $edd_options['exchange_rates_method'] == 'open_exchange') {
        //get open exchange rates
        $open_exchange = edd_currency_get_open_exchange_rates();
        //check is there any base exchange rate is set or not
        if (isset($open_exchange['rates'][$currency_code])) {
            return $open_exchange['rates'][$currency_code];
        }
    }
    //end else
    return false;
}
    } else {
        $data = $_POST;
    }
} else {
    //currency page title
    $currency_lable = __('Add New Currency', 'eddcurrency');
    //currency page submit button text either it is Add or Update
    $currency_btn = __('Save', 'eddcurrency');
    //if when error occured then assign $_POST to be field fields with none error fields
    if ($_POST) {
        //check if $_POST is set then set all $_POST values
        $data = $_POST;
    }
}
if (isset($edd_options['exchange_rates_method']) && $edd_options['exchange_rates_method'] != 'custom_rates') {
    $open_exchange_rates = edd_currency_get_open_exchange_rates();
    if (isset($open_exchange_rates['rates'][$data['edd_currency_code']])) {
        $data['edd_currency_open_ex_rate'] = $open_exchange_rates['rates'][$data['edd_currency_code']];
    }
}
$html .= '<div class="wrap">';
$html .= screen_icon('options-general');
$html .= '<h2>' . __($currency_lable, 'eddcurrency') . '<a class="add-new-h2" href="edit.php?post_type=download&page=edd_currency_converter">' . __('Go Back', 'eddcurrency') . '</a></h2>';
if (isset($errmsg['edd_currency_code']) && !empty($errmsg['edd_currency_code'])) {
    //check error message for currency title
    $html .= '<div class="updated settings-error" id="setting-error-settings_updated">
					<p><strong>' . $errmsg['edd_currency_code'] . '</strong></p>
				</div>';
}
$html .= '<!-- beginning of the currency meta box -->