$currency_name, '%currency_code%' => $currency_code, '%currency_symbol%' => get_woocommerce_currency_symbol( $currency_code ), '%product_price%' => $product_price, ); return str_replace( array_keys( $replaced_values ), array_values( $replaced_values ), get_option( 'alg_currency_switcher_format', '%currency_name%' ) ); } } if ( ! function_exists( 'alg_get_currency_selector' ) ) { /** * alg_get_currency_selector. * * @version 2.15.2 * @since 1.0.0 */ function alg_get_currency_selector( $type = 'select' ) { $flags_enabled = ( 'yes' === get_option( 'alg_wc_currency_switcher_flags_enabled', 'no' ) && get_option( 'wpwham_currency_switcher_version' ) !== 'legacy' ); $html = ''; $html .= '
'; if ( 'select' === $type ) { $html .= ' ' . '' . '
'; } } } if ( 'select' === $type ) { $html .= ''; } $html .= ''; $html .= '
'; return str_replace( '%currency_switcher%', $html, get_option( 'alg_currency_switcher_wrapper', '%currency_switcher%' ) ); } } if ( ! function_exists( 'alg_currency_select_drop_down_list' ) ) { /** * alg_currency_select_drop_down_list. * * @version 1.0.0 * @since 1.0.0 */ function alg_currency_select_drop_down_list() { return alg_get_currency_selector( 'select' ); } } if ( ! function_exists( 'alg_currency_select_radio_list' ) ) { /** * alg_currency_select_radio_list. * * @version 1.0.0 * @since 1.0.0 */ function alg_currency_select_radio_list() { return alg_get_currency_selector( 'radio' ); } } if ( ! function_exists( 'alg_currency_select_link_list' ) ) { /** * alg_currency_select_link_list. * * @version 2.8.4 * @since 1.0.0 */ function alg_currency_select_link_list( $atts = array() ) { $flags_enabled = ( 'yes' === get_option( 'alg_wc_currency_switcher_flags_enabled', 'no' ) && get_option( 'wpwham_currency_switcher_version' ) !== 'legacy' ); $function_currencies = alg_get_enabled_currencies(); $currencies = get_woocommerce_currencies(); $selected_currency = alg_get_current_currency_code(); $html = ''; $links = array(); $first_link = ''; foreach ( $function_currencies as $currency_code ) { if ( isset( $currencies[ $currency_code ] ) ) { $flag_img = ''; if ( $flags_enabled ) { $country_code = alg_get_country_flag_code( $currency_code ); $flag_img = ' '; } $the_text = $flag_img . alg_format_currency_switcher( $currencies[ $currency_code ], $currency_code, false ); $the_link = ( isset( $atts['no_links'] ) && 'yes' === $atts['no_links'] ? $the_text : '' . $the_text . '' ); if ( $currency_code != $selected_currency ) { $links[] = $the_link; } else { $first_link = $the_link; } } } if ( '' != $first_link ) { $links = array_merge( array( $first_link ), $links ); } $html .= implode( get_option( 'alg_wc_currency_switcher_link_list_separator', '
' ), $links ); $html = '
' . $html . '
'; return str_replace( '%currency_switcher%', $html, get_option( 'alg_currency_switcher_wrapper', '%currency_switcher%' ) ); } } if ( ! function_exists( 'alg_currency_select' ) ) { /** * alg_currency_select. * * @version 2.8.4 * @since 1.0.0 */ function alg_currency_select( $atts ) { if ( ! isset( $atts['type'] ) ) { $atts['type'] = 'drop_down'; } switch ( $atts['type'] ) { case 'radio': return alg_currency_select_radio_list(); case 'links': return alg_currency_select_link_list( $atts ); default: // 'drop_down' return alg_currency_select_drop_down_list(); } } } // Shortcodes add_shortcode( 'woocommerce_currency_switcher', 'alg_currency_select' ); add_shortcode( 'woocommerce_currency_switcher_drop_down_box', 'alg_currency_select_drop_down_list' ); add_shortcode( 'woocommerce_currency_switcher_radio_list', 'alg_currency_select_radio_list' ); add_shortcode( 'woocommerce_currency_switcher_link_list', 'alg_currency_select_link_list' );