| @@ -8,24 +8,33 @@ | ||
| 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 get_notice_count() { | |
| 21 | 15 | FrmFormMigratorsHelper::maybe_add_to_inbox(); |
| 22 | 16 | |
| 23 | 17 | $inbox = new FrmInbox(); |
| 24 | - return $inbox->unread_html( $filtered ); | |
| 18 | + return $inbox->unread_html(); | |
| 25 | 19 | } |
| 26 | 20 | |
| 27 | 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 | + /** | |
| 28 | 37 | * @since 6.8 |
| 29 | 38 | * |
| 30 | 39 | * @return array |
| 31 | 40 | */ |
| @@ -30,9 +39,9 @@ | ||
| 30 | 39 | * @return array |
| 31 | 40 | */ |
| 32 | 41 | public static function get_inbox_messages() { |
| 33 | 42 | self::add_tracking_request(); |
| 34 | - self::remove_free_template_message(); | |
| 43 | + self::add_free_template_message(); | |
| 35 | 44 | |
| 36 | 45 | $inbox = new FrmInbox(); |
| 37 | 46 | $unread_messages = $inbox->get_messages(); |
| 38 | 47 | $dismissed_messages = $unread_messages; |
| @@ -53,24 +62,18 @@ | ||
| 53 | 62 | * @return void |
| 54 | 63 | */ |
| 55 | 64 | public static function dismiss_message() { |
| 56 | 65 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 57 | - FrmAppHelper::permission_check( 'frm_view_forms' ); | |
| 66 | + FrmAppHelper::permission_check( 'frm_change_settings' ); | |
| 58 | 67 | |
| 59 | 68 | $key = FrmAppHelper::get_param( 'key', '', 'post', 'sanitize_text_field' ); |
| 60 | 69 | if ( ! empty( $key ) ) { |
| 61 | 70 | $message = new FrmInbox(); |
| 62 | 71 | $message->dismiss( $key ); |
| 63 | - | |
| 64 | 72 | if ( $key === 'review' ) { |
| 65 | 73 | $reviews = new FrmReviews(); |
| 66 | 74 | $reviews->dismiss_review(); |
| 67 | 75 | } |
| 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 | 76 | } |
| 74 | 77 | |
| 75 | 78 | wp_die(); |
| 76 | 79 | } |
| @@ -106,21 +109,49 @@ | ||
| 106 | 109 | * @since 4.10.03 |
| 107 | 110 | * |
| 108 | 111 | * @return void |
| 109 | 112 | */ |
| 110 | - private static function remove_free_template_message() { | |
| 111 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 112 | - $message = new FrmInbox(); | |
| 113 | - $message->dismiss( 'free_templates' ); | |
| 113 | + private static function add_free_template_message() { | |
| 114 | + if ( FrmAppHelper::pro_is_installed() ) { | |
| 115 | + return; | |
| 114 | 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 | + ); | |
| 115 | 135 | } |
| 116 | 136 | |
| 117 | 137 | /** |
| 118 | - * @since 4.06 | |
| 119 | - * @deprecated 6.16 | |
| 138 | + * @since 4.05 | |
| 139 | + * @deprecated 6.8 | |
| 120 | 140 | * |
| 121 | 141 | * @return void |
| 122 | 142 | */ |
| 123 | - public static function dismiss_all_button( $atts ) { | |
| 124 | - _deprecated_function( __METHOD__, '6.16' ); | |
| 143 | + public static function menu() { | |
| 144 | + _deprecated_function( __METHOD__, '6.8' ); | |
| 125 | 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 | + | |
| 126 | 157 | } |