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

163 lines 4.2 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 4.06
29 *
30 * @return void
31 */
32 public static function dismiss_all_button( $atts ) {
33 if ( empty( $atts['messages'] ) ) {
34 return;
35 }
36
37 echo '<button class="frm-button-secondary" id="frm-dismiss-inbox" type="button">' .
38 esc_html__( 'Dismiss All', 'formidable' ) .
39 '</button>';
40 }
41
42 /**
43 * @since 6.8
44 *
45 * @return array
46 */
47 public static function get_inbox_messages() {
48 self::add_tracking_request();
49 self::add_free_template_message();
50
51 $inbox = new FrmInbox();
52 $unread_messages = $inbox->get_messages();
53 $dismissed_messages = $unread_messages;
54
55 $inbox->filter_messages( $unread_messages, 'filter' );
56 $inbox->filter_messages( $dismissed_messages, 'dismissed' );
57
58 return array(
59 'unread' => array_reverse( $unread_messages ),
60 'dismissed' => array_reverse( $dismissed_messages ),
61 'user' => wp_get_current_user(),
62 );
63 }
64
65 /**
66 * @since 4.05
67 *
68 * @return void
69 */
70 public static function dismiss_message() {
71 check_ajax_referer( 'frm_ajax', 'nonce' );
72 FrmAppHelper::permission_check( 'frm_change_settings' );
73
74 $key = FrmAppHelper::get_param( 'key', '', 'post', 'sanitize_text_field' );
75 if ( ! empty( $key ) ) {
76 $message = new FrmInbox();
77 $message->dismiss( $key );
78 if ( $key === 'review' ) {
79 $reviews = new FrmReviews();
80 $reviews->dismiss_review();
81 }
82 }
83
84 wp_die();
85 }
86
87 /**
88 * @since 4.05
89 *
90 * @return void
91 */
92 private static function add_tracking_request() {
93 $settings = FrmAppHelper::get_settings();
94 if ( $settings->tracking ) {
95 return;
96 }
97
98 $link = admin_url( 'admin.php?page=formidable-settings&t=misc_settings' );
99
100 $message = new FrmInbox();
101 $message->add_message(
102 array(
103 'key' => 'usage',
104 '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>.',
105 'subject' => __( 'Help Formidable improve with usage tracking', 'formidable' ),
106 '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>',
107 'type' => 'feedback',
108 )
109 );
110 }
111
112 /**
113 * Adds free template design.
114 *
115 * @since 4.10.03
116 *
117 * @return void
118 */
119 private static function add_free_template_message() {
120 if ( FrmAppHelper::pro_is_installed() ) {
121 return;
122 }
123
124 $api = new FrmFormTemplateApi();
125 if ( $api->has_free_access() ) {
126 return;
127 }
128
129 $link = admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . '&free-templates=1' );
130
131 $message = new FrmInbox();
132 $message->add_message(
133 array(
134 'key' => 'free_templates',
135 'message' => 'Add your email address to get a code for 20+ free form templates.',
136 'subject' => 'Get 20+ Free Form Templates',
137 'cta' => '<a href="#" class="frm-button-secondary frm_inbox_dismiss">Dismiss</a> <a href="' . esc_url( $link ) . '" class="button-primary frm-button-primary">Get Now</a>',
138 'type' => 'feedback',
139 )
140 );
141 }
142
143 /**
144 * @since 4.05
145 * @deprecated 6.8
146 *
147 * @return void
148 */
149 public static function menu() {
150 _deprecated_function( __METHOD__, '6.8' );
151 }
152
153 /**
154 * @since 4.05
155 * @deprecated 6.8
156 *
157 * @return void
158 */
159 public static function inbox() {
160 _deprecated_function( __METHOD__, '6.8' );
161 }
162 }
163