Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .plugin-data
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.1.1",
"version": "1.2.0",
"slug": "multisite-shared-blocks"
}
15 changes: 14 additions & 1 deletion includes/Blocks/SharedBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions multisite-shared-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' );

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/blocks/shared-block/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Loading