Slim Jetpack Shortcodes

Below, you’ll find a detailed guide on how to add the Slim Jetpack Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Slim Jetpack Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Slim Jetpack Plugin and the shortcodes it provides:

Plugin Icon
Slim Jetpack

"Slim Jetpack is a streamlined WordPress plugin that enhances your site with powerful features. It's a lighter version of Jetpack, offering essential tools without slowing down performance."

★★★★✩ (24) Active Installs: 3000+ Tested with: 3.7.41 PHP Version: false
Included Shortcodes:
  • [contact-field]
  • [latex]
  • [archives]
  • [bandcamp]
  • [blip.tv]
  • [dailymotion]
  • [digg]
  • [facebook]
  • [flickr]
  • [googlemaps]
  • [googleplus]
  • [googlevideo]
  • [polldaddy]
  • [presentation]
  • [slide]
  • [scribd]
  • [slideshare]
  • [slideshow]
  • [soundcloud]
  • [ted]
  • [twitter-timeline]
  • [vimeo]
  • [vine]
  • [youtube]

Slim Jetpack Shortcode

The Slimjetpack plugin’s ‘gallery’ shortcode is used to create a customizable image gallery. It allows sorting images by specific criteria, including or excluding images, and enabling a slideshow. It extracts attributes like ‘order’, ‘orderby’, ‘id’, ‘include’, ‘exclude’, and ‘slideshow’ from the shortcode. The ‘win8_gallery_shortcode’ function is then used to create the gallery. It also adds a custom image size ‘win8app-column’ to the gallery. The shortcode retrieves image attachments based on the provided attributes and generates a gallery. If a caption is present, it’s added below the image.

Shortcode:

Parameters

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

  • order – determines the sort sequence of the images
  • orderby – specifies the field to sort the images by
  • id – unique identifier of the post
  • include – list of image IDs to be included in the gallery
  • exclude – list of image IDs to be excluded from the gallery
  • slideshow – whether to display the gallery as a slideshow

Examples and Usage

Basic example – Display a gallery with images attached to the post.

Advanced examples

Display a gallery with specific images, ordered randomly. The images are selected by their IDs.

Display a gallery with images attached to a specific post, excluding certain images. The post and images are selected by their IDs.

Display a gallery as a slideshow with images attached to the current post, ordered by menu order and ID.

These examples demonstrate the flexibility of the gallery shortcode. It can be used to display images attached to a post or specific images, and it can control the order in which they appear. The slideshow option adds even more possibilities for presenting images.

PHP Function Code

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

Shortcode line:

add_shortcode( 'gallery', array( &$this, 'win8_gallery_shortcode' ) );

Shortcode PHP function:

                    function win8_gallery_shortcode( $attr ) {
		global $post;

		static $instance = 0;
		$instance++;

		$output = '';

		// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
		if ( isset( $attr['orderby'] ) ) {
			$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
			if ( !$attr['orderby'] )
				unset( $attr['orderby'] );
		}

		extract( shortcode_atts( array(
			'order'     => 'ASC',
			'orderby'   => 'menu_order ID',
			'id'        => $post->ID,
			'include'   => '',
			'exclude'   => '',
			'slideshow' => false
		), $attr ) );

		// Custom image size and always use it
		add_image_size( 'win8app-column', 480 );
		$size = 'win8app-column';

		$id = intval( $id );
		if ( 'RAND' === $order )
			$orderby = 'none';

		if ( !empty( $include ) ) {
			$include      = preg_replace( '/[^0-9,]+/', '', $include );
			$_attachments = get_posts( array( 'include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) );
			$attachments  = array();
			foreach ( $_attachments as $key => $val ) {
				$attachments[$val->ID] = $_attachments[$key];
			}
		} elseif ( !empty( $exclude ) ) {
			$exclude     = preg_replace( '/[^0-9,]+/', '', $exclude );
			$attachments = get_children( array( 'post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) );
		} else {
			$attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) );
		}

		if ( ! empty( $attachments ) ) {
			foreach ( $attachments as $id => $attachment ) {
				$link = isset( $attr['link'] ) && 'file' === $attr['link'] ? wp_get_attachment_link( $id, $size, false, false ) : wp_get_attachment_link( $id, $size, true, false );

				if ( $captiontag && trim($attachment->post_excerpt) ) {
					$output .= "<div class='wp-caption aligncenter'>$link
						<p class='wp-caption-text'>" . wptexturize($attachment->post_excerpt) . "</p>
						</div>";
				} else {
					$output .= $link . ' ';
				}
			}
		}
	}
                    

Code file location:

slimjetpack/slimjetpack/class.json-api-endpoints.php

Slim Jetpack [contact-field] Shortcode

The Slimjetpack plugin shortcode, ‘contact-field’, is used to parse contact fields in a form. It creates a new Grunion_Contact_Form_Field object and assigns it to the field variable. The shortcode checks for a field ID and stores it in an array. If a POST submission is made for the contact form, it validates the field value and outputs the HTML for the field.

Shortcode: [contact-field]

Parameters

Here is a list of all possible contact-field shortcode parameters and attributes:

  • attributes – Specific features or characteristics of the contact form field
  • content – The actual information or data within the contact form field
  • field_id – The unique identifier for each individual field of the contact form
  • $_POST['action'] – The action taken when the contact form is submitted
  • $_POST['contact-form-id'] – The unique identifier for the submitted contact form

Examples and Usage

Basic example – A basic usage of the ‘contact-field’ shortcode would be to simply provide an ID for the contact field you want to display.

[contact-field id=1 /]

Advanced examples

Here, we are using the ‘contact-field’ shortcode to display a contact field with a specific ID, but we’re also specifying the content of the field. This can be useful if you want to pre-fill the field with some default content.

[contact-field id=1]Default content[/contact-field]

In this next example, we’re using the ‘contact-field’ shortcode to display a contact field with a specific ID, and we’re also specifying some additional attributes for the field. In this case, we’re setting the ‘required’ attribute to ‘true’, which means that the user will have to fill out this field before they can submit the form.

[contact-field id=1 required=true /]

Finally, in this example, we’re using the ‘contact-field’ shortcode to display a contact field with a specific ID, and we’re also specifying both the ‘required’ attribute and the ‘type’ attribute. The ‘type’ attribute allows you to specify what kind of field this should be (e.g., ‘text’, ’email’, ‘number’, etc.).

[contact-field id=1 required=true type=email /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'contact-field', array( $this, 'parse_contact_field' ) );

Shortcode PHP function:

                    function parse_contact_field( $attributes, $content ) {
		$field = new Grunion_Contact_Form_Field( $attributes, $content, $this );

		$field_id = $field->get_attribute( 'id' );
		if ( $field_id ) {
			$this->fields[$field_id] = $field;
		} else {
			$this->fields[] = $field;
		}

		if (
			isset( $_POST['action'] ) && 'grunion-contact-form' === $_POST['action']
		&&
			isset( $_POST['contact-form-id'] ) && $this->get_attribute( 'id' ) == $_POST['contact-form-id']
		) {
			// If we're processing a POST submission for this contact form, validate the field value so we can show errors as necessary.
			$field->validate();
		}

		// Output HTML
		return $field->render();
	}
                    

Code file location:

slimjetpack/slimjetpack/modules/contact-form/grunion-contact-form.php

Slim Jetpack [latex] Shortcode

The Slimjetpack Latex shortcode is a functional snippet that allows the rendering of Latex content on your WordPress site. This shortcode works by decoding the Latex content within your posts or pages and rendering it with the specified foreground and background colors. The ‘s’ attribute controls the size of the output.

Shortcode: [latex]

Parameters

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

  • s – determines the size of the LaTeX content
  • bg – sets the background color of the LaTeX content
  • fg – sets the text color of the LaTeX content
  • content – the actual LaTeX content to render

Examples and Usage

Basic example – Renders a latex shortcode with the default colors for text and background.

[latex]Your Latex Content Here[/latex]

Advanced examples

1. Renders a latex shortcode with a specified text color.

[latex fg=FFF]Your Latex Content Here[/latex]

2. Renders a latex shortcode with a specified background color.

[latex bg=000]Your Latex Content Here[/latex]

3. Renders a latex shortcode with both specified text and background colors.

[latex fg=FFF bg=000]Your Latex Content Here[/latex]

4. Renders a latex shortcode with a specified size.

[latex s=2]Your Latex Content Here[/latex]

5. Renders a latex shortcode with all parameters specified.

[latex s=2 fg=FFF bg=000]Your Latex Content Here[/latex]

PHP Function Code

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

Shortcode line:

add_shortcode( 'latex', 'latex_shortcode' );

Shortcode PHP function:

                    function latex_shortcode( $atts, $content = '' ) {
	extract( shortcode_atts( array(
		's' => 0,
		'bg' => latex_get_default_color( 'bg' ),
		'fg' => latex_get_default_color( 'text', '000' )
	), $atts ) );

	return latex_render( latex_entity_decode( $content ), $fg, $bg, $s );
}
                    

Code file location:

slimjetpack/slimjetpack/modules/latex.php

Slim Jetpack [archives] Shortcode

The Slimjetpack ‘archives’ shortcode is a versatile tool for displaying post archives on your WordPress site. This shortcode allows you to customize the type of archive (yearly, monthly, etc.), limit the number of posts displayed, choose the format (HTML, option, or custom), and decide whether to show a post count. You can further personalize the display with ‘before’ and ‘after’ parameters. The shortcode also supports ascending or descending order and provides a user-friendly message if no posts are available.

Shortcode: [archives]

Parameters

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

  • type – Determines the type of archives to display (yearly, monthly, daily, weekly, postbypost).
  • limit – Controls the number of archives to show.
  • format – Decides the format of the archive output (html, option, custom).
  • showcount – If true, displays the post count for each archive.
  • before – Defines any content to add before each archive.
  • after – Specifies any content to add after each archive.
  • order – Controls the order of archives (ascending or descending).

Examples and Usage

Basic example – A shortcode that displays archives of posts in descending order.

[archives]

Advanced examples

Displaying archives of posts in ascending order. The ‘order’ parameter is set to ‘asc’ for ascending order.

[archives order="asc"]

Displaying archives of posts as a dropdown list. The ‘format’ parameter is set to ‘option’ to display the archives as a dropdown list. The ‘limit’ parameter is set to ‘5’ to limit the number of archives to 5.

[archives format="option" limit="5"]

Displaying archives of posts with a post count. The ‘showcount’ parameter is set to ‘true’ to display the count of posts in each archive.

[archives showcount="true"]

Displaying archives of posts by month. The ‘type’ parameter is set to ‘monthly’ to display the archives by month.

[archives type="monthly"]

Displaying archives of posts by year. The ‘type’ parameter is set to ‘yearly’ to display the archives by year.

[archives type="yearly"]

Displaying archives of posts by day. The ‘type’ parameter is set to ‘daily’ to display the archives by day.

[archives type="daily"]

Displaying archives of posts by week. The ‘type’ parameter is set to ‘weekly’ to display the archives by week.

[archives type="weekly"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'archives', 'archives_shortcode' );

Shortcode PHP function:

                    function archives_shortcode( $attr ) {
	if ( is_feed() )
		return '[archives]';

	global $allowedposttags;

	$default_atts = array(
		'type'      => 'postbypost',
		'limit'     => '',
		'format'    => 'html',
		'showcount' => false,
		'before'    => '',
		'after'     => '',
		'order'     => 'desc',
	);
	extract( shortcode_atts( $default_atts, $attr ) );

	if ( !in_array( $type, array( 'yearly', 'monthly', 'daily', 'weekly', 'postbypost' ) ) )
		$type = 'postbypost';

	if ( !in_array( $format, array( 'html', 'option', 'custom' ) ) )
		$format =  'html';

	if ( '' != $limit )
		$limit = (int)$limit;

	$showcount = (bool)$showcount;
	$before = wp_kses( $before, $allowedposttags );
	$after = wp_kses( $after, $allowedposttags );

	// Get the archives
	$archives = wp_get_archives( array(
		'type'            => $type,
		'limit'           => $limit,
		'format'          => $format,
		'echo'            => false,
		'show_post_count' => $showcount,
		'before'          => $before,
		'after'           => $after
	) );

	if ( 'asc' == $order )
		$archives = implode( "\n", array_reverse( explode( "\n", $archives ) ) );


	// Check to see if there are any archives
	if ( empty( $archives ) )
		$archives = '<p>' . __( 'Your blog does not currently have any published posts.' , 'jetpack' ) . '</p>';
	elseif ( 'option' == $format )
		$archives = "<select name='archive-dropdown' onchange='document.location.href=this.options[this.selectedIndex].value;'><option value='" . get_permalink() . "'>--</option>" . $archives . "</select>";
	elseif ( 'html' == $format )
		$archives = '<ul>' . $archives . '</ul>';

	return $archives;
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/archives.php

Slim Jetpack Shortcode

The Slimjetpack ‘audio’ shortcode is a powerful tool for embedding audio files in your WordPress posts. This shortcode allows you to insert an audio player within your content. It supports multiple audio formats and includes options for autoplay, looping, and volume control. The player can be customized with color options and includes fallbacks for unsupported audio formats.

Shortcode:

Parameters

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

  • src – defines the source of the audio file
  • loop – allows the audio track to be played in a loop
  • width – sets the width of the audio player
  • initialvolume – sets the initial volume of the audio player
  • artists – lists the artists of the audio tracks
  • titles – lists the titles of the audio tracks

Examples and Usage

Basic example – Embed an audio file using its URL:

Advanced examples

Embed multiple audio files using their URLs. The audio player will play these files in the order they are listed:

Embed an audio file and customize the player’s appearance by specifying the color options. The color options are specified in hexadecimal format:

Embed an audio file and set it to auto loop:

Embed an audio file and set the initial volume to 60%:

Embed multiple audio files, set their titles and artists:

PHP Function Code

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

Shortcode line:

add_shortcode( 'audio', array( $this, 'audio_shortcode' ) );

Shortcode PHP function:

                    function audio_shortcode( $atts ) {
		global $ap_playerID;
		global $post;
		if ( ! is_array( $atts ) ) {
			return '<!-- Audio shortcode passed invalid attributes -->';
		}

		if ( ! isset( $atts[0] ) ) {
			if ( isset( $atts['src'] ) ) {
				$atts[0] = $atts['src'];
				unset( $atts['src'] );
			} else {
				return '<!-- Audio shortcode source not set -->';
			}
		}

		// add the special .js
		wp_enqueue_script(
			'audio-shortcode',
			plugins_url( 'js/audio-shortcode.js', __FILE__ ),
			array( 'jquery' ),
			'1.1',
			true);

		// alert the infinite scroll renderer that it should try to load the script
		self::$add_script = true;
		$atts[0] = strip_tags( join( ' ', $atts ) );
		$src = ltrim( $atts[0], '=' );
		$ap_options = apply_filters(
			'audio_player_default_colors',
			array(
				"bg"             => "0xF8F8F8",
				"leftbg"         => "0xEEEEEE",
				"lefticon"       => "0x666666",
				"rightbg"        => "0xCCCCCC",
				"rightbghover"   => "0x999999",
				"righticon"      => "0x666666",
				"righticonhover" => "0xFFFFFF",
				"text"           => "0x666666",
				"slider"         => "0x666666",
				"track"          => "0xFFFFFF",
				"border"         => "0x666666",
				"loader"         => "0x9FFFB8"
			) );

		if ( ! isset( $ap_playerID ) ) {
			$ap_playerID = 1;
		} else {
			$ap_playerID++;
		}

		if ( ! isset( $load_audio_script ) ) {
			$load_audio_script = true;
		}

		// prep the audio files
		$src = trim( $src, ' "' );
		$options = array();
		$data = preg_split( "/\|/", $src );
		$sound_file = $data[0];
		$sound_files = explode( ',', $sound_file );

		if ( is_ssl() ) {
			for ( $i = 0; $i < count( $sound_files ); $i++ ) {
				$sound_files[ $i ] = preg_replace( '#^http://([^.]+).files.wordpress.com/#', 'https://$1.files.wordpress.com/', $sound_files[ $i ] );
			}
		}

		$sound_files = array_map( 'trim', $sound_files );
		$sound_files = array_map( array( $this, 'rawurlencode_spaces' ), $sound_files );
		$sound_files = array_map( 'esc_url_raw', $sound_files ); // Ensure each is a valid URL
		$num_files = count( $sound_files );
		$sound_types = array(
			'mp3'  => 'mpeg',
			'wav'  => 'wav',
			'ogg'  => 'ogg',
			'oga'  => 'ogg',
			'm4a'  => 'mp4',
			'aac'  => 'mp4',
			'webm' => 'webm'
		);

		for ( $i = 1; $i < count( $data ); $i++ ) {
			$pair = explode( "=", $data[$i] );
			if ( strtolower( $pair[0] ) != 'autostart' ) {
				$options[$pair[0]] = $pair[1];
			}
		}

		// Merge runtime options to default colour options
		// (runtime options overwrite default options)
		foreach ( $ap_options as $key => $default ) {
			if ( isset( $options[$key] ) ) {
				if ( preg_match( '/^(0x)?[a-f0-9]{6}$/i', $default ) && !preg_match( '/^(0x)?[a-f0-9]{6}$/i', $options[$key] ) ) {
					// Default is a hex color, but input is not
					$options[$key] = $default;
				}
			} else {
				$options[$key] = $default;
			}
		}
		$options['soundFile'] = join( ',', $sound_files ); // Rebuild the option with our now sanitized data
		$flash_vars = array();
		foreach ( $options as $key => $value ) {
			$flash_vars[] = rawurlencode( $key ) . '=' . rawurlencode( $value );
		}
		$flash_vars = implode( '&amp;', $flash_vars );
		$flash_vars = esc_attr( $flash_vars );

		// extract some of the options to insert into the markup
		if ( isset( $options['bgcolor'] ) && preg_match( '/^(0x)?[a-f0-9]{6}$/i', $options['bgcolor'] ) ) {
			$bgcolor = preg_replace( '/^(0x)?/', '#', $options['bgcolor'] );
			$bgcolor = esc_attr( $bgcolor );
		} else {
			$bgcolor = '#FFFFFF';
		}

		if ( isset( $options['width'] ) ) {
			$width = intval( $options['width'] );
		} else {
			$width = 290;
		}

		$loop = '';
		$script_loop = 'false';
		if ( isset( $options['loop'] ) && 'yes' == $options['loop'] ) {
			$script_loop = 'true';
			if ( 1 == $num_files ) {
				$loop = 'loop';
			}
		}

		$volume = 0.6;
		if ( isset( $options['initialvolume'] ) &&
				0.0 < floatval( $options['initialvolume'] ) &&
				100.0 >= floatval( $options['initialvolume'] ) ) {

			$volume = floatval( $options['initialvolume'] )/100.0;
		}

		$file_artists = array_pad( array(), $num_files, '' );
		if ( isset( $options['artists'] ) ) {
			$artists = preg_split( '/,/', $options['artists'] );
			foreach ( $artists as $i => $artist ) {
				$file_artists[$i] = esc_html( $artist ) . ' - ';
			}
		}

		// generate default titles
		$file_titles = array();
		for ( $i = 0; $i < $num_files; $i++ ) {
			$file_titles[] = 'Track #' . ($i+1);
		}

		// replace with real titles if they exist
		if ( isset( $options['titles'] ) ) {
			$titles = preg_split( '/,/', $options['titles'] );
			foreach ( $titles as $i => $title ) {
				$file_titles[$i] = esc_html( $title );
			}
		}

		// fallback for the fallback, just a download link
		$not_supported = '';
		foreach ( $sound_files as $sfile ) {
			$not_supported .= sprintf(
				__( 'Download: <a href="%s">%s</a><br />', 'jetpack' ),
				esc_url( $sfile ),
				esc_html( basename( $sfile ) ) );
		}

		// HTML5 audio tag
		$html5_audio = '';
		$all_mp3 = true;
		$add_audio = true;
		$num_good = 0;
		$to_remove = array();
		foreach ( $sound_files as $i => $sfile ) {
			$file_extension = pathinfo( $sfile, PATHINFO_EXTENSION );
			if ( ! preg_match( '/^(mp3|wav|ogg|oga|m4a|aac|webm)$/i', $file_extension ) ) {
				$html5_audio .= '<!-- Audio shortcode unsupported audio format -->';
				if ( 1 == $num_files ) {
					$html5_audio .= $not_supported;
				}

				$to_remove[] = $i; // make a note of the bad files
				$all_mp3 = false;
				continue;
			} elseif ( ! preg_match( '/^mp3$/i', $file_extension ) ) {
				$all_mp3 = false;
			}

			if ( 0 == $i ) { // only need one player
				$html5_audio .= <<<AUDIO
				<span id="wp-as-{$post->ID}_{$ap_playerID}-container">
					<audio id='wp-as-{$post->ID}_{$ap_playerID}' controls preload='none' $loop style='background-color:$bgcolor;width:{$width}px;'>
						<span id="wp-as-{$post->ID}_{$ap_playerID}-nope">$not_supported</span>
					</audio>
				</span>
				<br />
AUDIO;
			}
			$num_good++;
		}

		// player controls, if needed
		if ( 1 < $num_files ) {
			$html5_audio .= <<<CONTROLS
				<span id='wp-as-{$post->ID}_{$ap_playerID}-controls' style='display:none;'>
					<a id='wp-as-{$post->ID}_{$ap_playerID}-prev'
						href='javascript:audioshortcode.prev_track( "{$post->ID}_{$ap_playerID}" );'
						style='font-size:1.5em;'>&laquo;</a>
					|
					<a id='wp-as-{$post->ID}_{$ap_playerID}-next'
						href='javascript:audioshortcode.next_track( "{$post->ID}_{$ap_playerID}", true, $script_loop );'
						style='font-size:1.5em;'>&raquo;</a>
				</span>
CONTROLS;
		}
		$html5_audio .= "<span id='wp-as-{$post->ID}_{$ap_playerID}-playing'></span>";

		if ( is_ssl() )
			$protocol = 'https';
		else
			$protocol = 'http';

		$swfurl = apply_filters(
			'jetpack_static_url',
			"$protocol://en.wordpress.com/wp-content/plugins/audio-player/player.swf" );

		// all the fancy javascript is causing Google Reader to break, just include flash in GReader
		// override html5 audio code w/ just not supported code
		if ( is_feed() ) {
			$html5_audio = $not_supported;
		}

		if ( $all_mp3 ) {
			// process regular flash player, inserting HTML5 tags into object as fallback
			$audio_tags = <<<FLASH
				<object id='wp-as-{$post->ID}_{$ap_playerID}-flash' type='application/x-shockwave-flash' data='$swfurl' width='$width' height='24'>
					<param name='movie' value='$swfurl' />
					<param name='FlashVars' value='{$flash_vars}' />
					<param name='quality' value='high' />
					<param name='menu' value='false' />
					<param name='bgcolor' value='$bgcolor' />
					<param name='wmode' value='opaque' />
					$html5_audio
				</object>
FLASH;
		} else { // just HTML5 for non-mp3 versions
			$audio_tags = $html5_audio;
		}

		// strip out all the bad files before it reaches .js
		foreach ( $to_remove as $i ) {
			array_splice( $sound_files, $i, 1 );
			array_splice( $file_artists, $i, 1 );
			array_splice( $file_titles, $i, 1 );
		}

		// mashup the artist/titles for the script
		$script_titles = array();
		for ( $i = 0; $i < $num_files; $i++ ) {
			$script_titles[] = $file_artists[$i] . $file_titles[$i];

		}

		// javacript to control audio
		$script_files   = json_encode( $sound_files );
		$script_titles  = json_encode( $script_titles );
		$script = <<<SCRIPT
			<script type='text/javascript'>
			//<![CDATA[
			(function() {
				var prep = function() {
					if ( 'undefined' === typeof window.audioshortcode ) { return; }
					audioshortcode.prep(
						'{$post->ID}_{$ap_playerID}',
						$script_files,
						$script_titles,
						$volume,
						$script_loop
					);
				};
				if ( 'undefined' === typeof jQuery ) {
					if ( document.addEventListener ) {
						window.addEventListener( 'load', prep, false );
					} else if ( document.attachEvent ) {
						window.attachEvent( 'onload', prep );
					}
				} else {
					jQuery(document).on( 'ready as-script-load', prep );
				}
			})();
			//]]>
			</script>
SCRIPT;

		// add the special javascript, if needed
		if ( 0 < $num_good && ! is_feed() ) {
			$audio_tags .= $script;
		}

		return "<span style='text-align:left;display:block;'><p>$audio_tags</p></span>";
	}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/audio.php

Slim Jetpack [bandcamp] Shortcode

The Slimjetpack Bandcamp shortcode allows you to embed a Bandcamp track or album on your WordPress site. It supports various attributes such as album or track ID, size, background color, link color, layout, width, height, tracklist, artwork, theme, and package. The shortcode generates an iframe with the specified attributes and embeds the Bandcamp player on your page.

Shortcode: [bandcamp]

Parameters

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

  • album – Identifies the album using its unique integer ID.
  • track – Identifies the track using its unique integer ID.
  • size – Sets the size of the player from a list of supported sizes.
  • bgcol – Sets the background color using a hexadecimal value without a ‘#’ prefix.
  • linkcol – Sets the color of links using a hexadecimal value without a ‘#’ prefix.
  • layout – Sets the layout of the player using an encoded layout URL.
  • width – Sets the width of the player using an integer with an optional ‘%’.
  • height – Sets the height of the player using an integer with an optional ‘%’.
  • notracklist – If set to “true”, the track list will not be displayed.
  • tracklist – If set to “false”, the track list will not be displayed.
  • artwork – Determines the size of the album art or if it will be displayed.
  • minimal – If set to “true”, displays a minimal version of the player.
  • theme – Sets the theme of the player, either “light” or “dark”.
  • package – Identifies the package using its unique integer ID.
  • t – Sets the track number using an integer.

Examples and Usage

Basic example – Embeds a Bandcamp track with the track ID 123456

[bandcamp track=123456 /]

Advanced examples

Embeds a Bandcamp album with the album ID 78910, with a ‘grande’ size, a background color of ‘000000’, and a link color of ‘FFFFFF’.

[bandcamp album=78910 size='grande' bgcol='000000' linkcol='FFFFFF' /]

Embeds a Bandcamp track with the track ID 123456, with a ‘large’ size, without tracklist, with a small artwork, and with a dark theme.

[bandcamp track=123456 size='large' notracklist='true' artwork='small' theme='dark' /]

Embeds a Bandcamp album with the album ID 78910, with a custom width of 500px and height of 200px, and with a custom package ID 1112.

[bandcamp album=78910 width='500' height='200' package=1112 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'bandcamp', 'shortcode_handler_bandcamp' );

Shortcode PHP function:

                    function shortcode_handler_bandcamp( $atts ) {
	// there are no default values, but specify here anyway
	// to explicitly list supported atts
	$attributes = shortcode_atts( array(
		'album'			=> null,		// integer album id
		'track'			=> null,		// integer track id
		'size'			=> 'venti',		// one of the supported sizes
		'bgcol'			=> 'FFFFFF',	// hex, no '#' prefix
		'linkcol'		=> null,		// hex, no '#' prefix
		'layout'		=> null,		// encoded layout url
		'width'			=> null,		// integer with optional "%"
		'height'		=> null,		// integer with optional "%"
		'notracklist'	=> null,		// may be string "true" (defaults false)
		'tracklist'		=> null,		// may be string "false" (defaults true)
		'artwork'		=> null,		// may be string "false" (alternately: "none") or "small" (default is large)
		'minimal'		=> null,		// may be string "true" (defaults false)
		'theme'			=> null,		// may be theme identifier string ("light"|"dark" so far)
		'package'		=> null,		// integer package id
		't'				=> null			// integer track number
	), $atts );

	$sizes = array(
		'venti'			=> array( 'width' => 400, 'height' => 100 ),
		'grande'		=> array( 'width' => 300, 'height' => 100 ),
		'grande2'		=> array( 'width' => 300, 'height' => 355 ),
		'grande3'		=> array( 'width' => 300, 'height' => 415 ),
		'tall_album'	=> array( 'width' => 150, 'height' => 295 ),
		'tall_track'	=> array( 'width' => 150, 'height' => 270 ),
		'tall2'			=> array( 'width' => 150, 'height' => 450 ),
		'short'			=> array( 'width' => 46, 'height' => 23 ),
		'large'			=> array( 'width' => 350, 'height' => 470 ),
		'medium'		=> array( 'width' => 450, 'height' => 120 ),
		'small'			=> array( 'width' => 350, 'height' => 42 )
	);

	$sizekey = $attributes['size'];
	$height = null;
	$width = null;

	// Build iframe url.  Args are appended as
	// extra path segments for historical reasons having to
	// do with an IE-only flash bug which required this URL
	// to contain no querystring

	$url = "http://bandcamp.com/EmbeddedPlayer/v=2/";
	if ( isset( $attributes['track'] ) ) {
		$track = (int) $attributes['track'];
		$url .= "track={$track}";

		if ( $sizekey == 'tall' ) {
			$sizekey .= '_track';
		}
	} elseif ( isset( $attributes['album'] ) ) {
		$album = (int) $attributes['album'];
		$url .= "album={$album}";
		$type = 'album';

		if ( $sizekey == 'tall' ) {
			$sizekey .= '_album';
		}
	} else {
		return "[bandcamp: shortcode must include track or album id]";
	}

	// if size specified that we don't recognize, fall back on venti
	if ( empty( $sizes[$sizekey] ) ) {
		$sizekey = 'venti';
		$attributes['size'] = 'venti';
	}

	// use strict regex for digits + optional % instead of absint for height/width
	// 'width' and 'height' params in the iframe url get the exact string from the shortcode
	// args, whereas the inline style attribute must have "px" added to it if it has no "%"
	if ( isset( $attributes['width'] ) && preg_match( "|^([0-9]+)(%)?$|", $attributes['width'], $matches ) ) {
		$width = $csswidth = $attributes['width'];
		if ( sizeof( $matches ) < 3 ) {
			$csswidth .= "px";
		}
	}
	if ( isset( $attributes['height'] ) && preg_match( "|^([0-9]+)(%)?$|", $attributes['height'], $matches ) ) {
		$height = $cssheight = $attributes['height'];
		if ( sizeof( $matches ) < 3 ) {
			$cssheight .= "px";
		}
	}

	if ( !$height ) {
		$height = $sizes[$sizekey]['height'];
		$cssheight = $height . "px";
	}

	if ( !$width ) {
		$width = $sizes[$sizekey]['width'];
		$csswidth = $width . "px";
	}

	if ( isset( $attributes['layout'] ) ) {
		$url .= "/layout={$attributes['layout']}";
	} elseif ( isset( $attributes['size'] ) && preg_match( "|^[a-zA-Z0-9]+$|", $attributes['size'] ) ) {
		$url .= "/size={$attributes['size']}";
	}

	if ( isset( $attributes['bgcol'] ) && preg_match( "|^[0-9A-Fa-f]+$|", $attributes['bgcol'] ) ) {
		$url .= "/bgcol={$attributes['bgcol']}";
	}

	if ( isset( $attributes['linkcol'] ) && preg_match( "|^[0-9A-Fa-f]+$|", $attributes['linkcol'] ) ) {
		$url .= "/linkcol={$attributes['linkcol']}";
	}

	if ( isset( $attributes['package'] ) && preg_match( "|^[0-9]+$|", $attributes['package'] ) ) {
		$url .= "/package={$attributes['package']}";
	}

	if ( isset( $attributes['t'] ) && preg_match( "|^[0-9]+$|", $attributes['t'] ) ) {
		$url .= "/t={$attributes['t']}";
	}

	if ( $attributes['notracklist'] == "true" ) {
		$url .= "/notracklist=true";
	}

	// 'tracklist' arg deprecates 'notracklist=true' to be less weird.
	// Note, behavior if both are specified is undefinied
	switch ( $attributes['tracklist'] ) {
		case "false":
		case "none":
			$url .= "/tracklist=false";
			break;
	}

	switch ( $attributes['artwork'] ) {
		case "false":
		case "none":
		case "small":
			$url .= "/artwork=" . $attributes['artwork'];
			break;
	}

	if ( $attributes['minimal'] == "true" ) {
		$url .= "/minimal=true";
	}

	if ( isset( $attributes['theme'] ) && preg_match( "|^[a-zA-Z_]+$|", $attributes['theme'] ) ) {
		$url .= "/theme={$attributes['theme']}";
	}

	$url .= '/';

	return "<iframe width='" . esc_attr( $width ) . "' height='" . esc_attr( $height ) . "' style='position: relative; display: block; width: " . esc_attr( $csswidth ) . "; height: " . esc_attr( $cssheight ) . ";' src='" . esc_url( $url ) . "' allowtransparency='true' frameborder='0'></iframe>";
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/bandcamp.php

Slim Jetpack [blip.tv] Shortcode

The Slimjetpack plugin’s ‘blip.tv’ shortcode is used to embed multimedia content from blip.tv into a WordPress site. This shortcode takes in a URL as an attribute and checks it against two patterns. If it matches the first pattern, a JavaScript player is returned, enabling the display of the specified blip.tv post. If it matches the second pattern, an embedded Flash player is returned, allowing the playback of the content directly from the URL. If no match is found, a comment is returned indicating no match.

Shortcode: [blip.tv]

Parameters

Here is a list of all possible blip.tv shortcode parameters and attributes:

  • posts_id – Specifies the unique identifier of the post on blip.tv
  • dest – Determines the cross-post destination for the video
  • view – Controls the view type of the video player
  • src – Defines the URL of the video to embed from blip.tv

Examples and Usage

Basic example – Display a video from blip.tv by using its URL as the attribute.

[blip.tv 'http://blip.tv/play/abc123']

Advanced examples

Display a video from blip.tv by referencing both the post’s id and destination. The video will first try to load by post id, but if not found, it will try to load by destination.

[blip.tv '?posts_id=123&dest=456']

Another advanced usage of the shortcode could be to display a video from blip.tv by using its URL. This example demonstrates how to use the URL of a video hosted on blip.tv as the shortcode attribute.

[blip.tv 'http://blip.tv/play/xyz789']

PHP Function Code

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

Shortcode line:

add_shortcode( 'blip.tv', 'blip_shortcode' );

Shortcode PHP function:

                    function blip_shortcode( $atts ) {
	if ( ! isset( $atts[0] ) )
		return '';
	$src = $atts[0];

	if ( preg_match( '/^\?posts_id=(\d+)&[^d]*dest=(-?\d+)$/', $src, $matches ) )
		return "<script type='text/javascript' src='http://blip.tv/syndication/write_player?skin=js&posts_id={$matches[1]}&cross_post_destination={$matches[2]}&view=full_js'></script>";
	elseif ( preg_match( '|^http://blip.tv/play/[.\w]+$|', urldecode( $src ) ) ) // WLS
		return "<embed src='$src' type='application/x-shockwave-flash' width='480' height='300' allowscriptaccess='never' allowfullscreen='true'></embed>";


	return "<!--blip.tv pattern not matched -->";
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/blip.php

Slim Jetpack [dailymotion] Shortcode

The Slimjetpack’s ‘dailymotion’ shortcode is used to embed Dailymotion videos in a WordPress post or page. The function ‘dailymotion_shortcode’ takes video ID as parameter and generates an iframe to display the video. It also allows adding video title and uploader’s username as optional parameters.

Shortcode: [dailymotion]

Parameters

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

  • id – Unique identifier of the Dailymotion video
  • video – Defines the specific video to be embedded
  • title – Sets the title of the embedded video
  • user – Specifies the Dailymotion user who uploaded the video

Examples and Usage

Basic example – Display a Dailymotion video by referencing its ID.

[dailymotion id=xyz123 /]

Advanced examples:

Display a Dailymotion video with a custom title and link to the video page.

[dailymotion id=xyz123 video=abc456 title="My Custom Title" /]

Display a Dailymotion video with a link to the uploader’s profile.

[dailymotion id=xyz123 user=user789 /]

Display a Dailymotion video with a custom title, link to the video page, and a link to the uploader’s profile.

[dailymotion id=xyz123 video=abc456 title="My Custom Title" user=user789 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'dailymotion', 'dailymotion_shortcode' );

Shortcode PHP function:

                    function dailymotion_shortcode( $atts ) {
	global $content_width;

	if ( isset( $atts[0] ) ) {
		$id = ltrim( $atts[0], '=' );
		$atts['id'] = $id;
	} else {
		$params = shortcode_new_to_old_params( $atts );
		parse_str( $params, $atts );
	}

	if ( isset( $atts['id'] ) )
		$id = $atts['id'];
	else
		return '<!--Dailymotion error: bad or missing ID-->';

	if ( !empty( $content_width ) )
		$width = min( 425, intval( $content_width ) );
	else
		$width = 425;

	$height = ( 425 == $width ) ? 334 : ( $width / 425 ) * 334;
	$id = urlencode( $id );

	if ( preg_match( '/^[A-Za-z0-9]+$/', $id ) ) {
		$output = '<iframe width="' . $width . '" height="' . $height . '" src="http://www.dailymotion.com/embed/video/' . $id . '" frameborder="0"></iframe>';
		$after = '';

		if ( array_key_exists( 'video', $atts ) && $video = preg_replace( '/[^-a-z0-9_]/i', '', $atts['video'] ) && array_key_exists( 'title', $atts ) && $title = wp_kses( $atts['title'], array() ) )
			$after .= '<br /><strong><a href="http://www.dailymotion.com/video/' . $video . '">' . $title . '</a></strong>';

		if ( array_key_exists( 'user', $atts ) && $user = preg_replace( '/[^-a-z0-9_]/i', '', $atts['user'] ) )
			$after .= '<br /><em>Uploaded by <a href="http://www.dailymotion.com/' . $user . '">' . $user . '</a></em>';
	}

	return $output . $after;
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/dailymotion.php

Slim Jetpack [digg] Shortcode

The Slimjetpack ‘digg’ shortcode is a tool for integrating Digg sharing functionality into your WordPress site. The shortcode adds a Digg share button to your post, allowing visitors to share your content on Digg. The button’s appearance can be customized using the ‘class’ attribute. The ‘class’ attribute accepts four values: ‘wide’, ‘medium’, ‘compact’, and ‘icon’. If no ‘class’ is specified, the button will default to ‘medium’. The shortcode also ensures that the necessary JavaScript for the Digg button is only printed once, regardless of how many times the shortcode is used within a page.

Shortcode: [digg]

Parameters

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

  • class – Defines the appearance of the Digg button: ‘wide’, ‘medium’, ‘compact’, or ‘icon’

Examples and Usage

Basic example – In this example, the digg shortcode is used without any parameters. This will display the Digg button with a default ‘Medium’ class.

[digg /]

Advanced examples

Use the shortcode to display a Digg button with a specific class. The class parameter can take four values: ‘wide’, ‘medium’, ‘compact’, and ‘icon’. The button’s appearance will change based on the class you set.

[digg class="wide" /]

Here’s another example where the shortcode is used with the ‘compact’ class:

[digg class="compact" /]

And here’s how you can use the shortcode with the ‘icon’ class:

[digg class="icon" /]

Remember, if you do not specify a class or use a class that’s not in the predefined list, the shortcode will default to the ‘Medium’ class.

PHP Function Code

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

Shortcode line:

add_shortcode( 'digg', 'digg_shortcode' );

Shortcode PHP function:

                    function digg_shortcode( $atts ) {
	static $printed_digg_code = false;

	if ( ! $printed_digg_code ) {
		add_action( 'wp_footer', 'digg_shortcode_js' );
		$printed_digg_code = true;
	}

	if ( isset( $atts['class']) && in_array( $atts['class'], array( 'wide', 'medium', 'compact', 'icon' ) ) )
		$class = ucfirst( $atts['class'] );
	else
		$class = 'Medium';

	return '<a class="DiggThisButton Digg' . $class . '" href="http://digg.com/submit?url=' . urlencode( get_permalink() ) . '&amp;title=' . urlencode( get_the_title() ) . '"></a>';
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/diggthis.php

Slim Jetpack [facebook] Shortcode

The Jetpack Facebook shortcode is a powerful tool that embeds Facebook posts or photos into your WordPress site. It requires the ‘url’ attribute, which should link to the Facebook content you wish to embed. If the URL doesn’t match the Facebook embed format, the function will return without embedding anything. It uses the global $wp_embed object to handle the shortcode and embed the content.

Shortcode: [facebook]

Parameters

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

  • url – the direct link to the Facebook content you wish to embed

Examples and Usage

Basic example – A simple usage of the shortcode to embed a Facebook post by providing the URL as a parameter.

[facebook url="https://www.facebook.com/YourPage/posts/YourPostID" /]

Advanced examples

Utilizing the shortcode to display a Facebook photo by providing the specific URL of the photo. The plugin will identify the URL pattern and embed the photo accordingly.

[facebook url="https://www.facebook.com/photo.php?fbid=YourPhotoID" /]

Embedding a Facebook video using the shortcode by supplying the URL of the video. The plugin will recognize the URL format and embed the video.

[facebook url="https://www.facebook.com/YourPage/videos/YourVideoID" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'facebook', 'jetpack_facebook_shortcode_handler' );

Shortcode PHP function:

                    function jetpack_facebook_shortcode_handler( $atts ) {
	global $wp_embed;

	if ( empty( $atts['url'] ) )
		return;

	if ( ! preg_match( JETPACK_FACEBOOK_EMBED_REGEX, $atts['url'] ) && ! preg_match( JETPACK_FACEBOOK_PHOTO_EMBED_REGEX, $atts['url'] ) )
		return;

	return $wp_embed->shortcode( $atts, $atts['url'] );
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/facebook.php

Slim Jetpack [flickr] Shortcode

The Slimjetpack Flickr shortcode provides a way to display Flickr videos or photos on your website. It allows customization of width, height, and visibility of information. It also includes a secret attribute for extra security. For videos, you can choose to show additional information. The shortcode automatically extracts photo or video ID from the provided source.

Shortcode: [flickr]

Parameters

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

  • video – the ID of the Flickr video to display
  • photo – the ID of the Flickr photo to display
  • show_info – whether to display video info (true or false)
  • w – the width of the media in pixels
  • h – the height of the media in pixels
  • secret – the secret key for the video
  • size – the size of the media, 0 for default

Examples and Usage

Basic example – A simple Flickr shortcode that will display a photo by referencing its photo ID.

[flickr photo="123456789" /]

Advanced examples

Displaying a video from Flickr by referencing its video ID, with custom width and height settings. If the video is not found, nothing will be displayed.

[flickr video="987654321" w="500" h="400" /]

Displaying a photo from Flickr by referencing its photo ID, with an option to show additional information about the photo. If the photo is not found, nothing will be displayed.

[flickr photo="123456789" show_info="true" /]

Displaying a video from Flickr by referencing its video ID, with a custom secret parameter. If the video is not found, nothing will be displayed.

[flickr video="987654321" secret="your_secret_key" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'flickr', 'flickr_shortcode_handler' );

Shortcode PHP function:

                    function flickr_shortcode_handler( $atts ) {
	$atts = shortcode_atts( array(
		'video'     => 0,
		'photo'     => 0,
		'show_info' => 0,
		'w'         => 400,
		'h'         => 300,
		'secret'    => 0,
		'size'      => 0,
	), $atts );

	if ( isset( $atts['video'] ) ) {
		$showing = 'video';
		$src = $atts['video'];
	} elseif ( isset( $atts['photo'] ) ) {
		$showing = 'photo';
		$src = $atts['photo'];
	} else {
		return '';
	}

	if ( preg_match( "!photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/([0-9]+)/?$!", $src, $m ) )
		$atts['photo_id'] = $m[4];
	else
		$atts['photo_id'] = $atts['video'];

	if ( $showing == 'video' ) {
		if ( ! isset( $atts['show_info'] ) || in_array( $atts['show_info'], array('yes', 'true') ) )
			$atts['show_info'] = 'true';
		elseif ( in_array( $atts['show_info'], array( 'false', 'no' ) ) )
			$atts['show_info'] = 'false';

    	if ( isset( $atts['secret'] ) )
		$atts['secret'] = preg_replace( '![^\w]+!i', '', $atts['secret'] );

		return flickr_shortcode_video_markup( $atts );
	} else {
		return '';
	}
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/flickr.php

Slim Jetpack [googlemaps] Shortcode

The Jetpack Google Maps shortcode allows you to embed Google Maps into your WordPress site. It parses URL parameters to customize the map’s size and appearance.

Shortcode: [googlemaps]

Parameters

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

  • w – sets the width of the Google Maps iframe
  • h – sets the height of the Google Maps iframe
  • hq – parameter that is removed from the URL
  • url – defines the Google Maps URL to be displayed
  • link_url – modifies the URL for the ‘View Larger Map’ link

Examples and Usage

Basic example – A simple usage of the shortcode to display a Google map on your page.

[googlemaps https://maps.google.com/?q=New+York]

Advanced examples

Using the shortcode to display a Google map with a specific width and height. The width and height parameters are set in pixels.

[googlemaps https://maps.google.com/?q=New+York&w=500&h=400]

Using the shortcode to display a Google map with a specific location and zoom level. The zoom level can be set from 1 (world view) to 20 (street view).

[googlemaps https://maps.google.com/?q=New+York&z=15]

Using the shortcode to display a Google map with a specific location, zoom level, and map type. The map type can be set to ‘m’ for map, ‘k’ for satellite, ‘h’ for hybrid, ‘p’ for terrain, or ‘e’ for Google Earth.

[googlemaps https://maps.google.com/?q=New+York&z=15&t=m]

PHP Function Code

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

Shortcode line:

add_shortcode( 'googlemaps', 'jetpack_googlemaps_shortcode' );

Shortcode PHP function:

                    function jetpack_googlemaps_shortcode( $atts ) {
	if ( !isset($atts[0]) || apply_filters( 'jetpack_bail_on_shortcode', false, 'googlemaps' ) )
		return '';

	$params = ltrim( $atts[0], '=' );

	$width = 425;
	$height = 350;

	if ( preg_match( '!^https?://maps\.google(\.co|\.com)?(\.[a-z]+)?/.*?(\?.+)!i', $params, $match ) ) {
		$params = str_replace( '&amp;amp;', '&amp;', $params );
		$params = str_replace( '&amp;', '&', $params );
		parse_str( $params, $arg );

		if ( isset( $arg['hq'] ) )
			unset( $arg['hq'] );

		$url = '';
		foreach ( (array) $arg as $key => $value ) {
			if ( 'w' == $key ) {
				$percent = ( '%' == substr( $value, -1 ) ) ? '%' : '';
				$width = (int) $value . $percent;
			} elseif ( 'h' == $key ) {
				$height = (int) $value;
			} else {
				$key = str_replace( '_', '.', $key );
				$url .= esc_attr( "$key=$value&amp;" );
			}
		}
		$url = substr( $url, 0, -5 );

		if( is_ssl() )
			$url = str_replace( 'http://', 'https://', $url );

		$link_url = preg_replace( '!output=embed!', 'source=embed', $url );

		return '<div class="googlemaps"><iframe width="' . $width . '" height="' . $height . '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' . $url . '"></iframe><br /><small><a href="' . $link_url . '" style="text-align:left">View Larger Map</a></small></div>';
	}
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/googlemaps.php

Slim Jetpack [googleplus] Shortcode

The ‘googleplus’ shortcode in the SlimJetpack plugin is designed to embed Google+ posts in WordPress. It uses the ‘jetpack_googleplus_shortcode_handler’ function to handle the shortcode attributes. This function checks if the ‘url’ attribute is present and if it matches the Google+ post URL format. If both conditions are met, it uses the WordPress Embed API to embed the Google+ post.

Shortcode: [googleplus]

Parameters

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

  • url – The web address of the Google+ post you want to embed.

Examples and Usage

Basic example – Utilizes the shortcode to embed a Google+ post based on a specific URL.

[googleplus url="https://plus.google.com/+YourPostURLHere"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'googleplus', 'jetpack_googleplus_shortcode_handler' );

Shortcode PHP function:

                    function jetpack_googleplus_shortcode_handler( $atts ) {
	global $wp_embed;

	if ( empty( $atts['url'] ) )
		return;

	if ( ! preg_match( JETPACK_GOOGLEPLUS_EMBED_REGEX, $atts['url'] ) )
		return;

	return $wp_embed->shortcode( $atts, $atts['url'] );
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/googleplus.php

Slim Jetpack [googlevideo] Shortcode

The ‘googlevideo’ shortcode from the SlimJetpack plugin is designed to embed Google videos into your WordPress site. It validates the URL, adjusts the video size based on your theme’s content width, and ensures optimal video quality.

Shortcode: [googlevideo]

Examples and Usage

Basic example – A simple shortcode to embed a Google video into your WordPress post or page. The only attribute it needs is the URL of the Google video.

[googlevideo=http://video.google.com/googleplayer.swf?docId=1234567890 /]

Advanced examples

Embedding a Google video with a specific width. This shortcode embeds a Google video and sets the width of the video player to a specific value. Note that the height of the video player is automatically calculated to maintain the aspect ratio.

[googlevideo=http://video.google.com/googleplayer.swf?docId=1234567890 width=500 /]

Embedding a Google video with a specific width and height. This shortcode embeds a Google video and sets the width and height of the video player to specific values. Note that this might distort the video if the aspect ratio of the video doesn’t match the aspect ratio of the player.

[googlevideo=http://video.google.com/googleplayer.swf?docId=1234567890 width=500 height=400 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'googlevideo', 'googlevideo_shortcode' );

Shortcode PHP function:

                    function googlevideo_shortcode( $atts ) {
	if ( !isset( $atts[0] ) )
		return '';

	$src = ltrim( $atts[0], '=' );

	if ( 0 !== strpos( $src, 'http://video.google.com/googleplayer.swf' ) ) {
		if ( !preg_match( '|^http://(video\.google\.[a-z]{2,3}(?:.[a-z]{2})?)/|', $src ) || !preg_match( '|.*docid=([0-9-]+).*|i', $src, $match ) || !is_numeric( $match[1] ) )
			return '<!--Google Video Error: bad URL entered-->';

		$src = 'http://video.google.com/googleplayer.swf?docId=' . $match[1];
	}

	// default width should be 400 unless the theme's content width is smaller than that
	global $content_width;
	$default_width = intval( !empty( $content_width ) ? min( $content_width, 400 ) : 400 );
	$height = intval( 0.825 * $default_width );
	$src = esc_attr( $src );

	return "<span style='text-align:center;display:block;'><object width='{$default_width}' height='{$height}' type='application/x-shockwave-flash' data='{$src}'><param name='allowScriptAccess' value='never' /><param name='movie' value='$src'/><param name='quality' value='best'/><param name='bgcolor' value='#ffffff' /><param name='scale' value='noScale' /><param name='wmode' value='opaque' /></object></span>";
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/googlevideo.php

Slim Jetpack [polldaddy] Shortcode

The Polldaddy shortcode is a versatile tool that lets you integrate various features into your WordPress site. It allows you to add surveys, polls, and ratings to your content. This shortcode extracts specific attributes like survey ID, link text, poll status, ratings, unique ID, item ID, and more. It checks the validity of the attributes and returns an error message if they’re invalid. It also supports different display modes like inline, infinite scroll, and no script. The shortcode can add a script to the footer of your webpage and supports ‘infinite-scroll’ for themes that have this feature. Moreover, it allows you to customize the appearance of the poll, survey, or rating by adjusting the alignment, style, text color, and background color. In short, the Polldaddy shortcode provides a simple and efficient way to engage your audience with interactive elements.

Shortcode: [polldaddy]

Parameters

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

  • survey – Identifier of the survey you want to display.
  • link_text – Custom text for the survey link.
  • poll – Identifier of the poll you want to display.
  • rating – Identifier of the rating you want to display.
  • unique_id – Unique identifier for the page or post.
  • item_id – Unique identifier for the item being rated.
  • title – Title to be displayed with the poll, rating, or survey.
  • permalink – Permanent URL to the page or post with the shortcode.
  • cb – A flag to indicate whether to use a cache-busting method.
  • type – Determines how the survey will be displayed.
  • body – Custom text for the body of the survey.
  • button – Custom text for the survey button.
  • text_color – Text color for the survey.
  • back_color – Background color for the survey.
  • align – Alignment of the survey on the page.
  • style – Style of the survey display.
  • width – Width of the survey.
  • height – Height of the survey.
  • delay – Delay before the survey appears.
  • visit – Determines whether the survey appears once or multiple times.
  • domain – Domain of the survey.
  • id – Identifier of the survey, poll, or rating.

Examples and Usage

Basic example – Display a polldaddy survey on your website.

[polldaddy survey="your-survey-id" /]

Advanced examples

Display a polldaddy poll with a custom link text and alignment.

[polldaddy poll="your-poll-id" link_text="Vote Now!" align="right" /]

Embed a polldaddy rating with a unique ID and item ID, along with a custom title and permalink.

[polldaddy rating="your-rating-id" unique_id="your-unique-id" item_id="your-item-id" title="Your Custom Title" permalink="your-custom-permalink" /]

Display a polldaddy survey as an iframe with specified width and height.

[polldaddy survey="your-survey-id" type="iframe" width="500" height="600" /]

Display a polldaddy survey as a button with custom text and background colors, alignment, and style.

[polldaddy survey="your-survey-id" type="button" text_color="FF0000" back_color="0000FF" align="left" style="rounded" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'polldaddy', array( $this, 'polldaddy_shortcode' ) );

Shortcode PHP function:

                    function polldaddy_shortcode( $atts ) {
		global $post;
		global $content_width;

		extract( shortcode_atts( array(
			'survey'     => null,
			'link_text'  => 'Take Our Survey',
			'poll'       => 'empty',
			'rating'     => 'empty',
			'unique_id'  => null,
			'item_id'    => null,
			'title'      => null,
			'permalink'  => null,
			'cb'         => 0,
			'type'       => 'button',
			'body'       => '',
			'button'     => '',
			'text_color' => '000000',
			'back_color' => 'FFFFFF',
			'align'      => '',
			'style'      => '',
			'width'      => $content_width,
			'height'     => floor( $content_width * 3 / 4 ),
			'delay'      => 100,
			'visit'      => 'single',
			'domain'     => '',
			'id'         => ''
		), $atts ) );

		if ( ! is_array( $atts ) ) {
			return '<!-- Polldaddy shortcode passed invalid attributes -->';
		}

		$inline          = false;
		$no_script       = false;
		$infinite_scroll = false;

		if ( is_home() && current_theme_supports( 'infinite-scroll' ) )
			$infinite_scroll = true;

		if ( defined( 'PADPRESS_LOADED' ) )
			$inline = true;

		if ( function_exists( 'get_option' ) && get_option( 'polldaddy_load_poll_inline' ) )
			$inline = true;

		if ( is_feed() || ( defined( 'DOING_AJAX' ) && !$infinite_scroll ) )
			$no_script = false;

		self::$add_script = $infinite_scroll;

		if ( intval( $rating ) > 0 && !$no_script ) { //rating embed

			if ( empty( $unique_id ) )
				$unique_id = is_page() ? 'wp-page-'.$post->ID : 'wp-post-'.$post->ID;

			if ( empty( $item_id ) )
				$item_id = is_page() ? '_page_'.$post->ID : '_post_'.$post->ID;

			if ( empty( $title ) )
				$title = apply_filters( 'wp_title', $post->post_title, '', '' );

			if ( empty( $permalink ) )
				$permalink = get_permalink( $post->ID );

			$rating    = intval( $rating );
			$unique_id = wp_strip_all_tags( $unique_id );
			$item_id   = wp_strip_all_tags( $item_id );
			$item_id   = preg_replace( '/[^_a-z0-9]/i', '', $item_id );

			$settings = json_encode( array(
				'id'        => $rating,
				'unique_id' => $unique_id,
				'title'     => rawurlencode( trim( $title ) ),
				'permalink' => esc_url( $permalink ),
				'item_id'   => $item_id
			) );

			$item_id = esc_js( $item_id );

			if ( $inline ) {
				return <<<SCRIPT
<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div>
<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!--
PDRTJS_settings_{$rating}{$item_id}={$settings};
//--><!]]></script>
<script type="text/javascript" charset="UTF-8" src="http://i.polldaddy.com/ratings/rating.js"></script>
SCRIPT;
			}
			else {
				if ( self::$scripts === false )
					self::$scripts = array();

				$data = array( 'id' => $rating, 'item_id' => $item_id, 'settings' => $settings );

				self::$scripts['rating'][] = $data;

				add_action( 'wp_footer', array( $this, 'generate_scripts' ) );

				$data = esc_attr( json_encode( $data ) );

				if ( $infinite_scroll )
					return <<<CONTAINER
<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}" data-settings="{$data}"></div>
CONTAINER;
				else
					return <<<CONTAINER
<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div>
CONTAINER;
			}
		}
		elseif ( intval( $poll ) > 0 ) { //poll embed

			$poll      = intval( $poll );
			$poll_url  = sprintf( 'http://polldaddy.com/poll/%d', $poll );
			$poll_js   = sprintf( '%s.polldaddy.com/p/%d.js', ( is_ssl() ? 'https://secure' : 'http://static' ), $poll );
			$poll_link = sprintf( '<a href="%s">Take Our Poll</a>', $poll_url );

			if ( $no_script )
				return $poll_link;
			else {
				if ( $type == 'slider' && !$inline ) {

					if( !in_array( $visit, array( 'single', 'multiple' ) ) )
						$visit = 'single';

					$settings = json_encode( array(
						'type'  => 'slider',
						'embed' => 'poll',
						'delay' => intval( $delay ),
						'visit' => $visit,
						'id'    => intval( $poll )
					) );

					return <<<SCRIPT
<script type="text/javascript" charset="UTF-8" src="http://i0.poll.fm/survey.js"></script>
<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!--
polldaddy.add( {$settings} );
//--><!]]></script>
<noscript>{$poll_link}</noscript>
SCRIPT;
				}
				else {
					$cb      = ( $cb == 1 ? '?cb='.mktime() : false );
					$margins = '';
					$float   = '';

					if ( in_array( $align, array( 'right', 'left' ) ) ) {
						$float = sprintf( 'float: %s;', $align );

						if ( $align == 'left')
							$margins = 'margin: 0px 10px 0px 0px;';
						elseif ( $align == 'right' )
							$margins = 'margin: 0px 0px 0px 10px';
					}

					if ( $cb === false && !$inline ) {
						if ( self::$scripts === false )
							self::$scripts = array();

						$data = array( 'url' => $poll_js );

						self::$scripts['poll'][] = $data;

						add_action( 'wp_footer', array( $this, 'generate_scripts' ) );

						$data = esc_attr( json_encode( $data ) );

						return <<<CONTAINER
<a id="pd_a_{$poll}"></a>
<div class="PDS_Poll" id="PDI_container{$poll}" data-settings="{$data}" style="display:inline-block;{$float}{$margins}"></div>
<div id="PD_superContainer"></div>
<noscript>{$poll_link}</noscript>
CONTAINER;
					}
					else {
						if ( $inline )
							$cb = '';

						return <<<CONTAINER
<a id="pd_a_{$poll}"></a>
<div class="PDS_Poll" id="PDI_container{$poll}" style="display:inline-block;{$float}{$margins}"></div>
<div id="PD_superContainer"></div>
<script type="text/javascript" charset="UTF-8" src="{$poll_js}{$cb}"></script>
<noscript>{$poll_link}</noscript>
CONTAINER;
					}
				}
			}
		}
		elseif ( !empty( $survey ) ) { //survey embed

			if ( in_array( $type, array( 'iframe', 'button', 'banner', 'slider' ) ) ) {

				if ( empty( $title ) ) {
					$title = 'Take Our Survey';
					if( !empty( $link_text ) )
						$title = $link_text;
				}

				$survey      = preg_replace( '/[^a-f0-9]/i', '', $survey );
				$survey_url  = esc_url( "http://polldaddy.com/s/{$survey}" );
				$survey_link = sprintf( '<a href="%s">%s</a>', $survey_url, esc_html( $title ) );

				if ( $no_script || $inline || $infinite_scroll )
					return $survey_link;

				if ( $type == 'iframe' ) {
					if ( $height != 'auto' ) {
						if ( isset( $content_width ) && is_numeric( $width ) && $width > $content_width )
							$width = $content_width;

						if ( !$width )
							$width = '100%';
						else
							$width = (int) $width;

						if ( !$height )
							$height = '600';
						else
							$height = (int) $height;

						return <<<CONTAINER
<iframe src="{$survey_url}?iframe=1" frameborder="0" width="{$width}" height="{$height}" scrolling="auto" allowtransparency="true" marginheight="0" marginwidth="0">{$survey_link}</iframe>
CONTAINER;
					}
					elseif ( !empty( $domain ) && !empty( $id ) ) {

						$auto_src = esc_url( "http://{$domain}.polldaddy.com/s/{$id}" );
						$auto_src = parse_url( $auto_src );

						if ( !is_array( $auto_src ) || count( $auto_src ) == 0 )
							return '<!-- no polldaddy output -->';

						if ( !isset( $auto_src['host'] ) || !isset( $auto_src['path'] ) )
							return '<!-- no polldaddy output -->';

						$domain   = $auto_src['host'].'/s/';
						$id       = str_ireplace( '/s/', '', $auto_src['path'] );

						$settings = json_encode( array(
							'type'       => $type,
							'auto'       => true,
							'domain'     => $domain,
							'id'         => $id
						) );
					}
				}
				else {
					$text_color = preg_replace( '/[^a-f0-9]/i', '', $text_color );
					$back_color = preg_replace( '/[^a-f0-9]/i', '', $back_color );

					if ( !in_array( $align, array( 'right', 'left', 'top-left', 'top-right', 'middle-left', 'middle-right', 'bottom-left', 'bottom-right' ) ) )
						$align = '';

					if ( !in_array( $style, array( 'inline', 'side', 'corner', 'rounded', 'square' ) ) )
						$style = '';

					$title  = wp_strip_all_tags( $title );
					$body   = wp_strip_all_tags( $body );
					$button = wp_strip_all_tags( $button );

					$settings = json_encode( array_filter( array(
						'title'      => $title,
						'type'       => $type,
						'body'       => $body,
						'button'     => $button,
						'text_color' => $text_color,
						'back_color' => $back_color,
						'align'      => $align,
						'style'      => $style,
						'id'         => $survey
					) ) );
				}
				return <<<CONTAINER
<script type="text/javascript" charset="UTF-8" src="http://i0.poll.fm/survey.js"></script>
<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!--
polldaddy.add( {$settings} );
//--><!]]></script>
<noscript>{$survey_link}</noscript>
CONTAINER;
			}
		}
		else
			return '<!-- no polldaddy output -->';
	}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/polldaddy.php

Slim Jetpack [presentation] Shortcode

The Slimjetpack plugin shortcode is responsible for creating a customizable presentation on your WordPress site. It allows users to set parameters such as duration, height, width, background color or image, autoplay, and transition effects. If no specific parameters are set, default values are used. The presentation is hidden by default in case scripts fail. It also includes a message for unsupported browsers.

Shortcode: [presentation]

Parameters

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

  • duration – Defines how long each slide lasts
  • height – Sets the height of the presentation
  • width – Determines the width of the presentation
  • bgcolor – Assigns a background color to the presentation
  • bgimg – Sets a background image for the presentation
  • autoplay – Controls automatic playback of the presentation
  • transition – Specifies the transition style between slides
  • scale – Decides the size of the presentation
  • rotate – Determines the rotation angle of the presentation
  • fade – Controls the fade effect on the presentation
  • fadebullets – Manages the fade effect on bullet points

Examples and Usage

Basic example – Utilizing the shortcode to display a basic presentation slide with default parameters. This presentation slide will have a default duration, height, width, and transition effects.

[presentation /]

Advanced examples

Using the shortcode to display a presentation slide with custom width, height, and autoplay duration. The width and height of the slide are set to 500 and 400 respectively, and the autoplay duration is set to 5 seconds.

[presentation width="500" height="400" autoplay="5" /]

Using the shortcode to display a presentation slide with a custom transition effect, scale, rotation, and fade effect. The transition effect is set to ‘up’, the scale is set to 1.5, the rotation is set to 45 degrees, and the fade effect is turned on.

[presentation transition="up" scale="1.5" rotate="45" fade="on" /]

Using the shortcode to display a presentation slide with a custom background color. The background color is set to ‘blue’.

[presentation bgcolor="blue" /]

Using the shortcode to display a presentation slide with a custom background image. The background image is set to the URL of the image.

[presentation bgimg="https://example.com/image.jpg" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'presentation', array( &$this, 'presentation_shortcode' ) );

Shortcode PHP function:

                    function presentation_shortcode( $atts, $content='' ) {
		// Mark that we've found a valid [presentation] shortcode
		$this->presentation_initialized = true;

		$atts = shortcode_atts( array(
			'duration'    => '',
			'height'      => '',
			'width'       => '',
			'bgcolor'     => '',
			'bgimg'       => '',
			'autoplay'    => '',

			// Settings
			'transition'  => '',
			'scale'       => '',
			'rotate'      => '',
			'fade'        => '',
			'fadebullets' => '',
		), $atts );

		$this->presentation_settings = array(
			'transition'  => 'down',
			'scale'       => 1,
			'rotate'      => 0,
			'fade'        => 'on',
			'fadebullets' => 0,
			'last'        => array(
				'x'       => 0,
				'y'       => 0,
				'scale'   => 1,
				'rotate'  => 0,
			),
		);

		// Set the presentation-wide settings
		if ( '' != trim( $atts['transition'] ) )
			$this->presentation_settings['transition'] = $atts['transition'];

		if ( '' != trim( $atts['scale'] ) )
			$this->presentation_settings['scale'] = floatval( $atts['scale'] );

		if ( '' != trim( $atts['rotate'] ) )
			$this->presentation_settings['rotate'] = floatval( $atts['rotate'] );

		if ( '' != trim( $atts['fade'] ) )
			$this->presentation_settings['fade'] = $atts['fade'];

		if ( '' != trim( $atts['fadebullets'] ) )
			$this->presentation_settings['fadebullets'] = $atts['fadebullets'];

		// Set any settings the slides don't care about
		if ( '' != trim( $atts['duration'] ) )
			$duration = floatval( $atts['duration'] ) . 's';
		else
			$duration = '1s';

		// Autoplay durations are set in milliseconds
		if ( '' != trim( $atts['autoplay'] ) )
			$autoplay = floatval( $atts['autoplay'] ) * 1000;
		else
			$autoplay = 0; // No autoplay

		// Set the presentation size as specified or with some nicely sized dimensions
		if ( '' != trim( $atts['width'] ) )
			$this->presentation_settings['width'] = intval( $atts['width'] );
		else
			$this->presentation_settings['width'] = 480;

		if ( '' != trim( $atts['height'] ) )
			$this->presentation_settings['height'] = intval( $atts['height'] );
		else
			$this->presentation_settings['height'] = 370;

		// Hide the content by default in case the scripts fail
		$style = 'display: none; width: ' . $this->presentation_settings['width'] . 'px; height: ' . $this->presentation_settings['height'] . 'px;';

		// Check for background color XOR background image
		// Use a white background if nothing specified
		if ( preg_match( '/https?\:\/\/[^\'"\s]*/', $atts['bgimg'], $matches ) ) {
			$style .= ' background-image: url("' . esc_url( $matches[0] ) . '");';
		} else if ( '' != trim( $atts['bgcolor'] ) ) {
			$style .= ' background-color: ' . esc_attr( $atts['bgcolor'] ) . ';';
		} else {
			$style .= ' background-color: #fff;';
		}

		// Not supported message style is inlined incase the style sheet doesn't get included
		$out = "<section class='presentation-wrapper'>";
		$out.= "<p class='not-supported-msg' style='display: inherit; padding: 25%; text-align: center;'>";
		$out.= __( 'This slideshow could not be started. Try refreshing the page or viewing it in another browser.' , 'jetpack' ) . '</p>';

		// Bail out unless the scripts were added
		if ( $this->scripts_and_style_included ) {
			$out.= sprintf(
				'<div class="presentation" duration="%s" data-autoplay="%s" style="%s">',
				esc_attr( $duration ),
				esc_attr( $autoplay ),
				esc_attr( $style )
			);
			$out.= "<div class='nav-arrow-left'></div>";
			$out.= "<div class='nav-arrow-right'></div>";
			$out.= "<div class='nav-fullscreen-button'></div>";

			if ( $autoplay ) {
				$out.= "<div class='autoplay-overlay' style='display: none'><p class='overlay-msg'>";
				$out.= __( 'Click to autoplay the presentation!' , 'jetpack' );
				$out.= "</p></div>";
			}

			$out.= do_shortcode( $content );
		}

		$out.= "</section>";

		$this->presentation_initialized = false;
		return $out;
	}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/presentations.php

Slim Jetpack [slide] Shortcode

The Slimjetpack ‘slide’ shortcode is designed to create a slide presentation on your WordPress site. It initiates a slide with customizable attributes such as transition, scale, rotation, fade effect, bullet fading, background color, and background image. This shortcode allows for dynamic presentations, offering a variety of transitions and effects. It also ensures that the content is properly formatted and visually appealing by adjusting the scale and rotation. It can control the visibility of content and bullets with fade effects. Additionally, it provides customization options for the slide’s background, either by setting a specific color or by using an image URL. This shortcode ultimately compiles these settings to generate a stylish, interactive slide for your WordPress site.

Shortcode: [slide]

Parameters

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

  • transition – Sets the transition effect for the slide.
  • scale – Adjusts the scale or size of the content.
  • rotate – Determines the rotation angle of the content.
  • fade – If set to ‘on’ or ‘true’, the content will fade in.
  • fadebullets – If set to ‘on’ or ‘true’, bullets will fade on step changes.
  • bgcolor – Sets the background color of the slide.
  • bgimg – Sets the background image of the slide.

Examples and Usage

Basic example – The following shortcode will create a slide with default settings. It will use the default transition, scale, and rotation settings defined in the plugin’s settings.

[slide][/slide]

Advanced examples

Creating a slide with specific transition, scale, and rotation settings. The transition will be set to ‘fade’, the scale to ‘2’, and the rotation to ’90’ degrees.

[slide transition="fade" scale="2" rotate="90"]Your content here[/slide]

Creating a slide with a background image. The URL of the image is passed in the ‘bgimg’ attribute.

[slide bgimg="https://example.com/path/to/image.jpg"]Your content here[/slide]

Creating a slide with a specific background color. The color is passed in the ‘bgcolor’ attribute.

[slide bgcolor="#ff0000"]Your content here[/slide]

Creating a slide where the bullets fade on step changes. This is achieved by setting the ‘fadebullets’ attribute to ‘true’.

[slide fadebullets="true"]Your content here[/slide]

PHP Function Code

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

Shortcode line:

add_shortcode( 'slide',        array( &$this, 'slide_shortcode'        ) );

Shortcode PHP function:

                    function slide_shortcode( $atts, $content = '' ) {
		// Bail out unless wrapped by a [presentation] shortcode
		if ( ! $this->presentation_initialized )
			return $content;

		$atts = shortcode_atts( array(
			'transition' => '',
			'scale'      => '',
			'rotate'     => '',
			'fade'       => '',
			'fadebullets'=> '',
			'bgcolor'    => '',
			'bgimg'      => '',
		), $atts );

		// Determine positioning based on transition
		if ( '' == trim( $atts['transition'] ) )
			$atts['transition'] = $this->presentation_settings['transition'];

		// Setting the content scale
		if ( '' == trim( $atts['scale'] ) )
			$atts['scale'] = $this->presentation_settings['scale'];

		if( '' == trim( $atts['scale'] ) )
			$scale = 1;
		else
			$scale = floatval( $atts['scale'] );

		if ( $scale < 0 )
			$scale *= -1;

		// Setting the content rotation
		if ( '' == trim( $atts['rotate'] ) )
			$atts['rotate'] = $this->presentation_settings['rotate'];

		if( '' == trim( $atts['rotate'] ) )
			$rotate = 0;
		else
			$rotate = floatval( $atts['rotate'] );

		// Setting if the content should fade
		if ( '' == trim( $atts['fade'] ) )
			$atts['fade'] = $this->presentation_settings['fade'];

		if ( 'on' == $atts['fade'] || 'true' == $atts['fade'] )
			$fade = 'fade';
		else
			$fade = '';

		// Setting if bullets should fade on step changes
		if ( '' == trim( $atts['fadebullets'] ) )
			$atts['fadebullets'] = $this->presentation_settings['fadebullets'];

		if ( 'on' == $atts['fadebullets'] || 'true' == $atts['fadebullets'] )
			$fadebullets = 'fadebullets';
		else
			$fadebullets = '';

		$coords = $this->get_coords( array(
			'transition' => $atts['transition'],
			'scale'      => $scale,
			'rotate'     => $rotate,
		));

		$x = $coords['x'];
		$y = $coords['y'];

		// Check for background color XOR background image
		// Use a white background if nothing specified
		if ( preg_match( '/https?\:\/\/[^\'"\s]*/', $atts['bgimg'], $matches ) ) {
			$style = 'background-image: url("' . esc_url( $matches[0] ) . '");';
		} else if ( '' != trim( $atts['bgcolor'] ) ) {
			$style = 'background-color: ' . esc_attr( $atts['bgcolor'] ) . ';';
		} else {
			$style = '';
		}

		// Put everything together and let jmpress do the magic!
		$out = sprintf(
			'<div class="step %s %s" data-x="%s" data-y="%s" data-scale="%s" data-rotate="%s" style="%s">',
			esc_attr( $fade ),
			esc_attr( $fadebullets ),
			esc_attr( $x ),
			esc_attr( $y ),
			esc_attr( $scale ),
			esc_attr( $rotate ),
			esc_attr( $style )
		);

		$out.= "<div class='slide-content'>";
		$out.= do_shortcode( $content );
		$out.= "</div></div>";
		return $out;
	}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/presentations.php

Slim Jetpack [scribd] Shortcode

The Slimjetpack Scribd shortcode is designed to handle and display Scribd documents on your website. It uses the ‘id’, ‘key’, and ‘mode’ attributes to customize the display.

Shortcode: [scribd]

Parameters

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

  • id – Unique identifier for the Scribd document
  • key – Special key associated with the Scribd document
  • mode – Display mode for the Scribd document. Accepts ‘list’, ‘book’, ‘slide’, ‘slideshow’, or ’tile’

Examples and Usage

Basic example – A simple usage of the shortcode to embed a document from Scribd using its unique ID and key.

[scribd id=12345 key=abcdef /]

Advanced examples

Here, the shortcode is used to embed a document from Scribd using its unique ID, key, and a specific display mode. The mode attribute can take values like ‘list’, ‘book’, ‘slide’, ‘slideshow’, or ’tile’. If the mode attribute is not one of these values, it defaults to an empty string, which means the document is displayed in the default mode.

[scribd id=12345 key=abcdef mode=slide /]

In this example, the shortcode is used to embed a document from Scribd using only its unique ID and key. If the key is not a valid alphanumeric string, the shortcode returns an empty string, which means no document is displayed.

[scribd id=12345 key=abcdef /]

Remember, the ID and key attributes are required for the shortcode to function. If they are not provided or are incorrect, the shortcode will not display any document.

PHP Function Code

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

Shortcode line:

add_shortcode( 'scribd', 'scribd_shortcode_handler' );

Shortcode PHP function:

                    function scribd_shortcode_handler( $atts ) {
	$atts = shortcode_atts( array(
		'id'   => 0,
		'key'  => 0,
		'mode' => "",
	), $atts );

	$modes = array( 'list', 'book', 'slide', 'slideshow', 'tile' );

	$atts['id'] = (int) $atts['id'];
	if ( preg_match( '/^[A-Za-z0-9-]+$/', $atts['key'], $m ) ) {
		$atts['key'] = $m[0];

		if ( !in_array( $atts['mode'], $modes ) )
			$atts['mode'] = '';

		return scribd_shortcode_markup( $atts );
	} else {
		return '';
	}
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/scribd.php

Slim Jetpack [slideshare] Shortcode

The Slimjetpack ‘slideshare’ shortcode enables the embedding of SlideShare presentations in your posts. It checks for valid ID and document parameters, and adjusts the width according to the content width or specified value.

Shortcode: [slideshare]

Parameters

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

  • id – Identifier for the SlideShare presentation.
  • doc – Name of the SlideShare document to display.
  • w – Sets the width of the displayed SlideShare. If not set, defaults to content width or 425.
  • type – Defines the player type. If set to ‘d’, uses a different player URL.

Examples and Usage

Basic example – Embeds a SlideShare presentation into a post or page using the presentation’s unique id and document name.

[slideshare id=12345 doc=example-document /]

Advanced examples

Embeds a SlideShare presentation into a post or page using the presentation’s unique id, document name, and specific width. The height will be calculated automatically to maintain the aspect ratio of the presentation.

[slideshare id=12345 doc=example-document w=800 /]

Embeds a SlideShare presentation into a post or page using the presentation’s unique id, document name, specific width, and type ‘d’. The ‘d’ type changes the style of the player.

[slideshare id=12345 doc=example-document w=800 type=d /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'slideshare', 'slideshare_shortcode' );

Shortcode PHP function:

                    function slideshare_shortcode( $atts ) {
	global $content_width;

	$params = shortcode_new_to_old_params( $atts );
	parse_str( $params, $arguments );

	if ( empty( $arguments ) )
		return "<!-- SlideShare error: no arguments -->";

	extract( $arguments );

	$pattern = '/[^-_a-zA-Z0-9]/';
	if ( empty( $id ) || preg_match( $pattern, $id ) )
		return "<!-- SlideShare error: id is missing or has illegal characters -->";

	if ( empty( $doc ) || preg_match( $pattern, $doc ) )
		return "<!-- SlideShare error: doc is missing or has illegal characters -->";

	if ( empty( $w ) && !empty( $content_width ) )
		$w = intval( $content_width );
	elseif ( ! ( $w = intval( $w ) ) || $w < 300 || $w > 1600 )
		$w = 425;
	else
		$w = intval( $w );

	$h = ceil( $w * 348 / 425 );

	$player = "<object type='application/x-shockwave-flash' wmode='opaque' data='http://static.slideshare.net/swf/ssplayer2.swf?id=$id&doc=$doc' width='$w' height='$h'><param name='movie' value='http://static.slideshare.net/swf/ssplayer2.swf?id=$id&doc=$doc' /><param name='allowFullScreen' value='true' /></object>";
	if ( !empty( $type ) && $type == 'd' )
		$player = "<object style='margin: 0px;' width='$w' height='$h'><param name='movie' value='http://static.slidesharecdn.com/swf/ssplayerd.swf?doc=$doc' /><param name='allowFullScreen' value='true' /><param name='wmode' value='opaque' /><embed src='http://static.slidesharecdn.com/swf/ssplayerd.swf?doc=$doc' type='application/x-shockwave-flash' allowfullscreen='true' wmode='opaque' width='$w' height='$h'></embed></object>";

	return $player;
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/slideshare.php

Slim Jetpack [slideshow] Shortcode

The SlimJetpack shortcode is a powerful tool that generates a slideshow from image attachments. It allows customization of transition style, order, and inclusion or exclusion of specific images. The PHP code fetches the images, applies filters, and prepares the slideshow. Additionally, it handles display settings, ensuring optimal view across different screen sizes. The shortcode also provides a link to the gallery in feeds, enhancing user accessibility.

Shortcode: [slideshow]

Parameters

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

  • trans – Specifies the transition effect for the slideshow
  • order – Determines the order of the images in the slideshow
  • orderby – Defines the criteria to order the images
  • id – Identifies the post from which to get the images
  • include – Lists the specific images to include in the slideshow
  • exclude – Lists the specific images to exclude from the slideshow

Examples and Usage

Basic example – The shortcode displays a slideshow from the images attached to the current post. The order of the images is determined by the menu order and ID.

[slideshow /]

Advanced examples

Using the shortcode to display a slideshow with specific transition effect. In this case, the transition effect is set to ‘fade’.

[slideshow trans='fade' /]

Using the shortcode to display a slideshow from a specific post by referencing the post ID. The images are ordered in ascending order.

[slideshow id='123' order='ASC' /]

Using the shortcode to display a slideshow from a specific post and excluding certain images. The images to be excluded are identified by their IDs.

[slideshow id='123' exclude='456,789' /]

Using the shortcode to display a slideshow from a specific post and including only certain images. The images to be included are identified by their IDs.

[slideshow id='123' include='456,789' /]

Using the shortcode to display a slideshow from a specific post with a custom order. The order is set to ‘rand’, which means the images will be displayed in a random order.

[slideshow id='123' order='rand' /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'slideshow', array( $this, 'shortcode_callback' ) );

Shortcode PHP function:

                    function shortcode_callback( $attr, $content = null ) {
		global $post, $content_width;

		$attr = shortcode_atts( array(
			'trans'     => 'fade',
			'order'     => 'ASC',
			'orderby'   => 'menu_order ID',
			'id'        => $post->ID,
			'include'   => '',
			'exclude'   => '',
		), $attr );

		if ( 'rand' == strtolower( $attr['order'] ) )
			$attr['orderby'] = 'none';

		$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
		if ( ! $attr['orderby'] )
			$attr['orderby'] = 'menu_order ID';

		// Don't restrict to the current post if include
		$post_parent = ( empty( $attr['include'] ) ) ? intval( $attr['id'] ) : null;

		$attachments = get_posts( array(
			'post_status'    => 'inherit',
			'post_type'      => 'attachment',
			'post_mime_type' => 'image',
			'posts_per_page' => -1,
			'post_parent'    => $post_parent,
			'order'          => $attr['order'],
			'orderby'        => $attr['orderby'],
			'include'        => $attr['include'],
			'exclude'        => $attr['exclude'],
		) );

		if ( count( $attachments ) < 2 )
			return;

		$gallery_instance = sprintf( "gallery-%d-%d", $attr['id'], ++$this->instance_count );

		$gallery = array();
		foreach ( $attachments as $attachment ) {
			$attachment_image_src = wp_get_attachment_image_src( $attachment->ID, 'full' );
			$attachment_image_src = $attachment_image_src[0]; // [url, width, height]
			$caption = apply_filters( 'jetpack_slideshow_slide_caption', wptexturize( strip_tags( $attachment->post_excerpt ) ), $attachment->ID );

			$gallery[] = (object) array(
				'src'     => (string) esc_url_raw( $attachment_image_src ),
				'id'      => (string) $attachment->ID,
				'caption' => (string) $caption,
			);
		}

		$max_width = intval( get_option( 'large_size_w' ) );
		$max_height = 450;
		if ( intval( $content_width ) > 0 )
			$max_width = min( intval( $content_width ), $max_width );

		$js_attr = array(
			'gallery'  => $gallery,
			'selector' => $gallery_instance,
			'width'    => $max_width,
			'height'   => $max_height,
			'trans'    => $attr['trans'] ? $attr['trans'] : 'fade',
		 );

		// Show a link to the gallery in feeds.
		if ( is_feed() )
			return sprintf( '<a href="%s">%s</a>',
				esc_url( get_permalink( $post->ID ) . '#' . $gallery_instance . '-slideshow' ),
				esc_html__( 'Click to view slideshow.', 'jetpack' )
			);

		return $this->slideshow_js( $js_attr );
	}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/slideshow.php

Slim Jetpack [soundcloud] Shortcode

The Slimjetpack Soundcloud shortcode allows users to customize Soundcloud embeds in their WordPress posts. It merges user preferences with shortcode options, ensuring the “url” option is present, and validating that “width” and “height” are integers. It also checks if the “iframe” option is true to load the iframe widget. Based on these conditions, it returns the appropriate Soundcloud widget.

Shortcode: [soundcloud]

Parameters

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

  • url – The link to the specific SoundCloud track or playlist.
  • params – Additional parameters to customize the player like auto_play and show_comments.
  • iframe – Determines if the iframe widget should be used.
  • width – Sets the width of the SoundCloud player.
  • height – Sets the height of the SoundCloud player.
  • auto_play – Automatically starts playing the track when the page loads.
  • show_comments – Displays comments on the SoundCloud track.
  • color – Changes the color of the SoundCloud player.
  • theme_color – Changes the theme color of the SoundCloud player.

Examples and Usage

Basic example – Embedding a SoundCloud track using its URL

[soundcloud]https://soundcloud.com/user/track[/soundcloud]

Advanced examples

Embedding a SoundCloud track with custom width and height parameters. The width is set to 500 pixels and the height is set to 300 pixels.

[soundcloud width="500" height="300"]https://soundcloud.com/user/track[/soundcloud]

Embedding a SoundCloud track with auto play enabled and comments disabled. The ‘auto_play’ parameter is set to ‘true’ and the ‘show_comments’ parameter is set to ‘false’.

[soundcloud params="auto_play=true&show_comments=false"]https://soundcloud.com/user/track[/soundcloud]

Embedding a SoundCloud track with a custom color and theme color. The ‘color’ parameter is set to ‘FF5500’ (orange) and the ‘theme_color’ parameter is set to ‘000000’ (black).

[soundcloud params="color=FF5500&theme_color=000000"]https://soundcloud.com/user/track[/soundcloud]

PHP Function Code

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

Shortcode line:

add_shortcode("soundcloud", "soundcloud_shortcode");

Shortcode PHP function:

                    function soundcloud_shortcode($atts, $content = null) {

  // Custom shortcode options
  $shortcode_options = array_merge(array('url' => trim($content)), is_array($atts) ? $atts : array());

  // Turn shortcode option "param" (param=value&param2=value) into array
  $shortcode_params = array();
  if (isset($shortcode_options['params'])) {
    parse_str(html_entity_decode($shortcode_options['params']), $shortcode_params);
  }
  $shortcode_options['params'] = $shortcode_params;

  // User preference options
  $plugin_options = array_filter(array(
    'iframe' => soundcloud_get_option('player_iframe', true),
    'width'  => soundcloud_get_option('player_width'),
    'height' =>  soundcloud_url_has_tracklist($shortcode_options['url']) ? soundcloud_get_option('player_height_multi') : soundcloud_get_option('player_height'),
    'params' => array_filter(array(
      'auto_play'     => soundcloud_get_option('auto_play'),
      'show_comments' => soundcloud_get_option('show_comments'),
      'color'         => soundcloud_get_option('color'),
      'theme_color'   => soundcloud_get_option('theme_color'),
    )),
  ));
  // Needs to be an array
  if (!isset($plugin_options['params'])) { $plugin_options['params'] = array(); }

  // plugin options < shortcode options
  $options = array_merge(
    $plugin_options,
    $shortcode_options
  );

  // plugin params < shortcode params
  $options['params'] = array_merge(
    $plugin_options['params'],
    $shortcode_options['params']
  );

  // The "url" option is required
  if (!isset($options['url'])) {
    return '';
  } else {
    $options['url'] = trim($options['url']);
  }

  // Both "width" and "height" need to be integers
  if (isset($options['width']) && !preg_match('/^\d+$/', $options['width'])) {
    // set to 0 so oEmbed will use the default 100% and WordPress themes will leave it alone
    $options['width'] = 0;
  }
  if (isset($options['height']) && !preg_match('/^\d+$/', $options['height'])) { unset($options['height']); }

  // The "iframe" option must be true to load the iframe widget
  $iframe = soundcloud_booleanize($options['iframe'])
    // Default to flash widget for permalink urls (e.g. http://soundcloud.com/{username})
    // because HTML5 widget doesn’t support those yet
    ? preg_match('/api.soundcloud.com/i', $options['url'])
    : false;

  // Return html embed code
  if ($iframe) {
    return soundcloud_iframe_widget($options);
  } else {
    return soundcloud_flash_widget($options);
  }

}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/soundcloud.php

Slim Jetpack [ted] Shortcode

The Slimjetpack shortcode ‘ted’ embeds a TED talk video into a WordPress post or page. It uses the TED talk’s ID to fetch the video and adjust its dimensions. The shortcode allows customization of width, height, and language. If no dimensions are specified, it defaults to a width of 500 and a 16:9 aspect ratio. The language defaults to English.

Shortcode: [ted]

Parameters

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

  • id – The unique identifier for the TED talk
  • width – Determines the display width of the embedded TED talk
  • height – Controls the display height of the embedded TED talk
  • lang – Specifies the language for the TED talk

Examples and Usage

Basic example – Embeds a TED talk on your page using the talk’s unique ID.

[ted id="2549" /]

Advanced examples

Embeds a TED talk with a specific width and height. This is useful if you want to control the size of the embedded video on your page.

[ted id="2549" width="500" height="300" /]

Embeds a TED talk and sets the language for the subtitles. This is useful if your audience speaks a different language. The ‘lang’ attribute accepts a language code (for example, ‘eng’ for English, ‘esp’ for Spanish, etc.).

[ted id="2549" lang="esp" /]

Combines all the above parameters to embed a TED talk with a specific size and subtitles in a specific language.

[ted id="2549" width="500" height="300" lang="esp" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'ted', 'shortcode_ted' );

Shortcode PHP function:

                    function shortcode_ted( $atts, $content = '' ) {
	global $wp_embed;

	$defaults = array(
			'id'          => '',
			'width'       => '',
			'height'      => '',
			'lang'        => 'eng',
		);
	$atts = shortcode_atts( $defaults, $atts );

	if ( empty( $atts['id'] ) )
		return '<!-- Missing TED ID -->';

	if ( preg_match( "#^[\d]+$#", $atts['id'], $matches ) )
		$url = 'http://ted.com/talks/view/id/' . $matches[0];
	elseif ( preg_match( "#^https?://(www\.)?ted\.com/talks/view/id/[0-9]+$#", $atts['id'], $matches ) )
		$url = $matches[0];

	unset( $atts['id'] );

	$args = array();
	if ( is_numeric( $atts['width'] ) )
		$args['width'] = $atts['width'];
	else if ( $embed_size_w = get_option( 'embed_size_w' ) )
		$args['width'] = $embed_size_w;
	else if ( ! empty( $GLOBALS['content_width'] ) )
		$args['width'] = (int)$GLOBALS['content_width'];
	else
		$args['width'] = 500;

	// Default to a 16x9 aspect ratio if there's no height set
	if ( is_numeric( $atts['height'] ) )
		$args['height'] = $atts['height'];
	else
		$args['height'] = $args['width'] * 0.5625;

	if ( ! empty( $atts['lang'] ) ) {
		$args['lang'] = sanitize_key( $atts['lang'] );
		add_filter( 'oembed_fetch_url', 'ted_filter_oembed_fetch_url', 10, 3 );
	}
	$retval = $wp_embed->shortcode( $args, $url );
	remove_filter( 'oembed_fetch_url', 'ted_filter_oembed_fetch_url', 10 );
	return $retval;
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/ted.php

Slim Jetpack [twitter-timeline] Shortcode

The SlimJetpack plugin’s shortcode, ‘twitter-timeline’, embeds a Twitter timeline onto your WordPress site. It accepts parameters like username, id, height, and width. It validates the username and id, and if they are valid, it generates an output showing tweets from the specified username. The shortcode also adds a ‘twitter_timeline_js’ action to the ‘wp_footer’ action hook.

Shortcode: [twitter-timeline]

Parameters

Here is a list of all possible twitter-timeline shortcode parameters and attributes:

  • username – The Twitter username to display the timeline of.
  • id – The unique identifier of the Twitter widget.
  • height – The height of the Twitter timeline in pixels.
  • width – The width of the Twitter timeline in pixels.

Examples and Usage

Basic example – A simple usage of the ‘twitter-timeline’ shortcode to display the Twitter timeline of a specific user by their username.

[twitter-timeline username="your_username" /]

Advanced examples

Using the shortcode to display a Twitter timeline from a specific user with a specific width and height. This example allows you to customize the dimensions of the embedded timeline to better fit your website’s design.

[twitter-timeline username="your_username" width="500" height="600" /]

Using the shortcode with all available parameters. This example includes the ‘id’ parameter, which corresponds to the data-widget-id attribute in the Twitter embed code. It’s a unique identifier for the widget and can be found in the embed code provided by Twitter.

[twitter-timeline username="your_username" id="your_widget_id" width="500" height="600" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'twitter-timeline', 'twitter_timeline_shortcode' );

Shortcode PHP function:

                    function twitter_timeline_shortcode( $attr ) {

	$default_atts = array(
		'username'         => '',
		'id'               => '',
		'height'           => 282,
		'width'            => 450,

	);

	$attr = shortcode_atts( $default_atts, $attr );

	if ( $attr['username'] != preg_replace( '/[^A-Za-z0-9_]+/', '', $attr['username'] ) )
		return '<!--' . __( 'Invalid username', 'jetpack' ) . '-->';

	if ( ! is_numeric( $attr['id'] ) )
		return '<!--' . __( 'Invalid id', 'jetpack' ) . '-->';

	$tweets_by = sprintf( __( 'Tweets by @%s', 'jetpack' ), $attr['username'] );
	$output = '<a class="twitter-timeline" width="' . (int)$attr['width'] . '" height="' . (int)$attr['width'] . '" href="' . esc_url( 'https://twitter.com/'. $attr['username'] ) . '" data-widget-id="' . (int)$attr['id'] . '">' . esc_html( $tweets_by ) . '</a>';
	add_action( 'wp_footer', 'twitter_timeline_js' );

	return $output;
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/twitter-timeline.php

Slim Jetpack [vimeo] Shortcode

The Slimjetpack Vimeo shortcode enables embedding of Vimeo videos into WordPress posts. It accepts parameters for video ID, width, and height. This shortcode uses the ‘vimeo_shortcode’ function, which extracts the video ID, width, and height from the shortcode attributes. If width or height is not provided, it calculates them based on a 16:9 ratio, defaulting to the content width if no width is set. The function then constructs an HTML iframe to embed the video, applying any filters to the video embed HTML before returning it.

Shortcode: [vimeo]

Parameters

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

  • id – Unique identifier for the Vimeo video.
  • width – Sets the width of the embedded video.
  • height – Sets the height of the embedded video.
  • w – Alternative way to set the video width.
  • h – Alternative way to set the video height.

Examples and Usage

Basic example – Embeds a Vimeo video on your WordPress site using the video’s ID.

[vimeo id=123456 /]

Advanced examples

Embeds a Vimeo video with a custom width and height. The width and height are specified in pixels.

[vimeo id=123456 width=500 height=400 /]

Embeds a Vimeo video with a custom width. The height is automatically calculated based on the width to maintain the video’s aspect ratio.

[vimeo id=123456 w=500 /]

Embeds a Vimeo video with a custom height. The width is automatically calculated based on the height to maintain the video’s aspect ratio.

[vimeo id=123456 h=300 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'vimeo', 'vimeo_shortcode' );

Shortcode PHP function:

                    function vimeo_shortcode( $atts ) {
	global $content_width;

	extract( array_map( 'intval', shortcode_atts( array(
		'id'     => 0,
		'width'  => 400,
		'height' => 300
	), $atts ) ) );

	if ( isset( $atts[0] ) )
		$id = jetpack_shortcode_get_vimeo_id( $atts );

	if ( ! $id ) return "<!-- vimeo error: not a vimeo video -->";

	// [vimeo 141358 h=500&w=350]
	$params = shortcode_new_to_old_params( $atts ); // h=500&w=350
	$params = str_replace( array( '&amp;', '&#038;' ), '&', $params );
	parse_str( $params, $args );

	if ( isset( $args['w'] ) ) {
		$width = (int) $args['w'];

		if ( ! isset( $args['h'] ) ) {
			// The case where w=300 is specified without h=200, otherwise $height
			// will always equal the default of 300, no matter what w was set to.
			$height = round( ( $width / 640 ) * 360 );
		}
	}

	if ( isset( $args['h'] ) ) {
		$height = (int) $args['h'];

		if ( ! isset( $args['w'] ) ) {
			$width = round( ( $height / 360 ) * 640 );
		}
	}

	if ( ! $width )
		$width = absint( $content_width );

	if ( ! $height )
		$height = round( ( $width / 640 ) * 360 );

	$html = "<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/$id' width='$width' height='$height' frameborder='0'></iframe></div>";
	$html = apply_filters( 'video_embed_html', $html );
	return $html;
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/vimeo.php

Slim Jetpack [vine] Shortcode

The Slimjetpack ‘vine’ shortcode embeds Vine videos into your WordPress site. It checks the URL provided in the shortcode to ensure it’s a valid Vine link.

Shortcode: [vine]

Parameters

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

  • url – the web address of the specific Vine video

Examples and Usage

Basic example – A simple Vine video embed using the given shortcode. This example only requires the URL of the Vine video you want to embed.

[vine url="https://vine.co/v/euEpIVegiIx" /]

Advanced examples

Embedding a Vine video by passing the video URL as an attribute. This example shows how you can use the shortcode to embed a Vine video by passing the URL of the video as an attribute to the shortcode. This can be useful if you want to dynamically generate the URL of the video you want to embed.

[vine url="https://vine.co/v/euEpIVegiIx" /]

Using the shortcode to embed a Vine video by passing the video ID as an attribute. This example shows how you can use the shortcode to embed a Vine video by passing the video ID as an attribute to the shortcode. This can be useful if you only have the ID of the video you want to embed, and not the full URL.

[vine id="euEpIVegiIx" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'vine', 'vine_shortcode' );

Shortcode PHP function:

                    function vine_shortcode( $atts ) {
	global $wp_embed;

	if ( empty( $atts['url'] ) )
		return '';

	if ( ! preg_match( '#https?://vine.co/v/([a-z0-9]+).*#i', $atts['url'] ) )
		return '';

	return $wp_embed->shortcode( $atts, $atts['url'] );
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/vine.php

Slim Jetpack [youtube] Shortcode

The Slimjetpack ‘youtube’ shortcode is designed to display YouTube videos. It retrieves the video ID from the shortcode parameters and embeds the video.

Shortcode: [youtube]

Parameters

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

  • youtube_id – The unique identifier of the YouTube video.
  • atts[0] – The first attribute in the shortcode, usually the YouTube video ID.

Examples and Usage

Basic example – Embed a YouTube video using its unique ID

[youtube 'jNQXAC9IVRw' /]

Advanced examples

Embed a YouTube video using its unique ID and specifying the start time in seconds.

[youtube 'jNQXAC9IVRw' start='30' /]

Embed a YouTube video using its unique ID, specifying the start time in seconds and the end time in seconds.

[youtube 'jNQXAC9IVRw' start='30' end='120' /]

Embed a YouTube video using its unique ID, specifying the start time in seconds, end time in seconds and autoplay enabled.

[youtube 'jNQXAC9IVRw' start='30' end='120' autoplay='1' /]
Note: In the above examples, ‘jNQXAC9IVRw’ is the YouTube video ID, ‘start’ and ‘end’ are the start and end times in seconds, and ‘autoplay’ is a boolean value where ‘1’ means autoplay is enabled and ‘0’ means autoplay is disabled.

PHP Function Code

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

Shortcode line:

add_shortcode( 'youtube', 'youtube_shortcode' );

Shortcode PHP function:

                    function youtube_shortcode( $atts ) {
	return youtube_id( ( isset ( $atts[0] ) ) ? ltrim( $atts[0] , '=' ) : shortcode_new_to_old_params( $atts ) );
}
                    

Code file location:

slimjetpack/slimjetpack/modules/shortcodes/youtube.php

Conclusion

Now that you’ve learned how to embed the Slim Jetpack Plugin shortcodes, 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 *