LLMS_Admin_Post_Tables::get_post_type_filter_html( string $name, string $post_type = 'course', int[] $selected = array() )

Get the HTML for a post type select2 filter


Description Description


Parameters Parameters

$name

(string) (Required) Name of the select element.

$post_type

(string) (Optional) Post type to search by.

Default value: 'course'

$selected

(int[]) (Optional) Array of POST IDs to use for the pre-selected options on page load.

Default value: array()


Top ↑

Return Return

(string)


Top ↑

Source Source

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

	public static function get_post_type_filter_html( $name, $post_type = 'course', $selected = array() ) {
		$obj = get_post_type_object( $post_type );
		$label = $obj->labels->singular_name;
		ob_start();
		?>
		<span class="llms-post-table-post-filter">
			<label for="<?php printf( 'filter-by-llms-post-%s', $post_type ); ?>" class="screen-reader-text">
				<?php printf( esc_html__( 'Filter by %s', 'lifterlms' ), $label ); ?>
			</label>
			<select class="llms-select2-post" data-allow_clear="true" data-placeholder="<?php printf( esc_attr__( 'Filter by %s', 'lifterlms' ), $label ); ?>" data-post-type="<?php echo $post_type; ?>" name="<?php echo $name; ?>" id="<?php printf( 'filter-by-llms-post-%s', $post_type ); ?>">
				<?php if ( $selected ) : ?>
					<?php foreach ( llms_make_select2_post_array( $selected ) as $data ) : ?>
						<option value="<?php echo $data['key']; ?>"><?php echo $data['title']; ?></option>
					<?php endforeach; ?>
				<?php endif; ?>
			</select>
		</span>
		<?php
		return ob_get_clean();
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.12.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: