@@ -23,18 +23,24 @@ public function __construct() {
2323 * @author Alexandre Sadowski
2424 */
2525 public function bea_set_yoast_seo_meta ( array $ data , $ sync_fields , WP_Post $ new_post ) {
26-
27- $ fb_seo_id = (int ) BEA_CSF_Relations::get_object_for_any ( 'attachment ' , $ data ['blogid ' ], $ sync_fields ['_current_receiver_blog_id ' ], $ data ['meta_data ' ]['_yoast_wpseo_opengraph-image-id ' ][0 ], $ data ['meta_data ' ]['_yoast_wpseo_opengraph-image-id ' ][0 ] );
28- if ( ! empty ( $ fb_seo_id ) && (int ) $ fb_seo_id > 0 ) {
29- update_post_meta ( $ new_post ->ID , '_yoast_wpseo_opengraph-image-id ' , (string )$ fb_seo_id );
26+ $ fb_image_meta = isset ($ data ['meta_data ' ]['_yoast_wpseo_opengraph-image-id ' ]) ? $ data ['meta_data ' ]['_yoast_wpseo_opengraph-image-id ' ] : null ;
27+ if ( ! empty ( $ fb_image_meta ) && isset ( $ fb_image_meta [0 ] ) ) {
28+ $ fb_seo_id = (int ) BEA_CSF_Relations::get_object_for_any ( 'attachment ' , $ data ['blogid ' ], $ sync_fields ['_current_receiver_blog_id ' ], $ fb_image_meta [0 ], $ fb_image_meta [0 ] );
29+
30+ if ( ! empty ( $ fb_seo_id ) && (int ) $ fb_seo_id > 0 ) {
31+ update_post_meta ( $ new_post ->ID , '_yoast_wpseo_opengraph-image-id ' , (string ) $ fb_seo_id );
32+ }
3033 }
3134
32- $ twitter_seo_id = (int ) BEA_CSF_Relations::get_object_for_any ( 'attachment ' , $ data ['blogid ' ], $ sync_fields ['_current_receiver_blog_id ' ], $ data ['meta_data ' ]['_yoast_wpseo_twitter-image-id ' ][0 ], $ data ['meta_data ' ]['_yoast_wpseo_twitter-image-id ' ][0 ] );
33- if ( ! empty ( $ twitter_seo_id ) && (int ) $ twitter_seo_id > 0 ) {
34- update_post_meta ( $ new_post ->ID , '_yoast_wpseo_twitter-image-id ' , (string )$ twitter_seo_id );
35+ $ twitter_image_meta = isset ($ data ['meta_data ' ]['_yoast_wpseo_twitter-image-id ' ]) ? $ data ['meta_data ' ]['_yoast_wpseo_twitter-image-id ' ] : null ;
36+ if ( ! empty ( $ twitter_image_meta ) && isset ( $ twitter_image_meta [0 ] ) ) {
37+ $ twitter_seo_id = (int ) BEA_CSF_Relations::get_object_for_any ( 'attachment ' , $ data ['blogid ' ], $ sync_fields ['_current_receiver_blog_id ' ], $ twitter_image_meta [0 ], $ twitter_image_meta [0 ] );
38+
39+ if ( ! empty ( $ twitter_seo_id ) && (int ) $ twitter_seo_id > 0 ) {
40+ update_post_meta ( $ new_post ->ID , '_yoast_wpseo_twitter-image-id ' , (string ) $ twitter_seo_id );
41+ }
3542 }
3643
3744 return $ data ;
3845 }
39-
4046}
0 commit comments