public function wc_quick_donation_handler($settings) { global $donation_box, $donation_price, $currency; $settings = shortcode_atts(array('type' => wcqd_get_option(WC_QD_DB . 'default_render_type'), 'grouped' => false, 'show_errors' => wcqd_get_option(WC_QD_DB . 'shortcode_show_errors'), 'selected_value' => wcqd_get_option(WC_QD_DB . 'pre_selected_project'), 'defined_amount' => false), $settings); $donation_box = WC_QD()->f()->generate_donation_selbox($settings['grouped'], $settings['type'], $settings['selected_value']); $donation_price = WC_QD()->f()->generate_price_box($settings['defined_amount']); $currency = get_woocommerce_currency_symbol(); $return_value = ''; $messages = ''; if ($settings['show_errors']) { ob_start(); wc_print_notices(); $return_value .= ob_get_clean(); ob_flush(); } do_action('wc_quick_donation_before_doantion_form', $return_value, $settings['type'], $settings['grouped']); $return_value .= WC_QD()->f()->load_template('donation-form.php', WC_QD_TEMPLATE, array('donation_box' => $donation_box, 'donation_price' => $donation_price, 'currency' => $currency)); do_action('wc_quick_donation_after_doantion_form', $return_value, $settings['type'], $settings['grouped']); return $return_value; }
public function generate_price_box($predefined = false) { global $id, $name, $class, $field_output, $attributes, $value; $type = 'text'; $field_type = 'number'; if ($predefined) { $type = 'select'; } $field_output = ''; $id = 'donation_price'; $name = 'wc_qd_donate_project_price'; $class = apply_filters('wcqd_project_price_class', array(), $type); $custom_attributes = apply_filters('wcqd_project_price_attribute', array(), $type); $value = ''; $pre_amt = array(); $class = implode(' ', $class); $attributes = ''; foreach ($custom_attributes as $attr_key => $attr_val) { $attributes .= $attr_key . '="' . $attr_val . '" '; } if ($predefined) { $amount = wcqd_get_option(WC_QD_DB . 'pre_defined_amount'); $amount = explode('|', $amount); $c = get_woocommerce_currency_symbol(); foreach ($amount as $amts) { $pre_amt[$amts] = $c . '' . $amts; } } $project_list = $pre_amt; $field_output = $this->load_template('field-' . $type . '.php', WC_QD_TEMPLATE . 'fields/', array('id' => $id, 'name' => $name, 'class' => $class, 'field_output' => $field_output, 'is_grouped' => false, 'project_list' => $project_list, 'pre_selected' => false, 'attributes' => $attributes, 'value' => $value, 'field_type' => $field_type)); return $field_output; }