Codeinwp / tweet-old-post

Plugin to tweet about your old posts to get more hits for them and keep them alive.
GNU General Public License v2.0
13 stars 16 forks source link

Postie posts don't display featured image #926

Closed AndreeaCristinaRadacina closed 3 months ago

AndreeaCristinaRadacina commented 5 months ago

Description

A user that uses Postie to convert emails into WP posts mentions that the posts started to not display the featured image anymore after the latest update.

The only way to make the featured image work is to go to the posts and manually publish them.

Might be related to this - https://github.com/Codeinwp/tweet-old-post-pro/issues/471

Step-by-step reproduction instructions

  1. Configure ROP to share posts on Facebook
  2. Send an email to the admin address from Postie
  3. Check how the posts appear on the Facebook page

Screenshots, screen recording, code snippet or Help Scout ticket

Screenshot 2024-03-01 at 17 22 14 Screenshot 2024-03-01 at 17 19 18

Environment info

No response

Is the issue you are reporting a regression

Yes, this is a regression.

AndreeaCristinaRadacina commented 5 months ago

More details can be found here - https://secure.helpscout.net/conversation/2510363899/404627/

Soare-Robert-Daniel commented 5 months ago

One thing to note here is that user is using a custom script to hook the postie to ROP:

/**
 * Postie post after.
 *
 * @param array $details Post data.
 * @return void
 */
function rop_postie_post_after( $details ) {
    if ( empty( $details['ID'] ) ) {
        return;
    }
    if ( ! class_exists( '\Rop_Admin' ) ) {
        return;
    }
    $rop_admin = new \Rop_Admin();

    $services = new \Rop_Services_Model();
    $settings = new \Rop_Settings_Model();
    $enabled  = array();

    $active                       = array_keys( $services->get_active_accounts() );
    $instant_share_custom_content = array();

    foreach ( $active as $account_id ) {
        $content = ! empty( $details['post_content'] ) ? $details['post_content'] : '';
        $content = strip_shortcodes( $content );
        $content = wp_strip_all_tags( html_entity_decode( $content, ENT_QUOTES ) );
        $content = trim( $content );

        $instant_share_custom_content[ $account_id ] = $content;
    }

    // If user wants to run this operation on page refresh instead of via Cron.
    if ( $settings->get_true_instant_share() ) {
        $rop_admin->rop_cron_job_publish_now( $post_id, $instant_share_custom_content );
        return;
    }

    update_post_meta( $post_id, 'rop_publish_now', 'yes' );
    update_post_meta( $post_id, 'rop_publish_now_accounts', $instant_share_custom_content );

    $cron = new Rop_Cron_Helper();
    $cron->manage_cron( array( 'action' => 'publish-now' ) );
}
add_action( 'postie_post_after', 'rop_postie_post_after' );

Conversation: https://secure.helpscout.net/conversation/2433651127/394480/


The user reported that this script was working until the last release. He reported that the normal workflow for featured images is working but on this custom script.

Also as a side note, the custom script is pretty hacky since it uses the custom content feature to display the post's content instead of normal workflow.

Also, we should implement a simple hook for this type of usage so that people can easily integrate it with ROP.

Soare-Robert-Daniel commented 5 months ago

I checked the script, and it is working. Also, the script can be written as (to be more like the real implementation):

/**
 * Hook the Revive Old Post sharing process to the Postie plugin.
 * 
 * This will mark the post as ready to publish now and start the sharing process.
 *
 * @param array $details Post data.
 * @return void
 */
function rop_postie_post_after( $details ) {

    if ( empty( $details['ID'] ) ) {
        return;
    }

    // Check if the plugin is installed and available.
    if ( ! class_exists( '\Rop_Admin' ) ) {
        return;
    }

    $postie_post_id = $details['ID']; // The ID of the post that was just created by Postie.

         // Pull the options for available Social Media accounts.
    $services = new \Rop_Services_Model();
    $active_social_accounts  = array_keys( $services->get_active_accounts() );
    $accounts_to_share_the_post = array();

        // Add them to the sharing list.
    foreach ( $active_social_accounts as $account_id ) {
        $accounts_to_share_the_post[ $account_id ] = "";
    }

    // Mark the post as ready to publish now and save the list of Social Media accounts to share the post.
    update_post_meta( $postie_post_id, 'rop_publish_now', 'yes' );
    update_post_meta( $postie_post_id, 'rop_publish_now_accounts', $accounts_to_share_the_post );

    $rop_admin = new \Rop_Admin();
    $rop_admin->rop_cron_job_publish_now( $postie_post_id, $accounts_to_share_the_post ); // Start the sharing process. 
}
add_action( 'postie_post_after', 'rop_postie_post_after' );
AndreeaCristinaRadacina commented 5 months ago

@Soare-Robert-Daniel will this solve the issue, or are there any other steps that I have to wait for?

Soare-Robert-Daniel commented 5 months ago

@AndreeaCristinaRadacina, you can share this code the users and see if it makes a difference: https://github.com/Codeinwp/tweet-old-post/issues/926#issuecomment-1985638929

Otherwise, we will need some screenshots of the Revive Old Post plugin settings. For the Postie plugin, we will need screenshots with those tabs:

Image