get_earnings() 공개 메소드

Retrieve the total earnings for the form
부터: 1.0
public get_earnings ( ) : float
리턴 float Donation form total earnings.
예제 #1
0
/**
 * Show Give Goals
 * @since 1.0
 *
 * @param int $form_id
 *
 * @return bool
 */
function give_show_goal_progress($form_id)
{
    $goal_option = get_post_meta($form_id, '_give_goal_option', true);
    $form = new Give_Donate_Form($form_id);
    $goal = $form->goal;
    $income = $form->get_earnings();
    $color = get_post_meta($form_id, '_give_goal_color', true);
    if (empty($form->ID) || $goal_option !== 'yes' || $goal == 0) {
        return false;
    }
    $progress = round($income / $goal * 100, 2);
    if ($income > $goal) {
        $progress = 100;
    }
    $output = '<div class="goal-progress">';
    $output .= '<div class="raised">';
    $output .= sprintf(_x('%s of %s raised', 'give', 'This text displays the amount of income raised compared to the goal.'), '<span class="income">' . give_currency_filter(give_format_amount($income)) . '</span>', '<span class="goal-text">' . give_currency_filter(give_format_amount($goal))) . '</span>';
    $output .= '</div>';
    $output .= '<div class="progress-bar">';
    $output .= '<span style="width: ' . esc_attr($progress) . '%;';
    if (!empty($color)) {
        $output .= 'background-color:' . $color;
    }
    $output .= '"></span>';
    $output .= '</div></div><!-- /.goal-progress -->';
    echo apply_filters('give_goal_output', $output);
}
예제 #2
0
<?php

/**
 * This template is used to display the goal with [give_goal]
 */
$goal_option = get_post_meta($form_id, '_give_goal_option', true);
$form = new Give_Donate_Form($form_id);
$goal = $form->goal;
$goal_format = get_post_meta($form_id, '_give_goal_format', true);
$income = $form->get_earnings();
$color = get_post_meta($form_id, '_give_goal_color', true);
$show_text = (bool) isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true;
$show_bar = (bool) isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true;
//Sanity check - respect shortcode args
if (isset($args['show_goal']) && $args['show_goal'] === false) {
    return false;
}
//Sanity check - ensure form has goal set to output
if (empty($form->ID) || is_singular('give_forms') && $goal_option !== 'yes' || $goal_option !== 'yes' || $goal == 0) {
    //not this form, bail
    return false;
}
$progress = round($income / $goal * 100, 2);
if ($income >= $goal) {
    $progress = 100;
}
?>
<div class="give-goal-progress">
    <?php 
if (!empty($show_text)) {
    ?>
예제 #3
0
파일: template.php 프로젝트: joedolson/Give
/**
 * Show Give Goals
 * @since 1.0
 *
 * @param int   $form_id
 * @param array $args
 *
 * @return mixed
 */
function give_show_goal_progress($form_id, $args)
{
    $goal_option = get_post_meta($form_id, '_give_goal_option', true);
    $form = new Give_Donate_Form($form_id);
    $goal = $form->goal;
    $income = $form->get_earnings();
    $color = get_post_meta($form_id, '_give_goal_color', true);
    $show_text = (bool) isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true;
    $show_bar = (bool) isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true;
    //Sanity check - respect shortcode args
    if (isset($args['show_goal']) && $args['show_goal'] === false) {
        return false;
    }
    //Sanity check - ensure form has goal set to output
    if (empty($form->ID) || is_singular('give_forms') && $goal_option !== 'yes' || $goal_option !== 'yes' || $goal == 0) {
        //not this form, bail
        return false;
    }
    $progress = round($income / $goal * 100, 2);
    if ($income > $goal) {
        $progress = 100;
    }
    $output = '<div class="goal-progress">';
    //Goal Progress Text
    if (!empty($show_text)) {
        $output .= '<div class="raised">';
        $output .= sprintf(_x('%s of %s raised', 'This text displays the amount of income raised compared to the goal.', 'give'), '<span class="income">' . give_currency_filter(give_format_amount($income)) . '</span>', '<span class="goal-text">' . give_currency_filter(give_format_amount($goal))) . '</span>';
        $output .= '</div>';
    }
    //Goal Progress Bar
    if (!empty($show_bar)) {
        $output .= '<div class="progress-bar">';
        $output .= '<span style="width: ' . esc_attr($progress) . '%;';
        if (!empty($color)) {
            $output .= 'background-color:' . $color;
        }
        $output .= '"></span>';
        $output .= '</div><!-- /.progress-bar -->';
    }
    $output .= '</div><!-- /.goal-progress -->';
    echo apply_filters('give_goal_output', $output);
    return false;
}