Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Added support for WPcom protected owner errors.
27 changes: 26 additions & 1 deletion projects/packages/connection/src/class-initial-state.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ private static function get_data() {
global $wp_version;

$status = new Status();
$host = new Status\Host();

// Initialize with regular connection errors
$connection_errors = Error_Handler::get_instance()->get_verified_errors();
$all_errors = $connection_errors;

// Check for Protected Owner errors via filter
$protected_owner_error = false;
if ( $host->is_woa_site() ) {
/**
* Filter to get Protected Owner errors
*
* @since $$next-version$$
*
* @param false $protected_owner_error Default error value (false)
*/
$protected_owner_error = apply_filters( 'jetpack_connection_protected_owner_error', false );
}

// If Protected Owner error exists, override regular errors with it
if ( $protected_owner_error ) {
// Reset errors array and add only the Protected Owner error
$all_errors = array();
$all_errors = $protected_owner_error;
}

return array(
'apiRoot' => esc_url_raw( rest_url() ),
Expand All @@ -33,7 +58,7 @@ private static function get_data() {
'connectedPlugins' => REST_Connector::get_connection_plugins( false ),
'wpVersion' => $wp_version,
'siteSuffix' => $status->get_site_suffix(),
'connectionErrors' => Error_Handler::get_instance()->get_verified_errors(),
'connectionErrors' => $all_errors,
'isOfflineMode' => $status->is_offline_mode(),
'calypsoEnv' => ( new Status\Host() )->get_calypso_env(),
);
Expand Down
11 changes: 11 additions & 0 deletions projects/packages/connection/src/class-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
*/
public $error_handler = null;

/**
* Protected owner error handler object.
* This will only be set if the wpcomsh plugin is active.
*
* @var \Automattic\WPComSH\Connection\Protected_Owner_Error_Handler|null
*/
public $protected_owner_error_handler = null;

Check failure on line 65 in projects/packages/connection/src/class-manager.php

View workflow job for this annotation

GitHub Actions / Static analysis

UndefError PhanUndeclaredTypeProperty Property \Automattic\Jetpack\Connection\Manager->protected_owner_error_handler has undeclared type \Automattic\WPComSH\Connection\Protected_Owner_Error_Handler FAQ on Phan issues: pdWQjU-Jb-p2

/**
* Jetpack_XMLRPC_Server object
*
Expand Down Expand Up @@ -132,6 +140,9 @@

$manager->error_handler = Error_Handler::get_instance();

// Use protected owner error handler if available via filter
$manager->protected_owner_error_handler = apply_filters( 'jetpack_connection_protected_owner_error_handler', null );

if ( $manager->is_connected() ) {
add_filter( 'xmlrpc_methods', array( $manager, 'public_xmlrpc_methods' ) );
add_filter( 'shutdown', array( new Package_Version_Tracker(), 'maybe_update_package_versions' ) );
Expand Down
Loading
Loading