/**
  * 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>';
}
/**
 * Disable the WooCommerce 'Un-force SSL when leaving checkout' option on EDD checkout
 * to prevent redirect loops
 *
 * @since 2.1
 * @return void
 */
function edd_disable_woo_ssl_on_checkout()
{
    if (edd_is_checkout() && edd_is_ssl_enforced()) {
        remove_action('template_redirect', array('WC_HTTPS', 'unforce_https_template_redirect'));
    }
}
Esempio n. 4
0
/**
 * Handle rewriting asset URLs for SSL enforced checkouts
 *
 * @since 2.0
 * @return void
 */
function edd_enforced_ssl_asset_handler()
{
    if (!edd_is_ssl_enforced() || !edd_is_checkout() || is_admin()) {
        return;
    }
    $filters = array('post_thumbnail_html', 'wp_get_attachment_url', 'wp_get_attachment_image_attributes', 'wp_get_attachment_url', 'option_stylesheet_url', 'option_template_url', 'script_loader_src', 'style_loader_src', 'template_directory_uri', 'stylesheet_directory_uri', 'site_url');
    $filters = apply_filters('edd_enforced_ssl_asset_filters', $filters);
    foreach ($filters as $filter) {
        add_filter($filter, 'edd_enforced_ssl_asset_filter', 1);
    }
}
 /**
  * do_ssl_check function.
  *
  * Check if we are forcing SSL on checkout pages. Advised but not required by gateway.
  *
  * @access public
  */
 public function do_ssl_check()
 {
     // Check for SSL
     if (edd_is_ssl_enforced()) {
         echo "<div class='error'><p>" . sprintf(__("<strong>%s</strong> payment gateway is enabled but Easy Digital Downloads is not forcing the SSL certificate on your checkout page.<br />For your security, please ensure that you have a valid SSL certificate and that you are forcing Checkout pages to be secured <a href=\"%s\">(check the box 'Force secure checkout').</a>"), $this->method_title, admin_url('admin.php?page=edd-settings&tab=misc&section=checkout')) . "</p></div>";
         return false;
     }
     return true;
 }