| @@ -8,58 +8,44 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | class FrmInboxController { |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | + * Get the HTML for the inbox notice. | |
| 13 | + * | |
| 12 | 14 | * @since 4.05 |
| 15 | + * @since 6.8.4 The $filtered parameter was added. | |
| 13 | 16 | * |
| 14 | - * @return void | |
| 17 | + * @param bool $filtered Set this to false to avoid the frm_inbox_badge filter. | |
| 18 | + * @return string | |
| 15 | 19 | */ |
| 16 | - public static function menu() { | |
| 17 | - $unread = self::get_notice_count(); | |
| 18 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Inbox', 'formidable' ), __( 'Inbox', 'formidable' ) . $unread, 'frm_change_settings', 'formidable-inbox', 'FrmInboxController::inbox' ); | |
| 19 | - } | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * @since 4.05 | |
| 23 | - */ | |
| 24 | - private static function get_notice_count() { | |
| 20 | + public static function get_notice_count( $filtered = true ) { | |
| 25 | 21 | FrmFormMigratorsHelper::maybe_add_to_inbox(); |
| 26 | 22 | |
| 27 | 23 | $inbox = new FrmInbox(); |
| 28 | - return $inbox->unread_html(); | |
| 24 | + return $inbox->unread_html( $filtered ); | |
| 29 | 25 | } |
| 30 | 26 | |
| 31 | 27 | /** |
| 32 | - * @since 4.06 | |
| 28 | + * @since 6.8 | |
| 33 | 29 | * |
| 34 | - * @return void | |
| 30 | + * @return array | |
| 35 | 31 | */ |
| 36 | - public static function dismiss_all_button( $atts ) { | |
| 37 | - if ( empty( $atts['messages'] ) ) { | |
| 38 | - return; | |
| 39 | - } | |
| 40 | - | |
| 41 | - echo '<button class="frm-button-secondary" id="frm-dismiss-inbox" type="button">' . | |
| 42 | - esc_html__( 'Dismiss All', 'formidable' ) . | |
| 43 | - '</button>'; | |
| 44 | - } | |
| 45 | - | |
| 46 | - /** | |
| 47 | - * @since 4.05 | |
| 48 | - * | |
| 49 | - * @return void | |
| 50 | - */ | |
| 51 | - public static function inbox() { | |
| 52 | - FrmAppHelper::include_svg(); | |
| 32 | + public static function get_inbox_messages() { | |
| 53 | 33 | self::add_tracking_request(); |
| 54 | 34 | self::add_free_template_message(); |
| 55 | 35 | |
| 56 | - $inbox = new FrmInbox(); | |
| 57 | - $messages = $inbox->get_messages( 'filter' ); | |
| 58 | - $messages = array_reverse( $messages ); | |
| 59 | - $user = wp_get_current_user(); | |
| 36 | + $inbox = new FrmInbox(); | |
| 37 | + $unread_messages = $inbox->get_messages(); | |
| 38 | + $dismissed_messages = $unread_messages; | |
| 60 | 39 | |
| 61 | - include( FrmAppHelper::plugin_path() . '/classes/views/inbox/list.php' ); | |
| 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 | + ); | |
| 62 | 48 | } |
| 63 | 49 | |
| 64 | 50 | /** |
| 65 | 51 | * @since 4.05 |
| @@ -73,12 +59,18 @@ | ||
| 73 | 59 | $key = FrmAppHelper::get_param( 'key', '', 'post', 'sanitize_text_field' ); |
| 74 | 60 | if ( ! empty( $key ) ) { |
| 75 | 61 | $message = new FrmInbox(); |
| 76 | 62 | $message->dismiss( $key ); |
| 63 | + | |
| 77 | 64 | if ( $key === 'review' ) { |
| 78 | 65 | $reviews = new FrmReviews(); |
| 79 | 66 | $reviews->dismiss_review(); |
| 80 | 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 | + } | |
| 81 | 73 | } |
| 82 | 74 | |
| 83 | 75 | wp_die(); |
| 84 | 76 | } |
| @@ -124,18 +116,28 @@ | ||
| 124 | 116 | if ( $api->has_free_access() ) { |
| 125 | 117 | return; |
| 126 | 118 | } |
| 127 | 119 | |
| 128 | - $link = admin_url( 'admin.php?page=formidable&triggerNewFormModal=1&free-templates=1' ); | |
| 120 | + $link = admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . '&free-templates=1' ); | |
| 129 | 121 | |
| 130 | 122 | $message = new FrmInbox(); |
| 131 | 123 | $message->add_message( |
| 132 | 124 | array( |
| 133 | 125 | 'key' => 'free_templates', |
| 134 | - 'message' => 'Add your email address to get a code for 10+ free form templates.', | |
| 135 | - 'subject' => 'Get 10+ Free Form Templates', | |
| 126 | + 'message' => 'Add your email address to get a code for 30+ free form templates.', | |
| 127 | + 'subject' => 'Get 30+ Free Form Templates', | |
| 136 | 128 | '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>', |
| 137 | 129 | 'type' => 'feedback', |
| 138 | 130 | ) |
| 139 | 131 | ); |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * @since 4.06 | |
| 136 | + * @deprecated 6.16 | |
| 137 | + * | |
| 138 | + * @return void | |
| 139 | + */ | |
| 140 | + public static function dismiss_all_button( $atts ) { | |
| 141 | + _deprecated_function( __METHOD__, '6.16' ); | |
| 140 | 142 | } |
| 141 | 143 | } |