File: //home/globfdxw/www/wp-content/plugins/wpforms-surveys-polls/templates/entries/graph.php
<?php
/**
* Graph preview.
*
* @since 1.18.0
*
* @var array $question_settings Question related settings.
* @var array $filter_settings Filter settings.
* @var array $legend_settings Legend settings.
* @var bool $show_toggle Whether to show print preview toggle button.
*/
use WPFormsSurveys\Helpers;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// When a question dropdown is present (entries list preview), any field type
// can be selected dynamically, so all content containers must be available.
// On the full report page each graph is rendered for a known field type,
// so we only output the container that matches.
$is_preview = ! empty( $question_settings['options'] );
$field_type = $question_settings['type'] ?? '';
$is_likert = $field_type === 'likert_scale';
$is_text = in_array( $field_type, Helpers::supported_text_field_types(), true );
$has_chart = ! $is_likert && ! $is_text;
$show_chart = $is_preview || $has_chart;
$show_likert = $is_preview || $is_likert;
$show_text = $is_preview || $is_text;
?>
<div class="wpforms-survey-graph-preview" data-field-id="<?php echo esc_attr( $question_settings['id'] ?? '' ); ?>" data-field-type="<?php echo esc_attr( $field_type ); ?>">
<?php if ( ! empty( $show_toggle ) ) : ?>
<a href="#" class="question-toggle"><i class="fa fa-chevron-down" aria-hidden="true"></i></a>
<?php endif; ?>
<div class="wpforms-survey-graph-header">
<div class="wpforms-survey-graph-header-left">
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wpforms_render( WPFORMS_SURVEYS_POLLS_PATH . 'templates/entries/dropdown', $question_settings, true );
?>
</div>
<div class="wpforms-survey-graph-header-right">
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wpforms_render(
WPFORMS_SURVEYS_POLLS_PATH . 'templates/entries/controls',
[
'field_id' => $question_settings['id'],
'filter_settings' => $filter_settings,
// Show settings only for fields that support chart customization.
'show_settings' => ! empty( $question_settings['show_settings'] ),
'settings_hidden' => ! empty( $question_settings['settings_hidden'] ),
'show_export_scope' => $legend_settings['is_list'],
// On Entries preview, include the Content group markup but hide it when the current field has no chart.
'has_chart' => $is_preview ? true : $has_chart,
'content_hidden' => $is_preview && ! $has_chart,
// Optionally hide "Apply To All Graphs" in Settings (e.g., single-field print view).
'hide_apply_all' => ! empty( $question_settings['hide_apply_all'] ),
],
true
);
?>
</div>
</div>
<div class="wpforms-survey-graph-content-wrapper">
<div class="wpforms-survey-graph-content">
<?php if ( $show_chart ) : ?>
<div class="wpforms-survey-graph-content-chart">
<canvas></canvas>
</div>
<?php endif; ?>
<?php if ( $show_likert ) : ?>
<div class="wpforms-survey-graph-content-likert wpforms-survey-question-content wpforms-hidden">
<div class="wpforms-survey-graph-content-legend">
<div class="wpforms-survey-graph-content-legend-table-wrapper">
<table class="wpforms-survey-graph-content-legend-table likert-results">
<thead><tr><th></th></tr></thead>
<tbody></tbody>
</table>
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wpforms_render( WPFORMS_SURVEYS_POLLS_PATH . 'templates/entries/legend-footer', $legend_settings, true );
?>
</div>
</div>
</div>
<?php endif; ?>
<?php if ( $show_text ) : ?>
<div class="wpforms-survey-graph-content-text wpforms-survey-question-content wpforms-hidden">
<div class="wpforms-survey-graph-content-legend">
<div class="wpforms-survey-graph-content-legend-table-wrapper">
<table class="wpforms-survey-graph-content-legend-table wpforms-table-sorting text-results">
<thead>
<tr>
<th><?php esc_html_e( 'Answers', 'wpforms-surveys-polls' ); ?></th>
<th data-sort="int" data-sort-default="desc" class="date"><span><?php esc_html_e( 'Date', 'wpforms-surveys-polls' ); ?></span></th>
</tr>
</thead>
<tbody></tbody>
</table>
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wpforms_render( WPFORMS_SURVEYS_POLLS_PATH . 'templates/entries/legend-footer', $legend_settings, true );
?>
</div>
</div>
</div>
<?php endif; ?>
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wpforms_render( WPFORMS_SURVEYS_POLLS_PATH . 'templates/entries/legend', $legend_settings, true );
?>
</div>
</div>
<div class="wpforms-survey-graph-error wpforms-hidden"></div>
</div>