| @@ -13,9 +13,8 @@ | ||
| 13 | 13 | * |
| 14 | 14 | * @since 6.17 |
| 15 | 15 | * |
| 16 | 16 | * @param array $item Inbox or Sale item. |
| 17 | - * | |
| 18 | 17 | * @return bool |
| 19 | 18 | */ |
| 20 | 19 | public static function is_for_user( $item ) { |
| 21 | 20 | if ( ! isset( $item['who'] ) || $item['who'] === 'all' ) { |
| @@ -20,28 +19,25 @@ | ||
| 20 | 19 | public static function is_for_user( $item ) { |
| 21 | 20 | if ( ! isset( $item['who'] ) || $item['who'] === 'all' ) { |
| 22 | 21 | return true; |
| 23 | 22 | } |
| 24 | - | |
| 25 | 23 | $who = (array) $item['who']; |
| 26 | - | |
| 27 | 24 | if ( self::is_for_everyone( $who ) ) { |
| 28 | 25 | return true; |
| 29 | 26 | } |
| 30 | - | |
| 31 | 27 | if ( self::is_user_type( $who ) ) { |
| 32 | 28 | return true; |
| 33 | 29 | } |
| 34 | - | |
| 35 | 30 | if ( in_array( 'free_first_30', $who, true ) && self::is_free_first_30() ) { |
| 36 | 31 | return true; |
| 37 | 32 | } |
| 38 | - | |
| 39 | 33 | if ( in_array( 'free_not_first_30', $who, true ) && self::is_free_not_first_30() ) { |
| 40 | 34 | return true; |
| 41 | 35 | } |
| 42 | - | |
| 43 | - return self::check_free_segments( $who ); | |
| 36 | + if ( self::check_free_segments( $who ) ) { | |
| 37 | + return true; | |
| 38 | + } | |
| 39 | + return false; | |
| 44 | 40 | } |
| 45 | 41 | |
| 46 | 42 | /** |
| 47 | 43 | * @since 6.17 |
| @@ -46,9 +42,8 @@ | ||
| 46 | 42 | /** |
| 47 | 43 | * @since 6.17 |
| 48 | 44 | * |
| 49 | 45 | * @param array $who |
| 50 | - * | |
| 51 | 46 | * @return bool |
| 52 | 47 | */ |
| 53 | 48 | private static function is_for_everyone( $who ) { |
| 54 | 49 | return in_array( 'all', $who, true ); |
| @@ -57,9 +52,8 @@ | ||
| 57 | 52 | /** |
| 58 | 53 | * @since 6.17 |
| 59 | 54 | * |
| 60 | 55 | * @param array $who |
| 61 | - * | |
| 62 | 56 | * @return bool |
| 63 | 57 | */ |
| 64 | 58 | private static function is_user_type( $who ) { |
| 65 | 59 | return in_array( self::get_user_type(), $who, true ); |
| @@ -96,15 +90,13 @@ | ||
| 96 | 90 | * @return bool |
| 97 | 91 | */ |
| 98 | 92 | private static function is_first_30() { |
| 99 | 93 | $activation_timestamp = get_option( 'frm_first_activation' ); |
| 100 | - | |
| 101 | 94 | if ( false === $activation_timestamp ) { |
| 102 | 95 | // If the option does not exist, assume that it is |
| 103 | - // Because the user was active before this option was introduced. | |
| 96 | + // because the user was active before this option was introduced. | |
| 104 | 97 | return false; |
| 105 | 98 | } |
| 106 | - | |
| 107 | 99 | $cutoff = strtotime( '-30 days' ); |
| 108 | 100 | return $activation_timestamp > $cutoff; |
| 109 | 101 | } |
| 110 | 102 | |
| @@ -131,9 +123,8 @@ | ||
| 131 | 123 | /** |
| 132 | 124 | * @since 6.18 |
| 133 | 125 | * |
| 134 | 126 | * @param array $who |
| 135 | - * | |
| 136 | 127 | * @return bool |
| 137 | 128 | */ |
| 138 | 129 | private static function check_free_segments( $who ) { |
| 139 | 130 | $segments = array( |
| @@ -169,15 +160,13 @@ | ||
| 169 | 160 | * @since 6.18 |
| 170 | 161 | * |
| 171 | 162 | * @param string $key |
| 172 | 163 | * @param int $activation_timestamp |
| 173 | - * | |
| 174 | 164 | * @return bool |
| 175 | 165 | */ |
| 176 | 166 | private static function matches_segment( $key, $activation_timestamp ) { |
| 177 | 167 | $range_part = str_replace( 'free_first_', '', $key ); |
| 178 | 168 | $range_parts = explode( '_', $range_part ); |
| 179 | - | |
| 180 | 169 | if ( ! $range_parts ) { |
| 181 | 170 | return false; |
| 182 | 171 | } |
| 183 | 172 | |