Download the PHP package automattic/jetpack-wp-js-data-sync without Composer

On this page you can find all versions of the php package automattic/jetpack-wp-js-data-sync. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package jetpack-wp-js-data-sync

WP JS Data Sync

Debug

WP JS DataSync listens for ds-debug-disable GET parameter to disable certain DataSync values.

To disable a specific DataSync value, add ?ds-debug-disable=<entry-key> to the URL. To disable all data sync values, add ?ds-debug-disable=all to the URL.

Debug Example

If your dashboard URL is https://example.com/wp-admin/admin.php?page=example, and you want to disable the widget_status value, you would navigate to https://example.com/wp-admin/admin.php?page=example?ds-debug-disable=widget_status.

Outdated Documentation:

WP JS Data Sync is a library designed to help sync data between WordPress and the JavaScript in the admin dashboard.

This helps create streamlined way to pass data from the WordPress backend to JavaScript and:

This package is currently used in combination with the @jetpack/js-packages/svelte-data-sync-client package, but can be extended to work with other libraries in the future.

Usage Overview

After integrating the package into your plugin, the typical setup for a new entry would look something like this:

This will pass the necessary data to the admin-page scripts via wp_localize_script:

And will also create a REST API endpoints that can be used to update the data:

To update the data, you can submit a fetch request and pass in both WordPress REST API nonce and the nonce for the specific entry:

The response will look like this:

To make it easy to use in Svelte, there's a @jetpack/js-packages/svelte-data-sync-client package that provides a Svelte store that can be used to interact with the data.

Setup

Step 1: Initialize Data Sync for the Admin Dashboard

The Data_Sync class is responsible for initializing and streamlining the setup for the Admin dashboard.

Initializing the Data Sync and pass in data about the admin environment. This only needs to be done once per $namespace and is going to attach all the necesasry hooks.

Step 2: Register Entries

Now that we have two handlers setup, we can register them with the Data Sync registry.

A simple example:

A more complex example:

The default storage is wp_options using the Data_Sync_Option class, but sometimes you might want to customize that.

Here's an example of how to make Data Sync use WordPress posts instead of WP Options

Step 3: Usage

Now that the entries are registered, just like in Usage section, you can interact with the data via REST API or the Entry object.

Or change the values via the Entry object in PHP:

Values provided to $entry->set() will always be validated by the Schema before being saved.

Utilities

If you're using the data in various places, it might be helpful to set up helper functions to make it easier to use:

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

WP JS Data Sync is licensed under GNU General Public License v2 (or later)


All versions of jetpack-wp-js-data-sync with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
automattic/jetpack-schema Version ^0.2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package automattic/jetpack-wp-js-data-sync contains the following files

Loading the files please wait ....