-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add classic editor fallback for webmention post settings #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -25,6 +25,7 @@ public static function init() { | |||||
// Send Webmentions from Every Type that Declared Webmention Support | ||||||
$post_types = get_post_types_by_support( 'webmentions' ); | ||||||
foreach ( $post_types as $post_type ) { | ||||||
add_action( 'save_' . $post_type, array( static::class, 'save_hook' ), 3 ); | ||||||
add_action( 'publish_' . $post_type, array( static::class, 'publish_hook' ), 3 ); | ||||||
add_action( 'trashed_' . $post_type, array( static::class, 'trash_hook' ) ); | ||||||
} | ||||||
|
@@ -36,6 +37,41 @@ public static function init() { | |||||
|
||||||
// remote delete posts | ||||||
add_action( 'webmention_delete', array( static::class, 'send_webmentions' ) ); | ||||||
\add_action( 'init', array( self::class, 'register_postmeta' ), 11 ); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Register post meta | ||||||
*/ | ||||||
public static function register_postmeta() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The other function is called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, moved it around...fine with changing it. |
||||||
$post_types = \get_post_types_by_support( 'webmentions' ); | ||||||
foreach ( $post_types as $post_type ) { | ||||||
\register_post_meta( | ||||||
$post_type, | ||||||
'webmentions_disabled_pings', | ||||||
array( | ||||||
'show_in_rest' => true, | ||||||
'single' => true, | ||||||
'type' => 'boolean', | ||||||
) | ||||||
); | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* Saves optional settings on save | ||||||
* | ||||||
* @param int $post_id Post ID. | ||||||
*/ | ||||||
public static function save_hook( $post_id ) { | ||||||
if ( array_key_exists( 'webmentions_disabled_pings', $_POST ) ) { | ||||||
if ( 1 === intval( $_POST['webmentions_disabled_pings'] ) ) { | ||||||
\add_post_meta( $post_id, 'webmentions_disabled_pings', '1', true ); | ||||||
} else { | ||||||
\delete_post_meta( $post_id, 'webmentions_disabled_pings' ); | ||||||
|
||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php $post_id = get_the_ID(); ?> | ||
<fieldset><ul> | ||
<li> | ||
<input type="hidden" name="webmentions_disabled" value="0" /> | ||
<input type="checkbox" class="widefat" name="webmentions_disabled" id="webmentions_disabled" value="1" <?php checked( 1, get_post_meta( $post_id, 'webmentions_disabled', 1 ) ); ?> /> | ||
<label><?php esc_html_e( 'Disable Incoming', 'webmention' ); ?></label> | ||
<legend><sub><?php _e( 'Do Not Accept incoming Webmentions for this post', 'webmention' ); ?></sub></legend><li> | ||
<li> | ||
<input type="hidden" name="webmentions_disabled_pings" value="0" /> | ||
<input type="checkbox" class="widefat" name="webmentions_disabled_pings" id="webmentions_disabled_pings" value="1" <?php checked( 1, intval( get_post_meta( $post_id, 'webmentions_disabled_pings', 1 ) ) ); ?> /> | ||
<label><?php esc_html_e( 'Disable Outgoing', 'webmention' ); ?></label> | ||
<legend><sub><?php _e( 'Do Not send outgoing Webmentions for this post', 'webmention' ); ?></sub></legend></li> | ||
</fieldset> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
init
function is already triggered on init?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense. I moved the code there and wasn't thinking.