PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.2.3
StreamCast – bring live radio to your site with a sleek player v2.2.3
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / freemius / templates / forms / premium-versions-upgrade-handler.php

premium-versions-upgrade-handler.php in StreamCast – bring live radio to your site with a sleek player 2.2.3, at freemius/templates/forms/premium-versions-upgrade-handler.php

205 lines 8.1 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 2.0.2
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var Freemius $fs
15 */
16 $fs = freemius( $VARS['id'] );
17 $slug = $fs->get_slug();
18
19 $plugin_data = $fs->get_plugin_data();
20 $plugin_name = $plugin_data['Name'];
21 $plugin_basename = $fs->get_plugin_basename();
22
23 $license = $fs->_get_license();
24
25 if ( ! is_object( $license ) ) {
26 $purchase_url = $fs->pricing_url();
27 } else {
28 $subscription = $fs->_get_subscription( $license->id );
29
30 $purchase_url = $fs->checkout_url(
31 is_object( $subscription ) ?
32 ( 1 == $subscription->billing_cycle ? WP_FS__PERIOD_MONTHLY : WP_FS__PERIOD_ANNUALLY ) :
33 WP_FS__PERIOD_LIFETIME,
34 false,
35 array( 'licenses' => $license->quota )
36 );
37 }
38
39 $message = sprintf(
40 fs_text_inline( 'There is a new version of %s available.', 'new-version-available-message', $slug ) .
41 fs_text_inline( ' %s to access version %s security & feature updates, and support.', 'x-for-updates-and-support', $slug ),
42 '<span id="plugin_name"></span>',
43 sprintf(
44 '<a id="pricing_url" href="">%s</a>',
45 is_object( $license ) ?
46 fs_text_inline( 'Renew your license now', 'renew-license-now', $slug ) :
47 fs_text_inline( 'Buy a license now', 'buy-license-now', $slug )
48 ),
49 '<span id="new_version"></span>'
50 );
51
52 $modal_content_html = "<p>{$message}</p>";
53
54 $header_title = fs_text_inline( 'New Version Available', 'new-version-available', $slug );
55
56 $renew_license_button_text = is_object( $license ) ?
57 fs_text_inline( 'Renew license', 'renew-license', $slug ) :
58 fs_text_inline( 'Buy license', 'buy-license', $slug );
59
60 fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
61 ?>
62 <script type="text/javascript">
63 (function( $ ) {
64 $( document ).ready(function() {
65 if ( 0 === $( '.license-expired' ).length ) {
66 return;
67 }
68
69 var modalContentHtml = <?php echo json_encode( $modal_content_html ) ?>,
70 modalHtml =
71 '<div class="fs-modal fs-modal-upgrade-premium-version">'
72 + ' <div class="fs-modal-dialog">'
73 + ' <div class="fs-modal-header">'
74 + ' <h4><?php echo esc_js( $header_title ) ?></h4>'
75 + ' <a href="!#" class="fs-close"><i class="dashicons dashicons-no" title="<?php echo esc_js( fs_text_x_inline( 'Dismiss', 'close a window', 'dismiss', $slug ) ) ?>"></i></a>'
76 + ' </div>'
77 + ' <div class="fs-modal-body">'
78 + ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
79 + ' </div>'
80 + ' <div class="fs-modal-footer">'
81 + ' <a class="button button-primary button-renew-license" tabindex="3" href="<?php echo $purchase_url ?>"><?php echo esc_js( $renew_license_button_text ) ?></a>'
82 + ' <button class="button button-secondary button-close" tabindex="4"><?php fs_esc_js_echo_inline( 'Cancel', 'cancel', $slug ) ?></button>'
83 + ' </div>'
84 + ' </div>'
85 + '</div>',
86 $modal = $( modalHtml ),
87 isPluginsPage = <?php echo Freemius::is_plugins_page() ? 'true' : 'false' ?>;
88
89 $modal.appendTo( $( 'body' ) );
90
91 function registerEventHandlers() {
92 $( 'body' ).on( 'click', '.license-expired', function( evt ) {
93 var $this = $( this );
94
95 if ( ! $this.is( ':checked' ) ||
96 (
97 isPluginsPage &&
98 'update-selected' !== $( '#bulk-action-selector-top' ).val() &&
99 'update-selected' !== $( '#bulk-action-selector-bottom' ).val()
100 )
101 ) {
102 return true;
103 }
104
105 evt.preventDefault();
106 evt.stopImmediatePropagation();
107
108 showModal( $this );
109 });
110
111 // If the user has clicked outside the window, close the modal.
112 $modal.on( 'click', '.fs-close, .button-secondary', function() {
113 closeModal();
114 return false;
115 });
116
117 if ( isPluginsPage ) {
118 $( 'body' ).on( 'change', 'select[id*="bulk-action-selector"]', function() {
119 if ( 'update-selected' === $( this ).val() ) {
120 setTimeout(function() {
121 $( '.license-expired' ).prop( 'checked', false );
122 $( '[id*="select-all"]' ).prop( 'checked', false );
123 }, 0);
124 }
125 });
126 }
127
128 $( 'body' ).on( 'click', '[id*="select-all"]', function( evt ) {
129 var $this = $( this );
130
131 if ( ! $this.is( ':checked' ) ) {
132 return true;
133 }
134
135 if ( isPluginsPage ) {
136 if ( 'update-selected' !== $( '#bulk-action-selector-top' ).val() &&
137 'update-selected' !== $( '#bulk-action-selector-bottom' ).val() ) {
138 return true;
139 }
140 }
141
142 var $table = $this.closest( 'table' ),
143 controlChecked = $this.prop( 'checked' ),
144 toggle = ( event.shiftKey || $this.data( 'wp-toggle' ) ),
145 $modules = $table.children( 'tbody' ).filter( ':visible' ).children().children( '.check-column' ).find( ':checkbox' ),
146 $modulesWithNonActiveLicense = $modules.filter( '.license-expired' );
147
148 if ( 0 === $modulesWithNonActiveLicense.length ) {
149 /**
150 * It's possible that the context HTML table element doesn't have checkboxes with
151 * ".license-expired" class if for example only the themes table has such checkboxes and the user
152 * clicks on a "Select All" checkbox on the plugins table which has no such checkboxes.
153 *
154 * @author Leo Fajardo (@leorw)
155 */
156 return true;
157 } else if ( 1 === $modulesWithNonActiveLicense.length ) {
158 showModal( $modulesWithNonActiveLicense );
159 }
160
161 /**
162 * Prevent the default WordPress handler from checking all checkboxes.
163 *
164 * @author Leo Fajardo (@leorw)
165 */
166 evt.stopImmediatePropagation();
167
168 $modules.filter( ':not(.license-expired)' )
169 .prop( 'checked', function() {
170 if ( $( this ).is( ':hidden,:disabled' ) ) {
171 return false;
172 }
173
174 if ( toggle ) {
175 return ! $( this ).prop( 'checked' );
176 } else if ( controlChecked ) {
177 return true;
178 }
179
180 return false;
181 });
182
183 return false;
184 });
185 }
186
187 registerEventHandlers();
188
189 function showModal( $module ) {
190 $modal.find( '#plugin_name' ).text( $module.data( 'plugin-name' ) );
191 $modal.find( '#pricing_url' ).attr( 'href', $module.data( 'pricing-url' ) );
192 $modal.find( '#new_version' ).text( $module.data( 'new-version' ) );
193
194 // Display the dialog box.
195 $modal.addClass( 'active' );
196 $( 'body' ).addClass( 'has-fs-modal' );
197 }
198
199 function closeModal() {
200 $modal.removeClass( 'active' );
201 $( 'body' ).removeClass( 'has-fs-modal' );
202 }
203 });
204 })( jQuery );
205 </script>