PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.21
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.21
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
formidable / classes / controllers / FrmInboxController.php

FrmInboxController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.21, at classes/controllers/FrmInboxController.php

127 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 /**
7 * @since 4.05
8 */
9 class FrmInboxController {
10
11 /**
12 * Get the HTML for the inbox notice.
13 *
14 * @since 4.05
15 * @since 6.8.4 The $filtered parameter was added.
16 *
17 * @param bool $filtered Set this to false to avoid the frm_inbox_badge filter.
18 * @return string
19 */
20 public static function get_notice_count( $filtered = true ) {
21 FrmFormMigratorsHelper::maybe_add_to_inbox();
22
23 $inbox = new FrmInbox();
24 return $inbox->unread_html( $filtered );
25 }
26
27 /**
28 * @since 6.8
29 *
30 * @return array
31 */
32 public static function get_inbox_messages() {
33 self::add_tracking_request();
34 self::remove_free_template_message();
35
36 $inbox = new FrmInbox();
37 $unread_messages = $inbox->get_messages();
38 $dismissed_messages = $unread_messages;
39
40 $inbox->filter_messages( $unread_messages, 'filter' );
41 $inbox->filter_messages( $dismissed_messages, 'dismissed' );
42
43 return array(
44 'unread' => array_reverse( $unread_messages ),
45 'dismissed' => array_reverse( $dismissed_messages ),
46 'user' => wp_get_current_user(),
47 );
48 }
49
50 /**
51 * @since 4.05
52 *
53 * @return void
54 */
55 public static function dismiss_message() {
56 check_ajax_referer( 'frm_ajax', 'nonce' );
57 FrmAppHelper::permission_check( 'frm_change_settings' );
58
59 $key = FrmAppHelper::get_param( 'key', '', 'post', 'sanitize_text_field' );
60 if ( ! empty( $key ) ) {
61 $message = new FrmInbox();
62 $message->dismiss( $key );
63
64 if ( $key === 'review' ) {
65 $reviews = new FrmReviews();
66 $reviews->dismiss_review();
67 }
68
69 if ( $key === 'onboarding_wizard' ) {
70 // Delete the skipped option or the inbox message will continue to get added.
71 delete_option( FrmOnboardingWizardController::ONBOARDING_SKIPPED_OPTION );
72 }
73 }
74
75 wp_die();
76 }
77
78 /**
79 * @since 4.05
80 *
81 * @return void
82 */
83 private static function add_tracking_request() {
84 $settings = FrmAppHelper::get_settings();
85 if ( $settings->tracking ) {
86 return;
87 }
88
89 $link = admin_url( 'admin.php?page=formidable-settings&t=misc_settings' );
90
91 $message = new FrmInbox();
92 $message->add_message(
93 array(
94 'key' => 'usage',
95 'message' => 'Gathering usage data allows us to improve Formidable. Your forms will be considered as we evaluate new features, judge the quality of an update, or determine if an improvement makes sense. You can always visit the <a href="' . esc_url( $link ) . '">Global Settings</a> and choose to stop sharing data. <a href="https://formidableforms.com/knowledgebase/global-settings-overview/#kb-usage-tracking" target="_blank" rel="noopener noreferrer">Read more about what data we collect</a>.',
96 'subject' => __( 'Help Formidable improve with usage tracking', 'formidable' ),
97 'cta' => '<a href="#" class="frm-button-secondary frm_inbox_dismiss">Dismiss</a> <a href="' . esc_url( $link ) . '" class="button-primary frm-button-primary frm_inbox_dismiss">Activate usage tracking</a>',
98 'type' => 'feedback',
99 )
100 );
101 }
102
103 /**
104 * Adds free template design.
105 *
106 * @since 4.10.03
107 *
108 * @return void
109 */
110 private static function remove_free_template_message() {
111 if ( ! FrmAppHelper::pro_is_installed() ) {
112 $message = new FrmInbox();
113 $message->dismiss( 'free_templates' );
114 }
115 }
116
117 /**
118 * @since 4.06
119 * @deprecated 6.16
120 *
121 * @return void
122 */
123 public static function dismiss_all_button( $atts ) {
124 _deprecated_function( __METHOD__, '6.16' );
125 }
126 }
127