/var/www/vhosts/ihelp.ro/ajutam.ro/wp-content/plugins/give/includes/forms
NameSizeModeActions
class-give-forms-query.php35460644editdlrm
functions.php396390644editdlrm
template.php785620644editdlrm
widget.php230900644editdlrm
Edit: /var/www/vhosts/ihelp.ro/ajutam.ro/wp-content/plugins/give/includes/forms/template.php (78562B)
ID ) { $args['id'] = $post->ID; } // set `form_id` for backward compatibility because many legacy filters and functions are using it. $args['form_id'] = $args['id']; /** * Fire the filter * Note: we will deprecate this filter soon. Use give_get_default_form_shortcode_args instead * * @deprecated 2.4.1 */ $args = apply_filters( 'give_form_args_defaults', $args ); $form = new Give_Donate_Form( $args['id'] ); // Bail out, if no form ID. if ( empty( $form->ID ) ) { return false; } $args['id_prefix'] = "{$form->ID}-{$count}"; $payment_mode = give_get_chosen_gateway( $form->ID ); $form_action = add_query_arg( apply_filters( 'give_form_action_args', [ 'payment-mode' => $payment_mode, 'form-id' => $form->ID, ] ), give_get_current_page_url() ); // Sanity Check: Donation form not published or user doesn't have permission to view drafts. if ( ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) || ( 'trash' === $form->post_status ) ) { return false; } // Get the form wrap CSS classes. $form_wrap_classes = $form->get_form_wrap_classes( $args ); // Get the
tag wrap CSS classes. $form_classes = $form->get_form_classes( $args ); ob_start(); /** * Fires while outputting donation form, before the form wrapper div. * * @param int Give_Donate_Form::ID The form ID. * @param array $args An array of form arguments. * * @since 1.0 */ do_action( 'give_pre_form_output', $form->ID, $args, $form ); ?>
is_close_donation_form() ) { $form_title = ! is_singular( 'give_forms' ) ? apply_filters( 'give_form_title', '

' . get_the_title( $form->ID ) . '

' ) : ''; // Get Goal thank you message. $goal_achieved_message = give_get_meta( $form->ID, '_give_form_goal_achieved_message', true ); $goal_achieved_message = ! empty( $goal_achieved_message ) ? $form_title . apply_filters( 'the_content', $goal_achieved_message ) : ''; // Print thank you message. echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form ); } else { /** * Show form title: * 1. if admin set form display_style to button or modal */ $form_title = apply_filters( 'give_form_title', '

' . get_the_title( $form->ID ) . '

' ); if ( ! doing_action( 'give_single_form_summary' ) && true === $args['show_title'] ) { echo $form_title; } /** * Fires while outputting donation form, before the form. * * @param int Give_Donate_Form::ID The form ID. * @param array $args An array of form arguments. * @param Give_Donate_Form $form Form object. * * @since 1.0 */ do_action( 'give_pre_form', $form->ID, $args, $form ); // Set form html tags. $form_html_tags = [ 'id' => "give-form-{$args['id_prefix']}", 'class' => $form_classes, 'action' => esc_url_raw( $form_action ), 'data-id' => $args['id_prefix'] ]; /** * Filter the form html tags. * * @param array $form_html_tags Array of form html tags. * @param Give_Donate_Form $form Form object. * * @since 1.8.17 */ $form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form ); ?> method="post"> ID, $args, $form ); /** * Fires while outputting donation form, for payment gateway fields. * * @param int Give_Donate_Form::ID The form ID. * @param array $args An array of form arguments. * @param Give_Donate_Form $form Form object. * * @since 1.7 */ do_action( 'give_payment_mode_select', $form->ID, $args, $form ); /** * Fires while outputting donation form, after all other fields. * * @param int Give_Donate_Form::ID The form ID. * @param array $args An array of form arguments. * @param Give_Donate_Form $form Form object. * * @since 1.0 */ do_action( 'give_donation_form_bottom', $form->ID, $args, $form ); ?> ID, $args, $form ); } ?>
ID, $args ); $final_output = ob_get_clean(); $count ++; echo apply_filters( 'give_donate_form', $final_output, $args ); } /** * Give Show Donation Form. * * Renders the Donation Form, hooks are provided to add to the checkout form. * The default Donation Form rendered displays a list of the enabled payment * gateways, a user registration form (if enable) and a credit card info form * if credit cards are enabled. * * @param int $form_id The form ID. * * @return string * @since 1.0 */ function give_show_purchase_form( $form_id, $args ) { $payment_mode = give_get_chosen_gateway( $form_id ); if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { $form_id = $_POST['give_form_id']; } /** * Fire before donation form render. * * @since 1.7 */ do_action( 'give_payment_fields_top', $form_id ); if ( give_can_checkout() && isset( $form_id ) ) { /** * Fires while displaying donation form, before registration login. * * @since 1.7 */ do_action( 'give_donation_form_before_register_login', $form_id, $args ); /** * Fire when register/login form fields render. * * @since 1.7 */ do_action( 'give_donation_form_register_login_fields', $form_id, $args ); /** * Fire when credit card form fields render. * * @since 1.7 */ do_action( 'give_donation_form_before_cc_form', $form_id, $args ); // Load the credit card form and allow gateways to load their own if they wish. if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { /** * Fires while displaying donation form, credit card form fields for a given gateway. * * @param int $form_id The form ID. * * @since 1.0 */ do_action( "give_{$payment_mode}_cc_form", $form_id, $args ); } else { /** * Fires while displaying donation form, credit card form fields. * * @param int $form_id The form ID. * * @since 1.0 */ do_action( 'give_cc_form', $form_id, $args ); } /** * Fire after credit card form fields render. * * @since 1.7 */ do_action( 'give_donation_form_after_cc_form', $form_id, $args ); } else { /** * Fire if user can not donate. * * @since 1.7 */ do_action( 'give_donation_form_no_access', $form_id ); } /** * Fire after donation form rendered. * * @since 1.7 */ do_action( 'give_payment_fields_bottom', $form_id, $args ); } add_action( 'give_donation_form', 'give_show_purchase_form', 10, 2 ); /** * Give Show Login/Register Form Fields. * * @param int $form_id The form ID. * * @return void * @since 1.4.1 */ function give_show_register_login_fields( $form_id ) { $show_register_form = give_show_login_register_option( $form_id ); if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?>
' . $symbol . ''; $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), [ 'sanitize' => false, 'currency' => give_get_currency( $form_id ), ] ); $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); /** * Fires while displaying donation form, before donation level fields. * * @param int $form_id The form ID. * @param array $args An array of form arguments. * * @since 1.0 */ do_action( 'give_before_donation_levels', $form_id, $args ); // Set Price, No Custom Amount Allowed means hidden price field. if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { ?>

'; foreach ( $prices as $price ) { $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], [ 'sanitize' => false ] ), [ 'currency_code' => give_get_currency( $form_id ) ] ), $form_id, $price ); $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( give_is_default_level_id( $price ) ? 'give-default-level' : '' ), $form_id, $price ); $formatted_amount = give_format_amount( $price['_give_amount'], [ 'sanitize' => false, 'currency' => give_get_currency( $form_id ), ] ); $output .= sprintf( '
  • ', $price['_give_id']['level_id'], $level_classes, $formatted_amount, array_key_exists( '_give_default', $price ) ? 1 : 0, $level_text ); } // Custom Amount. if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { $output .= sprintf( '
  • ', esc_html( $custom_amount_text ) ); } $output .= ''; break; case 'radios': $output .= ''; break; case 'dropdown': $output .= ''; $output .= ''; break; } echo apply_filters( 'give_form_level_output', $output, $form_id ); } /** * Display Reveal & Lightbox Button. * * Outputs a button to reveal form fields. * * @param int $form_id The form ID. * @param array $args An array of form arguments. * * @return string Checkout button. * @since 1.0 */ function give_display_checkout_button( $form_id, $args ) { $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) ? $args['display_style'] : give_get_meta( $form_id, '_give_payment_display', true ); if ( 'button' === $display_option ) { add_action( 'give_post_form', 'give_add_button_open_form', 10, 2 ); return ''; } if ( $display_option === 'onpage' ) { return ''; } $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); $output = ''; /** * filter the button html * * @param string $output Button HTML. * @param int $form_id Form ID. * @param array $args Shortcode argument */ echo apply_filters( 'give_display_checkout_button', $output, $form_id, $args ); } add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); /** * Display MagnificPopup Button. * * @since 2.5.11 * * @param $form_id * @param $args * * @return string */ function give_add_button_open_form( $form_id, $args ) { $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); $output = sprintf( '', $display_label ); /** * filter the button html * * @param string $output Button HTML. * @param int $form_id Form ID. * @param array $args Shortcode argument */ echo apply_filters( 'give_display_checkout_button', $output, $form_id, $args ); // Remove action otherwise button will be added to coming form. // @see https://github.com/impress-org/givewp/issues/4395 remove_action( 'give_post_form', 'give_add_button_open_form', 10 ); } /** * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. * * @param int $form_id The form ID. * * @return void * @see For Pattern Attribute: https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation * * @since 1.0 */ function give_user_info_fields( $form_id ) { // Get user info. $give_user_info = _give_get_prefill_form_field_values( $form_id ); $title = ! empty( $give_user_info['give_title'] ) ? $give_user_info['give_title'] : ''; $first_name = ! empty( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; $last_name = ! empty( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; $company_name = ! empty( $give_user_info['company_name'] ) ? $give_user_info['company_name'] : ''; $email = ! empty( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; $title_prefixes = give_get_name_title_prefixes( $form_id ); /** * Fire before user personal information fields * * @since 1.7 */ do_action( 'give_donation_form_before_personal_info', $form_id ); $title_prefix_classes = ''; if ( give_is_name_title_prefix_enabled( $form_id ) ) { $title_prefix_classes = 'give-title-prefix-wrap'; } ?>
    0 ) { ?>

    />

    />

    />

    />

    />

    />

    />

    />

    />

    ', 'data-time="' . time() . '" data-nonce-life="' . give_get_nonce_life() . '"/>', give_get_nonce_field( "give_form_create_user_nonce_{$form_id}", 'give-form-user-register-hash', false ) ); ?>
    ' . __( '(optional)', 'give' ) . ''; } ?>

    this form\'s settings.', 'give' ), $edit_term_url ); } return false; } /** * Filter the form term content * * @since 2.1.5 */ $terms = apply_filters( 'give_the_term_content', wpautop( do_shortcode( $terms ) ), $terms, $form_id ); ?>
    give_get_currency( $form_id ) ] ) ) : give_get_default_form_amount( $form_id ); // Only proceed if give_total available. if ( empty( $total ) ) { return; } ?>

    false, 'currency' => give_get_currency( $form_id ), ] ), [ 'currency_code' => give_get_currency( $form_id ) ] ); ?>

    $form_id, 'args' => $args, ] ); /** * Filter progress bar output * * @since 2.0 */ echo apply_filters( 'give_goal_output', ob_get_clean(), $form_id, $args ); return true; } add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); /** * Show Give Totals Progress. * * @param int $total Total amount based on shortcode parameter. * @param int $total_goal Total Goal amount passed by Admin. * * @return mixed * @since 2.1 */ function give_show_goal_totals_progress( $total, $total_goal ) { // Bail out if total goal is set as an array. if ( isset( $total_goal ) && is_array( $total_goal ) ) { return false; } ob_start(); give_get_template( 'shortcode-totals-progress', [ 'total' => $total, 'total_goal' => $total_goal, ] ); echo apply_filters( 'give_total_progress_output', ob_get_clean() ); return true; } add_action( 'give_pre_form', 'give_show_goal_totals_progress', 10, 2 ); /** * Get form content position. * * @param $form_id * @param $args * * @return mixed|string * @since 1.8 */ function give_get_form_content_placement( $form_id, $args ) { $show_content = ''; if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { // Content positions. $content_placement = [ 'above' => 'give_pre_form', 'below' => 'give_post_form', ]; // Check if content position already decoded. if ( in_array( $args['show_content'], $content_placement ) ) { return $args['show_content']; } $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { $show_content = give_get_meta( $form_id, '_give_content_placement', true ); } return $show_content; } /** * Adds Actions to Render Form Content. * * @param int $form_id The form ID. * @param array $args An array of form arguments. * * @return void|bool * @since 1.0 */ function give_form_content( $form_id, $args ) { $show_content = give_get_form_content_placement( $form_id, $args ); // Bailout. if ( empty( $show_content ) ) { return false; } // Add action according to value. add_action( $show_content, 'give_form_display_content', 10, 2 ); } add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); /** * Renders Post Form Content. * * Displays content for Give forms; fired by action from give_form_content. * * @param int $form_id The form ID. * @param array $args An array of form arguments. * * @return void * @since 1.0 */ function give_form_display_content( $form_id, $args ) { $content = give_get_meta( $form_id, '_give_form_content', true ); $show_content = give_get_form_content_placement( $form_id, $args ); if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { // Do not restore wpautop if we are still parsing blocks. $priority = has_filter( 'the_content', '_restore_wpautop_hook' ); if ( false !== $priority && doing_filter( 'the_content' ) ) { remove_filter( 'the_content', '_restore_wpautop_hook', $priority ); } $content = apply_filters( 'the_content', $content ); // Restore wpautop after done with blocks parsing. if ( $priority ) { // Run wpautop manually if parsing block $content = wpautop( $content ); add_filter( 'the_content', '_restore_wpautop_hook', $priority ); } } else { $content = wpautop( do_shortcode( $content ) ); } $output = sprintf( '
    %s
    ', $form_id, $show_content, $content ); /** * Filter form content html * * @param string $output * @param int $form_id * @param array $args * * @since 1.0 */ echo apply_filters( 'give_form_content_output', $output, $form_id, $args ); // remove action to prevent content output on addition forms on page. // @see: https://github.com/impress-org/give/issues/634. remove_action( $show_content, 'give_form_display_content' ); } /** * Renders the hidden Checkout fields. * * @param int $form_id The form ID. * @param array $args Shortcode args. * * @return void * @since 1.0 */ function give_checkout_hidden_fields( $form_id, $args = [] ) { /** * Fires while rendering hidden checkout fields, before the fields. * * @param int $form_id The form ID. * * @since 1.0 */ do_action( 'give_hidden_fields_before', $form_id, $args ); if ( is_user_logged_in() ) { ?>

    ' . esc_html__( 'Notice:', 'give' ) . ' ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '

    '; } } add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); /** * Members-only Form. * * If "Disable Guest Donations" and "Display Register / Login" is set to none. * * @param string $final_output * @param array $args * * @return string * @since 1.4.1 */ function give_members_only_form( $final_output, $args ) { $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; // Sanity Check: Must have form_id & not be logged in. if ( empty( $form_id ) || is_user_logged_in() ) { return $final_output; } // Logged in only and Register / Login set to none. if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { $final_output = Give_Notices::print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); return apply_filters( 'give_members_only_output', $final_output, $form_id ); } return $final_output; } add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); /** * Add donation form hidden fields. * * @param int $form_id * @param array $args * @param Give_Donate_Form $form * * @since 1.8.17 */ function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; ?> session->has_session() ) ); // WP nonce field. echo str_replace( '/>', "{$data_attr}/>", give_get_nonce_field( "give_donation_form_nonce_{$form_id}", 'give-form-hash', false ) ); // Price ID hidden field for variable (multi-level) donation forms. if ( give_has_variable_prices( $form_id ) ) { // Get the default price ID. $default_price = give_form_get_default_level( $form_id ); $price_id = isset( $default_price['_give_id']['level_id'] ) ? $default_price['_give_id']['level_id'] : 0; echo sprintf( '', $price_id ); } } add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); /** * Add currency settings on donation form. * * @param array $form_html_tags * @param Give_Donate_Form $form * * @return array * @since 1.8.17 */ function __give_form_add_currency_settings( $form_html_tags, $form ) { $form_currency = give_get_currency( $form->ID ); $currency_settings = give_get_currency_formatting_settings( $form_currency ); // Check if currency exist. if ( empty( $currency_settings ) ) { return $form_html_tags; } $form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency ); $form_html_tags['data-currency_code'] = $form_currency; if ( ! empty( $currency_settings ) ) { foreach ( $currency_settings as $key => $value ) { $form_html_tags[ "data-{$key}" ] = $value; } } return $form_html_tags; } add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); /** * Adds classes to progress bar container. * * @param string $class_goal * * @return string * @since 2.1 */ function add_give_goal_progress_class( $class_goal ) { $class_goal = 'progress progress-striped active'; return $class_goal; } /** * Adds classes to progress bar span tag. * * @param string $class_bar * * @return string * @since 2.1 */ function add_give_goal_progress_bar_class( $class_bar ) { $class_bar = 'bar'; return $class_bar; } /** * Add a class to the form wrap on the grid page. * * @param array $class Array of form wrapper classes. * @param int $id ID of the form. * @param array $args Additional args. * * @return array * @since 2.1 */ function add_class_for_form_grid( $class, $id, $args ) { $class[] = 'give-form-grid-wrap'; foreach ( $class as $index => $item ) { if ( false !== strpos( $item, 'give-display-' ) ) { unset( $class[ $index ] ); } } return $class; } /** * Add hidden field to Form Grid page * * @param int $form_id The form ID. * @param array $args An array of form arguments. * @param Give_Donate_Form $form Form object. * * @since 2.1 */ function give_is_form_grid_page_hidden_field( $id, $args, $form ) { echo ''; } /** * Redirect to the same paginated URL on the Form Grid page * and adds query parameters to open the popup again after * redirection. * * @param string $redirect URL for redirection. * @param array $args Array of additional args. * * @return string * @since 2.1 */ function give_redirect_and_popup_form( $redirect, $args ) { // Check the page has Form Grid. $is_form_grid = isset( $_POST['is-form-grid'] ) ? give_clean( $_POST['is-form-grid'] ) : ''; if ( 'true' === $is_form_grid ) { $payment_mode = give_clean( $_POST['payment-mode'] ); $form_id = $args['form-id']; // Get the URL without Query parameters. $redirect = strtok( $redirect, '?' ); // Add query parameters 'form-id' and 'payment-mode'. $redirect = add_query_arg( [ 'form-id' => $form_id, 'payment-mode' => $payment_mode, ], $redirect ); } // Return the modified URL. return $redirect; } add_filter( 'give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2 );