PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.9.1
Secure Custom Fields v6.9.1
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / Blocks / Bindings_Editor.php
secure-custom-fields / includes / Blocks Last commit date
Bindings.php 1 week ago Bindings_Editor.php 1 month ago
Bindings_Editor.php
52 lines
1 <?php
2 /**
3 * SCF block bindings editor integration.
4 *
5 * @package wordpress/secure-custom-fields
6 */
7
8 namespace SCF\Blocks;
9
10 /**
11 * Enqueues the JS layer that powers SCF block bindings in the block editor.
12 *
13 * The JS bindings layer registers a block binding source via the stable
14 * registerBlockBindingsSource API (WP 6.7+), enabling live preview and
15 * editing of SCF field values bound to block attributes. It runs alongside
16 * the shared server-side SCF\Blocks\Bindings class.
17 */
18 class Bindings_Editor {
19
20 /**
21 * Constructor.
22 */
23 public function __construct() {
24 // The JS bindings layer relies on the stable registerBlockBindingsSource
25 // API, which is only available on WP 6.7+.
26 global $wp_version;
27 if ( version_compare( $wp_version, '6.7', '<' ) ) {
28 return;
29 }
30
31 add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
32 }
33
34 /**
35 * Enqueues the JS block bindings source script on block editor screens.
36 *
37 * @return void
38 */
39 public function enqueue_block_editor_assets() {
40 if ( ! acf_get_setting( 'enable_block_bindings' ) ) {
41 return;
42 }
43
44 // JS bindings layer requires the datastore for live editor preview/editing.
45 if ( ! acf_is_using_datastore() ) {
46 return;
47 }
48
49 wp_enqueue_script( 'acf-field-bindings' );
50 }
51 }
52