Exemple #1
0
/**
 * Donation Form Shortcode
 *
 * Show the Give donation form.
 *
 * @since       1.0
 *
 * @param array $atts     Shortcode attributes
 * @param string $content
 *
 * @return string
 */
function give_form_shortcode($atts, $content = null)
{
    $atts = shortcode_atts(array('id' => '', 'show_title' => true, 'show_goal' => true, 'show_content' => '', 'float_labels' => '', 'display_style' => ''), $atts, 'give_form');
    foreach ($atts as $key => $value) {
        //convert shortcode_atts values to booleans
        if ($key == 'show_title') {
            $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
        } elseif ($key == 'show_goal') {
            $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
        }
        //validate show_content value
        if ($key == 'show_content') {
            if (!in_array($value, array('none', 'above', 'below'))) {
                $atts[$key] = '';
            } else {
                if ($value == 'above') {
                    $atts[$key] = 'give_pre_form';
                } else {
                    if ($value == 'below') {
                        $atts[$key] = 'give_post_form';
                    }
                }
            }
        }
        //validate display_style and float_labels value
        if ($key == 'display_style' && !in_array($value, array('onpage', 'reveal', 'modal')) || $key == 'float_labels' && !in_array($value, array('enabled', 'disabled'))) {
            $atts[$key] = '';
        }
    }
    //get the Give Form
    ob_start();
    give_get_donation_form($atts);
    $final_output = ob_get_clean();
    return apply_filters('give_donate_form', $final_output, $atts);
}
Exemple #2
0
/**
 * Donation Form Shortcode
 *
 * Show the Give donation form.
 *
 * @since 1.0
 *
 * @param array  $atts Shortcode attributes
 * @param string $content
 *
 * @return string
 */
function give_form_shortcode($atts, $content = null)
{
    $atts = shortcode_atts(array('id' => '', 'show_title' => true), $atts, 'give_form');
    //get the Give Form
    ob_start();
    give_get_donation_form($atts);
    $final_output = ob_get_clean();
    return apply_filters('give_donate_form', $final_output, $atts);
}
Exemple #3
0
 /**
  * Echo the widget content.
  *
  * @param array $args     Display arguments including before_title, after_title,
  *                        before_widget, and after_widget.
  * @param array $instance The settings for the particular instance of the widget.
  */
 public function widget($args, $instance)
 {
     extract($args);
     $title = !empty($instance['title']) ? $instance['title'] : '';
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     echo $before_widget;
     do_action('give_before_forms_widget');
     echo $title ? $before_title . $title . $after_title : '';
     give_get_donation_form($instance);
     echo $after_widget;
     do_action('give_after_forms_widget');
 }
Exemple #4
0
 /**
  * Echo the widget content.
  *
  * @param array $args     Display arguments including before_title, after_title,
  *                        before_widget, and after_widget.
  * @param array $instance The settings for the particular instance of the widget.
  */
 public function widget($args, $instance)
 {
     $title = !empty($instance['title']) ? $instance['title'] : '';
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     // If user set float labels to global then check global float label setting and update donation form widget accordingly.
     if ('global' === $instance['float_labels']) {
         $instance['float_labels'] = 'on' === give_get_option('enable_floatlabels', '') ? 'enabled' : 'disabled';
     }
     echo $args['before_widget'];
     do_action('give_before_forms_widget');
     echo $title ? $args['before_title'] . $title . $args['after_title'] : '';
     give_get_donation_form($instance);
     echo $args['after_widget'];
     do_action('give_after_forms_widget');
 }
 public function test_get_donation_form()
 {
     $this->go_to('/');
     $args = array('id' => $this->_post->ID);
     ob_start();
     $form = give_get_donation_form($args);
     $form = ob_get_clean();
     $this->assertInternalType('string', $form);
     $this->assertContains('<form id="give-form-', $form);
     $this->assertContains('class="give-form', $form);
     $this->assertContains('method="post">', $form);
     $this->assertContains('<input type="hidden" name="give-form-id" value="' . $this->_post->ID . '" />', $form);
     $this->assertContains('<input type="hidden" name="give-form-title" value="' . get_the_title($this->_post->ID) . '" />', $form);
     $this->assertContains('<input type="hidden" name="give-form-url" value="' . get_permalink($this->_post->ID) . '" />', $form);
     // The donation form we created has variable pricing, so ensure the price options render
     $this->assertContains('class="give-donation-levels-wrap', $form);
     $this->assertContains('<input type="hidden" name="give-price-id"', $form);
     // Test a single price point as well
 }
" 
                        aria-valuemin="0" aria-valuemax="100" style="min-width: 3em; width: <?php 
    echo $width_bar;
    ?>
%">
                        <?php 
    echo $width_bar;
    ?>
%
                    </div>
                </div>
                <?php 
    php;
    ?>
                <?php 
    give_get_donation_form($args = array());
    ?>
                
            </div>
        </div>
        </div><!-- #div row-## --> 
       
        <div class="row">
            <div class="col-md-12" id="text-content">
               <div id="give-form-content-<?php 
    echo $form_id;
    ?>
" class="text-explain"><?php 
    echo $content;
    ?>
 </div>
Exemple #7
0
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     echo $args['before_widget'];
     do_action('give_before_forms_widget');
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     give_get_donation_form($instance);
     echo $args['after_widget'];
     do_action('give_after_forms_widget');
 }