BP_Messages_Notice::get_notices( array $args = array() )

Pulls up a list of notices.


Description Description

To get all notices, pass a value of -1 to pag_num.


Parameters Parameters

$args

(Optional) Array of parameters.

  • 'pag_num'
    (int) Number of notices per page. Defaults to 20.
  • 'pag_page'
    (int) The page number. Defaults to 1.

Default value: array()


Top ↑

Return Return

(object) List of notices to display.


Top ↑

Source Source

File: bp-messages/classes/class-bp-messages-notice.php

	public static function get_notices( $args = array() ) {
		global $wpdb;

		$r = wp_parse_args( $args, array(
			'pag_num'  => 20, // Number of notices per page.
			'pag_page' => 1   // Page number.
		) );

		$limit_sql = '';
		if ( (int) $r['pag_num'] >= 0 ) {
			$limit_sql = $wpdb->prepare( "LIMIT %d, %d", (int) ( ( $r['pag_page'] - 1 ) * $r['pag_num'] ), (int) $r['pag_num'] );
		}

		$bp = buddypress();

		$notices = $wpdb->get_results( "SELECT * FROM {$bp->messages->table_name_notices} ORDER BY date_sent DESC {$limit_sql}" );

		// Integer casting.
		foreach ( (array) $notices as $key => $data ) {
			$notices[ $key ]->id        = (int) $notices[ $key ]->id;
			$notices[ $key ]->is_active = (int) $notices[ $key ]->is_active;
		}

		/**
		 * Filters the array of notices, sorted by date and paginated.
		 *
		 * @since 2.8.0
		 *
		 * @param array $r Array of parameters.
		 */
		return apply_filters( 'messages_notice_get_notices', $notices, $r );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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