type === self::TYPE; } /** * Add the type to the type list. * * @param array $types Type key => label. */ public static function register_type($types) { $types[self::TYPE] = __('Questionnaire', '3task-polls'); return $types; } /** * Add the type to a list of type keys. * * @param string[] $types Type keys. */ public static function add_type($types) { $types[] = self::TYPE; return $types; } /** * The questionnaire is sent once at the end. * * @param string $text Button text. * @param TPoll_Poll $poll Poll. */ public static function button_text($text, $poll) { return self::is_survey($poll) ? _x('Send', 'questionnaire button', '3task-polls') : $text; } /** * Steps as loaded polls, in their order. Steps that no longer exist are skipped. * * @param TPoll_Poll $poll Questionnaire. * @return TPoll_Poll[] */ public static function steps($poll) { $steps = array(); foreach (self::step_ids($poll) as $id) { $step = TPoll_Poll::get($id); if ($step && in_array($step->type, self::step_types(), true)) { $steps[] = $step; } } return $steps; } /** * Editor box: the questions of the questionnaire in their order. * * @param TPoll_Poll $poll Poll being edited. */ public static function render_edit_box($poll) { $types = TPoll_Poll::get_types(); $label = function ($step) use ($types) { return $step->title . ' (' . (isset($types[$step->type]) ? $types[$step->type] : $step->type) . ')'; }; $chosen = self::is_survey($poll) ? self::steps($poll) : array(); $chosen_ids = wp_list_pluck($chosen, 'id'); $available = array(); foreach (TPoll_Poll::get_all(array('status' => 'published', 'per_page' => 200, 'orderby' => 'title', 'order' => 'ASC')) as $candidate) { if (in_array($candidate->type, self::step_types(), true) && (int) $candidate->id !== (int) $poll->id) { $available[] = $candidate; } } ?>
id) : ?>
question); ?>
id, $step), false); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped inside results_html(). ?>