automattic / jetpack-sync
Everything needed to allow syncing to the WP.com infrastructure.
Installs: 566 829
Dependents: 16
Suggesters: 0
Security: 0
Stars: 4
Watchers: 4
Forks: 4
Type:jetpack-library
Requires
- php: >=7.2
- automattic/jetpack-connection: ^6.0.0
- automattic/jetpack-constants: ^3.0.0
- automattic/jetpack-ip: ^0.4.0
- automattic/jetpack-password-checker: ^0.4.0
- automattic/jetpack-roles: ^3.0.0
- automattic/jetpack-status: ^5.0.0
Requires (Dev)
- automattic/jetpack-changelogger: ^5.0.0
- automattic/jetpack-search: @dev
- automattic/jetpack-waf: @dev
- automattic/wordbless: @dev
- yoast/phpunit-polyfills: ^1.1.1
Suggests
- automattic/jetpack-autoloader: Allow for better interoperability with other plugins that use this package.
- dev-trunk / 4.0.x-dev
- v4.0.0
- v3.15.0
- v3.14.4
- v3.14.3
- v3.14.2
- v3.14.1
- v3.14.0
- v3.13.2
- v3.13.1
- v3.13.0
- v3.12.0
- v3.11.0
- v3.10.0
- v3.9.1
- v3.9.0
- v3.8.1
- v3.8.0
- v3.7.1
- v3.7.0
- v3.6.0
- v3.5.1
- v3.5.0
- v3.4.1
- v3.4.0
- v3.3.1
- v3.3.0
- v3.2.1
- v3.2.0
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.2
- v3.0.1
- v3.0.0
- v2.16.6
- v2.16.5
- v2.16.4
- v2.16.3
- v2.16.2
- v2.16.1
- v2.16.0
- v2.15.1
- v2.15.0
- v2.14.0
- v2.13.1
- v2.13.0
- v2.12.0
- v2.11.1
- v2.11.0
- v2.10.5
- v2.10.4
- v2.10.3
- v2.10.2
- v2.10.1
- v2.10.0
- v2.9.0
- v2.8.1
- v2.8.0
- v2.7.0
- v2.6.1
- v2.6.0
- v2.5.1
- v2.5.0
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.0
- v2.2.1
- v2.2.0
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.2
- v2.0.1
- v2.0.0
- v1.60.1
- v1.60.0
- v1.59.2
- v1.59.1
- v1.59.0
- v1.58.1
- v1.58.0
- v1.57.4
- v1.57.3
- v1.57.2
- v1.57.1
- v1.57.0
- v1.56.0
- v1.55.2
- v1.55.1
- v1.55.0
- v1.54.0
- v1.53.0
- v1.52.0
- v1.51.0
- v1.50.2
- v1.50.1
- v1.50.0
- v1.49.0
- v1.48.1
- v1.48.0
- v1.47.9
- v1.47.8
- v1.47.7
- v1.47.6
- v1.47.5
- v1.47.4
- v1.47.3
- v1.47.2
- v1.47.1
- v1.47.0
- v1.46.1
- v1.46.0
- v1.45.0
- v1.44.2
- v1.44.1
- v1.44.0
- v1.43.2
- v1.43.1
- v1.43.0
- v1.42.0
- v1.41.0
- v1.40.3
- v1.40.2
- v1.40.1
- v1.40.0
- v1.39.0
- v1.38.4
- v1.38.3
- v1.38.2
- v1.38.1
- v1.38.0
- v1.37.1
- v1.37.0
- v1.36.1
- v1.36.0
- v1.35.2
- v1.35.1
- v1.35.0
- v1.34.0
- v1.33.1
- v1.33.0
- v1.32.0
- v1.31.1
- v1.31.0.1
- v1.31.0
- v1.30.8
- v1.30.7
- v1.30.6
- v1.30.5
- v1.30.4
- v1.30.3
- v1.30.2
- v1.30.1
- v1.30.0
- v1.29.2
- v1.29.1
- v1.29.0
- v1.28.2
- v1.28.1
- v1.28.0
- v1.27.6
- v1.27.5
- v1.27.4
- v1.27.3
- v1.27.2
- v1.27.1
- v1.27.0
- v1.26.4
- v1.26.3
- v1.26.2
- v1.26.1
- v1.26.0
- v1.25.0
- v1.24.2
- v1.24.1
- v1.24.0
- v1.23.3
- v1.23.2
- v1.23.1
- v1.23.0
- v1.22.0
- v1.21.3
- v1.21.2
- 1.21.1
- v1.21.0
- v1.20.2
- v1.20.1
- v1.20.0
- v1.19.4
- v1.19.3
- v1.19.2
- v1.19.1
- v1.19.0
- v1.18.1
- v1.18.0
- v1.17.2
- v1.17.1
- v1.17.0
- v1.16.4
- v1.16.3
- v1.16.2
- v1.16.1
- v1.16.0
- v1.15.1
- v1.15.0
- v1.14.4
- v1.14.3
- v1.14.2
- v1.14.1
- v1.14.0
- v1.13.2
- v1.13.1
- v1.13.0
- v1.12.4
- v1.12.3
- v1.12.2
- v1.12.1
- v1.12.0
- v1.11.0
- v1.10.0
- v1.9.0
- v1.8.0
- v1.7.6
- v1.7.5
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.1
- v1.5.0
- v1.4.0
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.2
- v1.0.1
- v1.0.0
- dev-prerelease
- dev-release-v1.47.5
- dev-release-v1.31.0.1
- dev-fix/slack-workflow-branch-detection
- dev-fix/release-branch-typo
- dev-update/generate-branch-plugin
- dev-release-v1.23.3
- dev-release-v1.23.2
- dev-release-v1.21.0
- dev-release-v1.20.2
- dev-release-v1.20.1
- dev-release-v1.20.0
- dev-release-v1.19.4
- dev-release-v1.19.3
- dev-feature/reorg
- dev-release-v1.19.2
- dev-release-v1.19.1
- dev-release-v1.18.1
- dev-release-v1.18.0
- dev-release-v1.17.2
- dev-release-v1.17.1
- dev-release-v1.17.0
- dev-release-v1.16.4
- dev-release-v1.16.3
- dev-release-v1.16.2
- dev-release-v1.16.1
- dev-release-v1.16.0
- dev-release-v1.15.1
- dev-release-v1.15.0
- dev-release-v1.14.4
- dev-release-v1.14.3
- dev-release-v1.14.2
- dev-release-v1.14.1
- dev-release-v1.14.0
- dev-release-v1.13.2
- dev-release-v1.13.1
- dev-release-v1.13.0
- dev-try/jetpack-sync-composer-package
- dev-release-v1.12.4
- dev-release-v1.12.3
- dev-release-v1.12.2
- dev-release-v1.12.1
- dev-release-v1.12.0
- dev-release-v1.11.0
- dev-release-v1.10.0
- dev-release-v1.9.0
- dev-fork/jetpack-sync-v1.7.4+vip
- dev-update/jetpack-sync-v1.7.5
- dev-update/jetpack-sync-v1.6.2
This package is auto-updated.
Last update: 2024-11-14 21:12:35 UTC
README
Everything needed to allow syncing to the WordPress.com infrastructure.
Get Started
The easiest way to get started with Sync is via the Jetpack Configuration package.
Configuring Sync with all Sync Modules enabled
Assuming a $config
instance of Automattic/Jetpack/Config
, the following code will configure Sync with all its Modules enabled:
$config->ensure( 'sync' )
Configuring Sync with limited functionality
It's possible to limit Sync functionality by providing an explicit list of data to be synced.
Using the Config package those data settings can be passed as an array in the ensure
call for sync
.
Here's an example:
$config->ensure(
'sync',
array(
'jetpack_sync_options_whitelist' => array( 'my_plugin_option' ),
)
);
Alteratively, if you prefer to use the Sync package directly, you can set the Sync data settings using the Main::set_sync_data_options
method. For example:
Jetpack\Sync\Main::set_sync_data_options(
array(
'jetpack_sync_options_whitelist' => array( 'my_plugin_option' ),
)
);
Configurable Sync data settings
Here's a list of all the Sync data settings that are configurable:
jetpack_sync_modules
The list of Sync modules to enable. By default all Sync modules are enabled. You can override this behaviour by passing an array of Sync modules as follows:
$config->ensure(
'sync',
array(
'jetpack_sync_modules' => array(
'Automattic\\Jetpack\\Sync\\Modules\\Posts', // Only sync Post related data.
)
)
);
It's important to note that we consider a list of certain Sync modules required for Sync to properly function, therefore the following modules will be enabled no matter the configuration:
Automattic\\Jetpack\\Sync\\Modules\\Options
Automattic\\Jetpack\\Sync\\Modules\\Callables
Automattic\\Jetpack\\Sync\\Modules\\Constants
Automattic\\Jetpack\\Sync\\Modules\\Full_Sync_Immediately
Automattic\\Jetpack\\Sync\\Modules\\Stats
Automattic\\Jetpack\\Sync\\Modules\\Updates
Attention: Sync currently only supports configuring the list of default Sync modules. Any modules that Sync already loads conditionally, such as WooCommerce
or Search
are NOT configurable.
jetpack_sync_options_whitelist
/ jetpack_sync_options_contentless
Controlled by the Sync Options Module, which is required. You can limit the site options to sync by specifying a list of explicit options as follows:
$config->ensure(
'sync',
array(
'jetpack_sync_options_whitelist' => array( 'my_plugin_option' ),
)
);
It's important to note that we consider a list of certain options required for Sync to properly function, therefore the following options will be synced no matter the configuration:
jetpack_sync_non_blocking
, // Sync related optionjetpack_sync_non_public_post_stati
, // Sync related optionjetpack_sync_settings_comment_meta_whitelist
, // Sync related optionjetpack_sync_settings_post_meta_whitelist
, // Sync related optionjetpack_sync_settings_post_types_blacklist
, // Sync related optionjetpack_sync_settings_taxonomies_blacklist
, // Sync related optionjetpack_sync_settings_dedicated_sync_enabled
, // Sync related optionblog_charset
, // Generic site optionblog_public
, // Generic site optionblogdescription
, // Generic site optionblogname
, // Generic site optionpermalink_structure
, // Generic site optionstylesheet
, // Generic site optiontime_format
, // Generic site optiontimezone_string
, // Generic site optionactive_plugins
, // Generic site option
Passing a list of options will result in syncing those options plus the required ones.
Passing an empty array will result in syncing only the required options.
Not configuring this setting will result in syncing all default options, as defined by Sync (see Automattic\Jetpack\Sync\Defaults::$default_options_whitelist
)
Same logic applies for the list of "Contentless" options we sync. For those options we DO NOT sync contents, only the option name - Good for sensitive information that Sync does not need.
The exception here is that there are no required ones. Therefore, passing an empty array will result in NOT syncing any contentless options.
Not configuring this setting will result in syncing all default contentless options, as defined by Sync (see Automattic\Jetpack\Sync\Defaults::$default_options_contentless
)
jetpack_sync_callable_whitelist
/ jetpack_sync_multisite_callable_whitelist
Controlled by the Sync Callable Module, which is required. You can limit the callables to sync by specifying a list of explicit callables as follows:
$config->ensure(
'sync',
array(
'jetpack_sync_callable_whitelist' => array(
'my_plugin_settings' => array( 'My_Plugin_Class', 'get_settings' ),
),
)
);
When it comes to configuring callables, you need to pass an associative array where the key is the name of your callable and the value the corresponding callback function. It's important to note that we consider a list of certain callables required for Sync to properly function, therefore the following callables will be synced no matter the configuration:
site_url
home_url
get_plugins
get_themes
paused_plugins
paused_themes
timezone
wp_get_environment_type
wp_max_upload_size
wp_version
jetpack_connection_active_plugins
// Connection related callable
Passing a list of callables will result in syncing those callables plus the required ones.
Passing an empty array will result in syncing only the required callables.
Not configuring this setting will result in syncing all default callables, as defined by Sync (see Automattic\Jetpack\Sync\Defaults::$default_callable_whitelist
)
Same logic applies for the list of multisite callables we sync.
The exception here is that there are no required ones. Therefore, passing an empty array will result in NOT syncing any multisite callables.
Not configuring this setting will result in syncing all default multisite callables, as defined by Sync (see Automattic\Jetpack\Sync\Defaults::$default_multisite_callable_whitelist
)
jetpack_sync_constants_whitelist
Controlled by the Sync Constants Module, which is required. You can limit the constants to sync by specifying a list of explicit constants as follows:
$config->ensure(
'sync',
array(
'jetpack_sync_constants_whitelist' => array(
'MY_PLUGIN_CONSTANT'
),
)
);
It's important to note that we consider a list of certain constants required for Sync to properly function, therefore the following constants will be synced no matter the configuration:
ABSPATH
ALTERNATE_WP_CRON
ATOMIC_CLIENT_ID
AUTOMATIC_UPDATER_DISABLED
DISABLE_WP_CRON
DISALLOW_FILE_EDIT
DISALLOW_FILE_MODS
EMPTY_TRASH_DAYS
FS_METHOD
IS_PRESSABLE
PHP_VERSION
WP_ACCESSIBLE_HOSTS
WP_AUTO_UPDATE_CORE
WP_CONTENT_DIR
WP_CRON_LOCK_TIMEOUT
WP_DEBUG
WP_HTTP_BLOCK_EXTERNAL
WP_MAX_MEMORY_LIMIT
WP_MEMORY_LIMIT
WP_POST_REVISIONS
Passing a list of constants will result in syncing those constants plus the required ones.
Passing an empty array will result in syncing only the required constants.
Not configuring this setting will result in syncing all default constants, as defined by Sync (see Automattic\Jetpack\Sync\Defaults::$default_constants_whitelist
)
jetpack_sync_post_meta_whitelist
Controlled by the Sync Posts Module, which is NOT required. This means that you also need to add the Posts module in jetpack_sync_modules
otherwise this setting will be ignored.
You can limit the Post meta to sync by specifying a list of explicit Post meta as follows:
$config->ensure(
'sync',
array(
'jetpack_sync_modules' => array(
'Automattic\\Jetpack\\Sync\\Modules\\Posts', // Only sync Post related data.
),
'jetpack_sync_post_meta_whitelist' => array(
'my_custom_post_meta'
),
)
);
Passing an empty array will result in NOT syncing any Post meta.
Not configuring this setting will result in syncing all default Post meta, as defined by Sync (see Automattic\Jetpack\Sync\Defaults::$post_meta_whitelist
)
jetpack_sync_comment_meta_whitelist
Controlled by the Sync Comments Module, which is NOT required. This means that you also need to add the Comments module in jetpack_sync_modules
otherwise this setting will be ignored.
You can limit the Comment meta to sync by specifying a list of explicit Comment meta as follows:
$config->ensure(
'sync',
array(
'jetpack_sync_modules' => array(
'Automattic\\Jetpack\\Sync\\Modules\\Comments', // Only sync Comment related data.
),
'jetpack_sync_comment_meta_whitelist' => array(
'my_custom_comment_meta'
),
)
);
Passing an empty array will result in NOT syncing any Comment meta.
Not configuring this setting will result in syncing all default Comment meta, as defined by Sync (see Automattic\Jetpack\Sync\Defaults::$comment_meta_whitelist
)
jetpack_sync_capabilities_whitelist
Controlled by the Sync Users Module, which is NOT required. This means that you also need to add the Users module in jetpack_sync_modules
otherwise this setting will be ignored.
You can limit the capabilities to sync by specifying a list of explicit Comment meta as follows:
$config->ensure(
'sync',
array(
'jetpack_sync_modules' => array(
'Automattic\\Jetpack\\Sync\\Modules\\Users', // Only sync User related data.
),
'jetpack_sync_capabilities_whitelist' => array(
'list_users'
),
)
);
Passing an empty array will result in NOT syncing any capabilities.
Not configuring this setting will result in syncing all default capabilities, as defined by Sync (see Automattic\Jetpack\Sync\Defaults::$default_capabilities_whitelist
)
Initial Full Sync
An initial full sync of the site is started when the site is registered or when a user is authorized.
Actions::do_only_first_initial_sync
The Actions::do_only_first_initial_sync
method can be used to start an initial full sync when a site has not already had a full sync started. This is useful for situations in which a plugin needs to start an initial full sync only if no other plugin has already started one.
Examples
Using this package in your WordPress plugin
If you plan on using this package in your WordPress plugin, we would recommend that you use Jetpack Autoloader as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.
Security
Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.
License
jetpack-sync is licensed under GNU General Public License v2 (or later)