Helper; if ( $Helper->is_hidden( $data ) || ! $Helper->admin_view( $data ) ) { return ''; } $label = $Helper->get_data( $data, 'label', esc_html__( 'Social Media Links', 'adirectory' ) ); $name = '_social_media_link'; $placeholder = $Helper->get_data( $data, 'placeholder' ); $value = $Helper->meta_val( $post_id, 'adqs_social_media_link' ); // 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'] = ''; } } ?>