PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.4.7
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.4.7
2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 2.7.1 All 27 releases
insert-php / admin / pages / license.php

license.php in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 2.4.7, at admin/pages/license.php

357 lines 14.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * Class WINP_License_Page is used as template to display form to active premium functionality.
10 *
11 * @since 2.0.7
12 */
13 class WINP_License_Page extends WINP_Page {
14
15 /**
16 * {@inheritdoc}
17 */
18 public $type = "page";
19
20 /**
21 * {@inheritdoc}
22 */
23 public $page_menu_dashicon = 'dashicons-admin-network';
24
25 /**
26 * {@inheritdoc}
27 */
28 public $show_right_sidebar_in_options = false;
29
30 /**
31 * {@inheritdoc}
32 */
33 public $page_menu_position = 0;
34
35 /**
36 * {@inheritdoc}
37 */
38 public $available_for_multisite = true;
39
40 /**
41 * @var string Name of the paid plan.
42 */
43 public $plan_name;
44
45 // PREMIUM SECTION
46 // ------------------------------------------------------------------
47 /**
48 * @since 2.0.7
49 * @var bool
50 */
51 protected $is_premium;
52
53 /**
54 * @since 2.0.7
55 * @var \WBCR\Factory_458\Premium\Provider
56 */
57 protected $premium;
58
59 /**
60 * @since 2.0.7
61 * @var bool
62 */
63 protected $is_premium_active;
64
65 /**
66 * @since 2.0.7
67 * @var bool
68 */
69 protected $premium_has_subscription;
70
71 /**
72 * @since 2.0.7
73 * @var \WBCR\Factory_458\Premium\Interfaces\License
74 */
75 protected $premium_license;
76
77 // END PREMIUM SECTION
78 // ------------------------------------------------------------------
79
80 /**
81 * {@inheritdoc}
82 * @param Wbcr_Factory458_Plugin $plugin
83 */
84 public function __construct ( Wbcr_Factory458_Plugin $plugin ) {
85 $this->plugin = $plugin;
86
87 parent::__construct( $plugin );
88
89 $this->menu_post_type = WINP_SNIPPETS_POST_TYPE;
90 $this->id = 'license';
91 $this->menu_title = __( 'License', 'insert-php' );
92
93 $this->premium = WINP_Plugin::app()->premium;
94 $this->is_premium = $this->premium->is_activate();
95 $this->is_premium_active = $this->premium->is_active();
96 $this->premium_has_subscription = $this->premium->has_paid_subscription();
97 $this->premium_license = $this->premium->get_license();
98 }
99
100 /**
101 * [MAGIC] Magic method that configures assets for a page.
102 */
103 public function assets ( $scripts, $styles ) {
104 parent::assets( $scripts, $styles );
105
106 $this->styles->add( WINP_PLUGIN_URL . '/admin/assets/css/license-manager.css' );
107
108 $this->styles->request( array(
109 'bootstrap.core',
110 'bootstrap.form-groups',
111 'bootstrap.separator',
112 ), 'bootstrap' );
113
114 $this->scripts->add( WINP_PLUGIN_URL . '/admin/assets/js/license-manager.js' );
115 }
116
117 /**
118 * Get before content.
119 *
120 * @return string Before content.
121 */
122 protected function get_plan_description () {
123 return '';
124 }
125
126 /**
127 * @return string
128 */
129 protected function get_hidden_license_key () {
130 if ( ! $this->is_premium ) {
131 return '';
132 }
133
134 return $this->premium_license->get_hidden_key();
135 }
136
137 /**
138 * @return string
139 */
140 protected function get_plan () {
141 if ( ! $this->is_premium ) {
142 return 'free';
143 }
144
145 return $this->premium->get_plan();
146 }
147
148 /**
149 * @return mixed
150 */
151 protected function get_expiration_days () {
152 return $this->premium_license->get_expiration_time( 'days' );
153 }
154
155 /**
156 * @return string
157 */
158 protected function get_billing_cycle_readable () {
159 if ( ! $this->is_premium ) {
160 return '';
161 }
162
163 $billing_cycle = $this->premium->get_billing_cycle();
164 $billing = 'lifetime';
165
166 if ( 1 == $billing_cycle ) {
167 $billing = 'month';
168 } else if ( 12 == $billing_cycle ) {
169 $billing = 'year';
170 }
171
172 return $billing;
173 }
174
175 /**
176 * Тип лицензии, цветовое оформление для формы лицензирования
177 * free - бесплатная
178 * gift - пожизненная лицензия, лицензия на особы�
179 условия�
180
181 * trial - красный цвет, применяется для триалов, если лиценизия истекла или заблокирована
182 * paid - обычная оплаченная лицензия, в данный момент активна.
183 *
184 * @return string
185 */
186 protected function get_license_type () {
187 if ( ! $this->is_premium ) {
188 return 'free';
189 }
190
191 $license = $this->premium_license;
192
193 if ( $license->is_lifetime() ) {
194 return 'gift';
195 } else if ( $license->get_expiration_time( 'days' ) < 1 ) {
196 return 'trial';
197 }
198
199 return 'paid';
200 }
201
202 /**
203 *
204 */
205 public function indexAction () {
206 ?>
207 <div class="wrap">
208 <div class="<?php echo WINP_Helper::get_factory_class(); ?>">
209 <?php wp_nonce_field( 'license' ); ?>
210 <div id="winp-license-wrapper"
211 data-loader="<?php echo WINP_PLUGIN_URL . '/admin/assets/img/loader.gif'; ?>"
212 data-plugin="<?php echo get_class( $this->plugin ) ?>">
213
214 <div class="factory-bootstrap-459 onp-page-wrap <?php echo $this->get_license_type() ?>-license-manager-content"
215 id="license-manager">
216 <div>
217 <h3><?php printf( __( 'Activate %s', 'insert-php' ), $this->plan_name ) ?></h3>
218 <?php echo $this->get_plan_description() ?>
219 </div>
220 <br>
221
222 <div class="onp-container">
223 <div class="license-details">
224 <?php if ( $this->get_license_type() == 'free' ): ?>
225 <a href="<?php echo $this->plugin->get_support()->get_pricing_url( true, 'license_page' ); ?>"
226 class="purchase-premium" target="_blank" rel="noopener">
227 <span class="btn btn-gold btn-inner-wrap">
228 <?php printf( __( 'Upgrade to Premium for $%s', 'insert-php' ), $this->premium->get_price() ) ?>
229 </span>
230 </a>
231 <p><?php printf( __( 'Your current license for %1$s:', 'insert-php' ), $this->plugin->getPluginTitle() ) ?></p>
232 <?php endif; ?>
233 <div class="license-details-block <?php echo $this->get_license_type() ?>-details-block">
234 <?php if ( $this->is_premium ): ?>
235 <a data-action="deactivate" href="#"
236 class="btn btn-default btn-small license-delete-button winp-control-btn">
237 <?php _e( 'Delete Key', 'insert-php' ) ?>
238 </a>
239 <a data-action="sync" href="#"
240 class="btn btn-default btn-small license-synchronization-button winp-control-btn">
241 <?php _e( 'Synchronization', 'insert-php' ) ?>
242 </a>
243 <?php endif; ?>
244 <h3>
245 <?php echo ucfirst( $this->get_plan() ); ?>
246
247 <?php if ( $this->is_premium && $this->premium_has_subscription ): ?>
248 <span style="font-size: 15px;">
249 (<?php printf( __( 'Automatic renewal, every %s', '' ), esc_attr( $this->get_billing_cycle_readable() ) ); ?>
250 )
251 </span>
252 <?php endif; ?>
253 </h3>
254 <?php if ( $this->is_premium ): ?>
255 <div class="license-key-identity">
256 <code><?php echo esc_attr( $this->get_hidden_license_key() ) ?></code>
257 </div>
258 <?php endif; ?>
259 <div class="license-key-description">
260 <p><?php _e( 'Public License is a GPLv2 compatible license allowing you to change and use this version of the plugin for free. Please keep in mind this license covers only free edition of the plugin. Premium versions are distributed with other type of a license.', 'insert-php' ) ?>
261 </p>
262 <?php if ( $this->is_premium && $this->premium_has_subscription ): ?>
263 <p class="activate-trial-hint">
264 <?php _e( 'You use a paid subscription for the plugin updates. In case you don’t want to receive paid updates, please, click <a data-action="unsubscribe" class="winp-control-btn" href="#">cancel subscription</a>', 'insert-php' ) ?>
265 </p>
266 <?php endif; ?>
267
268 <?php if ( $this->get_license_type() == 'trial' ): ?>
269 <p class="activate-error-hint">
270 <?php printf( __( 'Your license has expired, please extend the license to get updates and support.', 'insert-php' ), '' ) ?>
271 </p>
272 <?php endif; ?>
273 </div>
274 <table class="license-params" colspacing="0" colpadding="0">
275 <tr>
276 <!--<td class="license-param license-param-domain">
277 <span class="license-value"><?php echo esc_attr( $_SERVER['SERVER_NAME'] ); ?></span>
278 <span class="license-value-name"><?php _e( 'domain', 'insert-php' ) ?></span>
279 </td>-->
280 <td class="license-param license-param-days">
281 <span class="license-value"><?php echo $this->get_plan() ?></span>
282 <span class="license-value-name"><?php _e( 'plan', 'insert-php' ) ?></span>
283 </td>
284 <?php if ( $this->is_premium ) : ?>
285 <td class="license-param license-param-sites">
286 <span class="license-value">
287 <?php echo esc_attr( $this->premium_license->get_count_active_sites() ); ?>
288 <?php _e( 'of', 'insert-php' ) ?>
289 <?php echo esc_attr( $this->premium_license->get_sites_quota() ); ?></span>
290 <span class="license-value-name"><?php _e( 'active sites', 'insert-php' ) ?></span>
291 </td>
292 <?php endif; ?>
293 <td class="license-param license-param-version">
294 <span class="license-value"><?php echo $this->plugin->getPluginVersion() ?></span>
295 <span class="license-value-name"><span><?php _e( 'version', 'insert-php' ) ?></span></span>
296 </td>
297 <?php if ( $this->is_premium ): ?>
298 <td class="license-param license-param-days">
299 <?php if ( $this->get_license_type() == 'trial' ): ?>
300 <span class="license-value"><?php _e( 'EXPIRED!', 'insert-php' ) ?></span>
301 <span class="license-value-name"><?php _e( 'please update the key', 'insert-php' ) ?></span>
302 <?php else: ?>
303 <span class="license-value">
304 <?php
305 if ( $this->premium_license->is_lifetime() ) {
306 echo 'infiniate';
307 } else {
308 echo $this->get_expiration_days();
309 }
310 ?>
311 <small> <?php _e( 'day(s)', 'insert-php' ) ?></small>
312 </span>
313 <span class="license-value-name"><?php _e( 'remained', 'insert-php' ) ?></span>
314 <?php endif; ?>
315 </td>
316 <?php endif; ?>
317 </tr>
318 </table>
319 </div>
320 </div>
321 <div class="license-input">
322 <form action="" method="post">
323 <?php if ( $this->is_premium ): ?>
324 <p><?php _e( 'Have a key to activate the premium version? Paste it here:', 'insert-php' ) ?><p>
325 <?php else: ?>
326 <p><?php _e( 'Have a key to activate the plugin? Paste it here:', 'insert-php' ) ?>
327 <p>
328 <?php endif; ?>
329 <button data-action="activate" class="btn btn-default winp-control-btn"
330 type="button"
331 id="license-submit">
332 <?php _e( 'Submit Key', 'insert-php' ) ?>
333 </button>
334 <div class="license-key-wrap">
335 <input type="text" id="license-key" name="licensekey" value=""
336 class="form-control"/>
337 </div>
338 <?php if ( $this->is_premium ): ?>
339 <p style="margin-top: 10px;">
340 <?php printf( __( '<a href="%s" target="_blank" rel="noopener">Lean more</a> about the premium version and get the license key to activate it now!', 'insert-php' ), $this->plugin->get_support()->get_pricing_url( true, 'license_page' ) ); ?>
341 </p>
342 <?php else: ?>
343 <p style="margin-top: 10px;">
344 <?php printf( __( 'Can’t find your key? Go to <a href="%s" target="_blank" rel="noopener">this page</a> and login using the e-mail address associated with your purchase.', 'insert-php' ), $this->plugin->get_support()->get_contacts_url( true, 'license_page' ) ) ?>
345 </p>
346 <?php endif; ?>
347 </form>
348 </div>
349 </div>
350 </div>
351 </div>
352 </div>
353 </div>
354 <?php
355 }
356 }
357