Commit 59a03869 authored by John James Jacoby's avatar John James Jacoby

Helper for checking if update is available.

License section description.
parent 51583b38
......@@ -44,6 +44,15 @@ final class Swifter_Theme_Updater_Admin extends Flox_Theme_Updater {
);
}
/**
* Add a brief description of the plugin in the license section
*
* @since SwifterNotificationsMenu (1.1.0)
*/
public function license_section() {
echo wpautop( esc_html__( 'The best theme around for BuddyPress & bbPress powered communities.', 'swifter' ) );
}
/**
* Outputs the markup used on the theme license page
*
......
......@@ -109,7 +109,7 @@ class Flox_Licensed_Product {
$this->author = $r['author'];
$this->download_id = $r['download_id'];
$this->renew_url = $r['renew_url'];
$this->admin_page = $r['admin_page'];
$this->admin_page = $r['admin_page'];
}
/**
......@@ -174,7 +174,7 @@ class Flox_Licensed_Product {
$field_id = $this->license_key();
$field_group = $this->admin_page;
$field_name = $this->name;
$field_label = __( 'License Key', 'flox' );
$field_label = esc_html__( 'License Key', 'flox' );
// Item section
add_settings_section(
......@@ -370,7 +370,7 @@ class Flox_Licensed_Product {
// Bail if response doesn't include license data
if ( empty( $license_data->license ) ) {
return __( 'The status of this license is unknown.', 'flox' );
return esc_html__( 'The status of this license is unknown.', 'flox' );
}
// Update the license status
......@@ -393,21 +393,21 @@ class Flox_Licensed_Product {
// Valid
case 'valid' :
$message[] = __( 'This license key is active on this site.', 'flox' );
$message[] = esc_html__( 'This license key is active on this site.', 'flox' );
if ( ! empty( $expires ) ) {
$message[] = sprintf( __( 'Expires %s.', 'flox' ), $expires );
$message[] = sprintf( esc_html__( 'Expires %s.', 'flox' ), $expires );
}
if ( isset( $license_data->site_count ) && isset( $license_data->license_limit ) ) {
if ( $license_data->site_count > $license_data->license_limit ) {
if ( 0 === $license_data->license_limit ) {
$message[] = sprintf( __( '%1$s of unlimited sites licensed.', 'flox' ), number_format_i18n( $license_data->site_count ) );
$message[] = sprintf( esc_html__( '%1$s of unlimited sites licensed.', 'flox' ), number_format_i18n( $license_data->site_count ) );
} else {
$message[] = sprintf( __( '%1$s of %2$s sites licensed.', 'flox' ), number_format_i18n( $license_data->site_count ), number_format_i18n( $license_data->license_limit ) );
$message[] = sprintf( esc_html__( '%1$s of %2$s sites licensed.', 'flox' ), number_format_i18n( $license_data->site_count ), number_format_i18n( $license_data->license_limit ) );
}
} else {
$message[] = __( 'You have reached your site limit.', 'flox' );
$message[] = esc_html__( 'You have reached your site limit.', 'flox' );
}
}
......@@ -416,9 +416,9 @@ class Flox_Licensed_Product {
// Expired
case 'expired' :
if ( ! empty( $expires ) ) {
$message[] = sprintf( __( 'This license key expired %s.', 'flox' ), $expires );
$message[] = sprintf( esc_html__( 'This license key expired %s.', 'flox' ), $expires );
} else {
$message[] = __( 'This license key has expired.', 'flox' );
$message[] = esc_html__( 'This license key has expired.', 'flox' );
}
if ( ! empty( $renew_link ) ) {
......@@ -429,27 +429,27 @@ class Flox_Licensed_Product {
// Invalid
case 'invalid' :
$message[] = __( 'This license key was not found.', 'flox' );
$message[] = esc_html__( 'This license key appears to be invalid.', 'flox' );
break;
// Valid but inactive
case 'inactive' :
$message[] = __( 'This license is inactive.', 'flox' );
$message[] = esc_html__( 'This license is inactive.', 'flox' );
break;
// Valid but disabled
case 'disabled' :
$message[] = __( 'This license key has been disabled.', 'flox' );
$message[] = esc_html__( 'This license key has been disabled.', 'flox' );
break;
// Site not licensed
case 'site_inactive' :
$message[] = __( 'This site is not currently licensed.', 'flox' );
$message[] = esc_html__( 'This site is not currently licensed.', 'flox' );
break;
// Unknown status
default :
$message[] = __( 'This license status is unknown.', 'flox' );
$message[] = esc_html__( 'This license status is unknown.', 'flox' );
break;
}
......@@ -521,7 +521,29 @@ class Flox_Licensed_Product {
$update_data = $this->check_for_update();
}
return (bool) version_compare( $this->version, $update_data->new_version, '<' );
$update_available = version_compare( $this->version, $update_data->new_version, '<' );
return (bool) $update_available;
}
/**
* Is the license for this product valid?
*
* @return bool
*/
protected function is_license_valid() {
// Not valid if no license
if ( ! $this->get_license() ) {
return false;
}
// Not valid if status is not 'valid'
if ( 'valid' !== $this->get_license_status() ) {
return false;
}
return true;
}
/**
......@@ -697,7 +719,7 @@ class Flox_Licensed_Product {
// Default message
if ( false === $license ) {
return __( 'Enter your license key.', 'flox' );
return esc_html__( 'Enter your license key.', 'flox' );
}
// Check for existing message
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment