rest_url(), ]); register_block_type( 'notificationx-pro/notificationx', [ 'editor_script' => 'notificationx-block-editor', 'editor_style' => 'notificationx-block-editor', // 'style' => 'notificationx-block', // 'script' => 'notificationx-block-frontend', 'render_callback' => [ $this, 'notificationx_render_callback' ], 'attributes' => array( 'nx_id' => array( 'type' => 'string', ), 'blockId' => array( 'type' => 'string', ), 'product_id' => array( 'type' => 'string', ), ), ] ); register_block_type( 'notificationx-pro/notificationx-render', [ 'render_callback' => [ $this, 'gutenberg_examples_dynamic_render_callback' ], 'attributes' => array( 'nx_id' => array( 'type' => 'string', ), 'blockId' => array( 'type' => 'string', ), 'product_id' => array( 'type' => 'string', ), 'post_type' => array( 'type' => 'string', ), ), ] ); } function notificationx_render_callback( $block_attributes, $content ) { if( ! is_admin() ){ wp_enqueue_style('notificationx-block'); wp_enqueue_script('notificationx-block-frontend'); } if ( is_admin() || $this->isRestUrl() ) { do_action( 'nx_ignore_analytics' ); } $nx_id = ! empty( $block_attributes['nx_id'] ) ? esc_attr($block_attributes['nx_id']) : ''; $product_id = ! empty( $block_attributes['product_id'] ) ? $block_attributes['product_id'] : ''; $block_id = ! empty( $block_attributes['blockId'] ) ? esc_attr($block_attributes['blockId']) : ''; $html = '
' . __( 'There is no data in this notification.', 'notificationx' ) . '
'; } $html .= '