Libsyn Publisher Hub Shortcode

Below, you’ll find a detailed guide on how to add the Libsyn Publisher Hub Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Libsyn Publisher Hub Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Libsyn Publisher Hub Plugin and the shortcodes it provides:

Plugin Icon
Libsyn Publisher Hub

"Libsyn Publisher Hub is a WordPress plugin designed for podcasting. With Libsyn, managing, scheduling, and publishing your podcast content directly to WordPress becomes easy and efficient."

★★★☆✩ (9) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 7.4
Included Shortcodes:
  • [iframe]

Libsyn Publisher Hub [iframe] Shortcode

The ‘iframe’ shortcode from the Libsyn Podcasting plugin is designed to embed a media player into a webpage. It handles various attributes, including source, height, and class, and can adjust the iframe’s height to match a target element. It also includes a download link for the episode, with customizable text. The placement of the player and download link can be set to either the top or bottom. Shortcode: [libsyn_unqprfx_embed_shortcode]

Shortcode: [iframe]

Parameters

Here is a list of all possible iframe shortcode parameters and attributes:

  • src – Defines the source URL of the iframe content.
  • class – Specifies the CSS class for the iframe.
  • same_height_as – Sets the iframe height to match another element.
  • disable_login – Disables the login for the myLibsyn widget.
  • get_params_from_url – Adds parameters from the URL to the iframe source.
  • use_download_link – Enables a download link for the player content.
  • primary_content_url – Sets the primary content URL for the download link.
  • download_link_text – Defines the text for the download link.
  • placement – Specifies the placement of the player download link.

Examples and Usage

Basic example – The following shortcode example embeds a podcast player into a WordPress post or page using the ‘iframe’ shortcode. The ‘src’ attribute is used to specify the source URL of the podcast episode.

[iframe src="https://your-podcast-url.com/episode-1" /]

Advanced examples

Embedding a podcast player with specific height and width. The ‘height’ and ‘width’ attributes allow you to define the size of the player.

[iframe src="https://your-podcast-url.com/episode-1" height="300" width="500" /]

Using the ‘disable_login’ attribute to disable the login feature of the myLibsyn widget. This is useful when you want to prevent users from logging into the widget.

[iframe src="https://your-podcast-url.com/episode-1" disable_login="true" /]

Embedding a podcast player with a download link. The ‘use_download_link’ attribute enables a download link for the podcast episode. The ‘primary_content_url’ attribute is used to specify the download URL of the episode. The ‘download_link_text’ attribute allows you to customize the text of the download link.

[iframe src="https://your-podcast-url.com/episode-1" use_download_link="true" primary_content_url="https://your-podcast-url.com/download/episode-1" download_link_text="Download this episode" /]

Changing the placement of the player. The ‘placement’ attribute allows you to specify the placement of the player. You can set it to ‘top’ to place the player at the top of the content, or ‘bottom’ to place it at the bottom.

[iframe src="https://your-podcast-url.com/episode-1" placement="top" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [iframe] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'iframe', 'libsyn_unqprfx_embed_shortcode' );

Shortcode PHP function:

function libsyn_unqprfx_embed_shortcode( $atts, $content = null ) {
		$defaults = libsyn_unqprfx_shortcode_defaults();

		foreach ( $defaults as $default => $value ) { // add defaults
			if ( ! @array_key_exists( $default, $atts ) ) { // hide warning with "@" when no params at all
				$atts[$default] = $value;
			}
		}

		$src_cut = substr( $atts["src"], 0, 35 ); // special case for google maps
		if( strpos( $src_cut, 'maps.google' ) ){
			$atts["src"] .= '&output=embed';
		}

		//handle myLibsyn widget disable player login
		if ( !empty( get_option('libsyn-podcasting-settings_enable_mylibsyn_widget', false) ) )  {
			$atts['disable_login'] = 'true';
			// $atts['src'] = rtrim($atts['src'], '/') . '/disable_login/true';
		}

		// get_params_from_url
		if ( isset( $atts["get_params_from_url"] ) && ( $atts["get_params_from_url"] == '1' || $atts["get_params_from_url"] == 1 || $atts["get_params_from_url"] == 'true' ) ) {
			if ( $_GET != NULL ) {
				if ( strpos( $atts["src"], '?' ) ) { // if we already have '?' and GET params
					$encode_string = '&';
				} else {
					$encode_string = '?';
				}
				foreach( $_GET as $key => $value ){
					$encode_string .= $key.'='.$value.'&';
				}
			}
			$atts["src"] .= $encode_string;
		}

		$html = '';
		if ( isset( $atts["same_height_as"] ) ) {
			$same_height_as = $atts["same_height_as"];
		} else {
			$same_height_as = '';
		}

		if ( $same_height_as != '' ) {
			$atts["same_height_as"] = '';
			if ( $same_height_as != 'content' ) { // we are setting the height of the iframe like as target element
				if ( $same_height_as == 'document' || $same_height_as == 'window' ) { // remove quotes for window or document selectors
					$target_selector = $same_height_as;
				} else {
					$target_selector = '"' . $same_height_as . '"';
				}
				/* @deprecated 1.3.1
				$html .= '
					<script>
					jQuery(function($){
						var target_height = $(' . $target_selector . ').height();
						$("iframe.' . $atts["class"] . '").height(target_height);
					});
					</script>';
				*/
				$html .= '
					<script>
					var ready = (callback) => {
					  if (document.readyState != "loading") callback();
					  else document.addEventListener("DOMContentLoaded", callback);
					}

					ready(() => {
						var libsyn_iframe_height = ' . $target_selector . '.querySelector("iframe.' . $atts["class"] . '").parentElement.getBoundingClientRect().height;
						' . $target_selector . '.querySelector("iframe.' . $atts["class"] . '").style.height = libsyn_iframe_height;
					});
					</script>';
			} else { // set the actual height of the iframe (show all content of the iframe without scroll)
				/* @deprecated 1.3.1
				$html .= '
					<script>
					jQuery(function($){
						$("iframe.' . $atts["class"] . '").bind("load", function() {
							var embed_height = $(this).contents().find("body").height();
							$(this).height(embed_height);
						});
					});
					</script>';
				*/
				$html .= '
					<script>
					var ready = (callback) => {
					  if (document.readyState != "loading") callback();
					  else document.addEventListener("DOMContentLoaded", callback);
					}

					ready(() => {
						var libsyn_iframe_element = document.querySelector("iframe.' . $atts["class"] . '");
						if ( libsyn_iframe_element.addEventListener ) {
							libsyn_iframe_element.addEventListener("load", function() {
								//var embed_height = libsyn_iframe_element.querySelector("body").getBoundingClientRect().height;
								var embed_height_defined = '.$atts['height'].';
								libsyn_iframe_element.style.height = embed_height_defined;
							}, false);
						}
					});
					</script>';
			}
		}
		$html .= '<iframe style="display:block;" ';
		foreach( $atts as $attr => $value ) {
			if ( $attr != 'same_height_as' ) { // remove some attributes
				if ( $value != '' ) { // adding all attributes
					$html .= ' ' . $attr . '="' . $value . '"';
				} else { // adding empty attributes
					$html .= '';
				}
			}
		}
		$html .= '></iframe>';

		//do player download link
		// @since 1.2.1
		if ( $atts['use_download_link'] && ( $atts['use_download_link'] == "true" || $atts['use_download_link'] == 1 || $atts['use_download_link'] === true || $atts['use_download_link'] == 'use_download_link' ) ) {
			if ( !empty($atts['primary_content_url']) ) {
				$download_url = $atts['primary_content_url'];
			} else {
				$download_url = $atts['src'];
			}
			if ( !empty($atts['download_link_text']) ) {
				$download_link_text = $atts['download_link_text'];
			} else {
				$download_link_text = 'Click here to download the Episode!';
			}

			$player_download_link = '<br /><a class="libsyn-download-link" href ="' . $download_url . '" target="_blank">' . $download_link_text . '</a><br />';
		} else {
			$player_download_link = '';
		}

		//handle player placement
		if ( $atts['placement'] == "top" ) {
			$html = $html.$player_download_link."<br />";
		} else {
			$html = "<br />".$html.$player_download_link;
		}

		return $html;
	}

Code file location:

libsyn-podcasting/libsyn-podcasting/admin/functions.php

Conclusion

Now that you’ve learned how to embed the Libsyn Publisher Hub Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *