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


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() ) {

		$id = sprintf( 'filter-by-llms-post-%s', $post_type );

		$obj = get_post_type_object( $post_type );
		// Translators: %s = the singular post type name.
		$label = sprintf( __( 'Filter by %s', 'lifterlms' ), $obj->labels->singular_name );
		ob_start();
		?>
		<span class="llms-post-table-post-filter">
			<label for="<?php echo $id; ?>" class="screen-reader-text">
				<?php echo esc_html( $label ); ?>
			</label>
			<select
				class="llms-select2-post"
				data-allow_clear="true"
				data-no-view-button="true"
				data-placeholder="<?php echo esc_attr( $label ); ?>"
				data-post-type="<?php echo $post_type; ?>"
				name="<?php echo $name; ?>"
				id="<?php echo $id; ?>"
			>
				<?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
6.0.0 Don't display a dynamic view post button.
3.12.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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