PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16
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 +16 -56 6.266.16 View file →
@@ -20,9 +20,9 @@
20 20 *
21 21 * @return void
22 22 */
23 23 public static function load_admin_hooks() {
24 - add_action( 'admin_menu', self::class . '::menu', 9 );
24 + add_action( 'admin_menu', __CLASS__ . '::menu', 9 );
25 25 }
26 26
27 27 /**
28 28 * Register Dashboard page tp Formidable admin menu.
@@ -43,11 +43,9 @@
43 43 public static function load_page() {
44 44 self::remove_admin_notices_on_dashboard();
45 45 self::load_assets();
46 46
47 - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
48 -
49 - add_filter( 'manage_' . sanitize_title( FrmAppHelper::get_menu_name() ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-dashboard_columns', 'FrmDashboardController::entries_columns' );
47 + add_filter( 'manage_' . sanitize_title( FrmAppHelper::get_menu_name() ) . '_page_formidable-dashboard_columns', 'FrmDashboardController::entries_columns' );
50 48 add_filter( 'frm_show_footer_links', '__return_false' );
51 49 add_filter( 'screen_options_show_screen', '__return_false' );
52 50 }
53 51
@@ -63,15 +61,13 @@
63 61 self::enqueue_assets();
64 62 }
65 63
66 64 /**
67 - * Gets dashboard helper instance.
65 + * Init dashboard page.
68 66 *
69 - * @since 6.17
70 - *
71 - * @return FrmDashboardHelper
67 + * @return void
72 68 */
73 - public static function get_dashboard_helper() {
69 + public static function route() {
74 70 $latest_available_form = FrmForm::get_latest_form();
75 71 $total_payments = self::view_args_payments();
76 72 $counters_value = array(
77 73 'forms' => FrmForm::get_forms_count(),
@@ -77,17 +73,16 @@
77 73 'forms' => FrmForm::get_forms_count(),
78 74 'entries' => FrmEntry::get_entries_count(),
79 75 );
80 76
81 - return new FrmDashboardHelper(
77 + $dashboard_view = new FrmDashboardHelper(
82 78 array(
83 - 'counters' => array(
79 + 'counters' => array(
84 80 'counters' => self::view_args_counters( $latest_available_form, $counters_value ),
85 81 ),
86 - 'license' => array(),
87 - 'get_free_templates' => array(),
88 - 'inbox' => self::view_args_inbox(),
89 - 'entries' => array(
82 + 'license' => array(),
83 + 'inbox' => self::view_args_inbox(),
84 + 'entries' => array(
90 85 'widget-heading' => __( 'Latest Entries', 'formidable' ),
91 86 'cta' => array(
92 87 'label' => __( 'View All Entries', 'formidable' ),
93 88 'link' => admin_url( 'admin.php?page=formidable-entries' ),
@@ -95,9 +90,9 @@
95 90 'show-placeholder' => 0 >= (int) $counters_value['entries'],
96 91 'count' => $counters_value['entries'],
97 92 'placeholder' => self::view_args_entries_placeholder( $counters_value['forms'] ),
98 93 ),
99 - 'payments' => array(
94 + 'payments' => array(
100 95 'show-placeholder' => empty( $total_payments ),
101 96 'placeholder' => array(
102 97 'copy' => __( 'You don\'t have a payment form setup yet.', 'formidable' ),
103 98 'cta' => array(
@@ -112,21 +107,12 @@
112 107 'items' => $total_payments,
113 108 ),
114 109 ),
115 110 ),
116 - 'video' => array( 'id' => self::get_youtube_embed_video( $counters_value['entries'] ) ),
111 + 'video' => array( 'id' => self::get_youtube_embed_video( $counters_value['entries'] ) ),
117 112 )
118 113 );
119 - }
120 114
121 - /**
122 - * Init dashboard page.
123 - *
124 - * @return void
125 - */
126 - public static function route() {
127 - $dashboard_view = self::get_dashboard_helper();
128 -
129 115 $should_display_videos = is_callable( 'FrmProDashboardHelper::should_display_videos' ) ? FrmProDashboardHelper::should_display_videos() : true;
130 116
131 117 require FrmAppHelper::plugin_path() . '/classes/views/dashboard/dashboard.php';
132 118 }
@@ -196,9 +182,8 @@
196 182 'heading' => $heading,
197 183 'counter' => $value,
198 184 'type' => 'default',
199 185 );
200 -
201 186 if ( ! empty( $cta ) ) {
202 187 $counter_args['cta'] = $cta;
203 188 }
204 189
@@ -232,9 +217,8 @@
232 217 $prepared_data = array();
233 218
234 219 $model_payments = new FrmTransLitePayment();
235 220 $payments = $model_payments->get_payments_stats();
236 -
237 221 foreach ( $payments['total'] as $currency => $total_payments ) {
238 222 if ( 0 < (int) $total_payments ) {
239 223 $prepared_data[] = array(
240 224 'counter_label' => FrmCurrencyHelper::get_currency( $currency ),
@@ -249,9 +233,8 @@
249 233 /**
250 234 * Init view args for entries placeholder.
251 235 *
252 236 * @param array $forms_count The total forms count. If there are no any forms yet, we'll have CTA pointing to creating a form.
253 - *
254 237 * @return array
255 238 */
256 239 private static function view_args_entries_placeholder( $forms_count ) {
257 240
@@ -258,9 +241,9 @@
258 241 if ( ! $forms_count ) {
259 242 $copy = sprintf(
260 243 /* translators: %1$s: HTML start of a tag, %2$s: HTML close a tag */
261 244 __( 'See the %1$sform documentation%2$s for instructions on publishing your form', 'formidable' ),
262 - '<a target="_blank" href="' . esc_url( FrmAppHelper::admin_upgrade_link( '', 'knowledgebase/publish-a-form/' ) ) . '">',
245 + '<a target="_blank" href="' . FrmAppHelper::admin_upgrade_link( '', 'knowledgebase/publish-a-form/' ) . '">',
263 246 '</a>'
264 247 );
265 248 return array(
266 249 'background' => 'entries-placeholder',
@@ -292,9 +275,8 @@
292 275 *
293 276 * @param string $counter_type
294 277 * @param int $counter_value
295 278 * @param false|object $latest_available_form The form object of the latest form available. If there are at least one form available we show "Add Entry" cta for entries counter.
296 - *
297 279 * @return array
298 280 */
299 281 public static function display_counter_cta( $counter_type, $counter_value, $latest_available_form = false ) {
300 282 if ( $counter_value > 0 || ( 'entries' === $counter_type && false === $latest_available_form ) ) {
@@ -314,9 +296,8 @@
314 296 return;
315 297 }
316 298
317 299 global $wp_filter;
318 -
319 300 if ( isset( $wp_filter['admin_notices'] ) ) {
320 301 unset( $wp_filter['admin_notices'] );
321 302 }
322 303 }
@@ -349,9 +330,8 @@
349 330 * Handle the entries list. Called via add_filter.
350 331 * Hook name: manage_formidable_page_formidable-dashboard_columns.
351 332 *
352 333 * @param array $columns An associative array of column headings.
353 - *
354 334 * @return array
355 335 */
356 336 public static function entries_columns( $columns = array() ) {
357 337 $columns['0_form_id'] = esc_html__( 'Form', 'formidable' );
@@ -388,9 +368,8 @@
388 368 /**
389 369 * Detect if the logged user's email is subscribed. Used for inbox email subscribe.
390 370 *
391 371 * @param string $email The logged user's email.
392 - *
393 372 * @return bool
394 373 */
395 374 public static function email_is_subscribed( $email ) {
396 375 $subscribed_emails = self::get_subscribed_emails();
@@ -434,10 +413,8 @@
434 413
435 414 /**
436 415 * Prepare inbox messages data.
437 416 *
438 - * @param array $data
439 - *
440 417 * @return array
441 418 */
442 419 private static function inbox_prepare_messages( $data ) {
443 420 foreach ( $data as $key => $messages ) {
@@ -449,15 +426,8 @@
449 426 }
450 427 return $data;
451 428 }
452 429
453 - /**
454 - * Clean messages CTA.
455 - *
456 - * @param string $cta
457 - *
458 - * @return string
459 - */
460 430 private static function inbox_clean_messages_cta( $cta ) {
461 431
462 432 // remove dismiss button
463 433 $pattern = '/<a[^>]*class="[^"]*frm_inbox_dismiss[^"]*"[^>]*>.*?<\/a>/is';
@@ -466,10 +436,9 @@
466 436
467 437 /**
468 438 * Get the embed YouTube video from YouTube feed api. If there are 0 entries we show the welcome video otherwise latest video from FF YouTube channel is displayed.
469 439 *
470 - * @param int|string $entries_count The total entries available.
471 - *
440 + * @param int $entries_count The total entries available.
472 441 * @return string|null The YouTube video ID.
473 442 */
474 443 private static function get_youtube_embed_video( $entries_count ) {
475 444 $youtube_api = new FrmYoutubeFeedApi();
@@ -478,19 +447,16 @@
478 447
479 448 if ( 0 === (int) $entries_count && false === $welcome_video && false === $featured_video ) {
480 449 return null;
481 450 }
482 -
483 451 if ( 0 === (int) $entries_count && false !== $welcome_video ) {
484 - return $welcome_video['video-id'] ?? null;
452 + return isset( $welcome_video['video-id'] ) ? $welcome_video['video-id'] : null;
485 453 }
486 -
487 454 // We might receive the most recent video feed as the featured selection.
488 455 if ( isset( $featured_video[0] ) ) {
489 456 return $featured_video[0]['video-id'];
490 457 }
491 -
492 - return $featured_video['video-id'] ?? null;
458 + return isset( $featured_video['video-id'] ) ? $featured_video['video-id'] : null;
493 459 }
494 460
495 461 /**
496 462 * Save subscribed user's email to dashboard options.
@@ -496,14 +462,12 @@
496 462 * Save subscribed user's email to dashboard options.
497 463 * Used for Inbox widget - email subscribe.
498 464 *
499 465 * @param string $email The user email address.
500 - *
501 466 * @return void
502 467 */
503 468 private static function save_subscribed_email( $email ) {
504 469 $subscribed_emails = self::get_subscribed_emails();
505 -
506 470 if ( ! in_array( $email, $subscribed_emails, true ) ) {
507 471 $subscribed_emails[] = $email;
508 472 self::update_dashboard_options( $subscribed_emails, 'inbox-subscribed-emails' );
509 473 }
@@ -530,18 +494,15 @@
530 494 /**
531 495 * Get the dashboard options from db.
532 496 *
533 497 * @param string|null $option_name The dashboard option name. If null it will return all dashboard options.
534 - *
535 498 * @return array
536 499 */
537 500 private static function get_dashboard_options( $option_name = null ) {
538 501 $options = get_option( self::OPTION_META_NAME, array() );
539 -
540 502 if ( null !== $option_name && ! isset( $options[ $option_name ] ) ) {
541 503 return array();
542 504 }
543 -
544 505 if ( null !== $option_name ) {
545 506 return $options[ $option_name ];
546 507 }
547 508 return $options;
@@ -568,9 +529,8 @@
568 529 */
569 530 private static function add_welcome_closed_banner_user_id() {
570 531 $users_list = self::get_closed_welcome_banner_user_ids();
571 532 $user_id = get_current_user_id();
572 -
573 533 if ( ! in_array( $user_id, $users_list, true ) ) {
574 534 $users_list[] = $user_id;
575 535 self::update_dashboard_options( $users_list, 'closed-welcome-banner-user-ids' );
576 536 }