diff --git a/classes/models/FrmInbox.php b/classes/models/FrmInbox.php index 116ec5c348..e4579b9bbd 100644 --- a/classes/models/FrmInbox.php +++ b/classes/models/FrmInbox.php @@ -209,15 +209,18 @@ private function is_for_user( $message ) { return true; } $who = (array) $message['who']; - if ( in_array( 'all', $who, true ) || in_array( 'everyone', $who, true ) ) { + if ( $this->is_for_everyone( $who ) ) { return true; } - if ( in_array( $this->get_user_type(), $who, true ) ) { + if ( $this->is_user_type( $who ) ) { return true; } if ( in_array( 'free_first_30', $who, true ) && $this->is_free_first_30() ) { return true; } + if ( in_array( 'free_not_first_30', $who, true ) && $this->is_free_not_first_30() ) { + return true; + } /** * Allow for other special inbox cases in other add-ons. * @@ -230,6 +233,26 @@ private function is_for_user( $message ) { return (bool) apply_filters( 'frm_inbox_message_is_for_user', false, $who, $message ); } + /** + * @since x.x + * + * @param array $who + * @return bool + */ + private function is_for_everyone( $who ) { + return in_array( 'all', $who, true ) || in_array( 'everyone', $who, true ); + } + + /** + * @since x.x + * + * @param array $who + * @return bool + */ + private function is_user_type( $who ) { + return in_array( $this->get_user_type(), $who, true ); + } + private function get_user_type() { if ( ! FrmAppHelper::pro_is_installed() ) { return 'free'; @@ -378,20 +401,45 @@ private function update_list() { * @return bool */ private function is_free_first_30() { + return $this->is_free() && $this->is_first_30(); + } + + /** + * @since x.x + * + * @return bool + */ + private function is_first_30() { $activation_timestamp = get_option( 'frm_first_activation' ); if ( false === $activation_timestamp ) { // If the option does not exist, assume that it is // because the user was active before this option was introduced. return false; } - if ( FrmAppHelper::pro_is_included() ) { - // Not free. - return false; - } $cutoff = strtotime( '-30 days' ); return $activation_timestamp > $cutoff; } + /** + * @since x.x + * + * @return bool + */ + private function is_free_not_first_30() { + return $this->is_free() && ! $this->is_first_30(); + } + + /** + * Check if the Pro plugin is active. If not, consider the user to be on the free version. + * + * @since x.x + * + * @return bool + */ + private function is_free() { + return ! FrmAppHelper::pro_is_included(); + } + /** * Show a banner message if one is available. *