PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.11.02
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.11.02
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/FrmInboxController.php +62 -48 6.284.11.02 View file →
@@ -8,71 +8,72 @@
8 8 */
9 9 class FrmInboxController {
10 10
11 11 /**
12 - * Get the HTML for the inbox notice.
13 - *
14 12 * @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 - *
19 - * @return string
20 13 */
21 - public static function get_notice_count( $filtered = true ) {
14 + public static function menu() {
15 + $unread = self::get_notice_count();
16 +
17 + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Inbox', 'formidable' ), __( 'Inbox', 'formidable' ) . $unread, 'frm_change_settings', 'formidable-inbox', 'FrmInboxController::inbox' );
18 + }
19 +
20 + /**
21 + * @since 4.05
22 + */
23 + private static function get_notice_count() {
22 24 FrmFormMigratorsHelper::maybe_add_to_inbox();
23 25
24 - $inbox = new FrmInbox();
25 - return $inbox->unread_html( $filtered );
26 + $inbox = new FrmInbox();
27 + return $inbox->unread_html();
26 28 }
27 29
28 30 /**
29 - * @since 6.8
30 - *
31 - * @return array
31 + * @since 4.06
32 32 */
33 - public static function get_inbox_messages() {
33 + public static function dismiss_all_button( $atts ) {
34 + if ( empty( $atts['messages'] ) ) {
35 + return;
36 + }
37 +
38 + echo '<button class="button-secondary frm-button-secondary" id="frm-dismiss-inbox" type="button">' .
39 + esc_html__( 'Dismiss All', 'formidable' ) .
40 + '</button>';
41 + }
42 +
43 + /**
44 + * @since 4.05
45 + */
46 + public static function inbox() {
47 + FrmAppHelper::include_svg();
34 48 self::add_tracking_request();
35 - self::remove_free_template_message();
49 + self::add_free_template_message();
36 50
37 - $inbox = new FrmInbox();
38 - $unread_messages = $inbox->get_messages();
39 - $dismissed_messages = $unread_messages;
51 + $inbox = new FrmInbox();
52 + $messages = $inbox->get_messages( 'filter' );
53 + $messages = array_reverse( $messages );
54 + $user = wp_get_current_user();
40 55
41 - $inbox->filter_messages( $unread_messages, 'filter' );
42 - $inbox->filter_messages( $dismissed_messages, 'dismissed' );
56 + wp_enqueue_script( 'frm-ac', FrmAppHelper::plugin_url() . '/js/ac.js', array(), FrmAppHelper::plugin_version(), true );
43 57
44 - return array(
45 - 'unread' => array_reverse( $unread_messages ),
46 - 'dismissed' => array_reverse( $dismissed_messages ),
47 - 'user' => wp_get_current_user(),
48 - );
58 + include( FrmAppHelper::plugin_path() . '/classes/views/inbox/list.php' );
49 59 }
50 60
51 61 /**
52 62 * @since 4.05
53 - *
54 - * @return void
55 63 */
56 64 public static function dismiss_message() {
57 65 check_ajax_referer( 'frm_ajax', 'nonce' );
58 - FrmAppHelper::permission_check( 'frm_view_forms' );
66 + FrmAppHelper::permission_check( 'frm_change_settings' );
59 67
60 68 $key = FrmAppHelper::get_param( 'key', '', 'post', 'sanitize_text_field' );
61 -
62 - if ( $key ) {
69 + if ( ! empty( $key ) ) {
63 70 $message = new FrmInbox();
64 71 $message->dismiss( $key );
65 -
66 72 if ( $key === 'review' ) {
67 73 $reviews = new FrmReviews();
68 74 $reviews->dismiss_review();
69 75 }
70 -
71 - if ( $key === 'onboarding_wizard' ) {
72 - // Delete the skipped option or the inbox message will continue to get added.
73 - delete_option( FrmOnboardingWizardController::ONBOARDING_SKIPPED_OPTION );
74 - }
75 76 }
76 77
77 78 wp_die();
78 79 }
@@ -78,26 +79,24 @@
78 79 }
79 80
80 81 /**
81 82 * @since 4.05
82 - *
83 - * @return void
84 83 */
85 84 private static function add_tracking_request() {
86 85 $settings = FrmAppHelper::get_settings();
87 -
88 86 if ( $settings->tracking ) {
89 87 return;
90 88 }
91 89
92 - $link = admin_url( 'admin.php?page=formidable-settings&t=misc_settings' );
90 + $link = admin_url( 'admin.php?page=formidable-settings&t=misc_settings' );
91 +
93 92 $message = new FrmInbox();
94 93 $message->add_message(
95 94 array(
96 95 'key' => 'usage',
97 - '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>.', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
96 + '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>.',
98 97 'subject' => __( 'Help Formidable improve with usage tracking', 'formidable' ),
99 - '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>', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
98 + 'cta' => '<a href="#" class="button-secondary 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>',
100 99 'type' => 'feedback',
101 100 )
102 101 );
103 102 }
@@ -105,14 +104,29 @@
105 104 /**
106 105 * Adds free template design.
107 106 *
108 107 * @since 4.10.03
109 - *
110 - * @return void
111 108 */
112 - private static function remove_free_template_message() {
113 - if ( ! FrmAppHelper::pro_is_installed() ) {
114 - $message = new FrmInbox();
115 - $message->dismiss( 'free_templates' );
109 + private static function add_free_template_message() {
110 + if ( FrmAppHelper::pro_is_installed() ) {
111 + return;
116 112 }
113 +
114 + $api = new FrmFormTemplateApi();
115 + if ( $api->has_free_access() ) {
116 + return;
117 + }
118 +
119 + $link = admin_url( 'admin.php?page=formidable&triggerNewFormModal=1&free-templates=1' );
120 +
121 + $message = new FrmInbox();
122 + $message->add_message(
123 + array(
124 + 'key' => 'free_templates',
125 + 'message' => 'Add your email address to get a code for 10+ free form templates.',
126 + 'subject' => 'Get 10+ Free Form Templates',
127 + 'cta' => '<a href="#" class="button-secondary frm-button-secondary frm_inbox_dismiss">Dismiss</a> <a href="' . esc_url( $link ) . '" class="button-primary frm-button-primary">Get Now</a>',
128 + 'type' => 'feedback',
129 + )
130 + );
117 131 }
118 132 }