MP_ShareIcons

Class MP_ShareIcons


Source Source

File: mortgage-platform/Inc/MP_ShareIcons.php

class MP_ShareIcons {



	/**
	 * Social icons.
	 * @since  1.0.0
	 * @access public
	 * @return mixed
	 */
	public function social_share() {

		if ( isset(  get_option(MortgagePlatform::$prefix.'style')['social_share'] ) &&
			 ! empty( get_option( MortgagePlatform::$prefix . 'mortgage_calculator' )['calculator_url'] ) &&
			 ( isset(  get_option(MortgagePlatform::$prefix.'style')['social_icon_facebook'] ) ||
			   isset(  get_option(MortgagePlatform::$prefix.'style')['social_icon_twitter'] ) ||
			   isset(  get_option(MortgagePlatform::$prefix.'style')['social_icon_pinterest'] ) ||
			   isset(  get_option(MortgagePlatform::$prefix.'style')['social_icon_linkedin'] ) ||
			   isset(  get_option(MortgagePlatform::$prefix.'style')['social_icon_reddit'] ) ||
			   ( isset(  get_option(MortgagePlatform::$prefix.'style')['social_icon_email'] ) &&
				 ! empty(  get_option(MortgagePlatform::$prefix.'style')['social_icon_email_text'] ) )
			 )
		) {

			if ( get_option( MortgagePlatform::$prefix . 'mortgage_calculator' )['calculator_url'] &&  get_option(MortgagePlatform::$prefix.'style')['bitly'] && ! empty(  get_option(MortgagePlatform::$prefix.'style')['bitly_API'] ) && ! empty(  get_option(MortgagePlatform::$prefix.'style')['bitly_user'] ) ) {
				$url                = esc_url( get_option( MortgagePlatform::$prefix . 'mortgage_calculator' )['calculator_url'] );
				$bitly              = new MP_Bitly();
				$social['shareURL'] = $bitly->get_short( $url );
			} else {
				$social['shareURL'] = esc_url( get_option( MortgagePlatform::$prefix . 'mortgage_calculator' )['calculator_url'] );
			}

			if ( isset( get_option(MortgagePlatform::$prefix.'style')['social_icon_facebook'] ) ) {
				$social['facebook'] = esc_attr( get_option(MortgagePlatform::$prefix.'style')['social_icon_facebook'] );
			}
			if ( isset( get_option(MortgagePlatform::$prefix.'style')['social_icon_twitter'] ) ) {
				$social['twitter'] = esc_attr( get_option(MortgagePlatform::$prefix.'style')['social_icon_twitter'] );
			}
			if ( isset( get_option(MortgagePlatform::$prefix.'style')['social_icon_pinterest'] ) ) {
				$social['pinterest'] = esc_attr( get_option(MortgagePlatform::$prefix.'style')['social_icon_pinterest'] );
			}
			if ( isset( get_option(MortgagePlatform::$prefix.'style')['social_icon_linkedin'] ) ) {
				$social['linkedin'] = esc_attr( get_option(MortgagePlatform::$prefix.'style')['social_icon_linkedin'] );
			}
			if ( isset( get_option(MortgagePlatform::$prefix.'style')['social_icon_reddit'] ) ) {
				$social['reddit'] = esc_attr( get_option(MortgagePlatform::$prefix.'style')['social_icon_reddit'] );
			};
			if ( isset( get_option(MortgagePlatform::$prefix.'style')['social_icon_email'] ) && ! empty( get_option(MortgagePlatform::$prefix.'style')['social_icon_email_text'] ) ) {
				$social['email']      = esc_attr( get_option(MortgagePlatform::$prefix.'style')['social_icon_email'] );
				$social['email_text'] = esc_attr( get_option(MortgagePlatform::$prefix.'style')['social_icon_email_text'] );
			}

			if ( isset( get_option(MortgagePlatform::$prefix.'style')['social_icon_pinterest'] ) ) {
				if ( ! empty( get_option(MortgagePlatform::$prefix.'style')['social_image'] ) ) {
					$social['shareThumbnail'] = esc_url( get_option(MortgagePlatform::$prefix.'style')['social_image'] );
				} else {
					$social['shareThumbnail'] = esc_url( plugins_url( '../assets/img/AnnuityCalculator.png', __FILE__ ) );
				}
			}
		} else {
			$social = null;
		}

		return $social;

	}


	/**
	 * Output meta tags.
	 * @since  1.0.0
	 * @access public
	 */
	public function social_meta_tags() {

		if ( ! empty( get_option(MortgagePlatform::$prefix.'style')['social_image'] ) ) {
			$social['shareThumbnail'] =  get_option(MortgagePlatform::$prefix.'style')['social_image'];
		} else {
			$social['shareThumbnail'] = plugins_url( '/Calculators/assets/img/MortgageCalculator.png', __FILE__ );
		}

		// Twitter specific
		echo '<meta name="twitter:card" 		content="summary_large_image" />';

		// Meta tags for Open Graph
		echo '<meta property="og:url"			content="' . esc_url( get_option( MortgagePlatform::$prefix . 'mortgage_calculator' )['calculator_url'] ) . '" />';
		echo '<meta property="og:type"			content="article" />';
		echo '<meta property="og:title"			content="' . esc_attr( get_option(MortgagePlatform::$prefix.'style')['social_title'] ) . '" />';
		echo '<meta property="og:description" 	content="' . esc_attr( get_option(MortgagePlatform::$prefix.'style')['social_description'] ) . '" />';
		echo '<meta property="og:image" content="' . esc_url( $social['shareThumbnail'] ) . '" />';

	}


}

Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.