ActionsGenerator.php
9 months ago
AddRatingGenerator.php
1 year ago
CourseMetaGenerator.php
9 months ago
ElementGenerator.php
1 year ago
MaterialGenerator.php
1 year ago
Preview.php
1 year ago
PriceGenerator.php
9 months ago
SocialLinkGenerator.php
1 year ago
ThumbnailGenerator.php
1 year ago
SocialLinkGenerator.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Preview script for html markup generator |
| 5 | * |
| 6 | * @package tutor-droip-elements |
| 7 | */ |
| 8 | |
| 9 | namespace TutorLMSDroip\ElementGenerator; |
| 10 | |
| 11 | use Tutor\Models\CourseModel; |
| 12 | |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit; // Exit if accessed directly. |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Class SocialLinkGenerator |
| 19 | * This class is used to define all helper functions. |
| 20 | */ |
| 21 | trait SocialLinkGenerator { |
| 22 | |
| 23 | /** |
| 24 | * Generate social link markup |
| 25 | * |
| 26 | * @return string |
| 27 | */ |
| 28 | private function generate_social_link_markup() { |
| 29 | $settings = isset( $this->element['properties']['settings'] ) ? $this->element['properties']['settings'] : array(); |
| 30 | $social_type = isset( $settings['social_link_type'] ) ? $settings['social_link_type'] : 'facebook'; |
| 31 | $target = isset( $settings['target'] ) && $settings['target'] ? '_blank' : ''; |
| 32 | $user_id = isset( $this->options['user'] ) ? $this->options['user']['ID'] : false; |
| 33 | $link = $this->get_social_link( $social_type, $user_id, $this->options ); |
| 34 | return "<a $this->attributes href=$link target=$target>" . $this->generate_child_elements() . '</a>'; |
| 35 | } |
| 36 | |
| 37 | |
| 38 | public function get_social_link( $social_type, $id, $options = array() ) { |
| 39 | $user_id = $id; |
| 40 | if ( isset( $options['user'] ) && isset( $options['user']['ID'] ) ) { |
| 41 | $user_id = $options['user']['ID']; |
| 42 | } |
| 43 | $url = get_user_meta( $user_id, '_tutor_profile_' . $social_type, true ); |
| 44 | return $url ? $url : '#'; |
| 45 | } |
| 46 | } |
| 47 |