BP_Activity_Activity::populate()

Populate the object with data about the specific activity item.


Description Description


Source Source

File: bp-activity/classes/class-bp-activity-activity.php

	public function populate() {
		global $wpdb;

		$row = wp_cache_get( $this->id, 'bp_activity' );

		if ( false === $row ) {
			$bp  = buddypress();
			$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );

			wp_cache_set( $this->id, $row, 'bp_activity' );
		}

		if ( empty( $row ) ) {
			$this->id = 0;
			return;
		}

		$this->id                = (int) $row->id;
		$this->item_id           = (int) $row->item_id;
		$this->secondary_item_id = (int) $row->secondary_item_id;
		$this->user_id           = (int) $row->user_id;
		$this->primary_link      = $row->primary_link;
		$this->component         = $row->component;
		$this->type              = $row->type;
		$this->action            = $row->action;
		$this->content           = $row->content;
		$this->date_recorded     = $row->date_recorded;
		$this->hide_sitewide     = (int) $row->hide_sitewide;
		$this->mptt_left         = (int) $row->mptt_left;
		$this->mptt_right        = (int) $row->mptt_right;
		$this->is_spam           = (int) $row->is_spam;

		// Generate dynamic 'action' when possible.
		$action = bp_activity_generate_action_string( $this );
		if ( false !== $action ) {
			$this->action = $action;

			// If no callback is available, use the literal string from
			// the database row.
		} elseif ( ! empty( $row->action ) ) {
			$this->action = $row->action;

			// Provide a fallback to avoid PHP notices.
		} else {
			$this->action = '';
		}
	}

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.