Another. This time when broadcasting:
Undefined property: threewp_broadcast\broadcasting_data::$attachment_id in /path/to/wp-content/plugins/threewp-broadcast/ThreeWP_Broadcast.php on line 2131
This line is the culprit:
$a->new = get_post( $o->attachment_id );
in this block:
foreach( $bcd->attachment_data as $key => $attachment )
{
if ( $key != 'thumbnail' )
{
$o = clone( $bcd );
$o->attachment_data = $attachment;
if ( $o->attachment_data->post->post_parent > 0 )
$o->attachment_data->post->post_parent = $bcd->new_post[ 'ID' ];
$this->maybe_copy_attachment( $o );
$a = new \stdClass();
$a->old = $attachment;
if ( !empty($o->attachment_id) )
$a->new = get_post( $o->attachment_id );
else
$a->new = null;
$bcd->copied_attachments[] = $a;
}
}
Now I haven’t dug deep enough to figure out exactly what’s going on here. But I guess your options are to either it to:
if ( !empty($o->attachment_id) )
$a->new = get_post( $o->attachment_id );
else
$a->new = null;
which then presents a problem in that it leads to a few more issues where you’re calling ->new->guid
which doesn’t exist…
Line 2148 change
foreach( $bcd->copied_attachments as $a )
{
// Replace the GUID with the new one.
$modified_post->post_content = str_replace( $a->old->guid, $a->new->guid, $modified_post->post_content );
// And replace the IDs present in any image captions.
$modified_post->post_content = str_replace( 'id="attachment_' . $a->old->id . '"', 'id="attachment_' . $a->new->id . '"', $modified_post->post_content );
}
to
foreach( $bcd->copied_attachments as $a )
{
if ( !$a->new )
continue;
// Replace the GUID with the new one.
$modified_post->post_content = str_replace( $a->old->guid, $a->new->guid, $modified_post->post_content );
// And replace the IDs present in any image captions.
$modified_post->post_content = str_replace( 'id="attachment_' . $a->old->id . '"', 'id="attachment_' . $a->new->id . '"', $modified_post->post_content );
}
and line 2171ish change
foreach( $bcd->copied_attachments as $ca )
{
if ( $ca->old->id != $id )
continue;
$new_ids[] = $ca->new->ID;
}
to
foreach( $bcd->copied_attachments as $ca )
{
if ( $ca->new && $ca->old->id != $id )
continue;
$new_ids[] = $ca->new->ID;
}
———-
Alternatively you could simply not add $a to the copied_attachments list if it doesn’t exist. Back up at line 2120 change
$bcd->copied_attachments[] = $a;
to
if ( $a->new )
$bcd->copied_attachments[] = $a;
Please enable WP_DEBUG to see these errors.