| @@ -8,69 +8,71 @@ | ||
| 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 | - * @return string | |
| 19 | 13 | */ |
| 20 | - public static function get_notice_count( $filtered = true ) { | |
| 14 | + public static function menu() { | |
| 15 | + $unread = self::get_notice_count(); | |
| 16 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Inbox', 'formidable' ), __( 'Inbox', 'formidable' ) . $unread, 'frm_change_settings', 'formidable-inbox', 'FrmInboxController::inbox' ); | |
| 17 | + } | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * @since 4.05 | |
| 21 | + */ | |
| 22 | + private static function get_notice_count() { | |
| 21 | 23 | FrmFormMigratorsHelper::maybe_add_to_inbox(); |
| 22 | 24 | |
| 23 | 25 | $inbox = new FrmInbox(); |
| 24 | - return $inbox->unread_html( $filtered ); | |
| 26 | + return $inbox->unread_html(); | |
| 25 | 27 | } |
| 26 | 28 | |
| 27 | 29 | /** |
| 28 | - * @since 6.8 | |
| 29 | - * | |
| 30 | - * @return array | |
| 30 | + * @since 4.06 | |
| 31 | 31 | */ |
| 32 | - public static function get_inbox_messages() { | |
| 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 4.05 | |
| 44 | + */ | |
| 45 | + public static function inbox() { | |
| 46 | + FrmAppHelper::include_svg(); | |
| 33 | 47 | self::add_tracking_request(); |
| 34 | - self::remove_free_template_message(); | |
| 48 | + self::add_free_template_message(); | |
| 35 | 49 | |
| 36 | - $inbox = new FrmInbox(); | |
| 37 | - $unread_messages = $inbox->get_messages(); | |
| 38 | - $dismissed_messages = $unread_messages; | |
| 50 | + $inbox = new FrmInbox(); | |
| 51 | + $messages = $inbox->get_messages( 'filter' ); | |
| 52 | + $messages = array_reverse( $messages ); | |
| 53 | + $user = wp_get_current_user(); | |
| 39 | 54 | |
| 40 | - $inbox->filter_messages( $unread_messages, 'filter' ); | |
| 41 | - $inbox->filter_messages( $dismissed_messages, 'dismissed' ); | |
| 55 | + wp_enqueue_script( 'frm-ac', FrmAppHelper::plugin_url() . '/js/ac.js', array(), FrmAppHelper::plugin_version(), true ); | |
| 42 | 56 | |
| 43 | - return array( | |
| 44 | - 'unread' => array_reverse( $unread_messages ), | |
| 45 | - 'dismissed' => array_reverse( $dismissed_messages ), | |
| 46 | - 'user' => wp_get_current_user(), | |
| 47 | - ); | |
| 57 | + include( FrmAppHelper::plugin_path() . '/classes/views/inbox/list.php' ); | |
| 48 | 58 | } |
| 49 | 59 | |
| 50 | 60 | /** |
| 51 | 61 | * @since 4.05 |
| 52 | - * | |
| 53 | - * @return void | |
| 54 | 62 | */ |
| 55 | 63 | public static function dismiss_message() { |
| 56 | 64 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 57 | - FrmAppHelper::permission_check( 'frm_view_forms' ); | |
| 65 | + FrmAppHelper::permission_check( 'frm_change_settings' ); | |
| 58 | 66 | |
| 59 | 67 | $key = FrmAppHelper::get_param( 'key', '', 'post', 'sanitize_text_field' ); |
| 60 | 68 | if ( ! empty( $key ) ) { |
| 61 | 69 | $message = new FrmInbox(); |
| 62 | 70 | $message->dismiss( $key ); |
| 63 | - | |
| 64 | 71 | if ( $key === 'review' ) { |
| 65 | 72 | $reviews = new FrmReviews(); |
| 66 | 73 | $reviews->dismiss_review(); |
| 67 | 74 | } |
| 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 | - } | |
| 73 | 75 | } |
| 74 | 76 | |
| 75 | 77 | wp_die(); |
| 76 | 78 | } |
| @@ -76,10 +78,8 @@ | ||
| 76 | 78 | } |
| 77 | 79 | |
| 78 | 80 | /** |
| 79 | 81 | * @since 4.05 |
| 80 | - * | |
| 81 | - * @return void | |
| 82 | 82 | */ |
| 83 | 83 | private static function add_tracking_request() { |
| 84 | 84 | $settings = FrmAppHelper::get_settings(); |
| 85 | 85 | if ( $settings->tracking ) { |
| @@ -103,24 +103,29 @@ | ||
| 103 | 103 | /** |
| 104 | 104 | * Adds free template design. |
| 105 | 105 | * |
| 106 | 106 | * @since 4.10.03 |
| 107 | - * | |
| 108 | - * @return void | |
| 109 | 107 | */ |
| 110 | - private static function remove_free_template_message() { | |
| 111 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 112 | - $message = new FrmInbox(); | |
| 113 | - $message->dismiss( 'free_templates' ); | |
| 108 | + private static function add_free_template_message() { | |
| 109 | + if ( FrmAppHelper::pro_is_installed() ) { | |
| 110 | + return; | |
| 114 | 111 | } |
| 115 | - } | |
| 116 | 112 | |
| 117 | - /** | |
| 118 | - * @since 4.06 | |
| 119 | - * @deprecated 6.16 | |
| 120 | - * | |
| 121 | - * @return void | |
| 122 | - */ | |
| 123 | - public static function dismiss_all_button( $atts ) { | |
| 124 | - _deprecated_function( __METHOD__, '6.16' ); | |
| 113 | + $api = new FrmFormTemplateApi(); | |
| 114 | + if ( $api->has_free_access() ) { | |
| 115 | + return; | |
| 116 | + } | |
| 117 | + | |
| 118 | + $link = admin_url( 'admin.php?page=formidable&triggerNewFormModal=1&free-templates=1' ); | |
| 119 | + | |
| 120 | + $message = new FrmInbox(); | |
| 121 | + $message->add_message( | |
| 122 | + array( | |
| 123 | + 'key' => 'free_templates', | |
| 124 | + 'message' => 'Add your email address to get a code for 10+ free form templates.', | |
| 125 | + 'subject' => 'Get 10+ Free Form Templates', | |
| 126 | + '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>', | |
| 127 | + 'type' => 'feedback', | |
| 128 | + ) | |
| 129 | + ); | |
| 125 | 130 | } |
| 126 | 131 | } |