| @@ -712,5 +712,48 @@ | ||
| 712 | 712 | <# } ); #> |
| 713 | 713 | </div> |
| 714 | 714 | <?php |
| 715 | 715 | } |
| 716 | + | |
| 717 | + public function render_markdown(): string { | |
| 718 | + $settings = $this->get_settings_for_display(); | |
| 719 | + if ( empty( $settings['social_icon_list'] ) ) { | |
| 720 | + return ''; | |
| 721 | + } | |
| 722 | + | |
| 723 | + $migration_allowed = Icons_Manager::is_migration_allowed(); | |
| 724 | + $links = []; | |
| 725 | + | |
| 726 | + foreach ( $settings['social_icon_list'] as $item ) { | |
| 727 | + $url = $item['link']['url'] ?? ''; | |
| 728 | + if ( empty( $url ) ) { | |
| 729 | + continue; | |
| 730 | + } | |
| 731 | + | |
| 732 | + $migrated = isset( $item['__fa4_migrated']['social_icon'] ); | |
| 733 | + $is_new = empty( $item['social'] ) && $migration_allowed; | |
| 734 | + $social = ''; | |
| 735 | + | |
| 736 | + if ( ! empty( $item['social'] ) ) { | |
| 737 | + $social = str_replace( 'fa fa-', '', $item['social'] ); | |
| 738 | + } | |
| 739 | + | |
| 740 | + if ( ( $is_new || $migrated ) && 'svg' !== ( $item['social_icon']['library'] ?? '' ) ) { | |
| 741 | + $parts = explode( ' ', $item['social_icon']['value'] ?? '', 2 ); | |
| 742 | + $social = ! empty( $parts[1] ) ? str_replace( 'fa-', '', $parts[1] ) : ''; | |
| 743 | + } | |
| 744 | + | |
| 745 | + if ( 'svg' === ( $item['social_icon']['library'] ?? '' ) ) { | |
| 746 | + $social = get_post_meta( $item['social_icon']['value']['id'] ?? 0, '_wp_attachment_image_alt', true ); | |
| 747 | + } | |
| 748 | + | |
| 749 | + $label = ucwords( str_replace( '-', ' ', $social ) ); | |
| 750 | + if ( empty( $label ) ) { | |
| 751 | + $label = 'Link'; | |
| 752 | + } | |
| 753 | + | |
| 754 | + $links[] = '- [' . $label . '](' . esc_url( $url ) . ')'; | |
| 755 | + } | |
| 756 | + | |
| 757 | + return implode( "\n", $links ); | |
| 758 | + } | |
| 716 | 759 | } |