diff --git a/.plugin-data b/.plugin-data index 1b2e2d5..bf853ba 100644 --- a/.plugin-data +++ b/.plugin-data @@ -1,4 +1,4 @@ { - "version": "1.1.1", + "version": "1.2.0", "slug": "multisite-shared-blocks" } \ No newline at end of file diff --git a/includes/Blocks/SharedBlock.php b/includes/Blocks/SharedBlock.php index 7a4dcca..a364006 100644 --- a/includes/Blocks/SharedBlock.php +++ b/includes/Blocks/SharedBlock.php @@ -288,7 +288,20 @@ private function get_rendered_block( int $site_id, int $post_id, string $block_i sprintf( '/multisite-shared-blocks/v1/renderer/%d/%s', $post_id, $block_id ) ); - $response = wp_safe_remote_get( $rest_url ); + // Prepare request arguments + $request_args = []; + // Add authentication headers if in non-production environment and credentials are defined + if ( defined( 'MULTISITE_BLOCKS_AUTH_USER' ) && defined( 'MULTISITE_BLOCKS_AUTH_PWD' ) && ! empty( MULTISITE_BLOCKS_AUTH_USER ) && ! empty( MULTISITE_BLOCKS_AUTH_PWD ) ) { + $request_args = [ + 'headers' => [ + 'Authorization' => 'Basic ' . base64_encode( MULTISITE_BLOCKS_AUTH_USER . ':' . MULTISITE_BLOCKS_AUTH_PWD ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode + ], + ]; + } + + // Make the request with authentication if available + $response = wp_safe_remote_get( $rest_url, $request_args ); + if ( is_wp_error( $response ) || 200 !== (int) wp_remote_retrieve_response_code( $response ) ) { return $block_data; } diff --git a/multisite-shared-blocks.php b/multisite-shared-blocks.php index 46fc744..96ba321 100644 --- a/multisite-shared-blocks.php +++ b/multisite-shared-blocks.php @@ -3,7 +3,7 @@ * Plugin Name: Multisite Shared Blocks * Plugin URI: https://github.com/BeAPI/multisite-shared-blocks * Description: Share blocks between network's sites. - * Version: 1.1.1 + * Version: 1.2.0 * Requires at least: 5.9 * Requires PHP: 7.2 * Author: Be API Technical team @@ -31,7 +31,7 @@ } // Plugin constants -define( 'MULTISITE_SHARED_BLOCKS_VERSION', '1.1.1' ); +define( 'MULTISITE_SHARED_BLOCKS_VERSION', '1.2.0' ); define( 'MULTISITE_SHARED_BLOCKS_CACHE_VERSION', '1' ); define( 'MULTISITE_SHARED_BLOCKS_VIEWS_FOLDER_NAME', 'multisite-shared-blocks' ); diff --git a/package-lock.json b/package-lock.json index df00944..bd1c879 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "multisite-shared-blocks", - "version": "1.1.1", + "version": "1.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "multisite-shared-blocks", - "version": "1.1.1", + "version": "1.2.0", "license": "GPL-2.0-or-later", "dependencies": { "react-infinite-scroll-component": "^6.1.0", diff --git a/package.json b/package.json index 6d5f02e..26646d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "multisite-shared-blocks", - "version": "1.1.1", + "version": "1.2.0", "description": "Share blocks between network's sites.", "main": "build/index.js", "scripts": { diff --git a/readme.txt b/readme.txt index 8048f40..6538bf3 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: beapi, momo360modena, rahe, asadowski10, petitphp Tags: network, multisite, block, share, gutenberg Requires at least: 5.9 Tested up to: 6.4 -Stable tag: 1.1.1 +Stable tag: 1.2.0 Requires PHP: 7.2 License: GPL v2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -26,6 +26,9 @@ This plugin allow contributors to share blocks from posts on the network. Other == Changelog == += 1.2.0 - 2025-09-12 = +* Add Basic authentication support for multisite blocks requests + = 1.1.1 - 2024-03-29 = * Load translations for editor script diff --git a/src/blocks/shared-block/block.json b/src/blocks/shared-block/block.json index 6487496..dc0efd6 100644 --- a/src/blocks/shared-block/block.json +++ b/src/blocks/shared-block/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "multisite-shared-blocks/shared-block", - "version": "1.1.1", + "version": "1.2.0", "title": "Shared Block", "category": "design", "description": "",