PluginProbe
Tiered Pricing Table for WooCommerce / 2.1.1
Tiered Pricing Table for WooCommerce v2.1.1
7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 All 90 releases
tier-pricing-table / freemius / templates / add-ons.php

add-ons.php in Tiered Pricing Table for WooCommerce 2.1.1, at freemius/templates/add-ons.php

197 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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.3
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 * @var Freemius
16 */
17 $fs = freemius( $VARS['id'] );
18
19 $slug = $fs->get_slug();
20
21 $open_addon_slug = fs_request_get( 'slug' );
22
23 $open_addon = false;
24
25 /**
26 * @var FS_Plugin[]
27 */
28 $addons = $fs->get_addons();
29
30 $has_addons = ( is_array( $addons ) && 0 < count( $addons ) );
31
32 $has_tabs = $fs->_add_tabs_before_content();
33 ?>
34 <div id="fs_addons" class="wrap fs-section">
35 <?php if ( ! $has_tabs ) : ?>
36 <h2><?php echo esc_html( sprintf( fs_text_inline( 'Add Ons for %s', 'add-ons-for-x', $slug ), $fs->get_plugin_name() ) ) ?></h2>
37 <?php endif ?>
38
39 <div id="poststuff">
40 <?php if ( ! $has_addons ) : ?>
41 <h3><?php echo esc_html( sprintf(
42 '%s... %s',
43 fs_text_x_inline( 'Oops', 'exclamation', 'oops', $slug ),
44 fs_text_inline( 'We could\'nt load the add-ons list. It\'s probably an issue on our side, please try to come back in few minutes.', 'add-ons-missing', $slug )
45 ) ) ?></h3>
46 <?php endif ?>
47 <ul class="fs-cards-list">
48 <?php if ( $has_addons ) : ?>
49 <?php foreach ( $addons as $addon ) : ?>
50 <?php
51 $open_addon = ( $open_addon || ( $open_addon_slug === $addon->slug ) );
52
53 $price = 0;
54 $has_trial = false;
55 $has_free_plan = false;
56 $has_paid_plan = false;
57
58 $result = $fs->get_api_plugin_scope()->get( $fs->add_show_pending( "/addons/{$addon->id}/pricing.json?type=visible" ) );
59 if ( ! isset( $result->error ) ) {
60 $plans = $result->plans;
61
62 if ( is_array( $plans ) && 0 < count( $plans ) ) {
63 foreach ( $plans as $plan ) {
64 if ( ! isset( $plan->pricing ) ||
65 ! is_array( $plan->pricing ) ||
66 0 == count( $plan->pricing )
67 ) {
68 // No pricing means a free plan.
69 $has_free_plan = true;
70 continue;
71 }
72
73
74 $has_paid_plan = true;
75 $has_trial = $has_trial || ( is_numeric( $plan->trial_period ) && ( $plan->trial_period > 0 ) );
76
77 $min_price = 999999;
78 foreach ( $plan->pricing as $pricing ) {
79 if ( ! is_null( $pricing->annual_price ) && $pricing->annual_price > 0 ) {
80 $min_price = min( $min_price, $pricing->annual_price );
81 } else if ( ! is_null( $pricing->monthly_price ) && $pricing->monthly_price > 0 ) {
82 $min_price = min( $min_price, 12 * $pricing->monthly_price );
83 }
84 }
85
86 if ( $min_price < 999999 ) {
87 $price = $min_price;
88 }
89
90 }
91 }
92
93 if ( ! $has_paid_plan && ! $has_free_plan ) {
94 continue;
95 }
96 }
97 ?>
98 <li class="fs-card fs-addon" data-slug="<?php echo $addon->slug ?>">
99 <?php
100 echo sprintf( '<a href="%s" class="thickbox fs-overlay" aria-label="%s" data-title="%s"></a>',
101 esc_url( network_admin_url( 'plugin-install.php?fs_allow_updater_and_dialog=true&tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
102 '&TB_iframe=true&width=600&height=550' ) ),
103 esc_attr( sprintf( fs_text_inline( 'More information about %s', 'more-information-about-x', $slug ), $addon->title ) ),
104 esc_attr( $addon->title )
105 );
106 ?>
107 <?php
108 if ( is_null( $addon->info ) ) {
109 $addon->info = new stdClass();
110 }
111 if ( ! isset( $addon->info->card_banner_url ) ) {
112 $addon->info->card_banner_url = '//dashboard.freemius.com/assets/img/marketing/blueprint-300x100.jpg';
113 }
114 if ( ! isset( $addon->info->short_description ) ) {
115 $addon->info->short_description = 'What\'s the one thing your add-on does really, really well?';
116 }
117 ?>
118 <div class="fs-inner">
119 <ul>
120 <li class="fs-card-banner"
121 style="background-image: url('<?php echo $addon->info->card_banner_url ?>');"></li>
122 <!-- <li class="fs-tag"></li> -->
123 <li class="fs-title"><?php echo $addon->title ?></li>
124 <li class="fs-offer">
125 <span
126 class="fs-price"><?php
127 $descriptors = array();
128
129 if ($has_free_plan)
130 $descriptors[] = fs_text_inline( 'Free', 'free', $slug );
131 if ($has_paid_plan && $price > 0)
132 $descriptors[] = '$' . number_format( $price, 2 );
133 if ($has_trial)
134 $descriptors[] = fs_text_x_inline( 'Trial', 'trial period', 'trial', $slug );
135
136 echo implode(' - ', $descriptors) ?></span>
137 </li>
138 <li class="fs-description"><?php echo ! empty( $addon->info->short_description ) ? $addon->info->short_description : 'SHORT DESCRIPTION' ?></li>
139 <li class="fs-cta"><a class="button"><?php fs_esc_html_echo_inline( 'View details', 'view-details', $slug ) ?></a></li>
140 </ul>
141 </div>
142 </li>
143 <?php endforeach ?>
144 <?php endif ?>
145 </ul>
146 </div>
147 </div>
148 <script type="text/javascript">
149 (function ($) {
150 <?php if ( $open_addon ) : ?>
151
152 var interval = setInterval(function () {
153 // Open add-on information page.
154 <?php
155 /**
156 * @author Vova Feldman
157 *
158 * This code does NOT expose an XSS vulnerability because:
159 * 1. This page only renders for admins, so if an attacker manage to get
160 * admin access, they can do more harm.
161 * 2. This code won't be rendered unless $open_addon_slug matches any of
162 * the plugin's add-ons slugs.
163 */
164 ?>
165 $('.fs-card[data-slug=<?php echo $open_addon_slug ?>] a').click();
166 if ($('#TB_iframeContent').length > 0) {
167 clearInterval(interval);
168 interval = null;
169 }
170 }, 200);
171
172 <?php else : ?>
173
174
175 $('.fs-card.fs-addon')
176 .mouseover(function () {
177 $(this).find('.fs-cta .button').addClass('button-primary');
178 }).mouseout(function () {
179 $(this).find('.fs-cta .button').removeClass('button-primary');
180 });
181
182 <?php endif ?>
183 })(jQuery);
184 </script>
185 <?php
186 if ( $has_tabs ) {
187 $fs->_add_tabs_after_content();
188 }
189
190 $params = array(
191 'page' => 'addons',
192 'module_id' => $fs->get_id(),
193 'module_type' => $fs->get_module_type(),
194 'module_slug' => $slug,
195 'module_version' => $fs->get_plugin_version(),
196 );
197 fs_require_template( 'powered-by.php', $params );