LLMS_Student_Query::parse_args()
Parses data passed to $statuses
Description Description
Convert strings to array and ensure resulting array contains only valid statuses If no valid statuses, returns to the default.
Return Return
(void)
Source Source
File: includes/class.llms.student.query.php
protected function parse_args() {
$statuses = $this->arguments['statuses'];
// Allow strings to be submitted when only requesting one status.
if ( is_string( $statuses ) ) {
$statuses = array( $statuses );
}
// Ensure only valid statuses are used.
$statuses = array_intersect( $statuses, array_keys( llms_get_enrollment_statuses() ) );
// No statuses should return original default.
if ( ! $statuses ) {
$statuses = array_keys( llms_get_enrollment_statuses() );
}
$this->arguments['statuses'] = $statuses;
// Allow numeric strings & ints to be passed instead of an array.
$post_ids = $this->arguments['post_id'];
if ( ! is_array( $post_ids ) && is_numeric( $post_ids ) && $post_ids > 0 ) {
$post_ids = array( $post_ids );
}
foreach ( $post_ids as $key => &$id ) {
$id = absint( $id ); // Verify we have ints.
if ( $id <= 0 ) { // Remove anything negative or 0.
unset( $post_ids[ $key ] );
}
}
$this->arguments['post_id'] = $post_ids;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.4.0 | |
| 3.13.0 | Introduced. |