Skip to content

Commit

Permalink
Merge pull request #2308 from Parsely/develop
Browse files Browse the repository at this point in the history
Release wp-parsely 3.14.2
  • Loading branch information
acicovic authored Mar 19, 2024
2 parents e8832cc + 8450e90 commit 3e4cfe6
Show file tree
Hide file tree
Showing 29 changed files with 168 additions and 89 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.14.2](https://github.com/Parsely/wp-parsely/compare/3.14.1...3.14.2) - 2024-03-19

### Changed

- PCH Related Posts: Don't show "Filter By" when not needed ([#2299](https://github.com/Parsely/wp-parsely/pull/2299))

### Fixed

- PCH: Resolve cursor jump to start in Paragraph Blocks upon selection ([#2305](https://github.com/Parsely/wp-parsely/pull/2305))
- PCH: Fix issue with common styles not being correctly bundled ([#2302](https://github.com/Parsely/wp-parsely/pull/2302))
- PCH Excerpt Generator: Fix missing styling ([#2300](https://github.com/Parsely/wp-parsely/pull/2300))
- PCH Editor Sidebar: Fix incorrect AI opt-in message ([#2296](https://github.com/Parsely/wp-parsely/pull/2296))

### Dependency Updates

- The list of all dependency updates for this release is available [here](https://github.com/Parsely/wp-parsely/pulls?q=is%3Apr+is%3Amerged+milestone%3A3.14.2+label%3A%22Component%3A+Dependencies%22).

## [3.14.1](https://github.com/Parsely/wp-parsely/compare/3.14.0...3.14.1) - 2024-03-14

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Parse.ly

Stable tag: 3.14.1
Stable tag: 3.14.2
Requires at least: 5.2
Tested up to: 6.4
Requires PHP: 7.2
Expand Down
2 changes: 1 addition & 1 deletion build/content-helper/dashboard-widget.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '68d9813064fecfe775a1');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '9d2937a55403c7a2c84f');
2 changes: 1 addition & 1 deletion build/content-helper/dashboard-widget.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/content-helper/editor-sidebar.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '01687777464a070fc26b');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '17c17c38e859a7a2cb72');
6 changes: 3 additions & 3 deletions build/content-helper/editor-sidebar.css

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions build/content-helper/editor-sidebar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/content-helper/excerpt-generator.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '6b5e0bb3951f7f8dece1');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => 'b8c5184c2f31db63e73a');
2 changes: 1 addition & 1 deletion build/content-helper/excerpt-generator.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build/content-helper/excerpt-generator.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wp-parsely",
"version": "3.14.1",
"version": "3.14.2",
"private": true,
"description": "The Parse.ly plugin facilitates real-time and historical analytics to your content through a platform designed and built for digital publishing.",
"author": "parsely, hbbtstar, jblz, mikeyarce, GaryJ, parsely_mike, acicovic, mehmoodak, vaurdan",
Expand Down Expand Up @@ -48,7 +48,7 @@
"@types/jest": "^29.5.12",
"@types/jest-environment-puppeteer": "^5.0.6",
"@types/lodash.debounce": "^4.0.9",
"@types/wordpress__block-editor": "^11.5.11",
"@types/wordpress__block-editor": "^11.5.12",
"@types/wordpress__blocks": "^12.5.13",
"@types/wordpress__components": "^23.0.11",
"@types/wordpress__edit-post": "^7.5.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,24 @@ protected function post_request( array $query = array(), array $body = array() )
return new WP_Error( 400, __( 'Unable to encode request body', 'wp-parsely' ) );
}
}

$response = wp_safe_remote_post( $full_api_url, $options );
if ( is_wp_error( $response ) ) {
return $response;
}

// Handle any errors returned by the API.
if ( 200 !== $response['response']['code'] ) {
$error = $response['response'];
return new WP_Error( $error['code'], $error['message'] );
$error = json_decode( wp_remote_retrieve_body( $response ), true );

if ( ! is_array( $error ) ) {
return new WP_Error(
400,
__( 'Unable to decode upstream API error', 'wp-parsely' )
);
}

return new WP_Error( $error['error'], $error['detail'] );
}

$body = wp_remote_retrieve_body( $response );
Expand Down
50 changes: 33 additions & 17 deletions src/content-helper/common/content-helper-error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@ export enum ContentHelperErrorCode {
ParselyApiResponseContainsError = 'ch_response_contains_error',
ParselyApiReturnedNoData = 'ch_parsely_api_returned_no_data',
ParselyApiReturnedTooManyResults = 'ch_parsely_api_returned_too_many_results',
ParselyApiUnauthorized = 401, // Intentionally without quotes.
ParselyInternalServerError = 500, // Intentionally without quotes.
ParselySchemaValidationFailed = 422, // Intentionally without quotes.
ParselyUpstreamMalformedResponse = 507, // Intentionally without quotes.
ParselyUpstreamNotAvailable = 503, // Intentionally without quotes.
PluginCredentialsNotSetMessageDetected = 'parsely_credentials_not_set_message_detected',
PluginSettingsApiSecretNotSet = 'parsely_api_secret_not_set',
PluginSettingsSiteIdNotSet = 'parsely_site_id_not_set',
PostIsNotPublished = 'ch_post_not_published',

// Suggestions API.
ParselySuggestionsApiAuthUnavailable = 'AUTH_UNAVAILABLE', // HTTP Code 503.
ParselySuggestionsApiNoAuthentication = 'NO_AUTHENTICATION', // HTTP Code 401.
ParselySuggestionsApiNoAuthorization = 'NO_AUTHORIZATION', // HTTP Code 403.
ParselySuggestionsApiNoData = 'NO_DATA', // HTTP Code 507.
ParselySuggestionsApiOpenAiError = 'OPENAI_ERROR', // HTTP Code 500.
ParselySuggestionsApiOpenAiSchema = 'OPENAI_SCHEMA', // HTTP Code 507.
ParselySuggestionsApiOpenAiUnavailable = 'OPENAI_UNAVAILABLE', // HTTP Code 500.
ParselySuggestionsApiSchemaError = 'SCHEMA_ERROR', // HTTP Code 422.
}

/**
Expand All @@ -57,11 +62,21 @@ export class ContentHelperError extends Error {
ContentHelperErrorCode.ParselyApiResponseContainsError,
ContentHelperErrorCode.ParselyApiReturnedNoData,
ContentHelperErrorCode.ParselyApiReturnedTooManyResults,
ContentHelperErrorCode.ParselyApiUnauthorized,
ContentHelperErrorCode.PluginCredentialsNotSetMessageDetected,
ContentHelperErrorCode.PluginSettingsApiSecretNotSet,
ContentHelperErrorCode.PluginSettingsSiteIdNotSet,
ContentHelperErrorCode.PostIsNotPublished,

// Don't perform any fetch retries for the Suggestions API due to
// its time-consuming operations.
ContentHelperErrorCode.ParselySuggestionsApiAuthUnavailable,
ContentHelperErrorCode.ParselySuggestionsApiNoAuthentication,
ContentHelperErrorCode.ParselySuggestionsApiNoAuthorization,
ContentHelperErrorCode.ParselySuggestionsApiNoData,
ContentHelperErrorCode.ParselySuggestionsApiOpenAiError,
ContentHelperErrorCode.ParselySuggestionsApiOpenAiSchema,
ContentHelperErrorCode.ParselySuggestionsApiOpenAiUnavailable,
ContentHelperErrorCode.ParselySuggestionsApiSchemaError,
];

this.retryFetch = ! noRetryFetchErrors.includes( this.code );
Expand All @@ -70,15 +85,16 @@ export class ContentHelperError extends Error {
Object.setPrototypeOf( this, ContentHelperError.prototype );

// Errors that need rephrasing.
if ( this.code === ContentHelperErrorCode.ParselyApiUnauthorized ) {
if ( this.code === ContentHelperErrorCode.ParselySuggestionsApiNoAuthorization ) {
this.message = __(
'This AI-powered feature is opt-in. To gain access, please submit a request ' +
'<a href="https://wpvip.com/parsely-content-helper/" target="_blank" rel="noreferrer">here</a>.',
'wp-parsely'
);
} else if ( this.code === ContentHelperErrorCode.ParselyInternalServerError ) {
} else if ( this.code === ContentHelperErrorCode.ParselySuggestionsApiOpenAiError ||
this.code === ContentHelperErrorCode.ParselySuggestionsApiOpenAiUnavailable ) {
this.message = __(
'The Parse.ly API returned an internal server error. Please try again later.',
'The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.',
'wp-parsely'
);
} else if ( this.code === ContentHelperErrorCode.HttpRequestFailed &&
Expand All @@ -87,23 +103,22 @@ export class ContentHelperError extends Error {
'The Parse.ly API did not respond in a timely manner. Please try again later.',
'wp-parsely'
);
} else if ( this.code === ContentHelperErrorCode.ParselySchemaValidationFailed ) {
} else if ( this.code === ContentHelperErrorCode.ParselySuggestionsApiSchemaError ) {
this.message = __(
'The Parse.ly API returned a validation error. Please try again later.',
'The Parse.ly API returned a validation error. Please try again with different parameters.',
'wp-parsely'
);
} else if ( this.code === ContentHelperErrorCode.ParselyUpstreamMalformedResponse &&
this.message.includes( 'Insufficient Storage' ) ) {
} else if ( this.code === ContentHelperErrorCode.ParselySuggestionsApiNoData ) {
this.message = __(
'The Parse.ly API couldn\'t find any relevant data to fulfill the request. Please retry with a different input.',
'wp-parsely'
);
} else if ( this.code === ContentHelperErrorCode.ParselyUpstreamMalformedResponse ) {
} else if ( this.code === ContentHelperErrorCode.ParselySuggestionsApiOpenAiSchema ) {
this.message = __(
'The Parse.ly API returned a malformed response. Please try again later.',
'The Parse.ly API returned an incorrect response. Please try again later.',
'wp-parsely'
);
} else if ( this.code === ContentHelperErrorCode.ParselyUpstreamNotAvailable ) {
} else if ( this.code === ContentHelperErrorCode.ParselySuggestionsApiAuthUnavailable ) {
this.message = __(
'The Parse.ly API is currently unavailable. Please try again later.',
'wp-parsely'
Expand Down Expand Up @@ -136,7 +151,8 @@ export class ContentHelperError extends Error {
'wp-parsely'
) );
}
if ( this.code === ContentHelperErrorCode.ParselyApiForbidden ) {
if ( this.code === ContentHelperErrorCode.ParselyApiForbidden ||
this.code === ContentHelperErrorCode.ParselySuggestionsApiNoAuthentication ) {
this.hint = this.Hint( __(
"Please ensure that the Site ID and API Secret given in the plugin's settings are correct.",
'wp-parsely'
Expand Down
7 changes: 7 additions & 0 deletions src/content-helper/common/css/common.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
@import "variables";
@import "functions";

/**
* Import custom components SCSS here.
*/
@import "../components/tone-selector/style";
@import "../components/persona-selector/style";
@import "../components/input-range/style";

/**
* Common styles for the content helper.
*/
Expand Down
Loading

0 comments on commit 3e4cfe6

Please sign in to comment.