Viewing 1 replies (of 1 total)
  • Plugin Author Devin Walker

    (@dlocc)

    Hey @naresh11381 – You’re right that snippet is a bit out of date. I’ve resolved the issue with it and added more parameters to the give_recurring_output_donors_choice_text within Recurring 1.6 which isn’t yet released. If you want to use the snippet now you can update the filter within the add-on yourself since it’s already included in the next version which has yet to be released.

    The updated code would be:

    
    /**
     *
     * Set Donors Choice Template Checkbox
     *
     * Outputs a checkbox that can be modified
     *
     * @param       $form_id
     *
     * @return mixed
     */
    function give_output_donors_choice_checkbox( $form_id ) {
    
    	$form_option = give_get_meta( $form_id, '_give_recurring', true );
    
    	// Sanity check, ensure donor choice is active
    	if ( $form_option !== 'yes_donor' ) {
    		return false;
    	}
    
    	$period_functionality = give_get_meta( $form_id, '_give_period_functionality', true );
    	$period               = give_get_meta( $form_id, '_give_period', true );
    	$times                = give_get_meta( $form_id, '_give_times', true );
    	$checked_option       = give_get_meta( $form_id, '_give_checkbox_default', true );
    	$checked              = ( $checked_option == 'yes' || empty( $checked_option ) ) ? 'checked' : ''; ?>
    
    	<div class="give-recurring-donors-choice">
    		<?php
    		$show_period = ( 'donors_choice' === $period_functionality ? give_recurring_donors_choice_period_element( $form_id ) : give_recurring_pretty_subscription_frequency( $period, $times, true ));
    
    		echo sprintf(
    			'<input id="%1$s" class="%2$s" name="%2$s" type="checkbox" data-period="%3$s" %4$s /> <label for="%1$s">%5$s</label>',
    			'give-' . $period_functionality . '-' . $form_id,
    			'give-recurring-period',
    			ucfirst( give_recurring_pretty_subscription_frequency( $period, $times, true ) ),
    			apply_filters( 'give_recurring_donors_choice_checked', $checked, $form_id ),
    			apply_filters(
    				'give_recurring_output_donors_choice_text',
    				sprintf(
    					esc_html__( 'Make this donation %1$s', 'give-recurring' ),
    					$show_period
    				),
                    $period,
                    $times,
    				$show_period,
                    $form_id
    			)
    		);
    		?>
    	</div>
    	<?php
    	return true;
    }
    
    add_action( 'give_after_donation_levels', 'give_output_donors_choice_checkbox', 1, 1 );
    

    I hope this helps you achieve the custom text you’re looking for. Thanks for pointing out that the code needed to be updated.

    • This reply was modified 1 year, 10 months ago by Devin Walker. Reason: code improvement
    • This reply was modified 1 year, 10 months ago by Devin Walker. Reason: code format
Viewing 1 replies (of 1 total)
  • The topic ‘Issues with filters’ is closed to new replies.