Ejemplo n.º 1
0
 /** Display widget */
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $title = apply_filters('widget_title', $instance['title']);
     if (!$instance['campaign_id']) {
         $query = new WP_Query(array('post_type' => Leyka_Campaign_Management::$post_type, 'posts_per_page' => 1));
         if (!$query->have_posts()) {
             return;
         }
         $campaign_id = $query->posts[0]->ID;
     } elseif ((int) $instance['campaign_id'] === 0) {
         $campaign_id = null;
     } else {
         $campaign_id = (int) $instance['campaign_id'];
     }
     $args = array('show_title' => !!$instance['show_title'], 'show_thumb' => !!$instance['show_thumb'], 'show_excerpt' => !!$instance['show_excerpt'], 'show_scale' => !!$instance['show_scale'], 'show_button' => !!$instance['show_button']);
     $css_id = 'leyka_campaign_card_widget-' . uniqid();
     $html = leyka_get_campaign_card($campaign_id, $args);
     if (!$html) {
         return;
     }
     $campaign = new Leyka_Campaign($campaign_id);
     if (!leyka_form_is_screening(false)) {
         // Don't increase campaign views counter if we're on a page with this campaign's donation form
         $campaign->increase_views_counter();
     }
     /** @var $before_widget */
     echo $before_widget;
     if ($title) {
         /**
          * @var $before_title
          * @var $after_title
          */
         echo $before_title . $title . $after_title;
     }
     echo '<div id="' . esc_attr($css_id) . '">' . $html . "</div>";
     /** @var $after_widget */
     echo $after_widget;
 }
		color: #fff;
		background: #1db318;
		padding: 0.5em 1.5em;
		-webkit-transition: all 0.3s ease;
		-moz-transition: all 0.3s ease;
		-ms-transition: all 0.3s ease;
		-o-transition: all 0.3s ease;
		transition: all 0.3s ease;
	}

	.leyka-scale-button a:hover,
	.leyka-scale-button a:focus,
	.leyka-scale-button a:active {
		background: #189414;
	}

</style>
</head>
<body>
    <div id="embedded-card">
    <?php 
echo leyka_get_campaign_card($campaign->id, array('embed_mode' => 1, 'increase_counters' => !empty($_GET['increase_counters'])));
if (!empty($_GET['increase_counters'])) {
    $campaign->increase_views_counter();
}
?>

    </div>
</body>

</html>
function leyka_print_donation_elements($content)
{
    global $post;
    $autoprint = leyka_options()->opt('donation_form_mode');
    if (!is_singular(Leyka_Campaign_Management::$post_type) || !$autoprint) {
        return $content;
    }
    $campaign = new Leyka_Campaign($post);
    if ($campaign->ignore_global_template_settings) {
        return $content;
    }
    $post_content = $content;
    $content = '';
    // Scale on top of form:
    if (leyka_options()->opt('scale_widget_place') == 'top' || leyka_options()->opt('scale_widget_place') == 'both') {
        $content .= do_shortcode("[leyka_scale show_button='1']");
    }
    $content .= $post_content;
    // Scale below form:
    if (!empty($campaign->target) && (leyka_options()->opt('scale_widget_place') == 'bottom' || leyka_options()->opt('scale_widget_place') == 'both')) {
        $content .= do_shortcode("[leyka_scale show_button='0']");
    }
    $content .= get_leyka_payment_form_template_html($post);
    // Payment form
    $campaign->increase_views_counter();
    // Increase campaign views counter
    // Donations list:
    if (leyka_options()->opt('leyka_donations_history_under_forms')) {
        $list = leyka_get_donors_list($post->ID);
        if ($list) {
            $label = apply_filters('leyka_donations_list_title', __('Our sincere thanks', 'leyka'), $post->ID);
            $content .= '<h3 class="leyka-donations-list-title">' . $label . '</h3>' . $list;
        }
    }
    return $content;
}
Ejemplo n.º 4
0
function leyka_get_payment_form($campaign = null, $args = array())
{
    global $post;
    $defaults = array('template' => null);
    $args = wp_parse_args($args, $defaults);
    if (!$campaign) {
        $campaign = $post;
    } elseif (is_int($campaign)) {
        $campaign = get_post($campaign);
    }
    if ($campaign->post_type != Leyka_Campaign_Management::$post_type) {
        return '';
    }
    $campaign = new Leyka_Campaign($campaign);
    $campaign->increase_views_counter();
    // Increase campaign views counter
    return get_leyka_payment_form_template_html($campaign, $args['template']);
}