@@ -131,9 +131,9 @@ public function register_hooks() {
131131
132132 \add_action ( 'wp_enqueue_scripts ' , array ( $ this , 'enqueue_scripts ' ) );
133133
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 );
137137 }
138138
139139 /**
@@ -191,14 +191,20 @@ public function enqueue_scripts() {
191191 /**
192192 * Delete the webmentions_disabled meta value if the post is updated.
193193 *
194- * @param int $meta_id The meta ID .
194+ * @param bool $check The check .
195195 * @param int $object_id The object ID.
196196 * @param string $meta_key The meta key.
197197 * @param mixed $meta_value The meta value.
198198 */
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 ) {
200200 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 ;
202206 }
207+
208+ return $ check ;
203209 }
204210}
0 commit comments