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.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class.llms.student.query.php

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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;
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.4.0
3.13.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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