zZzzZ.
home2
/
zrzvbdry
/
public_html
/
wp-content
/
plugins
/
wc-multi-currency
/
appcore
New Folder
Editing: plugin_helper.php
Save
Cancel
<?php /** * @since: 07/09/2019 * @author: Sarwar Hasan * @version 1.0.0 */ if ( ! function_exists('APBD_get_mc_currency_symbols')) { function APBD_get_mc_currency_symbols($code='') { $codes=apply_filters( 'woocommerce_currency_symbols', array( 'AED' => 'د.إ', 'AFN' => '؋', 'ALL' => 'L', 'AMD' => 'AMD', 'ANG' => 'ƒ', 'AOA' => 'Kz', 'ARS' => '$', 'AUD' => '$', 'AWG' => 'Afl.', 'AZN' => 'AZN', 'BAM' => 'KM', 'BBD' => '$', 'BDT' => '৳ ', 'BGN' => 'лв.', 'BHD' => '.د.ب', 'BIF' => 'Fr', 'BMD' => '$', 'BND' => '$', 'BOB' => 'Bs.', 'BRL' => 'R$', 'BSD' => '$', 'BTC' => '฿', 'BTN' => 'Nu.', 'BWP' => 'P', 'BYR' => 'Br', 'BYN' => 'Br', 'BZD' => '$', 'CAD' => '$', 'CDF' => 'Fr', 'CHF' => 'CHF', 'CLP' => '$', 'CNY' => '¥', 'COP' => '$', 'CRC' => '₡', 'CUC' => '$', 'CUP' => '$', 'CVE' => '$', 'CZK' => 'Kč', 'DJF' => 'Fr', 'DKK' => 'DKK', 'DOP' => 'RD$', 'DZD' => 'د.ج', 'EGP' => 'EGP', 'ERN' => 'Nfk', 'ETB' => 'Br', 'EUR' => '€', 'FJD' => '$', 'FKP' => '£', 'GBP' => '£', 'GEL' => '₾', 'GGP' => '£', 'GHS' => '₵', 'GIP' => '£', 'GMD' => 'D', 'GNF' => 'Fr', 'GTQ' => 'Q', 'GYD' => '$', 'HKD' => '$', 'HNL' => 'L', 'HRK' => 'kn', 'HTG' => 'G', 'HUF' => 'Ft', 'IDR' => 'Rp', 'ILS' => '₪', 'IMP' => '£', 'INR' => '₹', 'IQD' => 'ع.د', 'IRR' => '﷼', 'IRT' => 'تومان', 'ISK' => 'kr.', 'JEP' => '£', 'JMD' => '$', 'JOD' => 'د.ا', 'JPY' => '¥', 'KES' => 'KSh', 'KGS' => 'сом', 'KHR' => '៛', 'KMF' => 'Fr', 'KPW' => '₩', 'KRW' => '₩', 'KWD' => 'د.ك', 'KYD' => '$', 'KZT' => 'KZT', 'LAK' => '₭', 'LBP' => 'ل.ل', 'LKR' => 'රු', 'LRD' => '$', 'LSL' => 'L', 'LYD' => 'ل.د', 'MAD' => 'د.م.', 'MDL' => 'MDL', 'MGA' => 'Ar', 'MKD' => 'ден', 'MMK' => 'Ks', 'MNT' => '₮', 'MOP' => 'P', 'MRU' => 'UM', 'MUR' => '₨', 'MVR' => '.ރ', 'MWK' => 'MK', 'MXN' => '$', 'MYR' => 'RM', 'MZN' => 'MT', 'NAD' => '$', 'NGN' => '₦', 'NIO' => 'C$', 'NOK' => 'kr', 'NPR' => '₨', 'NZD' => '$', 'OMR' => 'ر.ع.', 'PAB' => 'B/.', 'PEN' => 'S/', 'PGK' => 'K', 'PHP' => '₱', 'PKR' => '₨', 'PLN' => 'zł', 'PRB' => 'р.', 'PYG' => '₲', 'QAR' => 'ر.ق', 'RMB' => '¥', 'RON' => 'lei', 'RSD' => 'дин.', 'RUB' => '₽', 'RWF' => 'Fr', 'SAR' => 'ر.س', 'SBD' => '$', 'SCR' => '₨', 'SDG' => 'ج.س.', 'SEK' => 'kr', 'SGD' => '$', 'SHP' => '£', 'SLL' => 'Le', 'SOS' => 'Sh', 'SRD' => '$', 'SSP' => '£', 'STN' => 'Db', 'SYP' => 'ل.س', 'SZL' => 'L', 'THB' => '฿', 'TJS' => 'ЅМ', 'TMT' => 'm', 'TND' => 'د.ت', 'TOP' => 'T$', 'TRY' => '₺', 'TTD' => '$', 'TWD' => 'NT$', 'TZS' => 'Sh', 'UAH' => '₴', 'UGX' => 'UGX', 'USD' => '$', 'UYU' => '$', 'UZS' => 'UZS', 'VEF' => 'Bs F', 'VES' => 'Bs.S', 'VND' => '₫', 'VUV' => 'Vt', 'WST' => 'T', 'XAF' => 'CFA', 'XCD' => '$', 'XOF' => 'CFA', 'XPF' => 'Fr', 'YER' => '﷼', 'ZAR' => 'R', 'ZMW' => 'ZK', ) ); if(!empty($code)){ return isset($codes[$code])? $codes[ $code ]:""; } return $codes; } } if ( ! function_exists('APBD_mc_get_currency_html_options')) { /** * @return APBDWMC_currency_item|array */ function APBD_mc_get_currency_html_options( $selected = '' ) { $currencies=get_woocommerce_currencies(); $currency_symbols=APBD_get_mc_currency_symbols(); //$curItems = getCurrencyItems(); foreach ( $currencies as $code=>$name ) { ?> <option value="<?php echo esc_attr($code); ?>" <?php echo ( ($selected == $code) ? " selected " : ""); ?>><?php echo esc_html($name.(!empty($currency_symbols[$code])?' ('.$currency_symbols[$code].')':'')); ?></option> <?php } } } if ( ! function_exists('APBD_get_mc_currency_row')) { /** * @param APBDWC_currency_item $currencyData */ function APBD_get_mc_currency_row($currencyData){ $app=APBDWooComMultiCurrency::GetInstance(); if(!empty($currencyData->code)){ $currencySymbol = APBD_get_mc_currency_symbols( $currencyData->code ); }else { $currencySymbol = APBD_get_mc_currency_symbols( 'USD' ); } ?> <tr id="tr_<?php echo esc_attr($currencyData->id); ?>" data-currency-id="<?php echo esc_attr($currencyData->id); ?>" class="apbd-cur-container"> <td> <h6 class="title"><?php $app->_e("Default"); ?></h6> <div class="wrap wrap-default"> <div class="ht-mcs-radio"> <input class="apbd-mc-default" id="mc-default-<?php echo esc_attr($currencyData->id); ?>" data-msg="<?php $app->_e("Are you sure to change the default currency? If yes then your need to review rate of other currency"); ?>" data-title="<?php $app->_e("Confirmation") ; ?>" name="is_default" value="<?php echo esc_attr($currencyData->id); ?>" type="radio" <?php echo ($currencyData->is_default)?' checked ':''; ?>> <label for="mc-default-<?php echo esc_attr($currencyData->id); ?>" title="Select Default"><span class="sr-only"><?php $app->_e("check one"); ?></span></label> </div> </div> </td> <td> <h6 class="title"><?php $app->_e("Show"); ?></h6> <div class="wrap wrap-show-hide"> <select name="mc_is_show" class="apbd-cur-input"> <option <?php echo esc_attr($currencyData->is_show?'selected':'') ?> value="Yes"><?php $app->_e("Show"); ?></option> <option <?php echo esc_attr($currencyData->is_show?'':'selected') ?> value="No"><?php $app->_e("Hide"); ?></option> </select> </div> </td> <td> <h6 class="title"><?php $app->_e("Currency"); ?></h6> <div class="wrap wrap-currency"> <select class="select-currency apbd-cur-input" name="mc_code" title="<?php $app->_e("Select Currency"); ?>"> <?php APBD_GetHTMLOption("",$app->__("Select")); APBD_mc_get_currency_html_options($currencyData->code);?> </select> </div> </td> <td> <h6 class="title"><?php $app->_e("Position"); ?></h6> <div class="wrap wrap-position"> <select class="select-position apbd-cur-input" name="mc_position" title="Select symbol position"> <?php APBD_GetHTMLOption("left",$app->__("Left %s99",$currencySymbol),$currencyData->position); ?> <?php APBD_GetHTMLOption("right",$app->__("Right 99%s",$currencySymbol),$currencyData->position); ?> <?php APBD_GetHTMLOption("left_space",$app->__("Left with space %s 99",$currencySymbol),$currencyData->position); ?> <?php APBD_GetHTMLOption("right_space",$app->__("Left with space 99 %s",$currencySymbol),$currencyData->position); ?> </select> </div> </td> <td> <h6 class="title"><?php $app->_e("Rate"); ?></h6> <div class="wrap wrap-fee"> <input type="number" class="apbd-cur-input input-field text-center" name="mc_rate" step="0.1" placeholder="Rate" value="<?php echo esc_attr($currencyData->rate); ?>" title="<?php $app->_e("Exchange Rate"); ?>"> <button class="btn btn-info btn-box apbd-mc-up-rate" title="Update Rate"><i class="fa fa-refresh"></i></button> </div> </td> <td> <h6 class="title"><?php $app->_e("Exchange Fee"); ?></h6> <div class="wrap wrap-rate"> <input type="number" class="apbd-cur-input input-field text-center" name="mc_ex_fee" step="0.1" placeholder="<?php $app->_e("Ex.Fee"); ?>" value="<?php echo esc_attr($currencyData->ex_fee); ?>" title="<?php $app->_e("Exchange Fee"); ?>"> </div> </td> <td> <h6 class="title"><?php $app->_e("Decimals"); ?></h6> <div class="wrap wrap-decimals"><input class="apbd-cur-input input-field text-center" name="mc_dec_num" type="number" value="<?php echo esc_attr($currencyData->dec_num); ?>" title="<?php $app->_e("Decimals"); ?>"></div> </td> <td> <h6 class="title"><?php $app->_e("Custom Symbol"); ?></h6> <div class="wrap wrap-rate"><input class="apbd-cur-input input-field text-center" type="text" name="mc_custom_symbol" value="<?php echo esc_attr($currencyData->custom_symbol); ?>" placeholder="" title="<?php $app->_e("Custom Symbol"); ?>"></div> </td> <td> <h6 class="title"><?php $app->_e("Actions"); ?></h6> <div class="wrap wrap-action"> <div class=" flex-nowrap"> <a href="<?php echo esc_url(APBDWMC_general::GetModuleActionUrl("delete-currency",["id"=>$currencyData->id])); ?>" data-msg="<?php $app->_e("Are you sure to delete?"); ?>" data-on-complete="APPSBDAPPJS_MC.General.OnRowDeleted" class="btn btn-danger btn-box ConfirmAjaxWR" title="<?php $app->_e("Remove") ; ?>"><i class="fa fa-trash-o"></i></a> </div> </div> </td> </tr> <?php } } if ( ! function_exists('getCurrencyCountryRow')) { /** * @param APBDWC_currency_item $currencyData */ function getCurrencyCountryRow($currencyData,$selected=[]){ $app=APBDWooComMultiCurrency::GetInstance(); if(empty($currencyData->code)){ $currencyName = $app->__("Not selected yet"); $currencySymbol = ""; }else { $currencies = get_woocommerce_currencies(); $currencyName = ! empty( $currencies[ $currencyData->code ] ) ? $currencies[ $currencyData->code ] : $currencyData->code; if ( ! empty( $currencyData->code ) ) { $currencySymbol = APBD_get_mc_currency_symbols( $currencyData->code ); } else { $currencySymbol = APBD_get_mc_currency_symbols( 'USD' ); } } $countries=WC()->countries->countries; ?> <tr id="cloc-<?php echo esc_attr($currencyData->id); ?>"> <td class="align-top" style="width: 30%"> <h6 class="title"><?php $app->_e("Currency"); ?></h6> <div class="wrap wrap-currency apbd-cur-title"> <?php if(empty($currencyData->code)){ echo esc_attr($currencyName); }else { echo esc_attr($currencyData->code . " - " . $currencyName . " (" . $currencySymbol . ")"); }?> </div> </td> <td> <h6 class="title"><?php $app->_e("Countries"); ?></h6> <div class=""> <select class="select-position countries-container apbd-app-multi-select" name="currency_location[<?php echo esc_attr($currencyData->id); ?>][]" multiple="multiple" data-selectedvalue="<?php echo implode(",",$selected); ?>"> <?php foreach ( $countries as $ccode=>$country ) { ?> <option value="<?php echo esc_attr($ccode); ?>" <?php echo esc_attr(in_array($ccode,$selected)?' selected ="selected" ':""); ?>><?php echo esc_attr($country); ?></option> <?php } ?> </select> <div class="mt-1"> <button class="btn btn-sm btn-danger btn-icon-left mr-1 apbd-empty-country"><i class="fa fa-trash-o"></i><?php $app->_e("Empty") ?></button> <button class="btn btn-sm btn-secondary btn-icon-left apbd-all-country"><i class="fa fa-star-o"></i><?php $app->_e("Select All Country") ?></button> </div> <div class="mt-3 form-inline"> <div class="form-group mt-3"> <div class="ht-mcs-switcher-wrap inline"> <button class="ml-2 btn btn-sm btn btn-warning apbd-pro-btn btn-icon-left"> <i class="fa fa-unlock"></i> <?php $app->_e("Unlock It") ; ?></button> </div> <label for="ht-is-dont-hide-cur-<?php echo esc_attr($currencyData->id); ?>" class="ml-3 text-bold"><?php $app->_e("Do not hide this currency in dropdown or country list"); ; ?></label> </div> </div> </div> </td> </tr> <?php } } if ( ! function_exists('getCurrencyPaymentGatewayRow')) { /** * @param APBDWC_currency_item $currencyData * @param WC_Payment_Gateway[] $gateways * @param array $selected */ function getCurrencyPaymentGatewayRow($currencyData,$gateways=[],$selected=[],$non_save_mode=true){ $app=APBDWooComMultiCurrency::GetInstance(); if(empty($currencyData->code)){ $currencyName = $app->__("Not selected yet"); $currencySymbol = ""; }else { $currencies = get_woocommerce_currencies(); $currencyName = ! empty( $currencies[ $currencyData->code ] ) ? $currencies[ $currencyData->code ] : $currencyData->code; if ( ! empty( $currencyData->code ) ) { $currencySymbol = APBD_get_mc_currency_symbols( $currencyData->code ); } else { $currencySymbol = APBD_get_mc_currency_symbols( 'USD' ); } } ?> <tr id="cur-gtw-<?php echo esc_attr($currencyData->id); ?>"> <td class="align-top"> <h6 class="title"><?php $app->_e("Currency"); ?></h6> <div class="wrap wrap-currency app-gt-cur"> <?php if(empty($currencyData->code)){ echo esc_attr($currencyName); }else { echo esc_attr($currencyData->code . " - " . $currencyName . " (" . $currencySymbol . ")"); }?> </div> </td> <td> <h6 class="title"><?php $app->_e("Payment Gateway"); ?></h6> <div class="wrap-position"> <div class="ht-mcs-checkbox-wrap inline"> <?php foreach ( $gateways as $gtid=>$gateway ) { if(!(strtolower($gateway->enabled)=='yes') && !$non_save_mode){ continue; } $isCheckedStr=in_array($gtid,$selected)?' checked ':''; ?> <div class="ht-mcs-checkbox"> <input id="<?php echo esc_attr($currencyData->id."_".$gtid); ?>" type="checkbox" <?php echo esc_attr($non_save_mode?' ' :' name="gateways['.esc_attr($currencyData->id).'][]" '); ?>> <label for="<?php echo esc_attr($currencyData->id."_".$gtid); ?>"><span><?php echo esc_attr($gateway->title); ; ?></span></label> </div> <?php } ?> </div> </div> </td> </tr> <?php } } if ( ! function_exists('APBD_get_floating_li')) { function APBD_get_floating_li($currency,$_default_mc_cur,$currencySymbol,$current_url,$plugin_file,$isReturn=false){ ob_start(); ?> <li class="<?php echo esc_attr(!empty($_default_mc_cur->code)&& $currency->code==$_default_mc_cur->code?" active ":"");?>"> <a href="<?php echo esc_url($current_url); ?>?_amc-currency=<?php echo esc_attr($currency->code);?>"><span class="icon"><img src="<?php echo esc_url(plugins_url("images/flags/circle/".strtoupper(esc_attr($currency->code)).'.png',$plugin_file)); ?>" alt=""></span><span class="text"><?php echo esc_attr($currency->code);?>(<?php echo esc_attr($currencySymbol); ?>)</span></a> </li> <?php if($isReturn){ return ob_get_clean(); } echo wp_kses_post(ob_get_clean()); } } if ( ! function_exists('APBD_current_url')) { function APBD_current_url(){ global $wp; return home_url( $wp->request ); } }