From 31feccee1a2c2ffd2e86fc5f074f10ddc2cc940c Mon Sep 17 00:00:00 2001 From: Eduardo humberto Date: Wed, 20 Dec 2017 10:00:30 -0200 Subject: [PATCH] allow external web components --- src/dev-interface/class-tainacan-dev-interface.php | 5 ++++- src/js/event-bus-web-components.js | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dev-interface/class-tainacan-dev-interface.php b/src/dev-interface/class-tainacan-dev-interface.php index e7c35bcea..2aa49e899 100644 --- a/src/dev-interface/class-tainacan-dev-interface.php +++ b/src/dev-interface/class-tainacan-dev-interface.php @@ -30,11 +30,14 @@ class DevInterface { function add_admin_js() { global $TAINACAN_BASE_URL; + $components = ( has_filter( 'tainacan_register_web_components' ) ) ? apply_filters('tainacan_register_web_components') : []; + wp_enqueue_script('wp-settings',$TAINACAN_BASE_URL . '/js/wp-settings.js'); $settings = [ 'root' => esc_url_raw( rest_url() ).'tainacan/v2', - 'nonce' => wp_create_nonce( 'wp_rest' ) + 'nonce' => wp_create_nonce( 'wp_rest' ), + 'components' => $components ]; wp_localize_script( 'wp-settings', 'wp_settings', $settings ); diff --git a/src/js/event-bus-web-components.js b/src/js/event-bus-web-components.js index 5ec770918..827c021a9 100644 --- a/src/js/event-bus-web-components.js +++ b/src/js/event-bus-web-components.js @@ -7,6 +7,11 @@ export const eventBus = new Vue({ componentsTag: [], errors : store.getters['item/getError'] }, + created(){ + if( wp_settings.components ){ + this.componentsTag = wp_settings.components; + } + }, methods : { registerComponent( name ){ this.componentsTag.push( name );