2
0
Fork 0
mirror of https://github.com/discourse/wp-discourse.git synced 2025-10-03 08:59:21 +08:00

Remove legacy setting (#554)
Some checks are pending
WP-Discourse Formatting / Formatting on PHP 5.6 (push) Waiting to run
WP-Discourse Formatting / Formatting on PHP 7.0 (push) Waiting to run
WP-Discourse Formatting / Formatting on PHP 7.4 (push) Waiting to run
WP-Discourse Formatting / Formatting on PHP 8.0 (push) Waiting to run
WP-Discourse Tests / Tests on PHP 8.2 (push) Waiting to run

'Match Posts by Title' has not be of utility for some years now. It's use of deprecated wp functions is the precipitating cause of its removal
This commit is contained in:
Angus McLeod 2025-09-29 17:22:07 +01:00 committed by GitHub
parent b87610d6d3
commit 4181491e51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 0 additions and 84 deletions

View file

@ -391,23 +391,6 @@ class NetworkOptions {
);
}

/**
* Outputs markup for webhook-match-old-topics input.
*/
public function webhook_match_old_topics_checkbox() {
$this->checkbox_input(
'webhook-match-old-topics',
__(
'Match WordPress posts with Discourse topics by title.',
'wp-discourse'
),
__(
'Sync Comment Data will attempt to match posts to topics by title if other methods of matching have not worked.',
'wp-discourse'
)
);
}

/**
* Outputs markup for use-discourse-user-webhook checkbox.
*/

View file

@ -79,17 +79,6 @@ class WebhookSettings {
'discourse_webhook_settings_section'
);

add_settings_field(
'discourse_webhook_match_old_topics',
__( 'Match Posts by Title', 'wp-discourse' ),
array(
$this,
'webhook_match_old_topics_checkbox',
),
'discourse_webhook',
'discourse_webhook_settings_section'
);

add_settings_field(
'discourse_use_discourse_user_webhook',
__( 'Update Userdata', 'wp-discourse' ),
@ -182,24 +171,6 @@ class WebhookSettings {
);
}

/**
* Outputs markup for webhook-match-old-topics input.
*/
public function webhook_match_old_topics_checkbox() {
$this->form_helper->checkbox_input(
'webhook-match-old-topics',
'discourse_webhook',
__(
'Match WordPress posts with Discourse topics by title.',
'wp-discourse'
),
__(
'Sync Comment Data will attempt to match posts to topics by title if other methods of matching have not worked.',
'wp-discourse'
)
);
}

/**
* Outputs markup for use-discourse-user-webhook checkbox.
*/

View file

@ -124,7 +124,6 @@ class Discourse {
protected $discourse_webhook = array(
'use-discourse-webhook' => 0,
'webhook-secret' => '',
'webhook-match-old-topics' => 0,
'use-discourse-user-webhook' => 0,
'webhook-match-user-email' => 0,
);

View file

@ -174,14 +174,6 @@ class SyncDiscourseTopic extends DiscourseBase {

$post_ids = $this->get_post_ids_from_topic_id( $topic_id );

// For matching posts that were published before the plugin was saving the discourse_topic_id as post_metadata.
if ( ! $post_ids && ! empty( $this->options['webhook-match-old-topics'] ) ) {
$post_id = $this->get_post_id_by_title( $post_title, $topic_id );
if ( $post_id ) {
$post_ids[] = $post_id;
}
}

if ( $post_ids ) {
foreach ( $post_ids as $post_id ) {
update_post_meta( $post_id, 'wpdc_sync_post_comments', 1 );
@ -244,35 +236,6 @@ class SyncDiscourseTopic extends DiscourseBase {
return null;
}

/**
* Tries to match a WordPress post with a Discourse topic by the topic title.
*
* This function is used to match posts that have been published through the WP Discourse plugin prior to version 1.4.0
* with their associated Discourse topics. It assumes that the posts are using the 'post' type. There is a filter
* available to change the post type. There's also an action that can be hooked into if you'd like to try to match
* more than one post type.
*
* @param string $title The topic_title returned from Discourse.
* @param int $topic_id The topic_id returned from Discourse.
*
* @return int|null
*/
protected function get_post_id_by_title( $title, $topic_id ) {
$id = null;
$title = strtolower( $title );
$post_type = apply_filters( 'wpdc_webhook_get_page_by_title_post_type', 'post' );
$post = get_page_by_title( $title, 'OBJECT', $post_type );
if ( $post && ! is_wp_error( $post ) ) {
$id = $post->ID;
// Update the 'discourse_topic_id' metadata so that it can be used on the next webhook request.
update_post_meta( $id, 'discourse_topic_id', $topic_id );
}

do_action( 'wpdc_webhook_after_get_page_by_title', $title );

return $id;
}

/**
* Tries to find a WordPress posts that are associated with a Discourse topic_id.
*