Shows evaluation results if a form ID is provided as GET parameter.
Description
See also
Parameters
- $submissions
-
(awsmug\Torro_Forms\DB_Objects\Submissions\Submission_Manager) (Required) Submission manager instance.
Source
File: src/modules/evaluators/module.php
protected function maybe_show_evaluation_results( $submissions ) { if ( empty( $_GET['form_id'] ) ) { return; } $form = $submissions->get_parent_manager( 'forms' )->get( (int) $_GET['form_id'] ); if ( ! $form ) { return; } $tabs = array(); foreach ( $this->submodules as $slug => $evaluator ) { if ( ! $evaluator->enabled( $form ) ) { continue; } $results = $evaluator->evaluate_all( $form ); ob_start(); $evaluator->show_results( $results, $form ); $tabs[ $evaluator->get_slug() ] = array( 'title' => $evaluator->get_title(), 'description' => $evaluator->get_description(), 'content' => ob_get_clean(), ); } if ( empty( $tabs ) ) { return; } $screen = get_current_screen(); $hidden = get_hidden_meta_boxes( $screen ); $closed = get_user_option( 'closedpostboxes_' . $screen->id ); if ( ! is_array( $closed ) ) { $closed = array(); } $box_id = 'torro-evaluations'; $box_class = 'torro-evaluations-box postbox' . ( in_array( $box_id, $closed, true ) ? ' closed' : '' ) . ( in_array( $box_id, $hidden, true ) ? ' hide-if-js' : '' ); $current_tab_slug = key( $tabs ); echo '<input type="hidden" id="closedpostboxespage" value="' . esc_attr( $screen->id ) . '" />'; wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> <div id="<?php echo esc_attr( $box_id ); ?>" class="<?php echo esc_attr( $box_class ); ?>"> <button type="button" class="handlediv" aria-expanded="true"> <span class="screen-reader-text"><?php _e( 'Toggle panel: Evaluations', 'torro-forms' ); ?></span> <span class="toggle-indicator" aria-hidden="true"></span> </button> <h2 class="hndle"> <span><?php _e( 'Evaluations', 'torro-forms' ); ?></span> </h2> <div class="inside"> <div class="torro-evaluations-tabs" role="tablist"> <?php foreach ( $tabs as $slug => $data ) : ?> <a id="<?php echo esc_attr( 'evaluations-tab-label-' . $slug ); ?>" class="torro-evaluations-tab" href="<?php echo esc_attr( '#evaluations-tab-' . $slug ); ?>" aria-controls="<?php echo esc_attr( 'evaluations-tab-' . $slug ); ?>" aria-selected="<?php echo $slug === $current_tab_slug ? 'true' : 'false'; ?>" role="tab"> <?php echo esc_html( $data['title'] ); ?> </a> <?php endforeach; ?> </div> <div class="torro-evaluations-content"> <?php foreach ( $tabs as $slug => $data ) : ?> <div id="<?php echo esc_attr( 'evaluations-tab-' . $slug ); ?>" class="torro-evaluations-tab-panel" aria-labelledby="<?php echo esc_attr( 'evaluations-tab-label-' . $slug ); ?>" aria-hidden="<?php echo $slug === $current_tab_slug ? 'false' : 'true'; ?>" role="tabpanel"> <div class="torro-evaluations-description-wrap"> <p class="description"><?php echo $data['description']; ?></p> </div> <div id="<?php echo esc_attr( 'torro-evaluations-results-' . $slug ); ?>" class="torro-evaluations-results"> <?php echo $data['content']; ?> </div> <div class="torro-evaluations-shortcode"> <label for="<?php echo esc_attr( 'torro-evaluations-shortcode-' . $slug ); ?>"><?php _e( 'Charts Shortcode:', 'torro-forms' ); ?></label> <input id="<?php echo esc_attr( 'torro-evaluations-shortcode-' . $slug ); ?>" class="clipboard-field regular-text" value="<?php echo esc_attr( sprintf( "[{$this->manager()->forms()->get_prefix()}form_charts id="%d" mode="%s"]", $form->id, $slug ) ); ?>" readonly="readonly" /> <button type="button" class="clipboard-button button" data-clipboard-target="#<?php echo esc_attr( 'torro-evaluations-shortcode-' . $slug ); ?>"> <?php $this->manager()->forms()->assets()->render_icon( 'torro-icon-clippy', __( 'Copy to clipboard', 'torro-forms' ) ); ?> </button> </div> </div> <?php endforeach; ?> </div> </div> </div> <?php }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |