Skip to content

Commit

Permalink
fix #1411
Browse files Browse the repository at this point in the history
  • Loading branch information
inc2734 committed Jun 25, 2024
1 parent f8c0d95 commit 5207d7e
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 634 deletions.
16 changes: 9 additions & 7 deletions Framework/Controller/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 25.4.9
*/

namespace Framework\Controller;
Expand Down Expand Up @@ -128,12 +128,12 @@ function ( $option ) {
}

if ( isset( $option['license-key'] ) && static::get_option( 'license-key' ) !== $option['license-key'] ) {
delete_transient( 'snow-monkey-license-status' );
delete_transient( 'snow-monkey-license-status-' . static::get_option( 'license-key' ) );
}

// XSERVER register key is not validated if a license key is entered.
if ( isset( $option['xserver-register-key'] ) && static::get_option( 'xserver-register-key' ) !== $option['xserver-register-key'] ) {
delete_transient( 'snow-monkey-xserver-register-status' );
delete_transient( 'snow-monkey-xserver-register-status-' . static::get_option( 'xserver-register-key' ) );

if ( ! empty( $option['license-key'] ) ) {
$option['xserver-register-key'] = '';
Expand Down Expand Up @@ -244,13 +244,14 @@ class="widefat"
* @return boolean
*/
public static function get_license_status( $license_key ) {
$transient = get_transient( 'snow-monkey-license-status' );
$transient_name = 'snow-monkey-license-status-' . $license_key;
$transient = get_transient( $transient_name );
if ( false !== $transient ) {
return $transient;
}

$status = static::_request_license_validate( $license_key );
set_transient( 'snow-monkey-license-status', $status ? $status : 'false', DAY_IN_SECONDS );
set_transient( $transient_name, $status ? $status : 'false', DAY_IN_SECONDS );
return $status;
}

Expand Down Expand Up @@ -295,13 +296,14 @@ protected static function _request_license_validate( $license_key ) {
* @return boolean
*/
public static function get_xserver_register_status( $xserver_register_key ) {
$transient = get_transient( 'snow-monkey-xserver-register-status' );
$transient_name = 'snow-monkey-xserver-register-status-' . $xserver_register_key;
$transient = get_transient( $transient_name );
if ( false !== $transient ) {
return $transient;
}

$status = static::_request_license_validate_xserver( $xserver_register_key );
set_transient( 'snow-monkey-xserver-register-status', $status ? $status : 'false', DAY_IN_SECONDS );
set_transient( $transient_name, $status ? $status : 'false', DAY_IN_SECONDS );
return $status;
}

Expand Down
65 changes: 63 additions & 2 deletions app/constructor/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,68 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 20.1.0
* @version 25.4.9
*/

new \Framework\Controller\Manager();
use Framework\Controller\Manager;

if ( ! class_exists( '\Inc2734\WP_GitHub_Theme_Updater\Bootstrap' ) ) {
return;
}

new Manager();

/**
* Admin notice
*/
add_action(
'admin_notices',
function () {
$screen = get_current_screen();
if ( ! $screen || 'post' === $screen->id ) {
return;
}

$license_status = Manager::get_license_status( Manager::get_option( 'license-key' ) );
if ( 'true' === $license_status ) {
return;
}

$xserver_register_status = Manager::get_xserver_register_status( Manager::get_option( 'xserver-register-key' ) );
if ( 'true' === $xserver_register_status ) {
return;
}

if ( new DateTime( '2024-08-01' ) <= new DateTime( wp_date( 'Y-m-d', null, new DateTimeZone( 'Asia/Tokyo' ) ) ) ) {
$message = sprintf(
// translators: %1$s: a start tag, %2$s: a end tag, %3$s: a start tag, %4$s: a end tag.
__( 'You have not set a valid license key. Setting a license key will allow you to use patterns registered in %3$the pattern library%4$ and update the Snow Monkey theme. If you do not update your theme, you risk the site not displaying properly or leaving vulnerabilities open. A license key is issued when you subscribe to %1$sSnow Monkey subscription%2$s. The license key can be set %5$shere%6$s.', 'snow-monkey' ),
'<a href="https://snow-monkey.2inc.org/product/snow-monkey/" target="_blank" rel="noreferrer">',
'</a>',
'<a href="https://snow-monkey.2inc.org/snow-monkey-patterns/" target="_blank" rel="noreferrer">',
'</a>',
'<a href="' . admin_url( 'options-general.php?page=snow-monkey' ) . '">',
'</a>',
);
} else {
$message = sprintf(
// translators: %1$s: a start tag, %2$s: a end tag, %3$s: a start tag, %4$s: a end tag.
__( 'You have not set a valid license key. Setting a license key will allow you to use patterns registered in %3$the pattern library%4$. A license key is issued when you subscribe to %1$sSnow Monkey subscription%2$s. The license key is set %5$shere%6$s.', 'snow-monkey' ),
'<a href="https://snow-monkey.2inc.org/product/snow-monkey/" target="_blank" rel="noreferrer">',
'</a>',
'<a href="https://snow-monkey.2inc.org/snow-monkey-patterns/" target="_blank" rel="noreferrer">',
'</a>',
'<a href="' . admin_url( 'options-general.php?page=snow-monkey' ) . '">',
'</a>',
);
}

wp_admin_notice(
$message,
array(
'type' => 'error',
'dismissible' => false,
)
);
}
);
40 changes: 18 additions & 22 deletions app/constructor/trial.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 25.4.9
*/

use Framework\Helper;
Expand Down Expand Up @@ -62,26 +62,22 @@ function () {
return;
}

?>
<div class="notice notice-warning">
<p>
<?php
echo wp_kses_post(
sprintf(
// translators: %1$s: <a> for Snow Monkey website, %2$s: </a> for Snow Monkey website, %3$s: <a> for Snow Monkey product page, %4$s: </a> for Snow Monkey product page.
__(
'You are currently using the %1$sSnow Monkey%2$s theme (trial version). The trial version will not be updated (no features will be added, no bug fixes or security improvements will be made). With the full version, you will receive updates, using support forum, access to limited articles, and other services. You can sign up %3$shere%4$s.',
'snow-monkey'
),
'<a href="https://snow-monkey.2inc.org" target="_blank" rel="noreferrer">',
'</a>',
'<a href="https://snow-monkey.2inc.org/product/snow-monkey/" target="_blank" rel="noreferrer">',
'</a>'
)
);
?>
</p>
</div>
<?php
wp_admin_notice(
sprintf(
// translators: %1$s: <a> for Snow Monkey website, %2$s: </a> for Snow Monkey website, %3$s: <a> for Snow Monkey product page, %4$s: </a> for Snow Monkey product page.
__(
'You are currently using the %1$sSnow Monkey%2$s theme (trial version). The trial version will not be updated (no features will be added, no bug fixes or security improvements will be made). With the full version, you will receive updates, using support forum, access to limited articles, and other services. You can sign up %3$shere%4$s.',
'snow-monkey'
),
'<a href="https://snow-monkey.2inc.org" target="_blank" rel="noreferrer">',
'</a>',
'<a href="https://snow-monkey.2inc.org/product/snow-monkey/" target="_blank" rel="noreferrer">',
'</a>'
),
array(
'type' => 'warning',
'dismissible' => false,
)
);
}
);
2 changes: 1 addition & 1 deletion languages/ja.l10n.php

Large diffs are not rendered by default.

Binary file modified languages/ja.mo
Binary file not shown.
Loading

0 comments on commit 5207d7e

Please sign in to comment.