Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Package: Moves the Users and Themes sync module #12737

Merged
merged 1 commit into from Jun 19, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/sync/legacy/class.jetpack-sync-modules.php
Expand Up @@ -13,9 +13,9 @@ class Jetpack_Sync_Modules {
'Jetpack_Sync_Module_Options',
'Jetpack_Sync_Module_Network_Options',
'Automattic\\Jetpack\\Sync\\Modules\\Terms',
'Jetpack_Sync_Module_Themes',
'Automattic\\Jetpack\\Sync\\Modules\\Themes',
'Jetpack_Sync_Module_Menus',
'Jetpack_Sync_Module_Users',
'Automattic\\Jetpack\\Sync\\Modules\\Users',
'Jetpack_Sync_Module_Posts',
'Jetpack_Sync_Module_Import',
'Jetpack_Sync_Module_Protect',
Expand Down
@@ -1,6 +1,8 @@
<?php

class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
namespace Automattic\Jetpack\Sync\Modules;

class Themes extends \Jetpack_Sync_Module {
function name() {
return 'themes';
}
Expand Down Expand Up @@ -293,7 +295,7 @@ public function check_upgrader( $upgrader, $details ) {

if ( 'install' === $details['action'] ) {
$theme = $upgrader->theme_info();
if ( ! $theme instanceof WP_Theme ) {
if ( ! $theme instanceof \WP_Theme ) {
return;
}
$theme_info = array(
Expand Down Expand Up @@ -324,7 +326,7 @@ public function check_upgrader( $upgrader, $details ) {
foreach ( $details['themes'] as $theme_slug ) {
$theme = wp_get_theme( $theme_slug );

if ( ! $theme instanceof WP_Theme ) {
if ( ! $theme instanceof \WP_Theme ) {
continue;
}

Expand Down Expand Up @@ -578,7 +580,7 @@ private function get_theme_support_info( $theme = null ) {
if ( $theme === null ) {
$theme = wp_get_theme();

foreach ( Jetpack_Sync_Defaults::$default_theme_support_whitelist as $theme_feature ) {
foreach ( \Jetpack_Sync_Defaults::$default_theme_support_whitelist as $theme_feature ) {
$has_support = current_theme_supports( $theme_feature );
if ( $has_support ) {
$theme_support[ $theme_feature ] = $_wp_theme_features[ $theme_feature ];
Expand Down
@@ -1,8 +1,10 @@
<?php

namespace Automattic\Jetpack\Sync\Modules;

use Automattic\Jetpack\Constants;

class Jetpack_Sync_Module_Users extends Jetpack_Sync_Module {
class Users extends \Jetpack_Sync_Module {
const MAX_INITIAL_SYNC_USERS = 100;

protected $flags = array();
Expand Down Expand Up @@ -82,7 +84,7 @@ private function get_user( $user ) {
if ( is_numeric( $user ) ) {
$user = get_user_by( 'id', $user );
}
if ( $user instanceof WP_User ) {
if ( $user instanceof \WP_User ) {
return $user;
}
return null;
Expand Down Expand Up @@ -119,7 +121,7 @@ public function get_real_user_capabilities( $user ) {
if ( is_wp_error( $user ) ) {
return $user_capabilities;
}
foreach ( Jetpack_Sync_Defaults::get_capabilities_whitelist() as $capability ) {
foreach ( \Jetpack_Sync_Defaults::get_capabilities_whitelist() as $capability ) {
if ( $user_has_capabilities = user_can( $user, $capability ) ) {
$user_capabilities[ $capability ] = true;
}
Expand Down Expand Up @@ -203,12 +205,12 @@ public function authenticate_handler( $user, $username, $password ) {
}

// We are only interested in successful authentication events.
if ( is_wp_error( $user ) || ! ( $user instanceof WP_User ) ) {
if ( is_wp_error( $user ) || ! ( $user instanceof \WP_User ) ) {
return $user;
}

jetpack_require_lib( 'class.jetpack-password-checker' );
$password_checker = new Jetpack_Password_Checker( $user->ID );
$password_checker = new \Jetpack_Password_Checker( $user->ID );

$test_results = $password_checker->test( $password, true );

Expand Down Expand Up @@ -469,15 +471,15 @@ public function remove_user_from_blog_handler( $user_id, $blog_id ) {
}

protected function is_add_new_user_to_blog() {
return Jetpack::is_function_in_backtrace( 'add_new_user_to_blog' );
return \Jetpack::is_function_in_backtrace( 'add_new_user_to_blog' );
}

protected function is_add_user_to_blog() {
return Jetpack::is_function_in_backtrace( 'add_user_to_blog' );
return \Jetpack::is_function_in_backtrace( 'add_user_to_blog' );
}

protected function is_delete_user() {
return Jetpack::is_function_in_backtrace( array( 'wp_delete_user', 'remove_user_from_blog' ) );
return \Jetpack::is_function_in_backtrace( array( 'wp_delete_user', 'remove_user_from_blog' ) );
}

protected function is_create_user() {
Expand All @@ -487,7 +489,7 @@ protected function is_create_user() {
'wp_insert_user', // Used to suppress jetpack_sync_save_user in save_user_cap_handler and save_user_role_handler when user registered on single site
);

return Jetpack::is_function_in_backtrace( $functions );
return \Jetpack::is_function_in_backtrace( $functions );
}

protected function get_reassigned_network_user_id() {
Expand Down