BP_Admin_Types::column_contents( $column_content = '', string $column_name = '', int $type_id )

Sets the content for the Plural name & Counts columns.


Parameters Parameters

$string

(string) (Required) Blank string.

$column_name

(string) (Optional) Name of the column.

Default value: ''

$type_id

(int) (Required) The type's term ID.


Top ↑

Return Return

(string) The Type Plural name.


Source Source

File: bp-core/classes/class-bp-admin-types.php

	public function column_contents( $column_content = '', $column_name = '', $type_id = 0 ) {
		if ( 'plural_name' !== $column_name && 'counts' !== $column_name || ! $type_id ) {
			return $column_content;
		}

		// Set the Plural name column.
		if ( 'plural_name' === $column_name ) {
			$type_plural_name = get_term_meta( $type_id, 'bp_type_name', true );

			// Plural name meta is not set? Let's check register by code types!
			if ( ! $type_plural_name ) {
				$type_name = get_term_field( 'name', $type_id, $this->taxonomy );

				/**
				 * Filter here to set missing term meta for registered by code types.
				 *
				 * @see bp_set_registered_by_code_member_type_metadata() for an example of use.
				 *
				 * @since 7.0.0
				 *
				 * @param string $value Metadata for the BP Type.
				 */
				$metadata = apply_filters( "{$this->taxonomy}_set_registered_by_code_metada", array(), $type_name );

				if ( isset( $metadata['bp_type_name'] ) ) {
					$type_plural_name = $metadata['bp_type_name'];
				}
			}

			echo esc_html( $type_plural_name );

			// Set the Totals column.
		} elseif ( 'counts' === $column_name ) {
			global $parent_file;
			$type  = bp_get_term_by( 'id', $type_id, $this->taxonomy );
			if ( 0 === (int) $type->count ) {
				return 0;
			}

			// Format the count.
			$count = number_format_i18n( $type->count );

			$args = array(
				str_replace( '_', '-', $this->taxonomy ) => $type->slug,
			);

			$base_url = $parent_file;
			if ( false === strpos( $parent_file, '.php' ) ) {
				$base_url = add_query_arg( 'page', $parent_file, 'admin.php' );
			}

			printf(
				'<a href="%1$s">%2$s</a>',
				esc_url( add_query_arg( $args, bp_get_admin_url( $base_url ) ) ),
				esc_html( $count )
			);
		}
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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