Giter Club home page Giter Club logo

Comments (7)

janboddez avatar janboddez commented on August 16, 2024 1

I know that, with Gutenberg, the action is run at least twice.

I'm guessing the first time, wp_is_post_revision( $post->ID ) || wp_is_post_autosave( $post->ID ) is somehow true, and the second time, it sees an update and decides not to crosspost.

from share-on-mastodon.

janboddez avatar janboddez commented on August 16, 2024

You could, potentially, prevent older posts from being shared (at all). Untested, but this may work (I mean, it's just an idea):

add_filter( 'share_on_mastodon_enabled', function( $is_enabled, $post_id ) {
  if ( get_post_timestamp( $post_id ) < strtotime( '2022-11-27' ) ) {
    return false;
  }

  return $is_enabled;
}, 10, 2 );

Should not affect any newer posts. (Note: get_post_timestamp() was introduced in WP 5.3.)

I could also limit sharing to when a post is first published by comparing its new post status with the previous one, but this is tricky. The old status could be non-existent, or draft, or even trashed. Plus, I kinda like that I can go back and syndicate old posts (kind of like "retweeting" your old stuff) when I feel like it. (I mean, I could've always done that, manually, but if I let the plugin do it [again], it stores the syndication link for me, which I can then display on my site, and so on.)

from share-on-mastodon.

janboddez avatar janboddez commented on August 16, 2024

Oh, and it is of course possible to just untick the checkbox ... :-)

If I'm going back and editing an old post, I wouldn't normally expect updating a change to trigger publication on Mastodon.

Or have it disabled by default (so that it would only syndicate after you explicitly checking it):

add_filter( 'share_on_mastodon_optin', '__return_true' );

from share-on-mastodon.

placoderm avatar placoderm commented on August 16, 2024

Thanks. I can see that the best solution would be for me to pay better attention to what I'm doing. I understand now why it works the way it does and how changing that doesn't look easy.

Great plugin!

from share-on-mastodon.

janboddez avatar janboddez commented on August 16, 2024

I'm going to reinvestigate this, comparing post dates to the most recent plugin activation date (or similar). But that approach still won't prevent "3rd-party" posts from being mass-crossposted if (1) share always is enabled programmatically AND (2) these posts were first published after the plugin was (re)activated AND (3) they are later on mass-updated.

But it would (I think?) override "Share Always" and the checkbox---this is a risk, as we'd basically be overriding site authors' choices here---for posts deemed too old.

from share-on-mastodon.

janboddez avatar janboddez commented on August 16, 2024

Current implementation fails with Gutenberg.

from share-on-mastodon.

janboddez avatar janboddez commented on August 16, 2024

Some quick logging

[06-Apr-2023 14:38:22 UTC] transition_post_status
[06-Apr-2023 14:38:22 UTC] New status: auto-draft
[06-Apr-2023 14:38:22 UTC] Old status: new

<< This must be where I click publish >>
[06-Apr-2023 14:38:35 UTC] transition_post_status
[06-Apr-2023 14:38:35 UTC] New status: publish
[06-Apr-2023 14:38:35 UTC] Old status: auto-draft
[06-Apr-2023 14:38:35 UTC] transition_post_status
[06-Apr-2023 14:38:35 UTC] New status: publish
[06-Apr-2023 14:38:35 UTC] Old status: publish
[06-Apr-2023 14:38:35 UTC] Not a new message

from share-on-mastodon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.