My theme contains support for featured image and gallery. I found following in my theme
add_action( 'job_manager_update_job_data', array( $this, 'save_featured_image' ), 10, 2 );
add_action( 'job_manager_update_job_data', array( $this, 'save_gallery_images' ), 10, 2 );
and using debugger, I found that these are called, but the following functions contained in same file never get called, thus even though the images are uploaded and attached to listing, they aren’t set as featured/listing gallery images.
public function save_featured_image( $job_id, $values ) {
$attachment_url = $values[ 'job' ][ 'featured_image' ];
$attach_id = listify_get_attachment_id_by_url( $attachment_url );
if ( $attach_id != get_post_thumbnail_id( $job_id ) ) {
set_post_thumbnail( $job_id, $attach_id );
} elseif( '' == $attachment_url && has_post_thumbnail( $job_id ) ) {
delete_post_thumbnail( $job_id );
}
}
public function save_gallery_images( $job_id, $values ) {
$images = $values[ 'job' ][ 'gallery_images' ];
if ( ! isset( $images ) || empty( $images ) ) {
return;
}
$gallery = array();
foreach ( $images as $image ) {
$gallery[] = listify_get_attachment_id_by_url( $image );
}
$gallery = implode( ',', $gallery );
$shortcode = '[gallery ids=' . $gallery . ']';
update_post_meta( $job_id, '_gallery', $shortcode );
}
Edit: Nevermind, the function listify_get_attachment_id_by_url doesn’t seem to be working. Looks like I need to debug it myself or contact Astoundify.