PHP code example of automattic / jetpack-sync

1. Go to this page and download the library: Download automattic/jetpack-sync library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

automattic / jetpack-sync example snippets


$config->ensure(
    'sync',
    array( 
        'jetpack_sync_options_whitelist'  => array( 'my_plugin_option' ),
    )
);

Jetpack\Sync\Main::set_sync_data_options(
    array( 
        'jetpack_sync_options_whitelist'  => array( 'my_plugin_option' ),
    )
); 

$config->ensure(
	'sync',
	array(
		'jetpack_sync_modules' => array(
			'Automattic\\Jetpack\\Sync\\Modules\\Posts', // Only sync Post related data.
		)
	)
);

$config->ensure(
    'sync',
    array( 
        'jetpack_sync_options_whitelist' => array( 'my_plugin_option' ),
    )
);

$config->ensure(
    'sync',
    array(
	    'jetpack_sync_callable_whitelist' => array(
			'my_plugin_settings' => array( 'My_Plugin_Class', 'get_settings' ),
		),
	)
);

$config->ensure(
    'sync',
    array(
	    'jetpack_sync_constants_whitelist' => array(
			'MY_PLUGIN_CONSTANT'
		),
	)
);

$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'
		),
	)
);

$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'
		),
	)
);

$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'
		),
	)
);