From 476d04b86c7188f57c5cc9361fbd709f36abf3cd Mon Sep 17 00:00:00 2001 From: Sybre Waaijer Date: Tue, 30 Oct 2018 07:55:38 +0100 Subject: [PATCH] API v2 migration --- .../focus/trunk/inc/classes/ajax.class.php | 8 +++ .../monitor/trunk/inc/classes/api.class.php | 7 +- .../abstract/secure.abstract.class.php | 4 +- inc/classes/accountactivation.class.php | 26 +++++-- inc/classes/api.class.php | 3 +- inc/classes/core.class.php | 21 ++++-- inc/classes/layout.class.php | 68 +++++++++++++++---- inc/classes/loadadmin.class.php | 14 ++-- inc/classes/panes.class.php | 29 +++++--- inc/traits/core/error.trait.php | 9 +++ .../manager/extensions-layout.trait.php | 1 - inc/traits/manager/options.trait.php | 2 +- lib/js/tsfem-form.js | 38 +++++------ lib/js/tsfem-inpost.js | 64 ++--------------- readme.txt | 7 +- the-seo-framework-extension-manager.php | 2 +- views/layout/general/footer.php | 40 +++++------ views/layout/general/top.php | 4 +- 18 files changed, 201 insertions(+), 146 deletions(-) diff --git a/extensions/essentials/focus/trunk/inc/classes/ajax.class.php b/extensions/essentials/focus/trunk/inc/classes/ajax.class.php index 827fb076..539ed8cb 100644 --- a/extensions/essentials/focus/trunk/inc/classes/ajax.class.php +++ b/extensions/essentials/focus/trunk/inc/classes/ajax.class.php @@ -156,6 +156,10 @@ public function _get_lexicalforms() { $send['results'] = $this->get_ajax_notice( false, 1100102 ); break; + case 'REQUEST_LIMIT_REACHED': + $send['results'] = $this->get_ajax_notice( false, 1100108 ); + break; + default: case 'LICENSE_TOO_LOW': case 'REMOTE_API_BODY_ERROR': @@ -225,6 +229,10 @@ public function _get_synonyms() { $send['results'] = $this->get_ajax_notice( false, 1100202 ); break; + case 'REQUEST_LIMIT_REACHED': + $send['results'] = $this->get_ajax_notice( false, 1100208 ); + break; + default: case 'LICENSE_TOO_LOW': case 'REMOTE_API_BODY_ERROR': diff --git a/extensions/premium/monitor/trunk/inc/classes/api.class.php b/extensions/premium/monitor/trunk/inc/classes/api.class.php index c551d6ad..2167fcf3 100644 --- a/extensions/premium/monitor/trunk/inc/classes/api.class.php +++ b/extensions/premium/monitor/trunk/inc/classes/api.class.php @@ -258,7 +258,12 @@ protected function api_request_crawl( $ajax = false ) { $response = $response['data']; - if ( 'failure' === $response['status'] ) { + if ( 'REQUEST_LIMIT_REACHED' === $response['status'] ) { + $this->set_remote_crawl_timeout(); + $ajax or $this->set_error_notice( [ 1010509 => '' ] ); + return $ajax ? $this->get_ajax_notice( false, 1010508 ) : false; + } + if ( in_array( $response['status'], [ 'failure', 'LICENSE_TOO_LOW' ], true ) ) { $ajax or $this->set_error_notice( [ 1010501 => '' ] ); return $ajax ? $this->get_ajax_notice( false, 1010501 ) : false; } diff --git a/inc/classes/abstract/secure.abstract.class.php b/inc/classes/abstract/secure.abstract.class.php index 3ec01133..4af8a4a2 100644 --- a/inc/classes/abstract/secure.abstract.class.php +++ b/inc/classes/abstract/secure.abstract.class.php @@ -220,7 +220,7 @@ final protected static function is_premium_user() { $level = isset( self::$account['level'] ) ? self::$account['level'] : ''; - return $is_premium = 'Premium' === $level; + return $is_premium = in_array( $level, [ 'Enterprise', 'Premium' ], true ); } /** @@ -240,7 +240,7 @@ final protected static function is_connected_user() { $level = isset( self::$account['level'] ) ? self::$account['level'] : ''; - return $is_connected = in_array( $level, [ 'Premium', 'Essentials' ], true ); + return $is_connected = in_array( $level, [ 'Enterprise', 'Premium', 'Essentials' ], true ); } /** diff --git a/inc/classes/accountactivation.class.php b/inc/classes/accountactivation.class.php index 3f8997c9..ba4ed381 100644 --- a/inc/classes/accountactivation.class.php +++ b/inc/classes/accountactivation.class.php @@ -346,11 +346,18 @@ protected function revalidate_subscription() { break; case 5: - //= Everything's premium. + //= Everything's Premium. ( $this->get_option( '_activation_level' ) !== 'Premium' ) and $this->update_option( '_activation_level', 'Premium' ) and $this->set_error_notice( [ 905 => '' ] ); break; + + case 6: + //= Everything's Enterprise. + ( $this->get_option( '_activation_level' ) !== 'Enterprise' ) + and $this->update_option( '_activation_level', 'Enterprise' ) + and $this->set_error_notice( [ 905 => '' ] ); + break; endswitch; return $status; @@ -361,6 +368,7 @@ protected function revalidate_subscription() { * * @since 1.0.0 * @since 1.3.0 Now returns an integer. + * @since 2.0.0 Our API no longer uses 'extra'. * * @return int : { * 0 : Not subscribed / API failure. @@ -369,6 +377,7 @@ protected function revalidate_subscription() { * 3 : Local connected user. Remote connected User. Instance verified. * 4 : Local connected user. Remote connected User. Instance verified. Domain verified. * 5 : Local connected user. Remote connected User. Instance verified. Domain verified. Premium verified. + * 6 : Local connected user. Remote connected User. Instance verified. Domain verified. Enterprise verified. * } */ protected function validate_remote_subscription_license() { @@ -376,19 +385,24 @@ protected function validate_remote_subscription_license() { $response = $this->get_remote_subscription_status(); $status = 0; - $extra = $this->coalesce_var( $response['status_extra'], [] ); while ( true ) { if ( ! isset( $response['status_check'] ) ) break; ++$status; if ( 'active' !== $response['status_check'] ) break; ++$status; - if ( $this->get_activation_instance() !== $this->coalesce_var( $extra['instance'], -1 ) ) break; - ++$status; - if ( $this->get_activation_site_domain() !== $this->coalesce_var( $extra['activation_domain'], -1 ) ) break; + if ( $this->get_activation_instance() !== $this->coalesce_var( $response['_instance'], -1 ) ) break; ++$status; - if ( 'Premium' !== $this->coalesce_var( $response['_activation_level'], 'Essentials' ) ) break; + if ( $this->get_activation_site_domain() !== $this->coalesce_var( $response['activation_domain'], -1 ) ) break; ++$status; + + $this->coalesce_var( $response['_activation_level'], '' ); + + if ( 'Premium' === $response['_activation_level'] ) { + $status += 1; + } elseif ( 'Enterprise' === $response['_activation_level'] ) { + $status += 2; + } break; } diff --git a/inc/classes/api.class.php b/inc/classes/api.class.php index b0d53fa7..9f52ff93 100644 --- a/inc/classes/api.class.php +++ b/inc/classes/api.class.php @@ -128,6 +128,7 @@ final protected function handle_request( $type = 'status', $args = [] ) { * but their activation still uses the original scheme. * * @since 1.0.0 + * @since 2.0.0 Now uses the site URL instead of the home URL. * * @return string Domain Host. */ @@ -231,7 +232,7 @@ final protected function get_api_response( array $args, $internal = true ) { 'licence_key' => '', 'instance' => $this->get_activation_instance( false ), 'platform' => $this->get_activation_site_domain(), - 'tsfemv2' => 'yes', // var_dump() TEMP? + 'version' => '2.0', ]; $args = \wp_parse_args( $args, $defaults ); diff --git a/inc/classes/core.class.php b/inc/classes/core.class.php index 11d78fd6..31351635 100644 --- a/inc/classes/core.class.php +++ b/inc/classes/core.class.php @@ -1333,18 +1333,18 @@ final protected function is_plugin_activated() { } /** - * Determines whether the plugin's use is premium. + * Determines whether the plugin's use is connected. * * @since 2.0.0 * - * @return bool True if the plugin is connected to the Premium or Essential API handler. + * @return bool True if the plugin is connected to the Enterprise, Premium, or Essential API handler. */ final public function is_connected_user() { - return in_array( $this->get_option( '_activation_level' ), [ 'Premium', 'Essentials' ], true ); + return in_array( $this->get_option( '_activation_level' ), [ 'Enterprise', 'Premium', 'Essentials' ], true ); } /** - * Determines whether the plugin's use is premium. + * Determines whether the plugin's use is Premium. * * @since 1.0.0 * @since 1.5.0 Now public. Enjoy. @@ -1352,7 +1352,18 @@ final public function is_connected_user() { * @return bool True if the plugin is connected to the Premium API handler. */ final public function is_premium_user() { - return 'Premium' === $this->get_option( '_activation_level' ); + return in_array( $this->get_option( '_activation_level' ), [ 'Enterprise', 'Premium' ], true ); + } + + /** + * Determines whether the plugin's use is Enterprise. + * + * @since 2.0.0 + * + * @return bool True if the plugin is connected to the Premium API handler and is of level Enterprise. + */ + final public function is_enterprise_user() { + return 'Enterprise' === $this->get_option( '_activation_level' ); } /** diff --git a/inc/classes/layout.class.php b/inc/classes/layout.class.php index 792bd2f1..cbdcd087 100644 --- a/inc/classes/layout.class.php +++ b/inc/classes/layout.class.php @@ -96,8 +96,8 @@ public static function get( $type = '' ) { return static::get_public_support_button(); break; - case 'premium-support-button': - return static::get_premium_support_button(); + case 'private-support-button': + return static::get_private_support_button(); break; case 'account-information': @@ -170,7 +170,7 @@ private static function get_disconnect_button() { * * @since 2.0.0 * - * @return string The free support button link. + * @return string The public support button link. */ private static function get_public_support_button() { @@ -183,18 +183,18 @@ private static function get_public_support_button() { } /** - * Outputs premium support button. + * Outputs private support button. * - * @since 1.0.0 + * @since 2.0.0 * - * @return string The premium support button link. + * @return string The private support button link. */ - private static function get_premium_support_button() { + private static function get_private_support_button() { if ( 'link' === self::get_property( '_type' ) ) { - return \tsf_extension_manager()->get_support_link( 'premium' ); + return \tsf_extension_manager()->get_support_link( 'private' ); } else { - \the_seo_framework()->_doing_it_wrong( __METHOD__, 'The premium support button only supports the link type.' ); + \the_seo_framework()->_doing_it_wrong( __METHOD__, 'The private support button only supports the link type.' ); return ''; } } @@ -223,15 +223,17 @@ private static function get_account_info() { $domain = str_ireplace( [ 'http://', 'https://' ], '', \esc_url( \get_home_url(), [ 'http', 'https' ] ) ); $end_date = ''; $payment_date = ''; + $requests_remaining = ''; if ( $data ) { if ( isset( $data['status']['status_check'] ) && 'inactive' === $data['status']['status_check'] ) { $level = \__( 'Decoupled', 'the-seo-framework-extension-manager' ); } else { //* UTC. - $end_date = isset( $data['status']['status_extra']['end_date'] ) ? $data['status']['status_extra']['end_date'] : ''; - $payment_date = isset( $data['status']['status_extra']['payment_date'] ) ? $data['status']['status_extra']['payment_date'] : ''; - $domain = isset( $data['status']['status_extra']['activation_domain'] ) ? $data['status']['status_extra']['activation_domain'] : ''; + $end_date = isset( $data['status']['end_date'] ) ? $data['status']['end_date'] : ''; + $payment_date = isset( $data['status']['payment_date'] ) ? $data['status']['payment_date'] : ''; + $domain = isset( $data['status']['activation_domain'] ) ? $data['status']['activation_domain'] : ''; + $requests_remaining = isset( $data['status']['requests_remaining'] ) ? $data['status']['requests_remaining'] : ''; } } @@ -243,6 +245,11 @@ private static function get_account_info() { $_class = [ 'tsfem-dashicon' ]; switch ( $level ) : + case 'Enterprise': + $_level = \__( 'Enterprise', 'the-seo-framework-extension-manager' ); + $_class[] = $valid_options ? 'tsfem-success' : 'tsfem-error'; + break; + case 'Premium': $_level = \__( 'Premium', 'the-seo-framework-extension-manager' ); $_class[] = $valid_options ? 'tsfem-success' : 'tsfem-error'; @@ -283,14 +290,39 @@ private static function get_account_info() { } } - $level = HTML::wrap_inline_tooltip( HTML::make_inline_tooltip( + $_level = HTML::wrap_inline_tooltip( HTML::make_inline_tooltip( $level, tsf_extension_manager()->coalesce_var( $level_desc, '' ), '', $_class ) ); - $output .= static::wrap_row_content( \esc_html__( 'Account level:', 'the-seo-framework-extension-manager' ), $level, false ); + $output .= static::wrap_row_content( \esc_html__( 'Account level:', 'the-seo-framework-extension-manager' ), $_level, false ); + + if ( is_int( $requests_remaining ) ) { + $_notice = ''; + $_classes = [ 'tsfem-dashicon' ]; + + if ( $requests_remaining > 100 ) { + $_notice = \esc_html__( 'Number of API requests left this month.', 'the-seo-framework-extension-manager' ); + $_classes[] = 'tsfem-success'; + } elseif ( $requests_remaining > 0 ) { + $_notice = \esc_html__( 'Only a few requests left for this month. Consider upgrading your account.', 'the-seo-framework-extension-manager' ); + $_classes[] = 'tsfem-warning'; + } else { + $_notice = \esc_html__( 'No requests left for this month. Consider upgrading your account.', 'the-seo-framework-extension-manager' ); + $_classes[] = 'tsfem-error'; + } + + //= Not necessarily this domain. + $_requests_remaining = HTML::wrap_inline_tooltip( HTML::make_inline_tooltip( + (int) $requests_remaining, + $_notice, + '', + $_classes + ) ); + $output .= static::wrap_row_content( \esc_html__( 'Requests remaining:', 'the-seo-framework-extension-manager' ), $_requests_remaining, false ); + } if ( $valid_options && $domain ) { //* Check for domain mismatch. If they don't match no premium extensions can be activated. @@ -330,6 +362,7 @@ private static function get_account_info() { $_class = 'tsfem-success'; $expires_in = ''; + // Move to time.trait? if ( $difference < 0 ) { //* Expired. $expires_in = \__( 'Account expired', 'the-seo-framework-extension-manager' ); @@ -374,7 +407,10 @@ private static function get_account_info() { $_class = 'tsfem-success'; $payment_in = ''; - if ( $difference < 0 ) { + if ( $difference < -5184000 ) { + // Probably a permanent subscription. Let's not bother my friends. + goto end; + } elseif ( $difference < 0 ) { //* Processing. $payment_in = \__( 'Payment processing', 'the-seo-framework-extension-manager' ); $_class = 'tsfem-warning'; @@ -402,6 +438,8 @@ private static function get_account_info() { $output .= static::wrap_row_content( \esc_html__( 'Payment due in:', 'the-seo-framework-extension-manager' ), $payment_in, false ); endif; + end:; + //= Wrap tooltips here. return sprintf( '
%s
', $output ); } diff --git a/inc/classes/loadadmin.class.php b/inc/classes/loadadmin.class.php index d94f200b..99082bfb 100644 --- a/inc/classes/loadadmin.class.php +++ b/inc/classes/loadadmin.class.php @@ -384,6 +384,11 @@ final public function _wp_ajax_tsfemForm_get_geocode() { $send['results'] = $this->get_ajax_notice( false, 17010 ); break; + case 'REQUEST_LIMIT_REACHED': + //= License request limit reached. + $send['results'] = $this->get_ajax_notice( false, 17013 ); + break; + case 'LICENSE_TOO_LOW': default: //= Undefined error. @@ -778,17 +783,18 @@ final protected function get_my_account_link() { } /** - * Generates support link for both Free and Premium. + * Generates support link for both Public and Private. * * @since 1.0.0 + * @since 2.0.0 Now goes by Private/Public * - * @param string $type The support link type. Accepts 'premium' or anything else for free. + * @param string $type The support link type. Accepts 'privte' or anything else for public. * @param bool $icon Whether to show a heart/star after the button text. * @return string The Support Link. */ - final public function get_support_link( $type = 'free', $icon = true ) { + final public function get_support_link( $type = 'public', $icon = true ) { - if ( 'premium' === $type ) { + if ( 'private' === $type ) { $url = 'https://premium.theseoframework.com/support/'; $title = \__( 'Get support via mail', 'the-seo-framework-extension-manager' ); diff --git a/inc/classes/panes.class.php b/inc/classes/panes.class.php index 83ce1605..9004185a 100644 --- a/inc/classes/panes.class.php +++ b/inc/classes/panes.class.php @@ -433,7 +433,14 @@ protected function get_actions_left_output() { $output = ''; $output .= $this->get_account_information(); - $output .= $this->get_support_buttons(); + if ( ! $this->is_auto_activated() ) { + if ( ! $this->is_connected_user() && $this->are_options_valid() ) { + $output .= $this->get_account_upgrade_form(); + } else { + //* TODO make this happen (on request/modal?). + // $output .= $this->get_account_extend_form(); + } + } return sprintf( '
%s
', $output ); } @@ -448,14 +455,8 @@ protected function get_actions_left_output() { protected function get_actions_right_output() { $output = ''; + $output .= $this->get_support_buttons(); if ( ! $this->is_auto_activated() ) { - if ( ! $this->is_connected_user() || ! $this->are_options_valid() ) { - $output .= $this->get_account_upgrade_form(); - } else { - //* TODO make this happen (on request/modal?). - // $output .= $this->get_account_extend_form(); - } - $output .= $this->get_disconnect_button(); } @@ -485,7 +486,15 @@ protected function get_account_information() { Layout::reset(); - $title = sprintf( '

%s

', \esc_html__( 'Account information', 'the-seo-framework-extension-manager' ) ); + $infos = []; + if ( $this->is_connected_user() ) + $infos[] = \esc_html__( 'This information is updated every few minutes, infrequently.', 'the-seo-framework-extension-manager' ); + + $title = sprintf( + '

%s %s

', + \esc_html__( 'Account information', 'the-seo-framework-extension-manager' ), + HTML::make_inline_question_tooltip( implode( ' ', $infos ), implode( '
', $infos ) ) + ); return sprintf( '
%s%s
', $title, $output ); } @@ -579,7 +588,7 @@ protected function get_support_buttons() { $buttons[1] = Layout::get( 'public-support-button' ); $description[1] = \__( 'Inquire your question publicly so more people will benefit from our support.', 'the-seo-framework-extension-manager' ); - $buttons[2] = Layout::get( 'premium-support-button' ); + $buttons[2] = Layout::get( 'private-support-button' ); $description[2] = \__( 'Questions about your account should be inquired via Premium Support.', 'the-seo-framework-extension-manager' ); Layout::reset(); diff --git a/inc/traits/core/error.trait.php b/inc/traits/core/error.trait.php index 7afda723..b1e2b1c0 100644 --- a/inc/traits/core/error.trait.php +++ b/inc/traits/core/error.trait.php @@ -359,6 +359,14 @@ protected function get_error_notice_by_key( $key, $get_type = true ) { $type = 'error'; break; + case 17013: + case 1100108: + case 1100208: + case 1010508: + $message = \esc_html__( 'Exceeded maximum number of monthly request. Upgrade your license or check back in next month.', 'the-seo-framework-extension-manager' ); + $type = 'error'; + break; + case 305: $message = sprintf( /* translators: %s = My Account */ @@ -436,6 +444,7 @@ protected function get_error_notice_by_key( $key, $get_type = true ) { break; case 2001: + case 6001: case 7001: case 7002: case 7101: diff --git a/inc/traits/manager/extensions-layout.trait.php b/inc/traits/manager/extensions-layout.trait.php index d02926e8..13094424 100644 --- a/inc/traits/manager/extensions-layout.trait.php +++ b/inc/traits/manager/extensions-layout.trait.php @@ -48,7 +48,6 @@ private static function obtain_i18n() { return $i18n = [ 'free' => \__( 'Free', 'the-seo-framework-extension-manager' ), - 'free+' => \__( 'Free+', 'the-seo-framework-extension-manager' ), 'essentials' => \__( 'Essentials', 'the-seo-framework-extension-manager' ), 'essentials+' => \__( 'Essentials+', 'the-seo-framework-extension-manager' ), 'premium' => \__( 'Premium', 'the-seo-framework-extension-manager' ), diff --git a/inc/traits/manager/options.trait.php b/inc/traits/manager/options.trait.php index 1ffd1a01..54b099db 100644 --- a/inc/traits/manager/options.trait.php +++ b/inc/traits/manager/options.trait.php @@ -161,7 +161,7 @@ final protected function update_option( $option, $value, $type = 'instance', $ki } if ( false === $this->verify_option_update_instance( $kill ) ) { - $this->set_error_notice( [ 7001 => '' ] ); + $this->set_error_notice( [ 6001 => '' ] ); //* Options have already been reverted. diff --git a/lib/js/tsfem-form.js b/lib/js/tsfem-form.js index 14640b98..bdb0ec72 100644 --- a/lib/js/tsfem-form.js +++ b/lib/js/tsfem-form.js @@ -526,8 +526,8 @@ window.tsfemForm = { if ( data.hasOwnProperty( components[ i ] ) ) { switchComponents: switch ( components[ i ] ) { - case 'route' : - case 'street_number' : + case 'route': + case 'street_number': // Collect route and street number if combined. if ( components.length > 1 ) { routeCombine[ components[ i ] ] = data[ components[ i ] ]; @@ -543,15 +543,15 @@ window.tsfemForm = { } break; - case 'locality' : - case 'country' : - case 'postal_code' : - case 'region' : + case 'locality': + case 'country': + case 'postal_code': + case 'region': element.value = data[ components[ i ] ]; break loopComponents; - case 'lat' : - case 'lng' : + case 'lat': + case 'lng': //* Convert string to float, convert float to 7 decimal places. element.value = parseFloat( parseFloat( data[ components[ i ] ] ).toFixed( 7 ) ); break loopComponents; @@ -604,32 +604,32 @@ window.tsfemForm = { for ( let __i in types ) { switchTypes: switch ( types[ __i ] ) { - case 'route' : - case 'street_number' : - case 'country' : - case 'postal_code' : + case 'route': + case 'street_number': + case 'country': + case 'postal_code': _optionValues[ i ][ types[ __i ] ] = shortname; break loopTypes; - case 'locality' : + case 'locality': _optionValues[ i ]['locality'] = shortname; break loopTypes; - case 'postal_town' : + case 'postal_town': //= Only fill this in if no locality is set. if ( ! types.locality ) _optionValues[ i ]['locality'] = shortname; break loopTypes; - case 'administrative_area_level_1' : + case 'administrative_area_level_1': _optionValues[ i ]['region'] = shortname; break loopTypes; - case 'administrative_area_level_2' : + case 'administrative_area_level_2': //= Only fill this in if no administrative_area_level_1 is set. if ( ! types.administrative_area_level_1 ) _optionValues[ i ]['region'] = shortname; break loopTypes; - default : + default: break switchTypes; } } @@ -1069,7 +1069,7 @@ window.tsfemForm = { key = $label.data( 'dyntitleid' ) + '[' + $label.data( 'dyntitlekey' ) + ']'; switch ( type ) { - case 'single' : + case 'single': let el = document.getElementById( key ); if ( event.target.checked ) { @@ -1079,7 +1079,7 @@ window.tsfemForm = { } break; - case 'plural' : + case 'plural': let $things = jQuery( document.getElementById( key ) ).find( 'input[type=checkbox]' ); if ( event.target.checked ) { diff --git a/lib/js/tsfem-inpost.js b/lib/js/tsfem-inpost.js index 6813823e..0674a3ae 100644 --- a/lib/js/tsfem-inpost.js +++ b/lib/js/tsfem-inpost.js @@ -207,54 +207,6 @@ window.tsfem_inpost = function( $ ) { return $dfd.promise(); } - /* Web Worker concept. It's bad. */ - // const blobWorkerLoop = ( iterable, cb ) => { - // - // const createWorker = ( cbVar, itVar, cb ) => { - // let blob = URL.createObjectURL( - // new Blob( - // [ - // '(', - // cbVar.toString(), - // itVar.toString(), - // cb.toString(), - // ')();' - // ], - // { type: 'application/javascript' } - // ) - // ); - // let worker = new Worker( blob ); - // URL.revokeObjectURL( blob ); - // return worker; - // } - // - // const looper = () => { - // for ( let i = 0; i < iterable.length; i++ ) { - // cb( iterable[ i ] ); - // } - // postMessage( 'done' ); - // } - // const makeCbVar = cb => 'var cb =' + cb.toString() + ';'; - // const makeItVar = iterable => 'var iterable =' + iterable.toString() + ';'; - // - // let $dfd = $.Deferred(), - // worker = createWorker( makeCbVar( cb ), makeItVar( makeItVar ), looper ); - // - // worker.onmessage = ( e ) => { - // worker.terminate(); - // $dfd.resolve(); - // } - // worker.onerror = ( e ) => { - // worker.terminate(); - // $dfd.reject(); - // } - // //= run. - // worker.postMessage(''); - // - // //= promise. - // return $dfd.promise(); - // } - /** * Performs inpost AJAX request. * @@ -551,24 +503,24 @@ window.tsfem_inpost = function( $ ) { let _error = ''; switch ( errorThrown ) { - case 'abort' : // client error, no code. - case 'timeout' : // 408 + case 'abort': // client error, no code. + case 'timeout': // 408 _error = i18n['TimeoutError']; break; - case 'Bad Request' : // 400 + case 'Bad Request': // 400 _error = i18n['BadRequest']; break; - case 'Internal Server Error' : // 500 + case 'Internal Server Error': // 500 _error = i18n['FatalError']; break; - case 'parsererror' : // PHP error, no code. + case 'parsererror': // PHP error, no code. _error = i18n['ParseError']; break; - default : + default: // @TODO use ajaxOptions.status? i.e. 400, 401, 402, 503. _error = i18n['UnknownError']; break; @@ -653,9 +605,7 @@ window.tsfem_inpost = function( $ ) { cO = 0, roughness = 10, fadeGo, - timeOut, - key = target.dataset.tsfemFadeId || '_' + Math.random().toString(22).substr(2,10), - didFunc = false; + key = target.dataset.tsfemFadeId || '_' + Math.random().toString(22).substr(2,10); target.dataset.tsfemFadeId = key; diff --git a/readme.txt b/readme.txt index 8b85d5ab..205dd8d8 100644 --- a/readme.txt +++ b/readme.txt @@ -172,14 +172,17 @@ If you were to get a plugin activation error, either open a support ticket [here * **Added:** The plugin now supports PHP 7.3. * **Added:** We integrated our own updating services. +* **Added:** This plugin now connects to our improved API services. +* **Added:** The interface now updates you (in irregular intervals) on the remaining API requests for the month. * **Added:** We added a new "Essential" extension tier. These extensions don't require our API actively, but give powerful SEO improvements regardless. -* **Added:** This plugin can now handle license upgrades and downgrades. It's just that our shop can't, yet. +* **Added:** This plugin can now handle license upgrades and downgrades. It's just that our shop can't without handing over a new key, yet. * **Added:** Various constants that allow you to easily manage multisite networks and customer websites. * **Improved:** When the class stops for any reason, it creates aliases to prevent crashing. * **Improved:** A deactivation from a connected state now brings you back to the Free tier, without losing your extension activation data. * Reconnect to reactivate the made-unavailable extensions automatically. + * Privacy-intensive extensions, like Monitor, might require you to revalidate. * **Removed:** Integrated fonts for pixel recognition tests. It was planned to be integrated for PHP-style pixel calculations, but was aborted for performance reasons. -* **Removed:** More legacy browser support. +* **Removed:** More legacy browser support. Stop using IE11. * **Fixed:** The human time is now correctly told in facing certain circumstances. * **Fixed:** TODO The AJAX notification no longer starts fading before it's processed. (we're used to servers that respond instantly...) * Test this with throttled connections in Chrome... diff --git a/the-seo-framework-extension-manager.php b/the-seo-framework-extension-manager.php index f8f19ddb..0bc97f5f 100644 --- a/the-seo-framework-extension-manager.php +++ b/the-seo-framework-extension-manager.php @@ -3,7 +3,7 @@ * Plugin Name: The SEO Framework - Extension Manager * Plugin URI: https://wordpress.org/plugins/the-seo-framework-extension-manager/ * Description: Add more powerful SEO features to The SEO Framework right from your WordPress Dashboard. - * Version: 2.0.0-dev-2018-10-20.0 + * Version: 2.0.0-dev-2018-10-30.0 * Author: Sybre Waaijer * Author URI: https://theseoframework.com/ * License: GPLv3 diff --git a/views/layout/general/footer.php b/views/layout/general/footer.php index 99b89008..8515b23b 100644 --- a/views/layout/general/footer.php +++ b/views/layout/general/footer.php @@ -2,15 +2,17 @@ defined( 'ABSPATH' ) and \tsf_extension_manager()->_verify_instance( $_instance, $bits[1] ) or die; if ( $this->is_plugin_activated() ) { - if ( $this->is_premium_user() ) { - $more_mottos = [ 'premium', 'essential' ]; + if ( $this->is_enterprise_user() ) { + $more_mottos = [ 'An enterprise', 'A premium', 'An essential' ]; + } elseif ( $this->is_premium_user() ) { + $more_mottos = [ 'A premium', 'An essential' ]; } elseif ( $this->is_connected_user() ) { - $more_mottos = [ 'essential' ]; + $more_mottos = [ 'An essential' ]; } else { - $more_mottos = [ 'free' ]; + $more_mottos = [ 'A free' ]; } } else { - $more_mottos = [ 'free', 'essential', 'premium' ]; + $more_mottos = [ 'A free', 'An essential', 'A premium', 'An enterprise' ]; } /** @@ -22,19 +24,19 @@ * c) we stray away from what the footer is about: recognition and branding. */ $mottos = [ - 'better', - 'fair', - 'supreme', - 'clean', - 'future', - 'prospective', - 'stronger', - 'sustainable', - 'state of the art', - 'social', - 'fast', - 'secure', - 'logical', + 'A better', + 'A fair', + 'A supreme', + 'A clean', + 'A future', + 'A prospective', + 'A stronger', + 'A sustainable', + 'A state of the art', + 'A social', + 'A fast', + 'A secure', + 'A logical', ]; $mottos = array_merge( $mottos, $more_mottos ); $motto_key = mt_rand( 0, count( $mottos ) - 1 ); @@ -44,6 +46,6 @@ The SEO Framework Extension Manager