@@ -21,8 +21,6 @@ public static function init() {
21
21
// This is already being called on the init hook, so just add it.
22
22
self ::register_blocks ();
23
23
24
- \add_action ( 'wp_head ' , array ( self ::class, 'inject_activitypub_options ' ), 11 );
25
- \add_action ( 'admin_print_scripts ' , array ( self ::class, 'inject_activitypub_options ' ) );
26
24
\add_action ( 'load-post-new.php ' , array ( self ::class, 'handle_in_reply_to_get_param ' ) );
27
25
// Add editor plugin.
28
26
\add_action ( 'enqueue_block_editor_assets ' , array ( self ::class, 'enqueue_editor_assets ' ) );
@@ -95,12 +93,24 @@ public static function register_postmeta() {
95
93
* Enqueue the block editor assets.
96
94
*/
97
95
public static function enqueue_editor_assets () {
96
+ $ data = array (
97
+ 'namespace ' => ACTIVITYPUB_REST_NAMESPACE ,
98
+ 'defaultAvatarUrl ' => ACTIVITYPUB_PLUGIN_URL . 'assets/img/mp.jpg ' ,
99
+ 'enabled ' => array (
100
+ 'site ' => ! is_user_type_disabled ( 'blog ' ),
101
+ 'users ' => ! is_user_type_disabled ( 'user ' ),
102
+ ),
103
+ 'maxImageAttachments ' => \get_option ( 'activitypub_max_image_attachments ' , ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS ),
104
+ );
105
+ wp_localize_script ( 'wp-editor ' , '_activityPubOptions ' , $ data );
106
+
98
107
// Check for our supported post types.
99
108
$ current_screen = \get_current_screen ();
100
109
$ ap_post_types = \get_post_types_by_support ( 'activitypub ' );
101
110
if ( ! $ current_screen || ! in_array ( $ current_screen ->post_type , $ ap_post_types , true ) ) {
102
111
return ;
103
112
}
113
+
104
114
$ asset_data = include ACTIVITYPUB_PLUGIN_DIR . 'build/editor-plugin/plugin.asset.php ' ;
105
115
$ plugin_url = plugins_url ( 'build/editor-plugin/plugin.js ' , ACTIVITYPUB_PLUGIN_FILE );
106
116
wp_enqueue_script ( 'activitypub-block-editor ' , $ plugin_url , $ asset_data ['dependencies ' ], $ asset_data ['version ' ], true );
@@ -121,42 +131,20 @@ public static function handle_in_reply_to_get_param() {
121
131
wp_enqueue_script ( 'activitypub-reply-intent ' , $ plugin_url , $ asset_data ['dependencies ' ], $ asset_data ['version ' ], true );
122
132
}
123
133
124
- /**
125
- * Output ActivityPub options as a script tag.
126
- */
127
- public static function inject_activitypub_options () {
128
- $ data = array (
129
- 'namespace ' => ACTIVITYPUB_REST_NAMESPACE ,
130
- 'defaultAvatarUrl ' => ACTIVITYPUB_PLUGIN_URL . 'assets/img/mp.jpg ' ,
131
- 'enabled ' => array (
132
- 'site ' => ! is_user_type_disabled ( 'blog ' ),
133
- 'users ' => ! is_user_type_disabled ( 'user ' ),
134
- ),
135
- 'maxImageAttachments ' => \get_option ( 'activitypub_max_image_attachments ' , ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS ),
136
- );
137
-
138
- printf (
139
- "\n<script>var _activityPubOptions = %s;</script> " ,
140
- wp_json_encode ( $ data )
141
- );
142
- }
143
-
144
134
/**
145
135
* Register the blocks.
146
136
*/
147
137
public static function register_blocks () {
148
- \register_block_type_from_metadata ( ACTIVITYPUB_PLUGIN_DIR . '/build/followers ' );
149
-
150
138
\register_block_type_from_metadata ( ACTIVITYPUB_PLUGIN_DIR . '/build/follow-me ' );
139
+ \register_block_type_from_metadata ( ACTIVITYPUB_PLUGIN_DIR . '/build/followers ' );
140
+ \register_block_type_from_metadata ( ACTIVITYPUB_PLUGIN_DIR . '/build/reactions ' );
151
141
152
142
\register_block_type_from_metadata (
153
143
ACTIVITYPUB_PLUGIN_DIR . '/build/reply ' ,
154
144
array (
155
145
'render_callback ' => array ( self ::class, 'render_reply_block ' ),
156
146
)
157
147
);
158
-
159
- \register_block_type_from_metadata ( ACTIVITYPUB_PLUGIN_DIR . '/build/reactions ' );
160
148
}
161
149
162
150
/**
0 commit comments