PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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/controllers/FrmDashboardController.php +26 -22 6.27 → trunk View file →
@@ -70,11 +70,10 @@
70 70 *
71 71 * @return FrmDashboardHelper
72 72 */
73 73 public static function get_dashboard_helper() {
74 - $latest_available_form = FrmForm::get_latest_form();
75 - $total_payments = self::view_args_payments();
76 - $counters_value = array(
74 + $total_payments = self::view_args_payments();
75 + $counters_value = array(
77 76 'forms' => FrmForm::get_forms_count(),
78 77 'entries' => FrmEntry::get_entries_count(),
79 78 );
80 79
@@ -80,9 +79,9 @@
80 79
81 80 return new FrmDashboardHelper(
82 81 array(
83 82 'counters' => array(
84 - 'counters' => self::view_args_counters( $latest_available_form, $counters_value ),
83 + 'counters' => self::view_args_counters( FrmForm::get_latest_form(), $counters_value ),
85 84 ),
86 85 'license' => array(),
87 86 'get_free_templates' => array(),
88 87 'inbox' => self::view_args_inbox(),
@@ -96,9 +95,9 @@
96 95 'count' => $counters_value['entries'],
97 96 'placeholder' => self::view_args_entries_placeholder( $counters_value['forms'] ),
98 97 ),
99 98 'payments' => array(
100 - 'show-placeholder' => empty( $total_payments ),
99 + 'show-placeholder' => ! $total_payments,
101 100 'placeholder' => array(
102 101 'copy' => __( 'You don\'t have a payment form setup yet.', 'formidable' ),
103 102 'cta' => array(
104 103 'link' => admin_url( 'admin.php?page=formidable-form-templates' ),
@@ -270,9 +269,9 @@
270 269
271 270 $copy = sprintf(
272 271 /* translators: %1$s: HTML start of a tag, %2$s: HTML close a tag */
273 272 __( 'See the %1$sform documentation%2$s for instructions on publishing a form. Once vou have at least one entry you\'ll see it here.', 'formidable' ),
274 - '<a target="_blank" href="' . FrmAppHelper::admin_upgrade_link( '', 'knowledgebase/publish-a-form/' ) . '">',
273 + '<a target="_blank" href="' . esc_url( FrmAppHelper::admin_upgrade_link( '', 'knowledgebase/publish-a-form/' ) ) . '">',
275 274 '</a>'
276 275 );
277 276 return array(
278 277 'background' => 'entries-placeholder',
@@ -358,11 +357,10 @@
358 357 *
359 358 * @return bool
360 359 */
361 360 public static function welcome_banner_has_closed() {
362 - $user_id = get_current_user_id();
363 361 $banner_closed_by_users = self::get_closed_welcome_banner_user_ids();
364 - return $banner_closed_by_users && in_array( $user_id, $banner_closed_by_users, true );
362 + return $banner_closed_by_users && in_array( get_current_user_id(), $banner_closed_by_users, true );
365 363 }
366 364
367 365 /**
368 366 * Check if is dashboard page.
@@ -380,10 +378,9 @@
380 378 *
381 379 * @return bool
382 380 */
383 381 public static function email_is_subscribed( $email ) {
384 - $subscribed_emails = self::get_subscribed_emails();
385 - return in_array( $email, $subscribed_emails, true );
382 + return in_array( $email, self::get_subscribed_emails(), true );
386 383 }
387 384
388 385 /**
389 386 * Register controller assets.
@@ -427,14 +424,17 @@
427 424 * @return array
428 425 */
429 426 private static function inbox_prepare_messages( $data ) {
430 427 foreach ( $data as $key => $messages ) {
431 - if ( in_array( $key, array( 'unread', 'dismissed' ), true ) ) {
432 - foreach ( $messages as $key_msg => $message ) {
433 - $data[ $key ][ $key_msg ]['cta'] = self::inbox_clean_messages_cta( $message['cta'] );
434 - }
428 + if ( ! in_array( $key, array( 'unread', 'dismissed' ), true ) ) {
429 + continue;
435 430 }
431 +
432 + foreach ( $messages as $key_msg => $message ) {
433 + $data[ $key ][ $key_msg ]['cta'] = self::inbox_clean_messages_cta( $message['cta'] );
434 + }
436 435 }
436 +
437 437 return $data;
438 438 }
439 439
440 440 /**
@@ -444,9 +444,9 @@
444 444 *
445 445 * @return string
446 446 */
447 447 private static function inbox_clean_messages_cta( $cta ) {
448 - // remove dismiss button
448 + // Remove dismiss button
449 449 $pattern = '/<a[^>]*class="[^"]*frm_inbox_dismiss[^"]*"[^>]*>.*?<\/a>/is';
450 450 return preg_replace( $pattern, ' ', $cta );
451 451 }
452 452
@@ -488,12 +488,14 @@
488 488 */
489 489 private static function save_subscribed_email( $email ) {
490 490 $subscribed_emails = self::get_subscribed_emails();
491 491
492 - if ( ! in_array( $email, $subscribed_emails, true ) ) {
493 - $subscribed_emails[] = $email;
494 - self::update_dashboard_options( $subscribed_emails, 'inbox-subscribed-emails' );
492 + if ( in_array( $email, $subscribed_emails, true ) ) {
493 + return;
495 494 }
495 +
496 + $subscribed_emails[] = $email;
497 + self::update_dashboard_options( $subscribed_emails, 'inbox-subscribed-emails' );
496 498 }
497 499
498 500 /**
499 501 * Get list of users' ids that have closed the welcome banner.
@@ -540,9 +542,9 @@
540 542 */
541 543 private static function update_dashboard_options( $data, $option_name ) {
542 544 $options = self::get_dashboard_options();
543 545 $options[ $option_name ] = $data;
544 - update_option( self::OPTION_META_NAME, $options, 'no' );
546 + update_option( self::OPTION_META_NAME, $options, false );
545 547 }
546 548
547 549 /**
548 550 * Save user id to closed banner list.
@@ -552,10 +554,12 @@
552 554 private static function add_welcome_closed_banner_user_id() {
553 555 $users_list = self::get_closed_welcome_banner_user_ids();
554 556 $user_id = get_current_user_id();
555 557
556 - if ( ! in_array( $user_id, $users_list, true ) ) {
557 - $users_list[] = $user_id;
558 - self::update_dashboard_options( $users_list, 'closed-welcome-banner-user-ids' );
558 + if ( in_array( $user_id, $users_list, true ) ) {
559 + return;
559 560 }
561 +
562 + $users_list[] = $user_id;
563 + self::update_dashboard_options( $users_list, 'closed-welcome-banner-user-ids' );
560 564 }
561 565 }