Skip to content

Commit a7f50f9

Browse files
committed
do not send pings
1 parent bb730fa commit a7f50f9

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

build/editor-plugin/plugin.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/class-block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function register_postmeta() {
2929
);
3030
\register_post_meta(
3131
$post_type,
32-
'webmentions_send_disabled',
32+
'webmentions_disabled_pings',
3333
array(
3434
'show_in_rest' => true,
3535
'single' => true,

includes/class-sender.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ public static function init() {
4444
* @param int $post_id Post ID.
4545
*/
4646
public static function publish_hook( $post_id ) {
47-
add_post_meta( $post_id, '_mentionme', '1', true );
47+
if ( \get_post_meta( $post_id, 'webmention_send_disabled', 1 ) ) {
48+
return;
49+
}
50+
51+
\add_post_meta( $post_id, '_mentionme', '1', true );
4852
// Post Types Other than Post Do Not Trigger Pings. This will unless it is already scheduled.
4953
if ( ! wp_next_scheduled( 'do_pings' ) ) {
5054
wp_schedule_single_event( time(), 'do_pings' );
@@ -188,6 +192,10 @@ public static function send_webmention( $source, $target, $post_id = null ) {
188192
* @return array|bool array of results or false if failed.
189193
*/
190194
public static function send_webmentions( $post_id ) {
195+
if ( \get_post_meta( $post_id, 'webmentions_disabled_pings', 1 ) ) {
196+
return;
197+
}
198+
191199
$source = get_post_meta( $post_id, 'webmention_canonical_url', true );
192200

193201
if ( ! $source ) {
@@ -321,7 +329,7 @@ public static function do_webmentions() {
321329
remove_filter( 'pre_get_posts', 'ksuce_exclude_categories' );
322330
}
323331

324-
$mentions = get_posts(
332+
$post_ids = get_posts(
325333
array(
326334
'meta_key' => '_mentionme',
327335
'post_type' => get_post_types_by_support( 'webmentions' ),
@@ -334,14 +342,14 @@ public static function do_webmentions() {
334342
add_filter( 'pre_get_posts', 'ksuce_exclude_categories' );
335343
}
336344

337-
if ( empty( $mentions ) ) {
345+
if ( empty( $post_ids ) ) {
338346
return;
339347
}
340348

341-
foreach ( $mentions as $mention ) {
342-
delete_post_meta( $mention, '_mentionme' );
349+
foreach ( $post_ids as $post_id ) {
350+
\delete_post_meta( $post_id, '_mentionme' );
343351
// send them Webmentions
344-
self::send_webmentions( $mention );
352+
self::send_webmentions( $post_id );
345353
}
346354
}
347355
}

includes/class-webmention.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function enqueue_scripts() {
197197
* @param mixed $meta_value The meta value.
198198
*/
199199
public function maybe_bypass_webmentions_disabled( $check, $object_id, $meta_key, $meta_value ) {
200-
$meta_keys = array( 'webmentions_disabled', 'webmentions_send_disabled' );
200+
$meta_keys = array( 'webmentions_disabled', 'webmentions_disabled_pings' );
201201

202202
if ( \in_array( $meta_key, $meta_keys, true ) && empty( $meta_value ) ) {
203203
if ( 'update_post_metadata' === current_action() ) {

src/editor-plugin/plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const EditorPlugin = () => {
3131
__nextHasNoMarginBottom
3232
label={ __( 'Disable outgoing', 'webmention' ) }
3333
help={ __( 'Do not send Webmentions for this post.', 'webmention' ) }
34-
checked={ meta.webmentions_send_disabled }
34+
checked={ meta.webmentions_disabled_pings }
3535
onChange={ ( value ) => {
36-
setMeta( { ...meta, webmentions_send_disabled: value } );
36+
setMeta( { ...meta, webmentions_disabled_pings: value } );
3737
} }
3838
/>
3939
</PluginDocumentSettingPanel>

0 commit comments

Comments
 (0)