• Resolved Myar

    (@myar)


    Hi there,

    after you added the function to stop sending to discord if a post is updated, this plugin didn’t send any post to discord anymore.
    So I have checked your code and in the file class-wp-discord-post-post.php I have changed this:

    On line 84:
    // if ( $post_date < current_time( 'timestamp' ) ) {

    This didn’t worked because after saving the post, the post_date is always older than the current time stamp.

    I added this (line 85):
    if ( $this->is_publish === false ) {

    So this variable has to be declared (line 17):
    private $is_publish = false;

    Alwas false. And now how to check if its published or updated (line 21 to 29):

    public function __construct() {
    		add_action( 'publish_post', array( $this, 'send_post' ), 10, 2 );
    		add_action( 'transition_post_status', function ( $new_status, $old_status, $post )
    		{
    		    if ('publish' === $new_status && 'publish' !== $old_status && 'post' === $post->post_type){
    		        $this->is_publish = true;
    		    }
    		}, 10, 3 );
    	}

    With the hook ‘transition_post_status’ you can check for status.
    Now the plugin is working again. I am not sure if this is the best way but its working. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • This is happening to me. There is an estimative about when this fix will be added to the source?

    Plugin Author Nico

    (@nicolamustone)

    Automattic Happiness Engineer

    Hi @myar and @jozephbrasil,
    sorry for the delay in the reply. I removed the culprit option and replace it with a filter, for now.

    Everything should be working now. Please confirm!

    Plugin Author Nico

    (@nicolamustone)

    Automattic Happiness Engineer

    I didn’t hear back from you, so I’m marking this as resolved! Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fix for your plugin (not sending at publish)’ is closed to new replies.