LLMS_Table_StudentManagement::get_data( string $key, LLMS_Student $student )

Retrieve data for the columns


Parameters Parameters

$key

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

$student

(LLMS_Student) (Required) Student object.


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/admin/post-types/tables/class.llms.table.student.management.php

	public function get_data( $key, $student ) {

		$value = '';

		switch ( $key ) {

			case 'actions':
				if ( $student->is_enrolled( $this->post_id ) ) {
					$trigger = $student->get_enrollment_trigger( $this->post_id );
					if ( false !== strpos( $trigger, 'order_' ) ) {
						$value = '<a class="llms-action-icon tip--top-left" href="' . get_edit_post_link( $student->get_enrollment_trigger_id( $this->post_id ) ) . '" target="_blank" data-tip="' . __( 'Visit the triggering order to manage this student\'s enrollment', 'lifterlms' ) . '"><span class="dashicons dashicons-external"></span></a>';
					} else {
						if ( current_user_can( 'unenroll' ) ) {
							$value = '<a class="llms-action-icon llms-remove-student tip--top-left" data-id="' . $student->get_id() . '" href="#llms-student-remove" data-tip="' . __( 'Cancel Enrollment', 'lifterlms' ) . '"><span class="dashicons dashicons-no"></span></a>';
						}
					}
				} else {
					if ( current_user_can( 'enroll' ) ) {
						$value = '<a class="llms-action-icon llms-add-student tip--top-left" data-id="' . $student->get_id() . '" href="#llms-student-add" data-tip="' . __( 'Reactivate Enrollment', 'lifterlms' ) . '"><span class="dashicons dashicons-update"></span></a>';
					}
					if ( current_user_can( 'unenroll' ) ) {
						$value .= '<a class="llms-action-icon danger llms-delete-enrollment tip--top-left" data-id="' . $student->get_id() . '" href="#llms-student-delete-enrollment" data-tip="' . __( 'Delete Enrollment', 'lifterlms' ) . '"><span class="dashicons dashicons-trash"></span></a>';
					}
				}
				break;

			case 'enrolled':
				$value = $student->get_enrollment_date( $this->post_id, 'updated' );
				break;

			case 'grade':
				$value = $student->get_grade( $this->post_id );
				break;

			case 'id':
				$id = $student->get_id();
				if ( current_user_can( 'edit_users', $id ) ) {
					$value = '<a href="' . esc_url( get_edit_user_link( $id ) ) . '">' . $id . '</a>';
				} else {
					$value = $id;
				}
				break;

			case 'last_lesson':
				$lid = $student->get_last_completed_lesson( $this->post_id );
				if ( $lid ) {
					$value = $this->get_post_link( $lid, llms_trim_string( get_the_title( $lid ), 30 ) );
				} else {
					$value = '&ndash;';
				}
				break;

			case 'name':
				$first = $student->get( 'first_name' );
				$last  = $student->get( 'last_name' );

				if ( ! $first || ! $last ) {
					$value = $student->get( 'display_name' );
				} else {
					$value = $last . ', ' . $first;
				}

				$url   = add_query_arg(
					array(
						'page'       => 'llms-reporting',
						'tab'        => 'students',
						'student_id' => $student->get_id(),
					),
					admin_url( 'admin.php' )
				);
				$value = '<a href="' . esc_url( $url ) . '">' . $value . '</a>';

				break;

			case 'progress':
				$value = $student->get_progress( $this->post_id ) . '%';
				break;

			case 'status':
				$value = llms_get_enrollment_status_name( $student->get_enrollment_status( $this->post_id ) );
				break;

			case 'trigger':
				$trigger = $student->get_enrollment_trigger( $this->post_id );
				if ( $trigger && false !== strpos( $trigger, 'order_' ) ) {
					$tid   = $student->get_enrollment_trigger_id( $this->post_id );
					$value = $this->get_post_link( $tid, sprintf( __( 'Order #%d', 'lifterlms' ), $tid ) );
				} elseif ( $trigger && false !== strpos( $trigger, 'admin_' ) ) {
					$tid        = $student->get_enrollment_trigger_id( $this->post_id );
					$admin      = llms_get_student( $tid );
					$admin_name = $admin ? $admin->get_name() : __( '[Deleted]', 'lifterlms' );
					$value      = $this->get_user_link( $tid, sprintf( __( 'Admin: %1$s (#%2$d)', 'lifterlms' ), $admin_name, $tid ) );
				} else {
					$value = $trigger;
				}
				break;

			default:
				$value = $key;

		}// End switch().

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

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.4.0
3.33.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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