-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
73 lines (65 loc) · 1.6 KB
/
index.php
File metadata and controls
73 lines (65 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Plugin Name: Question Answer Block
* Plugin URI: https://github.com/topo/question-answer
* Description: A fully open source Gutenberg block for Q&As
* Author: topolitique.ch
* Author URI: https://topolitique.ch
* Text Domain: topo-question-answer
* Domain Path: /languages
* Version: 0.1.0
*
* @package Topo_Question_Answer
*/
function question_answer_block_assets() {
/**
* Output scripts & styles
*
* */
wp_enqueue_style(
'question-answer-block-style',
plugins_url( 'block/index.css', __FILE__ ),
array()
);
wp_enqueue_script(
'question-answer-block-script',
plugins_url( 'block/block.js', __FILE__ ),
array(),
null,
true
);
}
add_action('enqueue_block_assets', 'question_answer_block_assets');
// Your code starts here.
function question_answer_block_init() {
// Skip block registration if Gutenberg is not enabled/merged.
if ( ! function_exists( 'register_block_type' ) ) {
return;
}
/**
* Editor scripts & styles
*
* */
wp_register_script(
'question-answer-block-editor',
plugins_url( 'block/index.js', __FILE__ ),
array(
'wp-blocks',
'wp-i18n',
'wp-element',
'wp-editor',
'wp-components'
)
);
wp_register_style(
'question-answer-block-editor',
plugins_url( 'block/index.css', __FILE__ ),
array()
);
register_block_type( 'topo/question-answer', array(
'editor_script' => 'question-answer-block-editor',
'editor_style' => 'question-answer-block-editor',
'style' => 'question-answer-block-style',
) );
}
add_action( 'init', 'question_answer_block_init' );