Skip to content
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

Add Autoshare For Twitter Support #221

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

elvismdev
Copy link

This hook in the Syndication Links plugin creates a conflict with the ongoing Autoshare for X + Syndication Links integration currently in progress at 10up/autoshare-for-twitter#331.

Incomplete Tweet URLs, such as https://twitter.com/i/web/status/, are being generated and added because the Syndication Links plugin hooks into autoshare_for_twitter_after_status_update to handle the same functionality being developed in the Autoshare for Twitter plugin PR.

Additionally, this implementation contains a bug in the variable names – it attempts to use the undefined variable $tweet_status, leaving $data unused.

Finally, by using add_post_syndication_link( $post->ID, $url ), it does not account for saving syndication link metadata in custom post types. This contrasts with using \Syn_Meta::add_syndication_link( $type, $post_id, $uri );, which allows specifying the post type object where the metadata should be saved through the $type parameter.

@dshanske
Copy link
Owner

dshanske commented Jan 6, 2025

This is great... I will dig in in further detail and review.

… Leveraging on the updated hook autoshare_for_twitter_post_tweet_status_updated which passes post_id and tweet_meta.
@elvismdev elvismdev changed the title Remove faulty integration with Autoshare for Twitter Add Autoshare For Twitter Support Jan 21, 2025
@elvismdev
Copy link
Author

Hey @dshanske ,

After chatting with the rest of my team, we've concluded that it makes more sense to move this Autoshare for Twitter integration directly into the Syndication Links plugin itself. The newly added parameters, $post_id and $tweet_meta, should provide a straightforward way for any function hooked into autoshare_for_twitter_post_tweet_status_updated to manage its own integration flow, without conflicting or duplicating logic elsewhere.

That said, I’m still encountering the same odd results I mentioned here in the Autoshare for Twitter plugin PR: the first tweet never seems to get stored in the mf2_syndication meta on initial post publish, but then the second (and subsequent) tweets always do. The debug logs show Syn_Meta::add_syndication_link returning success each time, but the metakey and its value only appear in the database after that second tweet is posted.

[21-Jan-2025 10:29:23 UTC] Starting handle_syndication_after_tweet_status_updated
[21-Jan-2025 10:29:23 UTC] Post ID: 140
[21-Jan-2025 10:29:23 UTC] Tweet Meta: Array
(
    [0] => Array
        (
            [status] => published
            [twitter_id] => 1881650291243884724
            [handle] => 10uptestdev
            [created_at] => 2025-01-21T10:29:23+00:00
        )

)

[21-Jan-2025 10:29:23 UTC] Processed tweets array: Array
(
    [0] => Array
        (
            [status] => published
            [twitter_id] => 1881650291243884724
            [handle] => 10uptestdev
            [created_at] => 2025-01-21T10:29:23+00:00
        )

)

[21-Jan-2025 10:29:23 UTC] Processing tweet: Array
(
    [status] => published
    [twitter_id] => 1881650291243884724
    [handle] => 10uptestdev
    [created_at] => 2025-01-21T10:29:23+00:00
)

[21-Jan-2025 10:29:23 UTC] Tweet is published and has twitter_id
[21-Jan-2025 10:29:23 UTC] Twitter ID: 1881650291243884724
[21-Jan-2025 10:29:23 UTC] Generated URI: https://twitter.com/10uptestdev/status/1881650291243884724
[21-Jan-2025 10:29:23 UTC] URI is valid, calling add_syndication_link
[21-Jan-2025 10:29:23 UTC] Post type: post
[21-Jan-2025 10:29:23 UTC] Final URI being added: https://twitter.com/10uptestdev/status/1881650291243884724
[21-Jan-2025 10:29:24 UTC] []
[21-Jan-2025 10:44:01 UTC] Starting handle_syndication_after_tweet_status_updated
[21-Jan-2025 10:44:01 UTC] Post ID: 140
[21-Jan-2025 10:44:01 UTC] Tweet Meta: Array
(
    [0] => Array
        (
            [status] => published
            [twitter_id] => 1881650291243884724
            [handle] => 10uptestdev
            [created_at] => 2025-01-21T10:29:23+00:00
        )

    [1] => Array
        (
            [status] => published
            [twitter_id] => 1881653973373100512
            [handle] => 10uptestdev
            [created_at] => 2025-01-21T10:44:01+00:00
        )

)

[21-Jan-2025 10:44:01 UTC] Processed tweets array: Array
(
    [0] => Array
        (
            [status] => published
            [twitter_id] => 1881650291243884724
            [handle] => 10uptestdev
            [created_at] => 2025-01-21T10:29:23+00:00
        )

    [1] => Array
        (
            [status] => published
            [twitter_id] => 1881653973373100512
            [handle] => 10uptestdev
            [created_at] => 2025-01-21T10:44:01+00:00
        )

)

[21-Jan-2025 10:44:01 UTC] Processing tweet: Array
(
    [status] => published
    [twitter_id] => 1881650291243884724
    [handle] => 10uptestdev
    [created_at] => 2025-01-21T10:29:23+00:00
)

[21-Jan-2025 10:44:01 UTC] Tweet is published and has twitter_id
[21-Jan-2025 10:44:01 UTC] Twitter ID: 1881650291243884724
[21-Jan-2025 10:44:01 UTC] Generated URI: https://twitter.com/10uptestdev/status/1881650291243884724
[21-Jan-2025 10:44:01 UTC] URI is valid, calling add_syndication_link
[21-Jan-2025 10:44:01 UTC] Post type: post
[21-Jan-2025 10:44:01 UTC] Final URI being added: https://twitter.com/10uptestdev/status/1881650291243884724
[21-Jan-2025 10:44:01 UTC] Processing tweet: Array
(
    [status] => published
    [twitter_id] => 1881653973373100512
    [handle] => 10uptestdev
    [created_at] => 2025-01-21T10:44:01+00:00
)

[21-Jan-2025 10:44:01 UTC] Tweet is published and has twitter_id
[21-Jan-2025 10:44:01 UTC] Twitter ID: 1881653973373100512
[21-Jan-2025 10:44:01 UTC] Generated URI: https://twitter.com/10uptestdev/status/1881653973373100512
[21-Jan-2025 10:44:01 UTC] URI is valid, calling add_syndication_link
[21-Jan-2025 10:44:01 UTC] Post type: post
[21-Jan-2025 10:44:01 UTC] Final URI being added: https://twitter.com/10uptestdev/status/1881653973373100512

Would you mind giving these latest changes a try whenever you have a chance? I would greatly appreciate any guidance or insights into what might be causing that metadata not to persist after the first publication, despite Syn_Meta::add_syndication_link being called properly with the necessary data it needs. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants