Skip to content

Commit

Permalink
Merge pull request #161 from alleyinteractive/fix/issue-159/fatal-fro…
Browse files Browse the repository at this point in the history
…ntend-trending-no-parsely-setup

fix issue introduced earlier
  • Loading branch information
mogmarsh authored Mar 27, 2024
2 parents 80e4c2c + 0c683e3 commit 382b246
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `WP Curate` will be documented in this file.

## 1.8.2 - 2024-03-27

- Bug Fix: Error in 1.8.1 when Parse.ly is not instantiated.

## 1.8.1 - 2024-03-27

- Bug Fix: Query blocks set to ordery trending fatal when Parse.ly is not set up.
Expand Down
8 changes: 7 additions & 1 deletion src/features/class-parsely-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function add_parsely_trending_posts_query( array $posts, array $args ): a
*/
public function get_trending_posts( array $args ): array {
$parsely = $GLOBALS['parsely'];
if ( ! $parsely ) {
return [];
}
if ( ! $parsely->api_secret_is_set() ) {
return [];
}
Expand Down Expand Up @@ -112,7 +115,10 @@ public function get_trending_posts( array $args ): array {
if ( false === $ids || ! is_array( $ids ) ) {
$api = new Analytics_Posts_API( $GLOBALS['parsely'] );
$posts = $api->get_posts_analytics( $parsely_args );
$ids = array_map(
if ( \is_wp_error( $posts ) || ! \is_array( $posts ) ) {
return [];
}
$ids = array_map(
function ( $post ) {
// Check if the metadata contains post_id, if not, use the URL to get the post ID.
$metadata = json_decode( $post['metadata'] ?? '', true );
Expand Down
2 changes: 1 addition & 1 deletion wp-curate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Curate
* Plugin URI: https://github.com/alleyinteractive/wp-curate
* Description: Plugin to curate homepages and other landing pages
* Version: 1.8.1
* Version: 1.8.2
* Author: Alley Interactive
* Author URI: https://github.com/alleyinteractive/wp-curate
* Requires at least: 6.4
Expand Down

0 comments on commit 382b246

Please sign in to comment.