Skip to content

Commit 6f99927

Browse files
committed
create instant-premium handlers
1 parent 88bda9e commit 6f99927

File tree

8 files changed

+47
-10
lines changed

8 files changed

+47
-10
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
/vendor/squizlabs/
66
/vendor/wp-coding-standards/
77
/vendor/bin/
8-
/vendor/phpcsstandards/
8+
/vendor/phpcsstandards/
9+
/premium-sample.php
10+
/premium.php
11+
/build-premium.sh

assets/settings/index.asset.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => 'e9520254aa18f86ede40');
1+
<?php return array('dependencies' => array(), 'version' => '5225b43bf9c22d7e6fae');

assets/settings/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/class-premium.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,14 @@ public static function update_license( $premium, $key = '', $error = '' ) {
200200
*/
201201
public static function launch_verification_event( $key = null ) {
202202
if ( ! is_null( $key ) ) {
203-
self::reschedule_verification();
203+
self::reschedule_verification(); // For backward compatibility before version 3.0.
204204
}
205205

206-
$license = get_option( self::OPTION_LICENSE, array() );
206+
$license = self::get_license();
207+
208+
if ( ! empty( $license['instant'] ) || ! empty( $license['develop'] ) ) {
209+
return;
210+
}
207211

208212
if ( empty( $license['key'] ) ) {
209213
return self::update_license( false, '' );
@@ -255,12 +259,12 @@ public static function is_premium_features() {
255259
}
256260

257261
/**
258-
* Reschedule license verification with current Premium key.
262+
* Reschedule license verification on load settings page.
259263
*/
260264
public static function check_verification_event() {
261265
$license = self::get_license();
262266

263-
if ( empty( $license['premium'] ) ) {
267+
if ( empty( $license['premium'] ) || ! empty( $license['instant'] ) ) {
264268
return;
265269
}
266270

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"license": "MIT",
66
"scripts": {
77
"build": "wp-scripts build",
8-
"start": "wp-scripts start"
8+
"start": "wp-scripts start",
9+
"premium": "cp premium-sample.php premium.php && git archive -o sharing-image.zip $(git rev-parse --abbrev-ref HEAD) && zip -j sharing-image.zip premium.php && rm premium.php"
910
},
1011
"prettier": {
1112
"printWidth": 120

premium-sample.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Optional file to set up settings for instant premium plugin build.
4+
*
5+
* @package sharing-image
6+
* @author Anton Lukin
7+
*/
8+
9+
if ( ! function_exists( 'sharing_image_instant_premium' ) ) :
10+
/**
11+
* Update license for instant premium plugin versions
12+
*/
13+
function sharing_image_instant_premium() {
14+
$license = array(
15+
'premium' => 1,
16+
'instant' => 1,
17+
);
18+
19+
return $license;
20+
}
21+
22+
add_filter( 'sharing_image_get_license', 'sharing_image_instant_premium', 20 );
23+
endif;

sharing-image.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/**
2525
* Plugin version.
2626
*/
27-
define( 'SHARING_IMAGE_VERSION', '3.3' );
27+
define( 'SHARING_IMAGE_VERSION', '3.3.1' );
2828

2929
/**
3030
* Main plugin file.
@@ -73,6 +73,10 @@ function sharing_image_plugin() {
7373
}
7474

7575
include SHARING_IMAGE_DIR . 'functions.php';
76+
77+
if ( file_exists( SHARING_IMAGE_DIR . 'premium.php' ) ) {
78+
include SHARING_IMAGE_DIR . 'premium.php';
79+
}
7680
}
7781
}
7882

src/settings/premium/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,9 @@ function showPremiumData( access, license ) {
332332
showLicenseInfo( access, license.key );
333333
}
334334

335-
showRevokeButton( access );
335+
if ( ! license.instant ) {
336+
return showRevokeButton( access );
337+
}
336338
}
337339

338340
/**

0 commit comments

Comments
 (0)