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