LLMS_Table_Achievements::get_data( string $key, LLMS_User_Achievement $achievement )

Retrieve data for the columns.


Parameters Parameters

$key

(string) (Required) The column id / key.

$achievement

(LLMS_User_Achievement) (Required) Object of achievement data.


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/admin/reporting/tables/llms.table.achievements.php

	public function get_data( $key, $achievement ) {

		// Handle old object being passed in.
		if ( ! is_a( $achievement, 'LLMS_User_Achievement' ) && property_exists( $achievement, 'achievement_id' ) ) {
			$achievement = new LLMS_User_Achievement( $achievement->certificate_id );
		}

		switch ( $key ) {

			case 'actions':
				$value = $this->get_actions_html( $achievement->get( 'id' ) );
				break;

			case 'related':
				if ( $achievement->get( 'related' ) && 'llms_achievement' !== get_post_type( $achievement->get( 'related' ) ) ) {
					if ( is_numeric( $achievement->get( 'related' ) ) ) {
						$value = $this->get_post_link( $achievement->get( 'related' ), get_the_title( $achievement->get( 'related' ) ) );
					} else {
						$value = $achievement->get( 'related' );
					}
				} else {
					$value = '–';
				}
				break;

			case 'earned':
				$value = $achievement->get_earned_date();
				$value = 'future' === $achievement->get( 'status' ) ? $value . ' ' . __( '(scheduled)', 'lifterlms' ) : $value;
				break;

			case 'id':
				$value = $achievement->get( 'id' );
				break;

			case 'image':
				$src   = $achievement->get_image( array( 32, 32 ) );
				$value = '<img src="' . esc_url( $src ) . '" alt="' . $achievement->get( 'title' ) . '" width="32" height="32">';
				break;

			case 'template_id':
				// Prior to 3.2 this data wasn't recorded.
				$template = $achievement->get( 'parent' );
				if ( $template ) {
					$value = $this->get_post_link( $template );
				} else {
					$value = '&ndash;';
				}
				break;

			case 'name':
				$value = $achievement->get( 'title' );
				break;

			default:
				$value = $key;

		}

		// Pass the "legacy" object to the filter.
		$backwards_compat_obj = array(
			'post_id'        => $achievement->get( 'related' ),
			'achievement_id' => $achievement->get( 'id' ),
			'earned_date'    => $achievement->get_earned_date(),
		);

		return $this->filter_get_data( $value, $key, (object) $backwards_compat_obj );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Retrieve earned date using the LLMS_User_Achievement model.
3.2.0
3.18.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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