@@ -14,6 +14,37 @@ public static function init() {
1414 \add_action ( 'wp_enqueue_scripts ' , array ( self ::class, 'add_data ' ) );
1515 \add_action ( 'enqueue_block_editor_assets ' , array ( self ::class, 'add_data ' ) );
1616 \add_action ( 'load-post-new.php ' , array ( self ::class, 'handle_in_reply_to_get_param ' ) );
17+ // Add editor plugin
18+ \add_action ( 'enqueue_block_editor_assets ' , array ( self ::class, 'enqueue_editor_assets ' ) );
19+ \add_action ( 'init ' , array ( self ::class, 'register_postmeta ' ), 11 );
20+ }
21+
22+ public static function register_postmeta () {
23+ $ ap_post_types = \get_post_types_by_support ( 'activitypub ' );
24+ foreach ( $ ap_post_types as $ post_type ) {
25+ \register_post_meta (
26+ $ post_type ,
27+ 'activitypub_content_warning ' ,
28+ array (
29+ 'show_in_rest ' => true ,
30+ 'single ' => true ,
31+ 'type ' => 'string ' ,
32+ 'sanitize_callback ' => 'sanitize_text_field ' ,
33+ )
34+ );
35+ }
36+ }
37+
38+ public static function enqueue_editor_assets () {
39+ // check for our supported post types
40+ $ current_screen = \get_current_screen ();
41+ $ ap_post_types = \get_post_types_by_support ( 'activitypub ' );
42+ if ( ! $ current_screen || ! in_array ( $ current_screen ->post_type , $ ap_post_types , true ) ) {
43+ return ;
44+ }
45+ $ asset_data = include ACTIVITYPUB_PLUGIN_DIR . 'build/editor-plugin/plugin.asset.php ' ;
46+ $ plugin_url = plugins_url ( 'build/editor-plugin/plugin.js ' , ACTIVITYPUB_PLUGIN_FILE );
47+ wp_enqueue_script ( 'activitypub-block-editor ' , $ plugin_url , $ asset_data ['dependencies ' ], $ asset_data ['version ' ], true );
1748 }
1849
1950 /**
0 commit comments