예제 #1
0
    function shortcode_cpt_causes($params = array())
    {
        extract(shortcode_atts(array('title' => '', 'id' => '', 'width' => '', 'position' => '', 'cssid' => ''), $params));
        if (!empty($width) || !empty($position)) {
            if (!empty($width)) {
                $width_style = 'width: ' . $width . '%;';
                if (intval($width) <= 50) {
                    $classes[] = 'narrow';
                } elseif (intval($width) == 100) {
                    $classes[] = 'full-width';
                }
            }
            if (!empty($position)) {
                $classes[] = $position;
            }
            $style = 'style="' . $width_style . '"';
            $classes = implode(' ', $classes);
        }
        $args = array('post_type' => 'post_causes', 'post_status' => 'publish', 'pagination' => false, 'ignore_sticky_posts' => true);
        if ($id == 'latest') {
            $args = array_merge(array('posts_per_page' => 1, 'order' => 'DESC', 'orderby' => 'date'), $args);
        } else {
            $args = array_merge(array('p' => $id), $args);
        }
        $wp_query = null;
        $wp_query = new WP_Query($args);
        if ($wp_query->have_posts()) {
            while ($wp_query->have_posts()) {
                $wp_query->the_post();
                $cause_meta = get_post_meta(get_the_ID());
                $donations_raised_number = wplook_donations_raised(get_the_ID());
                $donations_number = $donations_raised_number[0];
                $donations_raised = $donations_raised_number[1];
                $cause_goal_amount = isset($cause_meta['wpl_goal_amount'][0]) ? $cause_meta['wpl_goal_amount'][0] : 0;
                $cause_volunteer_link = isset($cause_meta['wpl_volunteer_link'][0]) ? $cause_meta['wpl_volunteer_link'][0] : false;
                $cause_location = isset($cause_meta['wpl_location'][0]) ? $cause_meta['wpl_location'][0] : false;
                if ($cause_goal_amount > 0) {
                    $percentage = min(wplook_format_money($donations_raised * 100 / $cause_goal_amount, true), 100);
                } else {
                    $percentage = 0;
                }
                ob_start();
                ?>

				<div class="shortcode-preview shortcode-preview-post_causes single-cause <?php 
                echo $classes;
                ?>
" itemscope="" itemtype="https://schema.org/Offer" <?php 
                echo $style;
                ?>
 id="<?php 
                echo $cssid;
                ?>
">
					<?php 
                if (!empty($title)) {
                    ?>
						<h2 class="preview-title"><?php 
                    echo $title;
                    ?>
</h2>
					<?php 
                } elseif (empty($title) && $id == 'latest') {
                    ?>
						<h2 class="preview-title"><?php 
                    the_title();
                    ?>
</h2>
					<?php 
                }
                ?>

					<figure class="single-cause-image">
						<?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('gallery-thumb');
                } else {
                    echo '<img src="' . get_template_directory_uri() . '/assets/images/gallery-thumb.png">';
                }
                ?>

						<figcaption>
							<div class="single-cause-buttons">
								<a href="<?php 
                the_permalink();
                ?>
" class="btn-red" itemprop="url"><?php 
                _e('Donate', 'wplook');
                ?>
</a>
							</div><!-- /.single-cause-buttons -->
						</figcaption>
					</figure><!-- /.single-cause-image -->

					<a href="<?php 
                the_permalink();
                ?>
">
						<div class="single-cause-body">
							<p><?php 
                echo wplook_short_excerpt(ot_get_option('wpl_cause_excerpt_limit'));
                ?>
</p>
						</div>

						<div class="single-cause-stats">
							<?php 
                if ($cause_location) {
                    echo '<h5>' . $cause_location . '</h5>';
                }
                ?>

							<div class="progress">
								<div class="progress-bar wow fadeInLeft" data-wow-duration="0.5s" data-wow-delay="0.4s" style="width: <?php 
                echo esc_attr($percentage);
                ?>
%; visibility: visible; animation-duration: 0.5s; animation-delay: 0.4s; animation-name: fadeInLeft;"></div>
							</div>
							<p>
								<?php 
                printf(__('%1$s of %2$s %3$s raised (%4$s%5$s)', 'wplook'), esc_attr(wplook_format_money($donations_raised)), esc_attr(wplook_format_money($cause_goal_amount)), esc_attr(ot_get_option('wpl_curency_code')), esc_attr($percentage), '%');
                ?>
							</p>
						</div>
					</a>
				</div><!-- /.single-cause -->

			<?php 
                return ob_get_clean();
            }
        } else {
            return __('No posts found.', 'wplook');
        }
        wp_reset_postdata();
    }
예제 #2
0
		</div><!-- /.page-head -->

		<div class="main">
			<div class="row">
				<div class="content columns small-12 large-9">
					<div class="causes-listing">

						<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
						<?php 
        $pid = $post->ID;
        $cause_meta = get_post_meta($pid);
        $donations_raised_number = wplook_donations_raised($pid);
        $donations_number = $donations_raised_number[0];
        $donations_raised = $donations_raised_number[1];
        $cause_goal_amount = isset($cause_meta['wpl_goal_amount'][0]) ? $cause_meta['wpl_goal_amount'][0] : 0;
        $cause_location = isset($cause_meta['wpl_location'][0]) ? $cause_meta['wpl_location'][0] : false;
        $cause_enddate = isset($cause_meta['wpl_enddate'][0]) ? $cause_meta['wpl_enddate'][0] : false;
        if ($cause_goal_amount > 0) {
            $percentage = min(wplook_format_money($donations_raised * 100 / $cause_goal_amount, true), 100);
        } else {
            $percentage = 0;
        }
        ?>

							<div class="single-cause" itemscope itemtype="https://schema.org/Offer">
								<figure class="single-cause-image">
									<?php 
예제 #3
0
			<?php 
    $args = array('post_type' => 'post_causes', 'post_status' => 'publish', 'pagination' => false, 'posts_per_page' => '8', 'order' => 'DESC', 'orderby' => $causes_orderby, 'post__not_in' => array(get_the_ID()));
    ?>
			<?php 
    $the_query = null;
    $the_query = new WP_Query($args);
    ?>
			<?php 
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            ?>
			<?php 
            $cause_meta = get_post_meta(get_the_ID());
            $donations_raised_number = wplook_donations_raised(get_the_ID());
            $donations_number = $donations_raised_number[0];
            $donations_raised = $donations_raised_number[1];
            $cause_goal_amount = isset($cause_meta['wpl_goal_amount'][0]) ? $cause_meta['wpl_goal_amount'][0] : 0;
            $cause_location = isset($cause_meta['wpl_location'][0]) ? $cause_meta['wpl_location'][0] : false;
            if ($cause_goal_amount > 0) {
                $percentage = min(wplook_format_money($donations_raised * 100 / $cause_goal_amount, true), 100);
            } else {
                $percentage = 0;
            }
            ?>


				<div class="single-cause" itemscope itemtype="https://schema.org/Offer">
					<figure class="single-cause-image">
						<?php 
예제 #4
0
    public function widget($args, $instance)
    {
        global $post;
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance);
        $subtitle = apply_filters('widget_title', empty($instance['subtitle']) ? '' : $instance['subtitle'], $instance);
        $nr_posts = isset($instance['nr_posts']) ? esc_attr($instance['nr_posts']) : '';
        $display_type = isset($instance['display_type']) ? esc_attr($instance['display_type']) : '';
        // WP_Query arguments
        $args = array('post_type' => 'post_causes', 'post_status' => 'publish', 'pagination' => false, 'posts_per_page' => $nr_posts, 'orderby' => $display_type);
        // The Query
        $the_query = null;
        $the_query = new WP_Query($args);
        ?>

			<section class="section-carousel section-causes wow fadeIn" data-wow-duration="0.5s" data-wow-delay="0.4s">
				<div class="row">
					<header class="section-head" itemprop="name">
						<h5><?php 
        echo esc_html($subtitle);
        ?>
</h5>
						<h2><?php 
        echo esc_html($title);
        ?>
</h2>
					</header><!-- /.section-head -->
					<div class="section-body">
						<div class="causes-list owl-carousel">
		<?php 
        if ($the_query->have_posts()) {
            while ($the_query->have_posts()) {
                $the_query->the_post();
                $cause_meta = get_post_meta(get_the_ID());
                $donations_raised_number = wplook_donations_raised(get_the_ID());
                $donations_number = $donations_raised_number[0];
                $donations_raised = $donations_raised_number[1];
                $cause_goal_amount = isset($cause_meta['wpl_goal_amount'][0]) ? $cause_meta['wpl_goal_amount'][0] : 0;
                $cause_location = isset($cause_meta['wpl_location'][0]) ? $cause_meta['wpl_location'][0] : false;
                if ($cause_goal_amount > 0) {
                    $percentage = min(wplook_format_money($donations_raised * 100 / $cause_goal_amount, true), 100);
                } else {
                    $percentage = 0;
                }
                ?>

						<div class="single-cause" itemscope itemtype="https://schema.org/Offer">
							<figure class="single-cause-image">
								<?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('gallery-thumb');
                } else {
                    echo '<img src="' . get_template_directory_uri() . '/assets/images/gallery-thumb.png">';
                }
                ?>

								<figcaption>
									<div class="single-cause-buttons">
										<a href="<?php 
                the_permalink();
                ?>
" class="btn-red" itemprop="url"><?php 
                _e('Donate', 'charity-life-wpl');
                ?>
</a>
									</div><!-- /.single-cause-buttons -->
								</figcaption>
							</figure><!-- /.single-cause-image -->

							<a href="<?php 
                the_permalink();
                ?>
">
								<div class="single-cause-body">
									<h4 itemprop="name"><?php 
                the_title();
                ?>
</h4>

									<p><?php 
                echo wplook_short_excerpt(ot_get_option('wpl_cause_excerpt_limit'));
                ?>
</p>
								</div>

								<div class="single-cause-stats">
									<?php 
                if ($cause_location) {
                    echo '<h5>' . $cause_location . '</h5>';
                }
                ?>
									<div class="progress">
										<div class="progress-bar wow fadeInLeft" data-wow-duration="0.5s" data-wow-delay="0.4s" style="width: <?php 
                echo esc_attr($percentage);
                ?>
%;"></div>
									</div>

									<p>
										<?php 
                printf(__('%1$s of %2$s %3$s raised (%4$s%5$s)', 'charity-life-wpl'), esc_attr(wplook_format_money($donations_raised)), esc_attr(wplook_format_money($cause_goal_amount)), esc_attr(ot_get_option('wpl_curency_code')), esc_attr($percentage), '%');
                ?>
									</p>
								</div>
							</a>
						</div><!-- /.single-cause -->
			<?php 
            }
            ?>
		<?php 
        }
        ?>
		<?php 
        wp_reset_postdata();
        ?>
						</div><!-- /.causes-list owl-carousel -->
					</div><!-- /.section-body -->
				</div><!-- /.row -->
			</section><!-- /.section-carousel <?php 
        echo esc_attr($this->id);
        ?>
 -->
		<?php 
    }