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

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