Exemplo n.º 1
0
 /**
  * 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>';
}
/**
 * Retrieves a template part
 *
 * @since v1.2
 *
 * Taken from bbPress
 *
 * @param string $slug
 * @param string $name Optional. Default null
 * @param bool   $load
 *
 * @return string
 *
 * @uses edd_locate_template()
 * @uses load_template()
 * @uses get_template_part()
 */
function edd_get_template_part($slug, $name = null, $load = true)
{
    // Execute code for this part
    do_action('get_template_part_' . $slug, $slug, $name);
    // Setup possible parts
    $templates = array();
    if (isset($name)) {
        $templates[] = $slug . '-' . $name . '.php';
    }
    $templates[] = $slug . '.php';
    // Allow template parts to be filtered
    $templates = apply_filters('edd_get_template_part', $templates, $slug, $name);
    // Return the part that is found
    return edd_locate_template($templates, $load, false);
}
Exemplo n.º 4
0
/**
 * Payment method icons callback
 *
 * @since 2.1
 * @param array $args Arguments passed by the setting
 * @global $edd_options Array of all the EDD Options
 * @return void
 */
function edd_payment_icons_callback($args)
{
    global $edd_options;
    if (!empty($args['options'])) {
        foreach ($args['options'] as $key => $option) {
            if (isset($edd_options[$args['id']][$key])) {
                $enabled = $option;
            } else {
                $enabled = NULL;
            }
            echo '<label for="edd_settings[' . $args['id'] . '][' . $key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
            echo '<input name="edd_settings[' . $args['id'] . '][' . $key . ']" id="edd_settings[' . $args['id'] . '][' . $key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
            if (edd_string_is_image_url($key)) {
                echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
            } else {
                $card = strtolower(str_replace(' ', '', $option));
                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);
                }
                echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
            }
            echo $option . '</label>';
        }
        echo '<p class="description" style="margin-top:16px;">' . $args['desc'] . '</p>';
    }
}