automattic / jetpack-jitm
Just in time messages for Jetpack
Installs: 35 881
Dependents: 5
Suggesters: 0
Security: 0
Stars: 5
Watchers: 5
Forks: 1
Type:jetpack-library
Requires
- php: >=7.2
- automattic/jetpack-a8c-mc-stats: ^3.0.0
- automattic/jetpack-assets: ^4.0.2
- automattic/jetpack-connection: ^6.2.1
- automattic/jetpack-device-detection: ^3.0.0
- automattic/jetpack-logo: ^3.0.0
- automattic/jetpack-redirect: ^3.0.1
- automattic/jetpack-status: ^5.0.1
Requires (Dev)
- automattic/jetpack-changelogger: ^5.1.0
- brain/monkey: ^2.6.2
- 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.3
- v4.0.2
- v4.0.1
- v4.0.0
- v3.1.29
- v3.1.28
- v3.1.27
- v3.1.26
- v3.1.25
- v3.1.24
- v3.1.23
- v3.1.22
- v3.1.21
- v3.1.20
- v3.1.19
- v3.1.18
- v3.1.17
- v3.1.16
- v3.1.15
- v3.1.14
- v3.1.13
- v3.1.12
- v3.1.11
- v3.1.10
- v3.1.9
- v3.1.8
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.19
- v2.3.18
- v2.3.17
- v2.3.16
- v2.3.15
- v2.3.14
- v2.3.13
- v2.3.12
- v2.3.11
- v2.3.10
- v2.3.9
- v2.3.8
- v2.3.7
- v2.3.6
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.42
- v2.2.41
- v2.2.40
- v2.2.39
- v2.2.38
- v2.2.37
- v2.2.36
- v2.2.35
- v2.2.34
- v2.2.33
- v2.2.32
- v2.2.31
- v2.2.30
- v2.2.29
- v2.2.28
- v2.2.27
- v2.2.26
- v2.2.25
- v2.2.24
- v2.2.23
- v2.2.22
- v2.2.21
- v2.2.20
- v2.2.19
- v2.2.18
- v2.2.17
- v2.2.16
- v2.2.15
- v2.2.14
- v2.2.13
- v2.2.12
- v2.2.11
- v2.2.10
- v2.2.9
- v2.2.8
- v2.2.7
- v2.2.6
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.16.2
- v1.16.1
- v1.16.0
- v1.15.1
- v1.15.0
- 1.14.1
- v1.14.0
- v1.13.5
- v1.13.4
- v1.13.3
- v1.13.2
- v1.13.1
- v1.13.0
- v1.12.2
- v1.12.1
- v1.12.0
- v1.11.2
- v1.11.1
- v1.11.0
- v1.10.4
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.1
- v1.9.0
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.5
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.1
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-prerelease
- dev-fix/slack-workflow-branch-detection
- dev-fix/release-branch-typo
- dev-update/generate-branch-plugin
- dev-release/v1.15.1
- dev-release-v1.14.0
- dev-release-v1.13.5
- dev-release-v1.13.4
- dev-release-v1.13.3
- dev-release-v1.13.2
- dev-release-v1.13.1
- dev-feature/reorg
- dev-release-v1.13.0
- dev-release-v1.12.2
- dev-release-v1.12.1
- dev-release-v1.12.0
- dev-release-v1.11.2
- dev-release-v1.11.1
- dev-release-v1.11.0
- dev-release-v1.10.4
- dev-release-v1.10.3
- dev-release-v1.10.2
- dev-release-v1.10.1
- dev-release-v1.10.0
- dev-release-v1.9.1
- dev-release-v1.9.0
- dev-release-v1.8.2
- dev-release-v1.8.1
- dev-release-v1.8.0
- dev-release-v1.7.2
- dev-release-v1.7.1
- dev-release-v1.7.0
- dev-release-v1.6.5
- dev-release-v1.6.4
- dev-release-v1.6.3
- dev-release-v1.6.2
- dev-release-v1.6.1
- dev-release-v1.6.0
- dev-release-v1.5.1
- dev-release-v1.5.0
- dev-release-v1.4.0
- dev-release-v1.3.0
This package is auto-updated.
Last update: 2024-12-20 05:34:24 UTC
README
A package encapsulating Just In Time Messages.
Just In Time Messages (JITMs) are real-time contextual in-admin notices. Such notices are displayed on specific admin pages, based on multiple parameters (page visited, Jetpack connection status, plan status, features active, ...).
There are 2 main ways to use JITMs:
- You can create static notices within the Jetpack plugin. Those will be displayed before the site is connected to WordPress.com. See
Pre_Connection_JITM
to find out more. - You can create dynamic notices once the Jetpack plugin is connected to WordPress.com. Those notices will be pulled from WordPress.com depending on the parameters mentioned above. See
Post_Connection_JITM
to find out more.
Usage
Using the Config Package
The JITMs can be enabled using the Config package:
use Automattic/Jetpack/Config;
// Configuring as early as plugins_loaded priority 1
// to make sure every action handler gets properly set.
add_action( 'plugins_loaded', 'configure_jitm', 1 );
function configure_jitm() {
$config = new Config();
$config->ensure( 'jitm' );
}
Directly Using the JITM Package
The JITMs can also be enabled by using the JITM package directly:
Automattic\Jetpack\JITMS\JITM::configure();
Where the JITM will be displayed
JITMs can be shown on any admin page that has the <div id="jp-admin-notices" />
element within the dom, as it's where the messages are injected.
You may need to add or adjust this element to fit in your plugin.
Adding Pre-Connection JITMs
Plugins can add pre-connection JITMs uisng the jetpack_pre_connection_jitms
filter. Each JITM message must be an array and must contain the following keys:
- id
- message_path
- message
- description
- button_link
- button_caption
If a JITM is missing one of the above keys, the JITM will not be displayed.
The JITM message array may also contain the following optional keys:
- icon - When the 'icon' key does not exist, the Jetpack icon is used by default. The available settings for this option are:
- 'jetpack' for the Jetpack icon.
- 'woocommerce' for the WooCommerce icon.
- An empty string for no icon.
The Jetpack plugin's pre-connection JITMs can be found in the Jetpack_Pre_Connection_JITMs
class.
Example
function add_preconnection_jitms( $messages ) {
$example_jitm = array(
'id' => 'example-jitm',
'message_path' => '/wp:plugins:admin_notices/',
'message' => __( 'An example message.', 'jetpack' ),
'description' => __( 'An example description.', 'jetpack' ),
'button_link' => 'https://example.com/path',
'button_caption' => __( 'Example button text', 'jetpack' ),
);
if ( ! is_array( $messages ) ) {
return array( $example_jitm );
}
return array_merge( $messages, array( $example_jitm ) );
}
add_filter( 'jetpack_pre_connection_jitms', 'add_preconnection_jitms' );
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-jitm is licensed under GNU General Public License v2 (or later)