enqueue_breakdance_ssr_preview_assets(); $this->render_breakdance_ssr_preview_markup( $this->get_html( $hide, $is_preview ), $is_preview ); $this->graph_scripts(); } /** * Enqueue Breakdance SSR preview assets and collect the generated style handles. * * @return void */ private function enqueue_breakdance_ssr_preview_assets() { $before_style_handles = wp_styles()->queue; $assets = new Forminator_Assets_Enqueue_Poll( $this->model, false ); $assets->enqueue_styles( $this ); $assets->enqueue_scripts(); $assets->load_module_css( true ); $this->set_breakdance_preview_style_handles( $before_style_handles ); } /** * Display form method * * @since 1.0 * * @param int $id Id. * @param bool $is_preview Is preview. * @param bool $data Data. * @param bool $hide If true, display: none will be added on the form markup and later removed with JS. */ public function display( $id, $is_preview = false, $data = false, $hide = true ) { if ( $data && ! empty( $data ) ) { // New form, we have to update the form id. $has_id = filter_var( $id, FILTER_VALIDATE_BOOLEAN ); if ( ! $has_id && isset( $data['settings']['form_id'] ) ) { $id = $data['settings']['form_id']; } $this->model = Forminator_Poll_Model::model()->load_preview( $id, $data ); // its preview! $this->model->id = $id; } else { $this->model = Forminator_Base_Form_Model::get_model( $id ); if ( ! $this->model instanceof Forminator_Poll_Model ) { return; } } $this->maybe_define_cache_constants(); $this->set_breakdance_ssr_preview( $is_preview ); // TODO: make preview and ajax load working similar. $is_ajax_load = $this->is_ajax_load( $is_preview ); if ( ! $this->is_breakdance_ssr_preview ) { // Load assets conditionally. $assets = new Forminator_Assets_Enqueue_Poll( $this->model, $is_ajax_load ); $assets->enqueue_styles( $this ); $assets->enqueue_scripts(); } if ( $is_ajax_load && $this->model->current_user_can_vote() ) { $this->generate_render_id( $id ); $this->get_form_placeholder( esc_attr( $id ), true ); return; } if ( $this->is_displayable( $is_preview ) ) { $this->generate_render_id( $id ); if ( $this->is_breakdance_ssr_preview ) { $this->render_breakdance_ssr_preview( $hide, $is_preview ); return; } echo $this->get_html( $hide, $is_preview ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ( is_admin() || $is_preview ) { $this->print_styles(); } add_action( 'wp_footer', array( $this, 'forminator_render_front_scripts' ), 9999 ); add_action( 'wp_footer', array( $this, 'graph_scripts' ), 100 ); } } /** * Return form fields * * @since 1.0 * @return array|mixed */ public function get_fields() { if ( is_object( $this->model ) ) { return $this->model->get_fields_grouped(); } else { return $this->message_not_found(); } } /** * Poll question * * @param object $model model. * * @since 1.0 * @return string */ public static function get_poll_question( $model ) { if ( is_object( $model ) && isset( $model->settings['poll-question'] ) ) { return $model->settings['poll-question']; } else { return ''; } } /** * Poll Description * * @param object $model model. * * @since 1.0 * @return string */ public static function get_poll_description( $model ) { if ( is_object( $model ) && isset( $model->settings['poll-description'] ) ) { return $model->settings['poll-description']; } else { return ''; } } /** * Poll Image * * @since 1.5.3 * @return string */ public function get_poll_image() { if ( is_object( $this->model ) && isset( $this->model->settings['poll-image'] ) ) { return $this->model->settings['poll-image']; } else { return ''; } } /** * Poll header * * @param string $maybe_error Error message. * * @since 1.0 * @return string */ public function render_form_header( $maybe_error = '' ) { $html = ''; $label_class = ''; $message_wrap = ''; $status_info = $this->model->opening_status(); if ( 'open' !== $status_info['status'] ) { $html .= ''; } $is_preview = $this->is_preview; if ( 'open' === $status_info['status'] ) { $hidden_wrap = '