LLMS_Table_Student_Certificates::get_data( string $key, LLMS_User_Certificate $certificate )

Retrieve data for the columns.


Parameters Parameters

$key

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

$certificate

(LLMS_User_Certificate) (Required) Object of certificate data.


Top ↑

Return Return

(mixed)


Top ↑

Source Source

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

	public function get_data( $key, $certificate ) {

		// Handle old object being passed in.
		if ( ! is_a( $certificate, 'LLMS_User_Certificate' ) && property_exists( $certificate, 'certificate_id' ) ) {
			$certificate = llms_get_certificate( $certificate->certificate_id );
		}

		switch ( $key ) {

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

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

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

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

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

			case 'template_id':
				$template = $certificate->get( 'parent' );
				if ( $template ) {
					$value = $this->get_post_link( $template );
				} else {
					$value = '–';
				}
				break;

			default:
				$value = $key;

		}

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

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

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Retrieve date using the LLMS_User_Certificate 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.