Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/header-in-old-browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Mar 11, 2022
2 parents 522a64d + 92df8fa commit 8d55a87
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions mu-plugins/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
require_once __DIR__ . '/blocks/global-header-footer/blocks.php';
require_once __DIR__ . '/global-fonts/index.php';
require_once __DIR__ . '/skip-to/skip-to.php';
require_once __DIR__ . '/stream-tweaks/index.php';
22 changes: 22 additions & 0 deletions mu-plugins/stream-tweaks/class-connector-posts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Connector for Posts
*
* This is a hotfix for the Stream plugin to enable logging post changes that happen through an API context (i.e.
* in the block editor). This change has been merged in the GitHub repo for the Stream plugin, but as of version
* 3.8.2 it has not been released to the plugin directory.
*/

namespace WordPressdotorg\MU_Plugins\Stream_Tweaks;

/**
* Class - Connector_Posts
*/
class Connector_Posts extends \WP_Stream\Connector_Posts {
/**
* Register connector in the WP Frontend
*
* @var bool
*/
public $register_frontend = true;
}
34 changes: 34 additions & 0 deletions mu-plugins/stream-tweaks/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace WordPressdotorg\MU_Plugins\Stream_Tweaks;

add_filter( 'wp_stream_connectors', __NAMESPACE__ . '\replace_posts_connector' );

/**
* Substitute Stream's posts connector class for our modified version.
*
* @param array $connector_classes
*
* @return mixed
*/
function replace_posts_connector( $connector_classes ) {
if ( ! function_exists( 'wp_stream_get_instance' ) ) {
return $connector_classes;
}

require_once __DIR__ . '/class-connector-posts.php';

$stream_plugin_instance = wp_stream_get_instance();
$new_posts_connector = new Connector_Posts( $stream_plugin_instance->log ); // WordPressdotorg namespaced version.

// Remove the default posts connector class if it has been initialized.
if ( isset( $connector_classes[ $new_posts_connector->name ] ) ) {
unset( $connector_classes[ $new_posts_connector->name ] );
}

if ( $new_posts_connector->is_dependency_satisfied() ) {
$connector_classes[ $new_posts_connector->name ] = $new_posts_connector;
}

return $connector_classes;
}

0 comments on commit 8d55a87

Please sign in to comment.