Skip to content

Commit

Permalink
fix #1441
Browse files Browse the repository at this point in the history
  • Loading branch information
inc2734 committed Oct 18, 2024
1 parent 7fa468a commit f22c544
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
8 changes: 7 additions & 1 deletion app/setup/remote-block-patterns.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 27.2.3
* @version 27.2.4
*/

use Framework\Controller\Manager;
Expand Down Expand Up @@ -39,6 +39,9 @@ function snow_monkey_get_remote_block_patten_categories() {
}

$pattern_categories = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $pattern_categories ) ) {
return array();
}

$new_pattern_categories = array();
foreach ( $pattern_categories as $pattern_category ) {
Expand Down Expand Up @@ -81,6 +84,9 @@ function _snow_monkney_get_remote_block_patterns( $url ) {
}

$patterns = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $patterns ) ) {
return array();
}

foreach ( $patterns as $key => $pattern ) {
$patterns[ $key ]['content'] = str_replace(
Expand Down
14 changes: 9 additions & 5 deletions app/setup/support-forum-widget.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 27.2.4
*
* renamed: app/setup/suppot-forum-widget.php
*/
Expand All @@ -16,9 +16,12 @@ function () {
function () {
global $wp_version;

$transient = get_transient( 'snow-monkey-support-forum-topics' );
$transient = get_transient( 'snow-monkey-support-forum-topics' );
$wp_api_posts = array();

if ( ! $transient ) {
if ( $transient ) {
$wp_api_posts = $transient;
} else {
$wp_api_posts = wp_remote_get(
'https://snow-monkey.2inc.org/wp-json/wp/v2/topic?per_page=5',
array(
Expand All @@ -30,11 +33,12 @@ function () {
$wp_api_posts = array();
} else {
$wp_api_posts = json_decode( $wp_api_posts['body'] );
if ( ! is_array( $wp_api_posts ) ) {
$wp_api_posts = array();
}
}

set_transient( 'snow-monkey-support-forum-topics', $wp_api_posts, 60 * 60 );
} else {
$wp_api_posts = $transient;
}

if ( ! $wp_api_posts ) {
Expand Down
14 changes: 9 additions & 5 deletions app/setup/update-info-widget.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 27.2.4
*/

add_action(
Expand All @@ -15,9 +15,12 @@ function () {
function () {
global $wp_version;

$transient = get_transient( 'snow-monkey-update-info' );
$transient = get_transient( 'snow-monkey-update-info' );
$wp_api_posts = array();

if ( ! $transient ) {
if ( $transient ) {
$wp_api_posts = $transient;
} else {
$wp_api_posts = wp_remote_get(
'https://snow-monkey.2inc.org/wp-json/wp/v2/posts?categories=194&per_page=5',
array(
Expand All @@ -29,11 +32,12 @@ function () {
$wp_api_posts = array();
} else {
$wp_api_posts = json_decode( $wp_api_posts['body'] );
if ( ! is_array( $wp_api_posts ) ) {
$wp_api_posts = array();
}
}

set_transient( 'snow-monkey-update-info', $wp_api_posts, 60 * 60 );
} else {
$wp_api_posts = $transient;
}

if ( ! $wp_api_posts ) {
Expand Down
24 changes: 12 additions & 12 deletions composer.lock

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

0 comments on commit f22c544

Please sign in to comment.