llms_make_select2_post_array( array $post_ids = array(), string $template = '' )

Create an array that can be passed to metabox select elements configured as an llms-select2-post query-ier


Description Description


Parameters Parameters

$post_ids

(array) (Optional) indexed array of WordPress Post IDs

Default value: array()

$template

(string) (Optional) an optional template to customize the way the results look {title} and {id} can be passed into the template and will be replaced with the post title and post id respectively

Default value: ''


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/llms.functions.core.php

function llms_make_select2_post_array( $post_ids = array(), $template = '' ) {

	if ( ! $template ) {
		$template = '{title} (' . __( 'ID#', 'lifterlms' ) . ' {id})';
	}

	if ( ! is_array( $post_ids ) ) {
		$post_ids = array( $post_ids );
	}

	$ret = array();
	foreach ( $post_ids as $id ) {

		$title = str_replace( array( '{title}', '{id}' ), array( get_the_title( $id ), $id ), $template );

		$ret[] = array(
			'key' => $id,
			'title' => $title,
		);
	}
	return apply_filters( 'llms_make_select2_post_array', $ret, $post_ids );

}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: