-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into fix/header-in-old-browsers
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |