当前位置: 首页>>代码示例>>PHP>>正文


PHP give_get_variable_prices函数代码示例

本文整理汇总了PHP中give_get_variable_prices函数的典型用法代码示例。如果您正苦于以下问题:PHP give_get_variable_prices函数的具体用法?PHP give_get_variable_prices怎么用?PHP give_get_variable_prices使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了give_get_variable_prices函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: give_single_forms_cmb2_metaboxes

/**
 * Define the metabox and field configurations.
 *
 * @param  array $meta_boxes
 *
 * @return array
 */
function give_single_forms_cmb2_metaboxes(array $meta_boxes)
{
    $post_id = give_get_admin_post_id();
    $price = give_get_form_price($post_id);
    $goal = give_get_form_goal($post_id);
    $variable_pricing = give_has_variable_prices($post_id);
    $prices = give_get_variable_prices($post_id);
    //No empty prices - min. 1.00 for new forms
    if (empty($price)) {
        $price = esc_attr(give_format_amount('1.00'));
    }
    // Start with an underscore to hide fields from custom fields list
    $prefix = '_give_';
    /**
     * Repeatable Field Groups
     */
    $meta_boxes['form_field_options'] = apply_filters('give_forms_field_options', array('id' => 'form_field_options', 'title' => __('Donation Options', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array(array('name' => __('Donation Option', 'give'), 'description' => __('Would you like this form to have one set donation price or multiple levels (for example, $10 silver, $20 gold, $50 platinum)?', 'give'), 'id' => $prefix . 'price_option', 'type' => 'radio_inline', 'default' => 'set', 'options' => apply_filters('give_forms_price_options', array('set' => __('Set Donation', 'give'), 'multi' => __('Multi-level Donation', 'give')))), array('name' => __('Set Donation', 'give'), 'description' => __('This is the set donation amount for this form.', 'give'), 'id' => $prefix . 'set_price', 'type' => 'text_small', 'row_classes' => 'give-subfield', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('1.00'), 'value' => $price, 'class' => 'cmb-type-text-small give-money-field')), array('id' => $prefix . 'levels_header', 'type' => 'levels_repeater_header'), array('id' => $prefix . 'donation_levels', 'type' => 'group', 'row_classes' => 'give-subfield', 'options' => array('add_button' => __('Add Level', 'give'), 'remove_button' => __('<span class="dashicons dashicons-no"></span>', 'give'), 'sortable' => true), 'fields' => apply_filters('give_donation_levels_table_row', array(array('name' => __('ID', 'give'), 'id' => $prefix . 'id', 'type' => 'levels_id'), array('name' => __('Amount', 'give'), 'id' => $prefix . 'amount', 'type' => 'text_small', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol  give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol  give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('1.00'), 'class' => 'cmb-type-text-small give-money-field'), 'before' => 'give_format_admin_multilevel_amount'), array('name' => __('Text', 'give'), 'id' => $prefix . 'text', 'type' => 'text', 'attributes' => array('placeholder' => __('Donation Level', 'give'), 'rows' => 3)), array('name' => __('Default', 'give'), 'id' => $prefix . 'default', 'type' => 'give_default_radio_inline')))), array('name' => __('Display Style', 'give'), 'description' => __('Set how the donations levels will display on the form.', 'give'), 'id' => $prefix . 'display_style', 'type' => 'radio_inline', 'default' => 'buttons', 'options' => array('buttons' => __('Buttons', 'give'), 'radios' => __('Radios', 'give'), 'dropdown' => __('Dropdown', 'give'))), array('name' => __('Custom Amount', 'give'), 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), 'id' => $prefix . 'custom_amount', 'type' => 'radio_inline', 'default' => 'no', 'options' => array('yes' => __('Yes', 'give'), 'no' => __('No', 'give'))), array('name' => __('Custom Amount Text', 'give'), 'description' => __('This text appears as a label next to the custom amount field for single level forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option). Add your own message or leave this field blank to prevent it from displaying within your form.', 'give'), 'id' => $prefix . 'custom_amount_text', 'type' => 'text', 'row_classes' => 'give-subfield', 'attributes' => array('rows' => 3, 'placeholder' => __('Give a Custom Amount', 'give'))), array('name' => __('Set Goal?', 'give'), 'description' => __('Do you want to set a donation goal for this form?', 'give'), 'id' => $prefix . 'goal_option', 'type' => 'radio_inline', 'default' => 'no', 'options' => array('yes' => __('Yes', 'give'), 'no' => __('No', 'give'))), array('name' => __('Set Goal', 'give'), 'description' => __('This is the goal you want to achieve for this form.', 'give'), 'id' => $prefix . 'set_goal', 'type' => 'text_small', 'row_classes' => 'give-subfield', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('0.00'), 'value' => isset($goal) ? esc_attr(give_format_amount($goal)) : '', 'class' => 'cmb-type-text-small give-money-field')), array('name' => __('Goal Progress Bar Color', 'give'), 'id' => $prefix . 'goal_color', 'type' => 'colorpicker', 'row_classes' => 'give-subfield', 'default' => '#2bc253')))));
    /**
     * Content Field
     */
    $meta_boxes['form_content_options'] = apply_filters('give_forms_content_options', array('id' => 'form_content_options', 'title' => __('Form Content', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_content_options_metabox_fields', array(array('name' => __('Display Content', 'give'), 'description' => __('Do you want to display content? If you select "Yes" a WYSIWYG editor will appear which you will be able to enter content to display above or below the form.', 'give'), 'id' => $prefix . 'content_option', 'type' => 'select', 'options' => apply_filters('give_forms_content_options_select', array('none' => __('No content', 'give'), 'give_pre_form' => __('Yes, display content ABOVE the form fields', 'give'), 'give_post_form' => __('Yes, display content BELOW the form fields', 'give'))), 'default' => 'none'), array('name' => __('Content', 'give'), 'description' => __('This content will display on the single give form page.', 'give'), 'id' => $prefix . 'form_content', 'row_classes' => 'give-subfield', 'type' => 'wysiwyg')))));
    /**
     * Display Options
     */
    $meta_boxes['form_display_options'] = apply_filters('give_form_display_options', array('id' => 'form_display_options', 'title' => __('Form Display Options', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => apply_filters('give_forms_display_options_metabox_fields', array(array('name' => __('Payment Fields', 'give'), 'desc' => __('How would you like to display payment information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon clicks slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give'), 'id' => $prefix . 'payment_display', 'type' => 'select', 'options' => array('onpage' => __('Show on Page', 'give'), 'reveal' => __('Reveal Upon Click', 'give'), 'modal' => __('Modal Window Upon Click', 'give')), 'default' => 'onpage'), array('id' => $prefix . 'reveal_label', 'name' => __('Reveal / Modal Open Text', 'give'), 'desc' => __('The button label for completing the donation.', 'give'), 'type' => 'text_small', 'row_classes' => 'give-subfield', 'attributes' => array('placeholder' => __('Donate Now', 'give'))), array('id' => $prefix . 'checkout_label', 'name' => __('Complete Donation Text', 'give'), 'desc' => __('The button label for completing a donation.', 'give'), 'type' => 'text_small', 'attributes' => array('placeholder' => __('Donate Now', 'give'))), array('name' => __('Default Gateway', 'give'), 'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), 'id' => $prefix . 'default_gateway', 'type' => 'default_gateway'), array('name' => __('Disable Guest Donations', 'give'), 'desc' => __('Do you want to require users be logged-in to make donations?', 'give'), 'id' => $prefix . 'logged_in_only', 'type' => 'checkbox'), array('name' => __('Register / Login Form', 'give'), 'desc' => __('Display the registration and login forms in the checkout section for non-logged-in users. Note: this option will not require users to register or log in prior to completing a donation. It simply determines whether the login and/or registration form are displayed on the checkout page.', 'give'), 'id' => $prefix . 'show_register_form', 'type' => 'select', 'options' => array('both' => __('Registration and Login Forms', 'give'), 'registration' => __('Registration Form Only', 'give'), 'login' => __('Login Form Only', 'give'), 'none' => __('None', 'give')), 'default' => 'none'), array('name' => __('Floating Labels', 'give'), 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url("http://bradfrost.com/blog/post/float-label-pattern/")), 'id' => $prefix . 'form_floating_labels', 'type' => 'select', 'options' => array('' => __('Use the global setting', 'give'), 'enabled' => __('Enabled', 'give'), 'disabled' => __('Disabled', 'give')), 'default' => 'none')))));
    /**
     * Terms & Conditions
     */
    $meta_boxes['form_terms_options'] = apply_filters('give_forms_terms_options', array('id' => 'form_terms_options', 'title' => __('Terms and Conditions', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array(array('name' => __('Terms and Conditions', 'give'), 'description' => __('Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give'), 'id' => $prefix . 'terms_option', 'type' => 'select', 'options' => apply_filters('give_forms_content_options_select', array('none' => __('No', 'give'), 'yes' => __('Yes', 'give'))), 'default' => 'none'), array('id' => $prefix . 'agree_label', 'name' => __('Agree to Terms Label', 'give'), 'desc' => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), 'type' => 'text', 'row_classes' => 'give-subfield', 'size' => 'regular', 'attributes' => array('placeholder' => __('Agree to Terms?', 'give'))), array('id' => $prefix . 'agree_text', 'row_classes' => 'give-subfield', 'name' => __('Agreement Text', 'give'), 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), 'type' => 'wysiwyg')))));
    return $meta_boxes;
}
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:38,代码来源:metabox.php

示例2: give_get_default_multilevel_amount

/**
 * Get the default amount for multi-level forms
 *
 * @access public
 * @since  1.0
 *
 * @param int $form_id
 *
 * @return string $default_price
 */
function give_get_default_multilevel_amount($form_id)
{
    $default_price = '0.00';
    $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id);
    foreach ($prices as $price) {
        if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
            $default_price = $price['_give_amount'];
        }
    }
    return $default_price;
}
开发者ID:helgatheviking,项目名称:Give,代码行数:21,代码来源:price-functions.php

示例3: give_generate_pdf

/**
 * Generate PDF Reports.
 *
 * Generates PDF report on donations and income for all forms for the current year.
 *
 * @since  1.0
 *
 * @param string $data
 *
 * @uses   give_pdf
 */
function give_generate_pdf($data)
{
    if (!current_user_can('view_give_reports')) {
        wp_die(esc_html__('You do not have permission to generate PDF sales reports.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
    }
    if (!wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) {
        wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
    }
    require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php';
    require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php';
    $daterange = utf8_decode(sprintf(esc_html__('%1$s to %2$s', 'give'), date_i18n(get_option('date_format'), mktime(0, 0, 0, 1, 1, date('Y'))), date_i18n(get_option('date_format'))));
    $pdf = new give_pdf();
    $pdf->AddPage('L', 'A4');
    $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give')));
    $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give')));
    $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give')));
    $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png'), 247, 8);
    $pdf->SetMargins(8, 8, 8);
    $pdf->SetX(8);
    $pdf->SetFont('Helvetica', '', 16);
    $pdf->SetTextColor(50, 50, 50);
    $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false);
    $pdf->SetFont('Helvetica', '', 13);
    $pdf->Ln();
    $pdf->SetTextColor(150, 150, 150);
    $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')) . $daterange, 0, 2, 'L', false);
    $pdf->Ln();
    $pdf->SetTextColor(50, 50, 50);
    $pdf->SetFont('Helvetica', '', 14);
    $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false);
    $pdf->SetFont('Helvetica', '', 12);
    $pdf->SetFillColor(238, 238, 238);
    $pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true);
    $pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true);
    $pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true);
    $pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true);
    $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true);
    $pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true);
    $year = date('Y');
    $give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1));
    if ($give_forms) {
        $pdf->SetWidths(array(70, 30, 50, 50, 45, 35));
        foreach ($give_forms as $form) {
            $pdf->SetFillColor(255, 255, 255);
            $title = $form->post_title;
            if (give_has_variable_prices($form->ID)) {
                $prices = give_get_variable_prices($form->ID);
                $first = $prices[0]['_give_amount'];
                $last = array_pop($prices);
                $last = $last['_give_amount'];
                if ($first < $last) {
                    $min = $first;
                    $max = $last;
                } else {
                    $min = $last;
                    $max = $first;
                }
                $price = html_entity_decode(give_currency_filter(give_format_amount($min)) . ' - ' . give_currency_filter(give_format_amount($max)));
            } else {
                $price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID)));
            }
            $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', '');
            $categories = !is_wp_error($categories) ? strip_tags($categories) : '';
            $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', '');
            $tags = !is_wp_error($tags) ? strip_tags($tags) : '';
            $sales = give_get_form_sales_stats($form->ID);
            $link = get_permalink($form->ID);
            $earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID)));
            if (function_exists('iconv')) {
                // Ensure characters like euro; are properly converted.
                $price = iconv('UTF-8', 'windows-1252', utf8_encode($price));
                $earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings));
            }
            $pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings));
        }
    } else {
        $pdf->SetWidths(array(280));
        $title = utf8_decode(sprintf(esc_html__('No %s found.', 'give'), give_get_forms_label_plural()));
        $pdf->Row(array($title));
    }
    $pdf->Ln();
    $pdf->SetTextColor(50, 50, 50);
    $pdf->SetFont('Helvetica', '', 14);
    $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false);
    $pdf->SetFont('Helvetica', '', 12);
    $image = html_entity_decode(urldecode(give_draw_chart_image()));
    $image = str_replace(' ', '%20', $image);
    $pdf->SetX(25);
    $pdf->Image($image . '&file=.png');
//.........这里部分代码省略.........
开发者ID:wordimpress,项目名称:give,代码行数:101,代码来源:pdf-reports.php

示例4: get_form_data

 /**
  * Given a give_forms post object, generate the data for the API output
  *
  * @since  1.1
  *
  * @param  object $form_info The Download Post Object
  *
  * @return array                Array of post data to return back in the API
  */
 private function get_form_data($form_info)
 {
     $form = array();
     $form['info']['id'] = $form_info->ID;
     $form['info']['slug'] = $form_info->post_name;
     $form['info']['title'] = $form_info->post_title;
     $form['info']['create_date'] = $form_info->post_date;
     $form['info']['modified_date'] = $form_info->post_modified;
     $form['info']['status'] = $form_info->post_status;
     $form['info']['link'] = html_entity_decode($form_info->guid);
     $form['info']['content'] = get_post_meta($form_info->ID, '_give_form_content', true);
     $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
     if (give_get_option('enable_categories') == 'on') {
         $form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
         $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
     }
     if (give_get_option('enable_tags') == 'on') {
         $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
     }
     if (user_can($this->user_id, 'view_give_reports') || $this->override) {
         $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID);
         $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID);
         $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
         $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID);
     }
     $counter = 0;
     if (give_has_variable_prices($form_info->ID)) {
         foreach (give_get_variable_prices($form_info->ID) as $price) {
             $counter++;
             //muli-level item
             $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-' . $counter;
             $form['pricing'][sanitize_key($level)] = $price['_give_amount'];
         }
     } else {
         $form['pricing']['amount'] = give_get_form_price($form_info->ID);
     }
     if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
         //Sensitive data here
     }
     return apply_filters('give_api_forms_form', $form);
     die;
 }
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:51,代码来源:class-give-api.php

示例5: give_get_price_option_amount

/**
 * Retrieves the amount of a variable price option
 *
 * @since 1.0
 *
 * @param int $form_id  ID of the form
 * @param int $price_id ID of the price option
 * @param     int       @payment_id ID of the payment
 *
 * @return float $amount Amount of the price option
 */
function give_get_price_option_amount($form_id = 0, $price_id = 0)
{
    $prices = give_get_variable_prices($form_id);
    $amount = 0.0;
    foreach ($prices as $price) {
        if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] === $price_id) {
            $amount = $price['_give_amount'];
        }
    }
    return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id);
}
开发者ID:helgatheviking,项目名称:Give,代码行数:22,代码来源:functions.php

示例6: give_output_levels

/**
 * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons
 *
 * @since 1.0
 *
 * @param int $form_id Give Form ID
 *
 * @return string
 */
function give_output_levels($form_id)
{
    //Get variable pricing
    $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id);
    $display_style = get_post_meta($form_id, '_give_display_style', true);
    $custom_amount = get_post_meta($form_id, '_give_custom_amount', true);
    $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
    $output = '';
    $counter = 0;
    switch ($display_style) {
        case 'buttons':
            $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">';
            foreach ($prices as $price) {
                $counter++;
                $output .= '<li>';
                $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class="give-donation-level-btn give-btn give-btn-level-' . $counter . ' ' . (isset($price['_give_default']) && $price['_give_default'] === 'default' ? 'give-default-level' : '') . '" value="' . give_format_amount($price['_give_amount']) . '">';
                $output .= !empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter($price['_give_amount']);
                $output .= '</button>';
                $output .= '</li>';
            }
            //Custom Amount
            if ($custom_amount === 'yes' && !empty($custom_amount_text)) {
                $output .= '<li>';
                $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">';
                $output .= $custom_amount_text;
                $output .= '</button>';
                $output .= '</li>';
            }
            $output .= '</ul>';
            break;
        case 'radios':
            $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">';
            foreach ($prices as $price) {
                $counter++;
                $output .= '<li>';
                $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="give-radio-input give-radio-input-level give-radio-level-' . $counter . (isset($price['_give_default']) && $price['_give_default'] === 'default' ? ' give-default-level' : '') . '" name="give-radio-donation-level" id="give-radio-level-' . $counter . '" ' . (isset($price['_give_default']) && $price['_give_default'] === 'default' ? 'checked="checked"' : '') . ' value="' . give_format_amount($price['_give_amount']) . '">';
                $output .= '<label for="give-radio-level-' . $counter . '">' . (!empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter($price['_give_amount'])) . '</label>';
                $output .= '</li>';
            }
            //Custom Amount
            if ($custom_amount === 'yes' && !empty($custom_amount_text)) {
                $output .= '<li>';
                $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">';
                $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>';
                $output .= '</li>';
            }
            $output .= '</ul>';
            break;
        case 'dropdown':
            $output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level">';
            //first loop through prices
            foreach ($prices as $price) {
                $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="give-donation-level-' . $form_id . '" ' . (isset($price['_give_default']) && $price['_give_default'] === 'default' ? 'selected="selected"' : '') . ' value="' . give_format_amount($price['_give_amount']) . '">';
                $output .= !empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter($price['_give_amount']);
                $output .= '</option>';
            }
            //Custom Amount
            if ($custom_amount === 'yes' && !empty($custom_amount_text)) {
                $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>';
            }
            $output .= '</select>';
            break;
    }
    echo apply_filters('give_form_level_output', $output, $form_id);
}
开发者ID:pantelicnevena,项目名称:hanan,代码行数:74,代码来源:template.php

示例7: give_check_for_form_price_variations

/**
 * Check for Price Variations (Multi-level donation forms)
 *
 * @since  1.5
 *
 * @return void
 */
function give_check_for_form_price_variations()
{
    if (!current_user_can('edit_give_forms', get_current_user_id())) {
        die('-1');
    }
    $form_id = intval($_POST['form_id']);
    $form = get_post($form_id);
    if ('give_forms' != $form->post_type) {
        die('-2');
    }
    if (give_has_variable_prices($form_id)) {
        $variable_prices = give_get_variable_prices($form_id);
        if ($variable_prices) {
            $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
            if (isset($_POST['all_prices'])) {
                $ajax_response .= '<option value="">' . esc_html__('All Levels', 'give') . '</option>';
            }
            foreach ($variable_prices as $key => $price) {
                $level_text = !empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
                $ajax_response .= '<option value="' . esc_attr($price['_give_id']['level_id']) . '">' . $level_text . '</option>';
            }
            $ajax_response .= '</select>';
            echo $ajax_response;
        }
    }
    give_die();
}
开发者ID:wordimpress,项目名称:give,代码行数:34,代码来源:ajax-functions.php

示例8: give_get_form_variable_price_dropdown

/**
 * Get/Print give form variable price dropdown html
 *
 * @since 1.6
 *
 * @param array $args Arguments for form dropdown
 * @param bool  $echo This parameter decide if print form dropdown html output or not
 *
 * @return string/void
 */
function give_get_form_variable_price_dropdown($args = array(), $echo = false)
{
    // Check for give form id.
    if (empty($args['id'])) {
        return false;
    }
    // Check if form has variable prices or not.
    if (!($variable_prices = give_has_variable_prices($args['id']))) {
        return false;
    }
    $variable_prices = give_get_variable_prices(absint($args['id']));
    $variable_price_options = array();
    // Check if multi donation form support custom donation or not.
    if (give_is_custom_price_mode(absint($args['id']))) {
        $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
    }
    // Get variable price and ID from variable price array.
    foreach ($variable_prices as $variable_price) {
        $variable_price_options[$variable_price['_give_id']['level_id']] = $variable_price['_give_text'];
    }
    // Update options.
    $args = array_merge($args, array('options' => $variable_price_options));
    // Generate select html.
    $form_dropdown_html = Give()->html->select($args);
    if (!$echo) {
        return $form_dropdown_html;
    }
    echo $form_dropdown_html;
}
开发者ID:wordimpress,项目名称:give,代码行数:39,代码来源:functions.php

示例9: get_data

 /**
  * Get the Export Data
  *
  * @access public
  * @since 1.5
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     $data = array();
     $meta = array('give_price', '_thumbnail_id', 'give_sku', 'give_product_notes', '_give_form_sales', '_give_download_earnings');
     $args = array('post_type' => 'download', 'posts_per_page' => 30, 'paged' => $this->step);
     $downloads = new WP_Query($args);
     if ($downloads->posts) {
         foreach ($downloads->posts as $download) {
             $row = array();
             foreach ($this->csv_cols() as $key => $value) {
                 // Setup default value
                 $row[$key] = '';
                 if (in_array($key, $meta)) {
                     switch ($key) {
                         case '_thumbnail_id':
                             $image_id = get_post_thumbnail_id($download->ID);
                             $row[$key] = wp_get_attachment_url($image_id);
                             break;
                         case 'give_price':
                             if (give_has_variable_prices($download->ID)) {
                                 $prices = array();
                                 foreach (give_get_variable_prices($download->ID) as $price) {
                                     $prices[] = $price['name'] . ': ' . $price['amount'];
                                 }
                                 $row[$key] = implode(' | ', $prices);
                             } else {
                                 $row[$key] = give_get_download_price($download->ID);
                             }
                             break;
                         case '_give_files':
                             $files = array();
                             foreach (give_get_download_files($download->ID) as $file) {
                                 $files[] = $file['file'];
                             }
                             $row[$key] = implode(' | ', $files);
                             break;
                         default:
                             $row[$key] = get_post_meta($download->ID, $key, true);
                             break;
                     }
                 } elseif (isset($download->{$key})) {
                     switch ($key) {
                         case 'post_author':
                             $row[$key] = get_the_author_meta('user_login', $download->post_author);
                             break;
                         default:
                             $row[$key] = $download->{$key};
                             break;
                     }
                 } elseif ('tags' == $key) {
                     $terms = get_the_terms($download->ID, 'download_tag');
                     if ($terms) {
                         $terms = wp_list_pluck($terms, 'name');
                         $row[$key] = implode(' | ', $terms);
                     }
                 } elseif ('categories' == $key) {
                     $terms = get_the_terms($download->ID, 'download_category');
                     if ($terms) {
                         $terms = wp_list_pluck($terms, 'name');
                         $row[$key] = implode(' | ', $terms);
                     }
                 }
             }
             $data[] = $row;
         }
         $data = apply_filters('give_export_get_data', $data);
         $data = apply_filters('give_export_get_data_' . $this->export_type, $data);
         return $data;
     }
     return false;
 }
开发者ID:wordimpress,项目名称:give,代码行数:78,代码来源:class-batch-export-forms.php


注:本文中的give_get_variable_prices函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。