allow external web components

This commit is contained in:
Eduardo humberto 2017-12-20 10:00:30 -02:00
parent 5d2f121159
commit 31feccee1a
2 changed files with 9 additions and 1 deletions

View File

@ -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 );

View File

@ -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 );