LLMS_Notification_View_Achievement_Earned::set_merge_data( string $code )

Replace merge codes with actual values


Parameters Parameters

$code

(string) (Required) The merge code to get merged data for.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/notifications/views/class.llms.notification.view.achievement.earned.php

	protected function set_merge_data( $code ) {

		$achievement = new LLMS_User_Achievement( $this->post );

		switch ( $code ) {

			case '{{ACHIEVEMENT_CONTENT}}':
				$code = $achievement->get( 'content' );
				break;

			case '{{ACHIEVEMENT_IMAGE}}':
				$title = $this->set_merge_data( '{{ACHIEVEMENT_TITLE}}' );
				$url   = $this->set_merge_data( '{{ACHIEVEMENT_IMAGE_URL}}' );
				$code  = '<img alt="' . sprintf( _x( '%s Icon', 'Achievement icon alt text', 'lifterlms' ), $title ) . '" src="' . $url . '">';
				break;

			case '{{ACHIEVEMENT_IMAGE_URL}}':
				$code = $achievement->get_image( 'medium', 'achievement_image' );
				if ( ! $code ) {
					$code = apply_filters( 'lifterlms_placeholder_img_src', llms()->plugin_url() . '/assets/images/optional_achievement.png' );
				}
				break;

			case '{{ACHIEVEMENT_TITLE}}':
				$code = $achievement->get( 'title' );
				break;

			case '{{STUDENT_NAME}}':
				$code = $this->is_for_self() ? __( 'you', 'lifterlms' ) : $this->user->get_name();
				break;

		}

		return $code;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Use title in favor of deprecated achievement_title meta key for the {{ACHIEVEMENT_TITLE}} merge code.
4.7.0 Use achievement_title in favor of title for the {{ACHIEVEMENT_TITLE}} merge code.
3.8.2 Unknown.
3.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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