LLMS_Admin_Meta_Boxes::maybe_modify_post_thumbnail_html( string $content, int $post_id, int $image_id )

Modifies the featured image metabox for achievement and certificate templates.


Description Description

Displays the default image, text denoting that the default image is being used, and a link to the settings page where the default image can be changed.

This additional content is only displayed when there’s no featured image set for the template.


Top ↑

Parameters Parameters

$content

(string) (Required) Default metabox HTML.

$post_id

(int) (Required) WP_Post ID of the post being edited.

$image_id

(int) (Required) Attachment ID for the saved featured image.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/admin/post-types/class.llms.meta.boxes.php

	public function maybe_modify_post_thumbnail_html( $content, $post_id, $image_id ) {

		$post_types = array(
			'llms_achievement',
			'llms_my_achievement',
			'llms_certificate',
			'llms_my_certificate',
		);
		$post_type  = get_post_type( $post_id );
		if ( ! $image_id && in_array( $post_type, $post_types, true ) ) {

			$add_content = '';

			$class = str_replace( array( 'llms_', 'my_' ), '', $post_type ) . 's';

			$image_id = llms()->$class()->get_default_image_id();
			$alt      = $image_id ? get_post_meta( $image_id, '_wp_attachment_image_alt', true ) : __( 'Default image', 'lifterlms' );

			$add_content = '<p><img alt="' . trim( wp_strip_all_tags( $alt ) ) . '" src="' . esc_url( llms()->$class()->get_default_image( $post_id ) ) . '" /></p>';

			$settings_url = admin_url( 'admin.php?page=llms-settings&tab=engagements' );
			$add_content .= '<p class="howto">' . __( 'Using the global default.', 'lifterlms' ) . ' <a href="' . esc_url( $settings_url ) . '">' . __( 'Edit', 'lifterlms' ) . '</a></p>';

			$content = $add_content . $content;
		}

		return $content;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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