Helper; if ( $Helper->is_hidden( $data ) || ! $Helper->admin_view( $data ) ) { return ''; } $name = 'social_media_link'; // Changed from '_social_media_link' to match listing-add.php $label = isset( $label ) ? $label : __( 'Social Media Links', 'adirectory' ); $placeholder = isset( $placeholder ) ? $placeholder : ''; // Get the saved value from post meta $value = ! empty( get_post_meta( $post_id, 'adqs_social_media_link', true ) ) ? get_post_meta( $post_id, 'adqs_social_media_link', true ) : ''; // Parse existing value if it's JSON $social_links = []; if ( ! empty( $value ) && is_string( $value ) ) { $decoded = json_decode( $value, true ); if ( is_array( $decoded ) ) { $social_links = $decoded; } } // If no existing data, create a default empty structure if ( empty( $social_links ) ) { $social_links = [ [ 'icon' => 'fab fa-facebook', 'label' => 'Facebook', 'url' => '', ], ]; } // Ensure all social links have the required structure foreach ( $social_links as $index => $link ) { if ( ! isset( $link['icon'] ) ) { $social_links[ $index ]['icon'] = 'fab fa-facebook'; } if ( ! isset( $link['label'] ) ) { $social_links[ $index ]['label'] = ''; } if ( ! isset( $link['url'] ) ) { $social_links[ $index ]['url'] = ''; } } ?>