-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpc-editorial-notes.php
54 lines (48 loc) · 1.55 KB
/
wpc-editorial-notes.php
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
<?php
/**
* Plugin Name: WPC Editorial Notes
* Plugin URI: https://github.com/bosconian-dynamics/wpc-editorial-notes
* Description: Adds a basic section for notes to the Document Settings sidebar in the Block Editor. Notes are stored in post meta.
* Version: 0.2.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Adam Bosco <[email protected]>
* License: MIT
*/
namespace BosconianDynamics\WPCEditorialNotes;
require_once __DIR__ . '/vendor/autoload.php';
\Puc_v4_Factory::buildUpdateChecker(
'https://github.com/bosconian-dynamics/wpc-editorial-notes/',
__FILE__,
'wpc-editorial-notes'
);
function register_assets() {
$asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php');
wp_register_script(
'wpc-editorial-notes_editor-plugin',
plugins_url( 'build/index.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version']
);
}
add_action( 'init', __NAMESPACE__ . '\\register_assets' );
function register_meta() {
register_post_meta(
'post',
'wpc_editorial_notes',
[
'show_in_rest' => true,
'single' => true,
'type' => 'string',
'auth_callback' => function() {
return current_user_can( 'edit_posts' );
}
]
);
}
add_action( 'init', __NAMESPACE__ . '\\register_meta' );
function enqueue_editor_assets() {
wp_enqueue_script( 'wpc-editorial-notes_editor-plugin' );
wp_enqueue_style( 'wp-components' );
}
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\enqueue_editor_assets' );