/** * Create the widget * * @access public * @since 1.0.0 * @param array $args The widget arguements * @param array $instance This widget instance * @return void */ public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title'], $instance, $args['id']); $payment_methods = edd_get_option('accepted_cards', array()); $icon_width = isset($instance['icon_width']) ? $instance['icon_width'] . 'px' : '32px'; if (empty($payment_methods)) { return; } echo $args['before_widget']; if ($title) { echo $args['before_title'] . $title . $args['after_title']; } do_action('edd_before_payment_icons_widget'); echo '<div class="edd-payment-icons-widget">'; if ($instance['above_icons']) { echo '<div class="edd-payment-icons-widget-text">'; echo html_entity_decode(esc_html($instance['above_icons'])); echo '</div>'; } foreach ($payment_methods as $key => $card) { if (edd_string_is_image_url($key)) { echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width: ' . $icon_width . '" />'; } else { $card = strtolower(str_replace(' ', '', $card)); if (has_filter('edd_accepted_payment_' . $card . '_image')) { $image = apply_filters('edd_accepted_payment_' . $card . '_image', ''); } else { $image = edd_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); $content_dir = WP_CONTENT_DIR; if (function_exists('wp_normalize_path')) { $image = wp_normalize_path($image); $content_dir = wp_normalize_path($content_dir); } $image = str_replace($content_dir, WP_CONTENT_URL, $image); } if (edd_is_ssl_enforced() || is_ssl()) { $image = edd_enforced_ssl_asset_filter($image); } echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width: ' . $icon_width . '" />'; } } if ($instance['below_icons']) { echo '<div class="edd-payment-icons-widget-text">'; echo html_entity_decode($instance['below_icons']); echo '</div>'; } echo '</div>'; do_action('edd_after_payment_icons_widget'); echo $args['after_widget']; }
/** * Show Payment Icons by getting all the accepted icons from the EDD Settings * then outputting the icons. * * @since 1.0 * @return void */ function edd_show_payment_icons() { if (edd_show_gateways() && did_action('edd_payment_mode_top')) { return; } $payment_methods = edd_get_option('accepted_cards', array()); if (empty($payment_methods)) { return; } echo '<div class="edd-payment-icons">'; foreach ($payment_methods as $key => $card) { if (edd_string_is_image_url($key)) { echo '<img class="payment-icon" src="' . esc_url($key) . '"/>'; } else { $card = strtolower(str_replace(' ', '', $card)); if (has_filter('edd_accepted_payment_' . $card . '_image')) { $image = apply_filters('edd_accepted_payment_' . $card . '_image', ''); } else { $image = edd_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); $content_dir = WP_CONTENT_DIR; if (function_exists('wp_normalize_path')) { // Replaces backslashes with forward slashes for Windows systems $image = wp_normalize_path($image); $content_dir = wp_normalize_path($content_dir); } $image = str_replace($content_dir, WP_CONTENT_URL, $image); } if (edd_is_ssl_enforced() || is_ssl()) { $image = edd_enforced_ssl_asset_filter($image); } echo '<img class="payment-icon" src="' . esc_url($image) . '"/>'; } } echo '</div>'; }