← All changes
|
freemius/includes/managers/class-fs-plan-manager.php
+9
-40
8.0.2
→
2.1.2
View file →
| @@ -107,9 +107,8 @@ | ||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Find all plans that have trial. |
| 111 | - * Since 2.6.2 call get_filtered_plan | |
| 112 | 111 | * |
| 113 | 112 | * @author Vova Feldman (@svovaf) |
| 114 | 113 | * @since 1.0.9 |
| 115 | 114 | * |
| @@ -117,52 +116,22 @@ | ||
| 117 | 116 | * |
| 118 | 117 | * @return FS_Plugin_Plan[] |
| 119 | 118 | */ |
| 120 | 119 | function get_trial_plans( $plans ) { |
| 121 | - return $this->get_filtered_plans( $plans, true ); | |
| 122 | - } | |
| 120 | + $trial_plans = array(); | |
| 123 | 121 | |
| 124 | - /** | |
| 125 | - * Find all plans that are not hidden and have trial. | |
| 126 | - * | |
| 127 | - * @author Daniele Alessandra (@danielealessandra) | |
| 128 | - * | |
| 129 | - * @param FS_Plugin_Plan[] $plans | |
| 130 | - * | |
| 131 | - * @return FS_Plugin_Plan[] | |
| 132 | - * @since 2.6.3 | |
| 133 | - * | |
| 134 | - */ | |
| 135 | - function get_visible_trial_plans( $plans ) { | |
| 136 | - return $this->get_filtered_plans( $plans, true, true ); | |
| 137 | - } | |
| 138 | - | |
| 139 | - /** | |
| 140 | - * Find all plans filtered by trial or visibility. | |
| 141 | - * | |
| 142 | - * @author Daniele Alessandra (@danielealessandra) | |
| 143 | - * | |
| 144 | - * @param FS_Plugin_Plan[] $plans | |
| 145 | - * @param boolean $should_have_trials | |
| 146 | - * @param boolean $should_be_visible | |
| 147 | - * | |
| 148 | - * @return FS_Plugin_Plan[] | |
| 149 | - * @since 2.6.3 | |
| 150 | - * | |
| 151 | - */ | |
| 152 | - function get_filtered_plans( $plans, $should_have_trials = false, $should_be_visible = false ) { | |
| 153 | - $filtered_plans = array(); | |
| 154 | - | |
| 155 | - if ( is_array( $plans ) && count( $plans ) > 0 ) { | |
| 156 | - foreach ( $plans as $plan ) { | |
| 157 | - if ( ( $should_have_trials && ! $plan->has_trial() ) || ( $should_be_visible && $plan->is_hidden ) ) { | |
| 158 | - continue; | |
| 122 | + if ( is_array( $plans ) && 0 < count( $plans ) ) { | |
| 123 | + /** | |
| 124 | + * @var FS_Plugin_Plan[] $plans | |
| 125 | + */ | |
| 126 | + for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) { | |
| 127 | + if ( $plans[ $i ]->has_trial() ) { | |
| 128 | + $trial_plans[] = $plans[ $i ]; | |
| 159 | 129 | } |
| 160 | - $filtered_plans[] = $plan; | |
| 161 | 130 | } |
| 162 | 131 | } |
| 163 | 132 | |
| 164 | - return $filtered_plans; | |
| 133 | + return $trial_plans; | |
| 165 | 134 | } |
| 166 | 135 | |
| 167 | 136 | /** |
| 168 | 137 | * Check if plugin has any trial plan. |