| @@ -14,9 +14,8 @@ | ||
| 14 | 14 | * @since 4.05 |
| 15 | 15 | * @since 6.8.4 The $filtered parameter was added. |
| 16 | 16 | * |
| 17 | 17 | * @param bool $filtered Set this to false to avoid the frm_inbox_badge filter. |
| 18 | - * | |
| 19 | 18 | * @return string |
| 20 | 19 | */ |
| 21 | 20 | public static function get_notice_count( $filtered = true ) { |
| 22 | 21 | FrmFormMigratorsHelper::maybe_add_to_inbox(); |
| @@ -25,8 +24,23 @@ | ||
| 25 | 24 | return $inbox->unread_html( $filtered ); |
| 26 | 25 | } |
| 27 | 26 | |
| 28 | 27 | /** |
| 28 | + * @since 4.06 | |
| 29 | + * | |
| 30 | + * @return void | |
| 31 | + */ | |
| 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 | + /** | |
| 29 | 43 | * @since 6.8 |
| 30 | 44 | * |
| 31 | 45 | * @return array |
| 32 | 46 | */ |
| @@ -31,9 +45,9 @@ | ||
| 31 | 45 | * @return array |
| 32 | 46 | */ |
| 33 | 47 | public static function get_inbox_messages() { |
| 34 | 48 | self::add_tracking_request(); |
| 35 | - self::remove_free_template_message(); | |
| 49 | + self::add_free_template_message(); | |
| 36 | 50 | |
| 37 | 51 | $inbox = new FrmInbox(); |
| 38 | 52 | $unread_messages = $inbox->get_messages(); |
| 39 | 53 | $dismissed_messages = $unread_messages; |
| @@ -54,25 +68,18 @@ | ||
| 54 | 68 | * @return void |
| 55 | 69 | */ |
| 56 | 70 | public static function dismiss_message() { |
| 57 | 71 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 58 | - FrmAppHelper::permission_check( 'frm_view_forms' ); | |
| 72 | + FrmAppHelper::permission_check( 'frm_change_settings' ); | |
| 59 | 73 | |
| 60 | 74 | $key = FrmAppHelper::get_param( 'key', '', 'post', 'sanitize_text_field' ); |
| 61 | - | |
| 62 | 75 | if ( ! empty( $key ) ) { |
| 63 | 76 | $message = new FrmInbox(); |
| 64 | 77 | $message->dismiss( $key ); |
| 65 | - | |
| 66 | 78 | if ( $key === 'review' ) { |
| 67 | 79 | $reviews = new FrmReviews(); |
| 68 | 80 | $reviews->dismiss_review(); |
| 69 | 81 | } |
| 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 | 82 | } |
| 76 | 83 | |
| 77 | 84 | wp_die(); |
| 78 | 85 | } |
| @@ -83,9 +90,8 @@ | ||
| 83 | 90 | * @return void |
| 84 | 91 | */ |
| 85 | 92 | private static function add_tracking_request() { |
| 86 | 93 | $settings = FrmAppHelper::get_settings(); |
| 87 | - | |
| 88 | 94 | if ( $settings->tracking ) { |
| 89 | 95 | return; |
| 90 | 96 | } |
| 91 | 97 | |
| @@ -109,11 +115,48 @@ | ||
| 109 | 115 | * @since 4.10.03 |
| 110 | 116 | * |
| 111 | 117 | * @return void |
| 112 | 118 | */ |
| 113 | - private static function remove_free_template_message() { | |
| 114 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 115 | - $message = new FrmInbox(); | |
| 116 | - $message->dismiss( 'free_templates' ); | |
| 119 | + private static function add_free_template_message() { | |
| 120 | + if ( FrmAppHelper::pro_is_installed() ) { | |
| 121 | + return; | |
| 117 | 122 | } |
| 123 | + | |
| 124 | + $api = new FrmFormTemplateApi(); | |
| 125 | + if ( $api->has_free_access() ) { | |
| 126 | + return; | |
| 127 | + } | |
| 128 | + | |
| 129 | + $link = admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . '&free-templates=1' ); | |
| 130 | + | |
| 131 | + $message = new FrmInbox(); | |
| 132 | + $message->add_message( | |
| 133 | + array( | |
| 134 | + 'key' => 'free_templates', | |
| 135 | + 'message' => 'Add your email address to get a code for 20+ free form templates.', | |
| 136 | + 'subject' => 'Get 20+ Free Form Templates', | |
| 137 | + '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>', | |
| 138 | + 'type' => 'feedback', | |
| 139 | + ) | |
| 140 | + ); | |
| 141 | + } | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * @since 4.05 | |
| 145 | + * @deprecated 6.8 | |
| 146 | + * | |
| 147 | + * @return void | |
| 148 | + */ | |
| 149 | + public static function menu() { | |
| 150 | + _deprecated_function( __METHOD__, '6.8' ); | |
| 151 | + } | |
| 152 | + | |
| 153 | + /** | |
| 154 | + * @since 4.05 | |
| 155 | + * @deprecated 6.8 | |
| 156 | + * | |
| 157 | + * @return void | |
| 158 | + */ | |
| 159 | + public static function inbox() { | |
| 160 | + _deprecated_function( __METHOD__, '6.8' ); | |
| 118 | 161 | } |
| 119 | 162 | } |