bbPress::register_meta()

Register bbPress meta-data


Description Description

Counts added in 2.6.0 to avoid negative values


Source Source

File: bbpress.php

	public function register_meta() {

		// Define "count" meta-type array
		$count = array(

			// Counts are always integers
			'type'              => 'integer',

			// Generic count description
			'description'       => esc_html__( 'bbPress Item Count', 'bbpress' ),

			// Counts are single values
			'single'            => true,

			// Counts should be made available in REST
			'show_in_rest'      => true,

			// Never allow counts to go negative
			'sanitize_callback' => 'bbp_number_not_negative',

			// All users may update count meta data
			'auth_callback'     => '__return_true'
		);

		/** Post **************************************************************/

		// Counts
		register_meta( 'post', '_bbp_topic_count',           $count );
		register_meta( 'post', '_bbp_reply_count',           $count );
		register_meta( 'post', '_bbp_total_topic_count',     $count );
		register_meta( 'post', '_bbp_total_reply_count',     $count );
		register_meta( 'post', '_bbp_voice_count',           $count );
		register_meta( 'post', '_bbp_anonymous_reply_count', $count );
		register_meta( 'post', '_bbp_topic_count_hidden',    $count );
		register_meta( 'post', '_bbp_reply_count_hidden',    $count );
		register_meta( 'post', '_bbp_forum_subforum_count',  $count );

		/* User ***************************************************************/

		// Counts
		register_meta( 'user', '_bbp_topic_count', $count );
		register_meta( 'user', '_bbp_reply_count', $count );

		// Activity
		register_meta( 'user', '_bbp_last_posted', array(
			'type'              => 'integer',
			'description'       => esc_html__( 'bbPress User Activity', 'bbpress' ),
			'single'            => true,
			'show_in_rest'      => true,
			'sanitize_callback' => 'bbp_number_not_negative',
			'auth_callback'     => '__return_true'
		) );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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