| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Freemius |
| 4 |
* @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 |
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
| 6 |
* @since 1.0.6 |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* @var array $VARS |
| 15 |
* |
| 16 |
* @var FS_Plugin $plugin |
| 17 |
*/ |
| 18 |
$plugin = $VARS['plugin']; |
| 19 |
|
| 20 |
$plans = $VARS['plans']; |
| 21 |
|
| 22 |
$features_plan_map = array(); |
| 23 |
foreach ( $plans as $plan ) { |
| 24 |
if (!empty($plan->features) && is_array($plan->features)) { |
| 25 |
foreach ( $plan->features as $feature ) { |
| 26 |
if ( ! isset( $features_plan_map[ $feature->id ] ) ) { |
| 27 |
$features_plan_map[ $feature->id ] = array( 'feature' => $feature, 'plans' => array() ); |
| 28 |
} |
| 29 |
|
| 30 |
$features_plan_map[ $feature->id ]['plans'][ $plan->id ] = $feature; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
// Add support as a feature. |
| 35 |
if ( ! empty( $plan->support_email ) || |
| 36 |
! empty( $plan->support_skype ) || |
| 37 |
! empty( $plan->support_phone ) || |
| 38 |
true === $plan->is_success_manager |
| 39 |
) { |
| 40 |
if ( ! isset( $features_plan_map['support'] ) ) { |
| 41 |
$support_feature = new stdClass(); |
| 42 |
$support_feature->id = 'support'; |
| 43 |
$support_feature->title = fs_text_inline( 'Support', $plugin->slug ); |
| 44 |
$features_plan_map[ $support_feature->id ] = array( 'feature' => $support_feature, 'plans' => array() ); |
| 45 |
} else { |
| 46 |
$support_feature = $features_plan_map['support']['feature']; |
| 47 |
} |
| 48 |
|
| 49 |
$features_plan_map[ $support_feature->id ]['plans'][ $plan->id ] = $support_feature; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
// Add updates as a feature for all plans. |
| 54 |
$updates_feature = new stdClass(); |
| 55 |
$updates_feature->id = 'updates'; |
| 56 |
$updates_feature->title = fs_text_inline( 'Unlimited Updates', 'unlimited-updates', $plugin->slug ); |
| 57 |
$features_plan_map[ $updates_feature->id ] = array( 'feature' => $updates_feature, 'plans' => array() ); |
| 58 |
foreach ( $plans as $plan ) { |
| 59 |
$features_plan_map[ $updates_feature->id ]['plans'][ $plan->id ] = $updates_feature; |
| 60 |
} |
| 61 |
?> |
| 62 |
<div class="fs-features"> |
| 63 |
<table> |
| 64 |
<thead> |
| 65 |
<tr> |
| 66 |
<th></th> |
| 67 |
<?php foreach ( $plans as $plan ) : ?> |
| 68 |
<th> |
| 69 |
<?php echo $plan->title ?> |
| 70 |
<span class="fs-price"><?php |
| 71 |
if ( empty( $plan->pricing ) ) { |
| 72 |
fs_esc_html_echo_inline( 'Free', 'free', $plugin->slug ); |
| 73 |
} else { |
| 74 |
foreach ( $plan->pricing as $pricing ) { |
| 75 |
/** |
| 76 |
* @var FS_Pricing $pricing |
| 77 |
*/ |
| 78 |
if ( 1 == $pricing->licenses ) { |
| 79 |
if ( $pricing->has_annual() ) { |
| 80 |
echo "\${$pricing->annual_price} / " . fs_esc_html_x_inline( 'year', 'as annual period', 'year', $plugin->slug ); |
| 81 |
} else if ( $pricing->has_monthly() ) { |
| 82 |
echo "\${$pricing->monthly_price} / " . fs_esc_html_x_inline( 'mo', 'as monthly period', 'mo', $plugin->slug ); |
| 83 |
} else { |
| 84 |
echo "\${$pricing->lifetime_price}"; |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
?></span> |
| 90 |
</th> |
| 91 |
<?php endforeach ?> |
| 92 |
</tr> |
| 93 |
</thead> |
| 94 |
<tbody> |
| 95 |
<?php $odd = true; |
| 96 |
foreach ( $features_plan_map as $feature_id => $data ) : ?> |
| 97 |
<tr class="fs-<?php echo $odd ? 'odd' : 'even' ?>"> |
| 98 |
<td><?php echo esc_html( ucfirst( $data['feature']->title ) ) ?></td> |
| 99 |
<?php foreach ( $plans as $plan ) : ?> |
| 100 |
<td> |
| 101 |
<?php if ( isset( $data['plans'][ $plan->id ] ) ) : ?> |
| 102 |
<?php if ( ! empty( $data['plans'][ $plan->id ]->value ) ) : ?> |
| 103 |
<b><?php echo esc_html( $data['plans'][ $plan->id ]->value ) ?></b> |
| 104 |
<?php else : ?> |
| 105 |
<i class="dashicons dashicons-yes"></i> |
| 106 |
<?php endif ?> |
| 107 |
<?php endif ?> |
| 108 |
</td> |
| 109 |
<?php endforeach ?> |
| 110 |
</tr> |
| 111 |
<?php $odd = ! $odd; endforeach ?> |
| 112 |
</tbody> |
| 113 |
</table> |
| 114 |
</div> |