| @@ -89,8 +89,9 @@ | ||
| 89 | 89 | 'active_license' => FrmAppHelper::pro_is_installed(), |
| 90 | 90 | 'form_count' => $form_counts->published, |
| 91 | 91 | 'entry_count' => FrmEntry::getRecordCount(), |
| 92 | 92 | 'timestamp' => gmdate( 'c' ), |
| 93 | + 'misc' => array(), | |
| 93 | 94 | |
| 94 | 95 | 'theme_name' => is_object( $theme_data ) ? $theme_data->Name : '', // phpcs:ignore WordPress.NamingConventions |
| 95 | 96 | 'plugins' => $this->plugins(), |
| 96 | 97 | 'settings' => array( |
| @@ -197,12 +198,22 @@ | ||
| 197 | 198 | */ |
| 198 | 199 | $long_text_keys = apply_filters( 'frm_usage_long_text_keys', $long_text_keys ); |
| 199 | 200 | |
| 200 | 201 | foreach ( $data as $key => &$value ) { |
| 201 | - if ( ! $value || in_array( $key, $skip_keys, true ) || str_ends_with( $key, '_url' ) ) { | |
| 202 | + if ( ! $value ) { | |
| 202 | 203 | continue; |
| 203 | 204 | } |
| 204 | 205 | |
| 206 | + if ( in_array( $key, $skip_keys, true ) || str_ends_with( $key, '_url' ) ) { | |
| 207 | + unset( $data[ $key ] ); | |
| 208 | + continue; | |
| 209 | + } | |
| 210 | + | |
| 211 | + if ( is_object( $value ) ) { | |
| 212 | + $value = '{{object}}'; | |
| 213 | + continue; | |
| 214 | + } | |
| 215 | + | |
| 205 | 216 | if ( is_array( $value ) ) { |
| 206 | 217 | $this->clean_before_send( $value ); |
| 207 | 218 | continue; |
| 208 | 219 | } |
| @@ -213,9 +224,9 @@ | ||
| 213 | 224 | continue; |
| 214 | 225 | } |
| 215 | 226 | |
| 216 | 227 | // If key ends with `_email`, or value contains `@`, this might contain an email address. |
| 217 | - if ( str_ends_with( $key, '_email' ) || str_contains( $value, '@' ) ) { | |
| 228 | + if ( str_ends_with( $key, '_email' ) || ( is_string( $value ) && str_contains( $value, '@' ) ) ) { | |
| 218 | 229 | // Replace it with a placeholder. |
| 219 | 230 | $value = '{{contain_email}}'; |
| 220 | 231 | } |
| 221 | 232 | }//end foreach |
| @@ -256,24 +267,13 @@ | ||
| 256 | 267 | */ |
| 257 | 268 | private function payments( $table = 'frm_payments' ) { |
| 258 | 269 | $allowed_tables = array( 'frm_payments', 'frm_subscriptions' ); |
| 259 | 270 | |
| 260 | - if ( ! in_array( $table, $allowed_tables, true ) ) { | |
| 271 | + if ( ! in_array( $table, $allowed_tables, true ) || ! FrmTransLiteAppHelper::payments_table_exists() ) { | |
| 261 | 272 | return array(); |
| 262 | 273 | } |
| 263 | 274 | |
| 264 | - if ( ! FrmTransLiteAppHelper::payments_table_exists() ) { | |
| 265 | - return array(); | |
| 266 | - } | |
| 267 | - | |
| 268 | - global $wpdb; | |
| 269 | - $rows = $wpdb->get_results( | |
| 270 | - $wpdb->prepare( | |
| 271 | - 'SELECT amount, status, paysys, created_at FROM %1$s', | |
| 272 | - $wpdb->prefix . $table | |
| 273 | - ) | |
| 274 | - ); | |
| 275 | - | |
| 275 | + $rows = $this->get_payment_db_rows( $table ); | |
| 276 | 276 | $payments = array(); |
| 277 | 277 | |
| 278 | 278 | foreach ( $rows as $row ) { |
| 279 | 279 | $payments[] = array( |
| @@ -287,8 +287,36 @@ | ||
| 287 | 287 | return $payments; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
| 291 | + * @since 6.30 | |
| 292 | + * | |
| 293 | + * @param string $table | |
| 294 | + * | |
| 295 | + * @return array | |
| 296 | + */ | |
| 297 | + private function get_payment_db_rows( $table ) { | |
| 298 | + global $wpdb; | |
| 299 | + | |
| 300 | + if ( FrmDb::db_column_exists( $table, 'test' ) ) { | |
| 301 | + return $wpdb->get_results( | |
| 302 | + $wpdb->prepare( | |
| 303 | + 'SELECT amount, status, paysys, created_at FROM %i WHERE test IS NULL OR test != 1', | |
| 304 | + $wpdb->prefix . $table | |
| 305 | + ) | |
| 306 | + ); | |
| 307 | + } | |
| 308 | + | |
| 309 | + // Fallback for PayPal add-on where this column does not exist. | |
| 310 | + return $wpdb->get_results( | |
| 311 | + $wpdb->prepare( | |
| 312 | + 'SELECT amount, status, paysys, created_at FROM %i', | |
| 313 | + $wpdb->prefix . $table | |
| 314 | + ) | |
| 315 | + ); | |
| 316 | + } | |
| 317 | + | |
| 318 | + /** | |
| 291 | 319 | * @since 3.06.04 |
| 292 | 320 | * |
| 293 | 321 | * @return array |
| 294 | 322 | */ |
| @@ -476,28 +504,31 @@ | ||
| 476 | 504 | 'form_action_count' => $this->form_action_count( $form->id ), |
| 477 | 505 | ); |
| 478 | 506 | |
| 479 | 507 | foreach ( $settings as $setting ) { |
| 480 | - if ( isset( $form->options[ $setting ] ) ) { | |
| 481 | - if ( 'custom_style' === $setting ) { | |
| 482 | - $style->id = $form->options[ $setting ]; | |
| 508 | + if ( ! isset( $form->options[ $setting ] ) ) { | |
| 509 | + continue; | |
| 510 | + } | |
| 483 | 511 | |
| 484 | - if ( ! $style->id ) { | |
| 485 | - $style_name = 0; | |
| 486 | - } elseif ( 1 === intval( $style->id ) ) { | |
| 487 | - $style_name = 'formidable-style'; | |
| 488 | - } else { | |
| 489 | - $style_post = $style->get_one(); | |
| 490 | - $style_name = $style_post ? $style_post->post_name : 'formidable-style'; | |
| 491 | - } | |
| 512 | + if ( 'custom_style' !== $setting ) { | |
| 513 | + $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] ); | |
| 514 | + continue; | |
| 515 | + } | |
| 492 | 516 | |
| 493 | - $new_form[ $setting ] = $style_name; | |
| 494 | - } else { | |
| 495 | - $new_form[ $setting ] = $this->maybe_json( $form->options[ $setting ] ); | |
| 496 | - } | |
| 517 | + $style->id = $form->options[ $setting ]; | |
| 518 | + | |
| 519 | + if ( ! $style->id ) { | |
| 520 | + $style_name = 0; | |
| 521 | + } elseif ( 1 === intval( $style->id ) ) { | |
| 522 | + $style_name = 'formidable-style'; | |
| 523 | + } else { | |
| 524 | + $style_post = $style->get_one(); | |
| 525 | + $style_name = $style_post ? $style_post->post_name : 'formidable-style'; | |
| 497 | 526 | } |
| 498 | - } | |
| 499 | 527 | |
| 528 | + $new_form[ $setting ] = $style_name; | |
| 529 | + }//end foreach | |
| 530 | + | |
| 500 | 531 | $forms[] = apply_filters( 'frm_usage_form', $new_form, compact( 'form' ) ); |
| 501 | 532 | }//end foreach |
| 502 | 533 | |
| 503 | 534 | // If the array uses numeric keys, reset them. |
| @@ -571,24 +602,43 @@ | ||
| 571 | 602 | * |
| 572 | 603 | * @return array |
| 573 | 604 | */ |
| 574 | 605 | private function actions() { |
| 575 | - $args = array( | |
| 576 | - 'post_type' => FrmFormActionsController::$action_post_type, | |
| 577 | - 'numberposts' => 100, | |
| 578 | - ); | |
| 606 | + $actions = array(); | |
| 607 | + $offset = 0; | |
| 608 | + $limit = 100; | |
| 609 | + $limit_plus_one = $limit + 1; | |
| 579 | 610 | |
| 580 | - $actions = array(); | |
| 581 | - $saved_actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' ); | |
| 611 | + do { | |
| 612 | + $args = array( | |
| 613 | + 'post_type' => FrmFormActionsController::$action_post_type, | |
| 614 | + 'numberposts' => $limit_plus_one, | |
| 615 | + 'offset' => $offset, | |
| 616 | + ); | |
| 617 | + $saved_actions = get_posts( $args ); | |
| 618 | + $has_more = count( $saved_actions ) === $limit_plus_one; | |
| 582 | 619 | |
| 583 | - foreach ( $saved_actions as $action ) { | |
| 584 | - $actions[] = array( | |
| 585 | - 'form_id' => $action->menu_order, | |
| 586 | - 'type' => $action->post_excerpt, | |
| 587 | - 'status' => $action->post_status, | |
| 588 | - 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ), | |
| 589 | - ); | |
| 590 | - } | |
| 620 | + if ( $has_more ) { | |
| 621 | + // Pop off the last item as it is only queried to determine if there are more results. | |
| 622 | + array_pop( $saved_actions ); | |
| 623 | + } | |
| 624 | + | |
| 625 | + foreach ( $saved_actions as $action ) { | |
| 626 | + $actions[] = array( | |
| 627 | + 'form_id' => $action->menu_order, | |
| 628 | + 'type' => $action->post_excerpt, | |
| 629 | + 'status' => $action->post_status, | |
| 630 | + 'settings' => FrmAppHelper::maybe_json_decode( $action->post_content ), | |
| 631 | + ); | |
| 632 | + unset( $action ); | |
| 633 | + } | |
| 634 | + | |
| 635 | + $offset += $limit; | |
| 636 | + | |
| 637 | + unset( $saved_actions ); | |
| 638 | + | |
| 639 | + gc_collect_cycles(); | |
| 640 | + } while ( $has_more ); | |
| 591 | 641 | |
| 592 | 642 | return $actions; |
| 593 | 643 | } |
| 594 | 644 | |