PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5.4
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmEntriesHelper.php +7 -140 6.5.15.5.4 View file →
@@ -4,24 +4,8 @@
4 4 }
5 5
6 6 class FrmEntriesHelper {
7 7
8 - /**
9 - * "Submitted" entry status.
10 - *
11 - * @since 6.4.2
12 - * @var int
13 - */
14 - const SUBMITTED_ENTRY_STATUS = 0;
15 -
16 - /**
17 - * "Draft" entry status.
18 - *
19 - * @since 6.4.2
20 - * @var int
21 - */
22 - const DRAFT_ENTRY_STATUS = 1;
23 -
24 8 public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
25 9 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
26 10
27 11 $values = array(
@@ -187,14 +171,8 @@
187 171
188 172 return $message;
189 173 }
190 174
191 - /**
192 - * @param stdClass $entry
193 - * @param stdClass $field
194 - * @param array $atts
195 - * @return string
196 - */
197 175 public static function prepare_display_value( $entry, $field, $atts ) {
198 176 $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
199 177
200 178 if ( FrmAppHelper::pro_is_installed() ) {
@@ -209,16 +187,14 @@
209 187 if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
210 188 return self::display_value( $field_value, $field, $atts );
211 189 }
212 190
213 - if ( ! FrmAppHelper::pro_is_installed() ) {
214 - return '';
215 - }
191 + // This is an embeded form.
192 + $val = '';
216 193
217 - // This is an embeded form.
218 194 if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
219 195 // This is a repeating section.
220 - $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true );
196 + $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
221 197 } else {
222 198 // Get all values for this field.
223 199 $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
224 200
@@ -228,10 +204,10 @@
228 204 }
229 205
230 206 $field_value = array();
231 207
232 - if ( empty( $child_entries ) ) {
233 - return '';
208 + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209 + return $val;
234 210 }
235 211
236 212 foreach ( $child_entries as $child_entry ) {
237 213 $atts['item_id'] = $child_entry->id;
@@ -311,9 +287,9 @@
311 287 return $value;
312 288 }
313 289
314 290 $unfiltered_value = $value;
315 - FrmFieldsHelper::prepare_field_value( $unfiltered_value, $field->type );
291 + FrmAppHelper::unserialize_or_decode( $unfiltered_value );
316 292
317 293 $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
318 294 $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
319 295
@@ -676,9 +652,9 @@
676 652 }
677 653
678 654 if ( current_user_can( 'frm_delete_entries' ) ) {
679 655 $actions['frm_delete'] = array(
680 - 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
656 + 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ),
681 657 'label' => __( 'Delete Entry', 'formidable' ),
682 658 'icon' => 'frm_icon_font frm_delete_icon',
683 659 'data' => array(
684 660 'frmverify' => __( 'Delete this form entry?', 'formidable' ),
@@ -708,18 +684,8 @@
708 684 ),
709 685 'icon' => 'frm_icon_font frm_email_icon',
710 686 );
711 687
712 - if ( ! function_exists( 'frm_pdfs_autoloader' ) && FrmAppHelper::show_new_feature( 'pdfs' ) ) {
713 - $actions['frm_download_pdf'] = array(
714 - 'url' => '#',
715 - 'label' => __( 'Download as PDF', 'formidable' ),
716 - 'class' => 'frm_noallow',
717 - 'data' => self::get_pdfs_upgrade_link_data( 'download-pdf-entry' ),
718 - 'icon' => 'frm_icon_font frm_download_icon',
719 - );
720 - }
721 -
722 688 $actions['frm_edit'] = array(
723 689 'url' => '#',
724 690 'label' => __( 'Edit Entry', 'formidable' ),
725 691 'class' => 'frm_noallow',
@@ -734,32 +700,8 @@
734 700 return apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
735 701 }
736 702
737 703 /**
738 - * Gets data attributes for PDFs addon upgrade link.
739 - *
740 - * @param string $medium The source of the upgrade link used for analytics data.
741 - * @return array
742 - */
743 - private static function get_pdfs_upgrade_link_data( $medium = 'pdfs' ) {
744 - $data = array(
745 - 'oneclick' => '',
746 - 'requires' => '',
747 - 'upgrade' => __( 'Forms to PDF', 'formidable' ),
748 - 'medium' => $medium,
749 - );
750 -
751 - $upgrading = FrmAddonsController::install_link( 'pdfs' );
752 - if ( isset( $upgrading['url'] ) ) {
753 - $data['oneclick'] = json_encode( $upgrading );
754 - } else {
755 - $data['requires'] = FrmAddonsController::get_addon_required_plan( 28136428 );
756 - }
757 -
758 - return $data;
759 - }
760 -
761 - /**
762 704 * @since 5.0.15
763 705 *
764 706 * @param string|int $entry_id
765 707 * @return void
@@ -780,80 +722,5 @@
780 722 return;
781 723 }
782 724 }
783 725 }
784 -
785 - /**
786 - * Return entry status based on is_draft column value.
787 - *
788 - * @since 6.5
789 - *
790 - * @param int $status is_draft column.
791 - *
792 - * @return int
793 - */
794 - public static function get_entry_status( $status ) {
795 - $statuses = self::get_entry_statuses();
796 -
797 - if ( array_key_exists( $status, $statuses ) ) {
798 - return $status;
799 - }
800 -
801 - if ( empty( $status ) ) {
802 - return self::SUBMITTED_ENTRY_STATUS; // If the status is empty, let's default to 0.
803 - }
804 -
805 - return self::DRAFT_ENTRY_STATUS; // If it has a value that isn't in the array, let's default to 1. There may be old entries that don't have a value for is_draft.
806 - }
807 -
808 - /**
809 - * Return entry status label based on passed value.
810 - *
811 - * @since 6.5
812 - *
813 - * @param int $status is_draft column.
814 - *
815 - * @return string
816 - */
817 - public static function get_entry_status_label( $status ) {
818 - $statuses = self::get_entry_statuses();
819 -
820 - return $statuses[ self::get_entry_status( $status ) ];
821 - }
822 -
823 - /**
824 - * Get all entry statuses.
825 - *
826 - * @since 6.5
827 - *
828 - * @return array<string>
829 - */
830 - private static function get_entry_statuses() {
831 -
832 - $default_entry_statuses = array(
833 - self::SUBMITTED_ENTRY_STATUS => __( 'Submitted', 'formidable' ),
834 - self::DRAFT_ENTRY_STATUS => __( 'Draft', 'formidable' ),
835 - );
836 -
837 - /**
838 - * Register entry status.
839 - *
840 - * "2" is used in abandonment-addon and reserved for "In progress".
841 - * "3" is used in abandonment-addon and reserved for "Abandoned".
842 - *
843 - * @since 6.5
844 - *
845 - * @param array<string> $extended_entry_status Entry statuses.
846 - */
847 - $extended_entry_status = apply_filters( 'frm_entry_statuses', array() );
848 -
849 - if ( ! is_array( $extended_entry_status ) ) {
850 - _doing_it_wrong( __METHOD__, esc_html__( 'Entry status must be return in array format.', 'formidable' ), 'x.x' );
851 - $extended_entry_status = array();
852 - }
853 -
854 - $existing_entry_statuses = array_replace( $default_entry_statuses, $extended_entry_status );
855 -
856 - return $existing_entry_statuses;
857 - }
858 -
859 726 }