@@ -131,9 +131,9 @@ public function register_hooks() {
131
131
132
132
\add_action ( 'wp_enqueue_scripts ' , array ( $ this , 'enqueue_scripts ' ) );
133
133
134
- // remove the "webmentions_disabled" meta value if the post is updated
135
- \add_action ( 'updated_post_meta ' , array ( $ this , 'maybe_remove_webmentions_disabled ' ), 10 , 4 );
136
- \add_action ( 'added_post_meta ' , array ( $ this , 'maybe_remove_webmentions_disabled ' ), 10 , 4 );
134
+ // Do not add the "webmentions_disabled" meta value if it is set to 0
135
+ \add_filter ( 'update_post_metadata ' , array ( $ this , 'maybe_bypass_webmentions_disabled ' ), 10 , 4 );
136
+ \add_filter ( 'add_post_metadata ' , array ( $ this , 'maybe_bypass_webmentions_disabled ' ), 10 , 4 );
137
137
}
138
138
139
139
/**
@@ -191,14 +191,20 @@ public function enqueue_scripts() {
191
191
/**
192
192
* Delete the webmentions_disabled meta value if the post is updated.
193
193
*
194
- * @param int $meta_id The meta ID .
194
+ * @param bool $check The check .
195
195
* @param int $object_id The object ID.
196
196
* @param string $meta_key The meta key.
197
197
* @param mixed $meta_value The meta value.
198
198
*/
199
- public function maybe_remove_webmentions_disabled ( $ meta_id , $ object_id , $ meta_key , $ meta_value ) {
199
+ public function maybe_bypass_webmentions_disabled ( $ check , $ object_id , $ meta_key , $ meta_value ) {
200
200
if ( 'webmentions_disabled ' === $ meta_key && empty ( $ meta_value ) ) {
201
- \delete_post_meta ( $ object_id , 'webmentions_disabled ' );
201
+ if ( 'update_post_metadata ' === current_action () ) {
202
+ \delete_post_meta ( $ object_id , $ meta_key );
203
+ }
204
+
205
+ $ check = true ;
202
206
}
207
+
208
+ return $ check ;
203
209
}
204
210
}
0 commit comments