llms_get_picture_choice_question_cols( int $num_choices )
Retrieve the number of columns needed for a picture choice question.
Parameters Parameters
- $num_choices
-
(int) (Required) Number of choices.
Return Return
(int)
Source Source
File: includes/functions/llms.functions.quiz.php
function llms_get_picture_choice_question_cols( $num_choices ) { /** * Allow 3rd parties to override this function with a custom number of columns. * * If this responds with a non null will bypass column counter function return it immediately * * @since 3.16.0 * * @param null|int $cols Number of columns needed for a picture choice question. * @param int $num_choices Number of choices. */ $cols = apply_filters( 'llms_get_picture_choice_question_cols', null, $num_choices ); if ( 1 === $num_choices ) { $cols = 1; } elseif ( $num_choices >= 25 ) { $cols = 5; } elseif ( $num_choices >= 10 ) { $max_cols = 5; $min_cols = 3; } else { $max_cols = 4; $min_cols = 2; } if ( is_null( $cols ) ) { $i = $max_cols; while ( $i >= $min_cols ) { if ( 0 === $num_choices % $i ) { $cols = $i; break; } $i--; } if ( ! $cols ) { $cols = llms_get_picture_choice_question_cols( $num_choices + 1 ); } } /** This filter is documented above */ return apply_filters( 'llms_get_picture_choice_question_cols', $cols, $num_choices ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.16.0 | Introduced. |