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
formidable / classes / controllers / FrmInboxController.php

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

138 lines 3.8 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::add_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 if ( $key === 'review' ) {
64 $reviews = new FrmReviews();
65 $reviews->dismiss_review();
66 }
67 }
68
69 wp_die();
70 }
71
72 /**
73 * @since 4.05
74 *
75 * @return void
76 */
77 private static function add_tracking_request() {
78 $settings = FrmAppHelper::get_settings();
79 if ( $settings->tracking ) {
80 return;
81 }
82
83 $link = admin_url( 'admin.php?page=formidable-settings&t=misc_settings' );
84
85 $message = new FrmInbox();
86 $message->add_message(
87 array(
88 'key' => 'usage',
89 '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>.',
90 'subject' => __( 'Help Formidable improve with usage tracking', 'formidable' ),
91 '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>',
92 'type' => 'feedback',
93 )
94 );
95 }
96
97 /**
98 * Adds free template design.
99 *
100 * @since 4.10.03
101 *
102 * @return void
103 */
104 private static function add_free_template_message() {
105 if ( FrmAppHelper::pro_is_installed() ) {
106 return;
107 }
108
109 $api = new FrmFormTemplateApi();
110 if ( $api->has_free_access() ) {
111 return;
112 }
113
114 $link = admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . '&free-templates=1' );
115
116 $message = new FrmInbox();
117 $message->add_message(
118 array(
119 'key' => 'free_templates',
120 'message' => 'Add your email address to get a code for 20+ free form templates.',
121 'subject' => 'Get 20+ Free Form Templates',
122 '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>',
123 'type' => 'feedback',
124 )
125 );
126 }
127
128 /**
129 * @since 4.06
130 * @deprecated 6.16
131 *
132 * @return void
133 */
134 public static function dismiss_all_button( $atts ) {
135 _deprecated_function( __METHOD__, '6.16' );
136 }
137 }
138