BP_XProfile_Field_Type_Checkbox_Acceptance::display_filter( string $field_value, int $field_id )

Modify the appearance of value.


Parameters Parameters

$field_value

(string) (Required) Original value of field.

$field_id

(int) (Required) field id.


Top ↑

Return Return

(string) Value formatted


Source Source

File: bp-xprofile/classes/class-bp-xprofile-field-type-checkbox-acceptance.php

	public static function display_filter( $field_value, $field_id = 0 ) {
		$page_id = bp_xprofile_get_meta( $field_id, 'field', 'bp_xprofile_checkbox_acceptance_page', true );
		$page    = null;
		$html    = esc_html__( 'No', 'buddypress' );

		/* translators: %s: link to the page the user needs to accept the terms of. */
		$acceptance_text = esc_html__( 'I did not agree to %s', 'buddypress' );

		if ( $page_id ) {
			$page = get_post( $page_id );
		}

		if ( ! empty( $field_value ) ) {
			$html = esc_html__( 'Yes', 'buddypress' );

			/* translators: %s: link to the page the user needs to accept the terms of. */
			$acceptance_text = esc_html__( 'I agreed to %s.', 'buddypress' );
		}

		if ( $page instanceof WP_Post ) {
			$html = sprintf(
				$acceptance_text,
				'<a href="' . esc_url( get_permalink( $page ) ) . '">' . esc_html( get_the_title( $page ) ) . '</a>'
			);
		}

		return $html;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
8.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.