Below, you’ll find a detailed guide on how to add the 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 Jetpack Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Jetpack Plugin and the shortcodes it provides:
"Jetpack – WP Security, Backup, Speed, & Growth is a comprehensive plugin for WordPress. It enhances site security, provides backup solutions, boosts website speed and promotes growth. A must-have tool for every WP user."
- [contact-field]
- [videopress]
- [portfolio]
- [jetpack_testimonials]
- [geo-location]
- [latex]
- [jetpack_relatedposts]
- [archiveorg-book]
- [archiveorg]
- [archives]
- [bandcamp]
- [Jetpack_Brightcove_Shortcode]
- [crowdsignal]
- [polldaddy]
- [dailymotion]
- [dailymotion-channel]
- [facebook]
- [flickr]
- [gist]
- [googleapps]
- [googlemaps]
- [googleplus]
- [jetpack_gravatar_shortcode]
- [gravatar_profile]
- [houzz]
- [kickstarter]
- [medium]
- [mixcloud]
- [presentation]
- [slide]
- [quiz-wrapper]
- [quiz]
- [question]
- [answer]
- [wrong]
- [explanation]
- [recipe]
- [recipe-notes]
- [recipe-ingredients]
- [recipe-directions]
- [recipe-nutrition]
- [recipe-image]
- [scribd]
- [sitemap]
- [slideshare]
- [slideshow]
- [soundcloud]
- [ted]
- [tweet]
- [twitch]
- [twitter-timeline]
- [stub_shortcode]
- [untappd-menu]
- [ustream]
- [ustreamsocial]
- [vimeo]
- [vine]
- [vr]
- [wordads]
- [wufoo]
- [youtube]
- [jetpack_subscription_form]
- [jetpack_top_posts_widget]
- [ccpa-do-not-sell-link]
Jetpack [contact-field] Shortcode
The Jetpack Contact Form shortcode enables the creation of contact fields within a form on a WordPress site. It parses attributes like ‘type’ and ‘label’, and generates HTML based on these inputs.
Shortcode: [contact-field]
Parameters
Here is a list of all possible contact-field shortcode parameters and attributes:
id
– Unique identifier for the contact form.type
– Determines the type of contact form field.options
– Defines the choices for a checkbox or radio field.label
– Text displayed as the field’s title or question.values
– Predefined selections for a dropdown field.content
– The specific text or HTML content for the field.
Examples and Usage
Basic example – A simple contact form field with a label and type defined.
[contact-field label="Your Name" type="text" /]
Advanced examples
Creates a contact form field with multiple checkbox options. The options are defined within the shortcode.
[contact-field label="Select your favorite fruit" type="checkbox-multiple"]
[option label="Apple"]
[option label="Banana"]
[option label="Cherry"]
[/contact-field]
Defines a contact form field with a default value. The value will be pre-filled when the form loads.
[contact-field label="Email" type="email" default="example@example.com" /]
Creates a contact form field with specific id. This can be useful for targeting the field with CSS or JavaScript.
[contact-field label="Message" type="textarea" id="message" /]
Defines a contact form field that is required. The form will not submit unless this field is filled out.
[contact-field label="Your Name" type="text" required="1" /]
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( '\Automattic\Jetpack\Forms\ContactForm\Contact_Form', 'parse_contact_field' ) );
Shortcode PHP function:
function parse_contact_field( $attributes, $content ) {
// Don't try to parse contact form fields if not inside a contact form
if ( ! Contact_Form_Plugin::$using_contact_form_field ) {
$type = isset( $attributes['type'] ) ? $attributes['type'] : null;
if ( $type === 'checkbox-multiple' || $type === 'radio' ) {
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches );
if ( ! empty( $matches[0] ) ) {
$options = array();
foreach ( $matches[0] as $shortcode ) {
$attr = shortcode_parse_atts( $shortcode );
if ( ! empty( $attr['label'] ) ) {
$options[] = $attr['label'];
}
}
$attributes['options'] = $options;
}
}
if ( ! isset( $attributes['label'] ) ) {
$attributes['label'] = self::get_default_label_from_type( $type );
}
$att_strs = array();
foreach ( $attributes as $att => $val ) {
if ( is_numeric( $att ) ) { // Is a valueless attribute
$att_strs[] = self::esc_shortcode_val( $val );
} elseif ( isset( $val ) ) { // A regular attr - value pair
if ( ( $att === 'options' || $att === 'values' ) && is_string( $val ) ) { // remove any empty strings
$val = explode( ',', $val );
}
if ( is_array( $val ) ) {
$val = array_filter( $val, array( __CLASS__, 'remove_empty' ) ); // removes any empty strings
$att_strs[] = esc_html( $att ) . '="' . implode( ',', array_map( array( __CLASS__, 'esc_shortcode_val' ), $val ) ) . '"';
} elseif ( is_bool( $val ) ) {
$att_strs[] = esc_html( $att ) . '="' . ( $val ? '1' : '' ) . '"';
} else {
$att_strs[] = esc_html( $att ) . '="' . self::esc_shortcode_val( $val ) . '"';
}
}
}
$shortcode_type = 'contact-field';
if ( $type === 'field-option' ) {
$shortcode_type = 'contact-field-option';
}
$html = '[' . $shortcode_type . ' ' . implode( ' ', $att_strs );
if ( isset( $content ) && ! empty( $content ) ) { // If there is content, let's add a closing tag
$html .= ']' . esc_html( $content ) . '[/contact-field]';
} else { // Otherwise let's add a closing slash in the first tag
$html .= '/]';
}
return $html;
}
$form = self::$current_form;
$field = new Contact_Form_Field( $attributes, $content, $form );
$field_id = $field->get_attribute( 'id' );
if ( $field_id ) {
$form->fields[ $field_id ] = $field;
} else {
$form->fields[] = $field;
}
if ( // phpcs:disable WordPress.Security.NonceVerification.Missing
isset( $_POST['action'] ) && 'grunion-contact-form' === $_POST['action']
&&
isset( $_POST['contact-form-id'] ) && (string) $form->get_attribute( 'id' ) === $_POST['contact-form-id']
&&
isset( $_POST['contact-form-hash'] ) && is_string( $_POST['contact-form-hash'] ) && hash_equals( $form->hash, wp_unslash( $_POST['contact-form-hash'] ) )
) { // phpcs:enable
// 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:
jetpack/jetpack/jetpack_vendor/automattic/jetpack-forms/src/contact-form/class-contact-form-plugin.php
Jetpack [videopress] Shortcode
The VideoPress shortcode is used to embed a VideoPress video into a WordPress site. It accepts a GUID as an argument, which is the unique identifier for the video. The shortcode has several optional parameters that allow you to customize the video player, such as width, height, autoplay, loop, and more. It generates an iframe with the VideoPress video player, ensuring a seamless viewing experience.
Shortcode: [videopress]
Parameters
Here is a list of all possible videopress shortcode parameters and attributes:
w
– Defines the width of the video player in pixels.h
– Sets the height of the video player in pixels.at
– Specifies the starting point of the video in seconds.loop
– Determines whether the video will loop continuously.autoplay
– Decides if the video will start playing automatically on load.cover
– Determines whether the video scales to fit its container.muted
– Specifies whether the video should start without sound.controls
– Indicates whether the video player controls should be displayed.playsinline
– Determines if the video should play inline on supported browsers.useaveragecolor
– Decides if the video should use the seekbar’s automatic average color.preloadcontent
– Specifies what part of the video should load first.
Examples and Usage
Basic example – Embeds a VideoPress video using its GUID (Global Unique Identifier).
[videopress Qq0h1qNe]
Advanced examples
Embeds a VideoPress video with custom width, autoplay enabled, and loop enabled.
[videopress Qq0h1qNe w=800 autoplay=true loop=true]
Embeds a VideoPress video with custom width, autoplay enabled, loop enabled, and initially muted.
[videopress Qq0h1qNe w=800 autoplay=true loop=true muted=true]
Embeds a VideoPress video with custom width, autoplay enabled, loop enabled, initially muted, and without controls.
[videopress Qq0h1qNe w=800 autoplay=true loop=true muted=true controls=false]
Embeds a VideoPress video with custom width, autoplay enabled, loop enabled, initially muted, without controls, and allowing inline play.
[videopress Qq0h1qNe w=800 autoplay=true loop=true muted=true controls=false playsinline=true]
Embeds a VideoPress video with all the available parameters customized.
[videopress Qq0h1qNe w=800 h=450 at=60 loop=true autoplay=true cover=false muted=true controls=false playsinline=true useaveragecolor=true preloadcontent=auto]
PHP Function Code
In case you have difficulties debugging what causing issues with [videopress]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'videopress', array( static::class, 'videopress_embed_shortcode' ) );
Shortcode PHP function:
function videopress_embed_shortcode( $atts ) {
/**
* We only accept GUIDs as a first unnamed argument.
*/
$guid = isset( $atts[0] ) ? $atts[0] : null;
/**
* Make sure the GUID passed in matches how actual GUIDs are formatted.
*/
if ( ! videopress_is_valid_guid( $guid ) ) {
return '<!-- error: missing or invalid VideoPress video ID -->';
}
/**
* Set the defaults
*/
$defaults = array(
'w' => 640, // Width of the video player, in pixels
'h' => 0, // Height of the video player, in pixels
'at' => 0, // How many seconds in to initially seek to
'loop' => false, // Whether to loop the video repeatedly
'autoplay' => false, // Whether to autoplay the video on load
'cover' => true, // Whether to scale the video to its container
'muted' => false, // Whether the video should start without sound
'controls' => true, // Whether the video should display controls
'playsinline' => false, // Whether the video should be allowed to play inline (for browsers that support this)
'useaveragecolor' => false, // Whether the video should use the seekbar automatic average color
'preloadcontent' => 'metadata',
);
// Make sure "false" will be actually false.
foreach ( $atts as $key => $value ) {
if ( is_string( $value ) && 'false' === strtolower( $value ) ) {
$atts[ $key ] = 0;
}
}
if ( isset( $atts['preload'] ) ) {
$atts['preloadcontent'] = $atts['preload'];
}
$atts = shortcode_atts( $defaults, $atts, 'videopress' );
$base_url = 'https://videopress.com/embed/' . $guid;
$query_params = array(
'at' => $atts['at'],
'loop' => $atts['loop'],
'autoplay' => $atts['autoplay'],
'muted' => $atts['muted'],
'controls' => $atts['controls'],
'playsinline' => $atts['playsinline'],
'useAverageColor' => $atts['useaveragecolor'], // The casing is intentional, shortcode params are lowercase, but player expects useAverageColor
'preloadContent' => $atts['preloadcontent'], // The casing is intentional, shortcode params are lowercase, but player expects preloadContent
);
$src = esc_url( add_query_arg( $query_params, $base_url ) );
$width = absint( $atts['w'] );
if ( ! $atts['h'] ) {
$aspect_ratio = 16 / 9; // TODO: Get the correct aspect ratio for the video.
$height = $width / $aspect_ratio;
} else {
$height = absint( $atts['h'] );
}
$cover = $atts['cover'] ? ' data-resize-to-parent="true"' : '';
$block_template =
'<figure class="wp-block-videopress-video wp-block-jetpack-videopress jetpack-videopress-player">' .
'<div class="jetpack-videopress-player__wrapper">' .
'<iframe ' .
'title="' . __( 'VideoPress Video Player', 'jetpack-videopress-pkg' ) . '" ' .
'aria-label="' . __( 'VideoPress Video Player', 'jetpack-videopress-pkg' ) . '" ' .
'src="%s" ' .
'width="%s"' .
'height="%s" ' .
'frameborder="0" ' .
'allowfullscreen%s allow="clipboard-write">' .
'</iframe>' .
'</div>' .
'</figure>';
$version = Package_Version::PACKAGE_VERSION;
wp_enqueue_script( 'videopress-iframe', 'https://videopress.com/videopress-iframe.js', array(), $version, true );
return sprintf( $block_template, $src, $width, $height, $cover );
}
Code file location:
jetpack/jetpack/jetpack_vendor/automattic/jetpack-videopress/src/class-block-editor-content.php
Jetpack Shortcode
The Jetpack Gallery shortcode allows you to display a gallery of images in your posts. It accepts parameters for ordering, inclusion and exclusion of images, and slideshow mode.
Shortcode:
Parameters
Here is a list of all possible gallery shortcode parameters and attributes:
order
– defines the order of the images, ascending (ASC) by defaultorderby
– sets the field to order the images by, defaults to ‘menu_order ID’id
– specifies the ID of the post to get images frominclude
– includes specific images by their IDsexclude
– excludes specific images by their IDsslideshow
– if set to true, displays the gallery as a slideshow
Examples and Usage
Basic example – Display a gallery using the default parameters.
Advanced examples
Display a gallery with specific images by including their IDs. The images will be ordered by menu order and ID in ascending order, which is the default behaviour.
Display a gallery excluding specific images by their IDs. This will show all the images attached to the post except the ones with IDs specified.
Display a gallery with images in a random order.
Display a gallery with images from a specific post by its ID.
Display a gallery with a slideshow enabled.
Remember that the ‘gallery’ shortcode relies on the ‘win8_gallery_shortcode’ function, which should be defined in your theme’s functions.php file or in a custom plugin. The function takes care of querying the images based on the parameters provided and outputting the HTML for the gallery.
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;
// @todo - find out if this is a bug, intentionally unused, or can be removed.
$output = ''; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
// 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'] );
}
}
$atts = shortcode_atts(
array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'include' => '',
'exclude' => '',
'slideshow' => false,
),
$attr,
'gallery'
);
$id = ! empty( $atts['id'] ) ? (int) $atts['id'] : 0;
// Custom image size and always use it.
add_image_size( 'win8app-column', 480 );
$size = 'win8app-column';
if ( 'RAND' === $atts['order'] ) {
$orderby = 'none';
} else {
$orderby = $atts['orderby'];
}
if ( ! empty( $atts['include'] ) ) {
$include = preg_replace( '/[^0-9,]+/', '', $atts['include'] );
$_attachments = get_posts(
array(
'include' => $include,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => $atts['order'],
'orderby' => $orderby,
)
);
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[ $val->ID ] = $_attachments[ $key ];
}
} elseif ( ! empty( $atts['exclude'] ) ) {
$exclude = preg_replace( '/[^0-9,]+/', '', $atts['exclude'] );
$attachments = get_children(
array(
'post_parent' => $id,
'exclude' => $exclude,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => $atts['order'],
'orderby' => $orderby,
)
);
} else {
$attachments = get_children(
array(
'post_parent' => $id,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => $atts['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 );
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
if ( $captiontag && trim( $attachment->post_excerpt ) ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
$output .= "<div class='wp-caption aligncenter'>$link
<p class='wp-caption-text'>" . wptexturize( $attachment->post_excerpt ) . '</p>
</div>';
} else {
$output .= $link . ' ';
}
// phpcs:enable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
}
}
}
Code file location:
jetpack/jetpack/json-endpoints/class.wpcom-json-api-post-endpoint.php
Jetpack [portfolio] Shortcode
The Jetpack Portfolio shortcode is designed to display portfolio projects. It offers customization options such as the ability to display types, tags, content, and author. It also allows for post filtering, inclusion of specific types or tags, column number adjustments, and post order settings. The shortcode sanitizes attributes for secure usage and ensures the correct enqueue of portfolio styles.
Shortcode: [portfolio]
Parameters
Here is a list of all possible portfolio shortcode parameters and attributes:
display_types
– Decides whether to show portfolio types or not.display_tags
– Controls if portfolio tags are shown.display_content
– Determines if content is displayed and to what extent (false, true, full).display_author
– Toggles the display of the author’s name.show_filter
– Determines if a filter option is available.include_type
– Specifies which portfolio types to include.include_tag
– Specifies which portfolio tags to include.columns
– Defines the number of columns in the portfolio grid.showposts
– Sets the number of portfolio items to display (-1 shows all).order
– Sets the order of portfolio items (asc or desc).orderby
– Determines the parameter by which items are ordered (author, date, title, rand).
Examples and Usage
Basic example – A simple way to display your portfolio using the shortcode. This will display all your portfolio items in ascending order by date, with two items per row.
[portfolio]
Advanced examples
Displaying a portfolio with specific types and tags. This example will only show portfolio items of the type ‘photography’ and tagged ‘black-and-white’. It will display the portfolio items in descending order by the author, with three items per row.
[portfolio include_type='photography' include_tag='black-and-white' order='desc' orderby='author' columns='3']
Displaying a portfolio without showing the content. This example will only display the portfolio items’ types and tags, without showing the content. It will display the portfolio items in ascending order by title, with four items per row.
[portfolio display_content=false orderby='title' columns='4']
Displaying a limited number of portfolio items. This example will only display the five most recent portfolio items, without showing the author. It will display the portfolio items in ascending order by date, with two items per row.
[portfolio display_author=false showposts='5']
PHP Function Code
In case you have difficulties debugging what causing issues with [portfolio]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'portfolio', array( $this, 'portfolio_shortcode' ) );
Shortcode PHP function:
function portfolio_shortcode( $atts ) {
// Default attributes.
$atts = shortcode_atts(
array(
'display_types' => true,
'display_tags' => true,
'display_content' => true, // Can be false, true, or full.
'display_author' => false,
'show_filter' => false,
'include_type' => false,
'include_tag' => false,
'columns' => 2,
'showposts' => -1,
'order' => 'asc',
'orderby' => 'date',
),
$atts,
'portfolio'
);
/*
* A little sanitization for our shortcode attributes aiming to use booleans.
* Attributes can be booleans (from the default values) or strings.
*/
foreach ( $atts as $attribute_name => $attribute_value ) {
if ( preg_match( '#^(?:display_|show_)#i', $attribute_name ) ) {
// display_content is a special case.
if ( 'display_content' === $attribute_name && 'full' === $attribute_value ) {
$atts['display_content'] = 'full';
continue;
}
$atts[ $attribute_name ] = self::sanitize_boolean_attribute( $attribute_value );
}
}
if ( $atts['include_type'] ) {
$atts['include_type'] = explode( ',', str_replace( ' ', '', $atts['include_type'] ) );
}
if ( $atts['include_tag'] ) {
$atts['include_tag'] = explode( ',', str_replace( ' ', '', $atts['include_tag'] ) );
}
$atts['columns'] = absint( $atts['columns'] );
$atts['showposts'] = (int) $atts['showposts'];
if ( $atts['order'] ) {
$atts['order'] = urldecode( $atts['order'] );
$atts['order'] = strtoupper( $atts['order'] );
if ( 'DESC' !== $atts['order'] ) {
$atts['order'] = 'ASC';
}
}
if ( $atts['orderby'] ) {
$atts['orderby'] = urldecode( $atts['orderby'] );
$atts['orderby'] = strtolower( $atts['orderby'] );
$allowed_keys = array( 'author', 'date', 'title', 'rand' );
$parsed = array();
foreach ( explode( ',', $atts['orderby'] ) as $orderby ) {
if ( ! in_array( $orderby, $allowed_keys, true ) ) {
continue;
}
$parsed[] = $orderby;
}
if ( empty( $parsed ) ) {
unset( $atts['orderby'] );
} else {
$atts['orderby'] = implode( ' ', $parsed );
}
}
// enqueue shortcode styles when shortcode is used.
if ( ! wp_style_is( 'jetpack-portfolio-style', 'enqueued' ) ) {
wp_enqueue_style( 'jetpack-portfolio-style', plugins_url( 'css/portfolio-shortcode.css', __FILE__ ), array(), '20140326' );
}
return self::portfolio_shortcode_html( $atts );
}
Code file location:
jetpack/jetpack/modules/custom-post-types/portfolios.php
Jetpack [jetpack_testimonials] Shortcode
The Jetpack Testimonials shortcode is a tool that allows you to display testimonials on your website. This shortcode enables you to customize the display, including the content, images, columns, and order.
Shortcode: [jetpack_testimonials]
Parameters
Here is a list of all possible jetpack_testimonials shortcode parameters and attributes:
display_content
– Determines whether to show testimonial content.image
– Decides if an image should be displayed.columns
– Defines the number of columns for testimonials.showposts
– Controls the number of testimonials to show.order
– Sets the order of testimonials (ascending or descending).orderby
– Specifies the parameter to order testimonials by.
Examples and Usage
Basic example – A simple usage of the jetpack testimonial shortcode. This will display all testimonials in ascending order, with content and image, in a single column.
[jetpack_testimonials]
Advanced examples
Displaying testimonials without content and image, in two columns, and limiting the number of testimonials to 5.
[jetpack_testimonials display_content=false image=false columns=2 showposts=5]
Displaying testimonials in descending order, ordered by date, in three columns, and without images.
[jetpack_testimonials order='desc' orderby='date' columns=3 image=false]
Displaying testimonials in ascending order, ordered by author, in a single column, with images, and showing full content.
[jetpack_testimonials order='asc' orderby='author' columns=1 image=true display_content='full']
PHP Function Code
In case you have difficulties debugging what causing issues with [jetpack_testimonials]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'jetpack_testimonials', array( $this, 'jetpack_testimonial_shortcode' ) );
Shortcode PHP function:
function jetpack_testimonial_shortcode( $atts ) {
// Default attributes.
$atts = shortcode_atts(
array(
'display_content' => true, // Can be false, true, or full.
'image' => true,
'columns' => 1,
'showposts' => -1,
'order' => 'asc',
'orderby' => 'menu_order,date',
),
$atts,
'testimonial'
);
// A little sanitization.
if (
$atts['display_content']
&& 'true' != $atts['display_content'] // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
&& 'full' !== $atts['display_content']
) {
$atts['display_content'] = false;
}
if ( $atts['image'] && 'true' != $atts['image'] ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
$atts['image'] = false;
}
$atts['columns'] = absint( $atts['columns'] );
$atts['showposts'] = (int) $atts['showposts'];
if ( $atts['order'] ) {
$atts['order'] = urldecode( $atts['order'] );
$atts['order'] = strtoupper( $atts['order'] );
if ( 'DESC' !== $atts['order'] ) {
$atts['order'] = 'ASC';
}
}
if ( $atts['orderby'] ) {
$atts['orderby'] = urldecode( $atts['orderby'] );
$atts['orderby'] = strtolower( $atts['orderby'] );
$allowed_keys = array( 'author', 'date', 'title', 'menu_order', 'rand' );
$parsed = array();
foreach ( explode( ',', $atts['orderby'] ) as $orderby ) {
if ( ! in_array( $orderby, $allowed_keys, true ) ) {
continue;
}
$parsed[] = $orderby;
}
if ( empty( $parsed ) ) {
unset( $atts['orderby'] );
} else {
$atts['orderby'] = implode( ' ', $parsed );
}
}
// enqueue shortcode styles when shortcode is used
if ( ! wp_style_is( 'jetpack-testimonial-style', 'enqueued' ) ) {
wp_enqueue_style( 'jetpack-testimonial-style', plugins_url( 'css/testimonial-shortcode.css', __FILE__ ), array(), '20140326' );
}
return self::jetpack_testimonial_shortcode_html( $atts );
}
Code file location:
jetpack/jetpack/modules/custom-post-types/testimonial.php
Jetpack [geo-location] Shortcode
The Jetpack Geo-Location shortcode is used to retrieve the location data of a specific post. . This shortcode takes either ‘post’ or ‘id’ as an attribute. If ‘post’ is provided, it fetches the location of that particular post. If ‘id’ is given, it retrieves the location of the post with that ID. The function ‘jetpack_geo_get_location’ is called to carry out this operation. It’s a versatile tool for adding location-specific functionality to your WordPress site.
Shortcode: [geo-location]
Parameters
Here is a list of all possible geo-location shortcode parameters and attributes:
post
– specifies the post from which to retrieve geo-location dataid
– alternative to ‘post’, identifies specific content for geo-location
Examples and Usage
Basic example – A simple usage of the ‘geo-location’ shortcode would be to display the location of a specific post using its ID.
[geo-location id=123 /]
Advanced examples
Utilizing the ‘geo-location’ shortcode to display the location of a specific post by referencing its post slug. The location will first attempt to load by post slug, but if not found, it will try to load by ID.
[geo-location post='my-first-post' /]
Another advanced usage of the ‘geo-location’ shortcode could be to display the location of a specific post by referencing both its ID and post slug. The location will first try to load by ID, but if not found, it will try to load by post slug.
[geo-location post='my-first-post' id=123 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [geo-location]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'geo-location', 'jetpack_geo_shortcode' );
Shortcode PHP function:
function jetpack_geo_shortcode( $attributes ) {
$attributes = shortcode_atts(
array(
'post' => null,
'id' => null,
),
$attributes
);
return jetpack_geo_get_location( $attributes['post'] ? $attributes['post'] : $attributes['id'] );
}
Code file location:
jetpack/jetpack/modules/geo-location.php
Jetpack [latex] Shortcode
The Jetpack plugin’s ‘latex’ shortcode is used to render LaTeX code in WordPress. It decodes the content and applies the specified foreground, background colors, and size.
Shortcode: [latex]
Parameters
Here is a list of all possible latex shortcode parameters and attributes:
s
– The scale factor for the latex, default is 0.bg
– The background color of the latex, default color is set by the function ‘latex_get_default_color’.fg
– The text color of the latex, default color is ‘000’ (black).
Examples and Usage
Basic example – The shortcode displays the LaTeX code with default colors.
[latex]E = mc^2[/latex]
Advanced examples
1. Displaying the LaTeX code with customized foreground and background colors. The ‘fg’ attribute changes the foreground (text) color, and the ‘bg’ attribute changes the background color. Both colors are defined in hexadecimal color codes.
[latex fg="ffffff" bg="000000"]E = mc^2[/latex]
2. Changing the size of the LaTeX output. The ‘s’ attribute adjusts the size of the LaTeX output. A higher value will result in a larger output.
[latex s="2"]E = mc^2[/latex]
3. Using the shortcode with multiple attributes. This example uses all three attributes to customize the LaTeX output fully.
[latex s="2" fg="ffffff" bg="000000"]E = mc^2[/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 = '' ) {
$attr = shortcode_atts(
array(
's' => 0,
'bg' => latex_get_default_color( 'bg' ),
'fg' => latex_get_default_color( 'text', '000' ),
),
$atts,
'latex'
);
return latex_render( latex_entity_decode( $content ), $attr['fg'], $attr['bg'], $attr['s'] );
}
Code file location:
jetpack/jetpack/modules/latex.php
Jetpack [jetpack_relatedposts] Shortcode
The Jetpack Related Posts shortcode enhances website functionality by displaying related content. It employs the ‘get_client_rendered_html’ function to render HTML for related posts.
Shortcode: [jetpack_relatedposts]
Examples and Usage
Basic example – The shortcode is used to display related posts. The related posts are determined based on the post ID that is currently being viewed.
[jetpack-relatedposts id=1 /]
Advanced examples
Using the shortcode to display related posts, but excluding a specific post by its ID. This is useful when you have a post that you don’t want to show up in the related posts section.
[jetpack-relatedposts id=2 exclude=1 /]
Another advanced usage could be displaying related posts with a custom headline. The headline is set using the ‘headline’ attribute in the shortcode. This feature allows you to customize the heading of the related posts section.
[jetpack-relatedposts id=3 headline="Check out these related articles!" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [jetpack_relatedposts]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( self::SHORTCODE, array( $this, 'get_client_rendered_html' ) );
Shortcode PHP function:
function get_client_rendered_html() {
if ( Settings::is_syncing() ) {
return '';
}
/**
* Filter the Related Posts headline.
*
* @module related-posts
*
* @since 3.0.0
*
* @param string $headline Related Posts heading.
*/
$headline = apply_filters( 'jetpack_relatedposts_filter_headline', $this->get_headline() );
if ( $this->previous_post_id ) {
$exclude = "data-exclude='{$this->previous_post_id}'";
} else {
$exclude = '';
}
return <<<EOT
<div id='jp-relatedposts' class='jp-relatedposts' $exclude>
$headline
</div>
EOT;
}
Code file location:
jetpack/jetpack/modules/related-posts/jetpack-related-posts.php
Jetpack [archiveorg-book] Shortcode
The Jetpack Archive.org Book shortcode embeds an archive.org book into a WordPress post or page. It allows customization of the book’s dimensions. . The shortcode requires an ‘id’ attribute, which is the archive.org book ID. If the ‘id’ isn’t provided, an error message is displayed. The ‘width’ and ‘height’ attributes are optional and default to 480 and 430 respectively. The embedded book is displayed within an iframe, which is responsive and allows fullscreen view.
Shortcode: [archiveorg-book]
Parameters
Here is a list of all possible archiveorg-book shortcode parameters and attributes:
id
– The unique identifier for the archive.org bookwidth
– Defines the width of the embedded book interfaceheight
– Sets the height of the embedded book interface
Examples and Usage
Basic Example – A simple usage of the shortcode to embed an archive.org book using its ID.
[archiveorg-book id="bookID" /]
Advanced Examples
Embedding an archive.org book using its ID and specifying the width and height of the iframe.
[archiveorg-book id="bookID" width="500" height="400" /]
Embedding an archive.org book using its ID and specifying only the width of the iframe. The height will be calculated automatically based on the width.
[archiveorg-book id="bookID" width="500" /]
Embedding an archive.org book using its ID and specifying only the height of the iframe. The width will be set to the default value of 480.
[archiveorg-book id="bookID" height="400" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [archiveorg-book]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'archiveorg-book', 'jetpack_archiveorg_book_shortcode' );
Shortcode PHP function:
function jetpack_archiveorg_book_shortcode( $atts ) {
global $content_width;
if ( isset( $atts[0] ) && empty( $atts['id'] ) ) {
$atts['id'] = jetpack_shortcode_get_archiveorg_book_id( $atts );
}
$atts = shortcode_atts(
array(
'id' => '',
'width' => 480,
'height' => 430,
),
$atts
);
if ( ! $atts['id'] ) {
return '<!-- error: missing archive.org book ID -->';
}
$id = $atts['id'];
if ( ! $atts['width'] ) {
$width = absint( $content_width );
} else {
$width = (int) $atts['width'];
}
if ( ! $atts['height'] ) {
$height = round( ( $width / 640 ) * 360 );
} else {
$height = (int) $atts['height'];
}
return sprintf(
'<div class="embed-archiveorg-book" style="text-align:center;"><iframe title="%s" src="%s" width="%s" height="%s" style="border:0;" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen></iframe></div>',
esc_attr__( 'Archive.org Book', 'jetpack' ),
esc_url( "https://archive.org/stream/{$id}?ui=embed#mode/1up" ),
esc_attr( $width ),
esc_attr( $height )
);
}
Code file location:
jetpack/jetpack/modules/shortcodes/archiveorg-book.php
Jetpack [archiveorg] Shortcode
The Jetpack Archive.org shortcode allows embedding of content from Archive.org. It accepts parameters like ‘id’, ‘width’, ‘height’, ‘autoplay’, and ‘poster’. . If ‘id’ is missing, it returns an error. ‘Width’ and ‘height’ default to 640 and 480 respectively, but can be customized. ‘Autoplay’ and ‘poster’ are optional parameters.
Shortcode: [archiveorg]
Parameters
Here is a list of all possible archiveorg shortcode parameters and attributes:
id
– The unique identifier for the archive.org content.width
– Defines the width of the embedded content in pixels.height
– Sets the height of the embedded content in pixels.autoplay
– Controls automatic playback of the content, 1 for yes, 0 for no.poster
– Specifies the URL of an image to show until the user plays the content.
Examples and Usage
Basic example – Embeds an archive.org video using the video’s unique ID.
[archiveorg id="sampleVideo" /]
Advanced examples
Embeds an archive.org video with custom width and height. The width is set to 800px and the height is set to 600px.
[archiveorg id="sampleVideo" width=800 height=600 /]
Embeds an archive.org video with autoplay enabled. The video will start playing as soon as the page loads.
[archiveorg id="sampleVideo" autoplay=1 /]
Embeds an archive.org video with a custom poster. The poster image will be displayed before the video starts playing.
[archiveorg id="sampleVideo" poster="samplePoster" /]
Embeds an archive.org video with custom width, height, autoplay enabled, and a custom poster. This is an example of using all available parameters.
[archiveorg id="sampleVideo" width=800 height=600 autoplay=1 poster="samplePoster" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [archiveorg]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'archiveorg', 'jetpack_archiveorg_shortcode' );
Shortcode PHP function:
function jetpack_archiveorg_shortcode( $atts ) {
global $content_width;
if ( isset( $atts[0] ) && empty( $atts['id'] ) ) {
$atts['id'] = jetpack_shortcode_get_archiveorg_id( $atts );
}
$atts = shortcode_atts(
array(
'id' => '',
'width' => 640,
'height' => 480,
'autoplay' => 0,
'poster' => '',
),
$atts
);
if ( ! $atts['id'] ) {
return '<!-- error: missing archive.org ID -->';
}
$id = $atts['id'];
if ( ! $atts['width'] ) {
$width = absint( $content_width );
} else {
$width = (int) $atts['width'];
}
if ( ! $atts['height'] ) {
$height = round( ( $width / 640 ) * 360 );
} else {
$height = (int) $atts['height'];
}
if ( $atts['autoplay'] ) {
$autoplay = '&autoplay=1';
} else {
$autoplay = '';
}
if ( $atts['poster'] ) {
$poster = '&poster=' . $atts['poster'];
} else {
$poster = '';
}
return sprintf(
'<div class="embed-archiveorg" style="text-align:center;"><iframe title="%s" src="%s" width="%s" height="%s" style="border:0;" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen></iframe></div>',
esc_attr__( 'Archive.org', 'jetpack' ),
esc_url( "https://archive.org/embed/{$id}{$autoplay}{$poster}" ),
esc_attr( $width ),
esc_attr( $height )
);
}
Code file location:
jetpack/jetpack/modules/shortcodes/archiveorg.php
Jetpack [bandcamp] Shortcode
The Jetpack Bandcamp shortcode allows users to embed a Bandcamp album, track, or video on their WordPress site. It provides customization options such as size, layout, color, and more.
Shortcode: [bandcamp]
Parameters
Here is a list of all possible bandcamp shortcode parameters and attributes:
album
– The unique identifier of the album.track
– The unique identifier of the track.video
– The unique identifier of the video track.size
– Defines the size of the player.bgcol
– Sets the background color in hexadecimal format.linkcol
– Sets the link color in hexadecimal format.layout
– Encoded URL for a specific layout.width
– Sets the width of the player.height
– Sets the height of the player.notracklist
– If set to true, the tracklist is not displayed.tracklist
– If set to false, the tracklist is not displayed.artwork
– Controls the display of artwork, can be none or small.minimal
– If set to true, displays a minimalistic player.theme
– Sets the theme for the player, can be light or dark.package
– The unique identifier of the package.t
– The unique track number.tracks
– Comma-separated list of allowed tracks.esig
– Hexadecimal value without ‘#’ prefix.
Examples and Usage
Basic example – Display a specific album using the ‘album’ attribute.
[bandcamp album=12345 /]
Advanced examples
Display a specific track with a custom background color and link color.
[bandcamp track=67890 bgcol=000000 linkcol=ffffff /]
Display a specific video with a custom width and height.
[bandcamp video=11223 width=500 height=300 /]
Display a specific album with a custom layout and size.
[bandcamp album=12345 layout=layout_url size=grande /]
Display a specific track without the tracklist and with small artwork.
[bandcamp track=67890 notracklist=true artwork=small /]
Display a specific video in a minimal theme.
[bandcamp video=11223 minimal=true theme=dark /]
Display a specific album with a specific package and track number.
[bandcamp album=12345 package=1 t=2 /]
Display a specific track with a list of allowed tracks.
[bandcamp track=67890 tracks=1,2,3,4,5 esig=abcdef /]
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 ) {
$csswidth = null;
$cssheight = null;
// 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.
'video' => null, // integer track id for video player.
'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).
// phpcs:ignore Squiz.PHP.CommentedOutCode.Found -- false positive
'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.
'tracks' => null, // comma separated list of allowed tracks.
'esig' => null, // hex, no '#' prefix.
),
$atts,
'bandcamp'
);
$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;
$is_video = false;
/*
* Build iframe url. For audio players, 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. Delay the actual joining
* of args into a string until after we decide if it's
* a video player or an audio player
*/
$argparts = array();
if ( ! isset( $attributes['album'] ) && ! isset( $attributes['track'] ) && ! isset( $attributes['video'] ) ) {
return "[bandcamp: shortcode must include 'track', 'album', or 'video' param]";
}
if ( isset( $attributes['track'] ) && is_numeric( $attributes['track'] ) ) {
$track = esc_attr( $attributes['track'] );
array_push( $argparts, "track={$track}" );
} elseif ( isset( $attributes['video'] ) && is_numeric( $attributes['video'] ) ) {
$track = esc_attr( $attributes['video'] ); // videos are referenced by track id.
$url = '//bandcamp.com/EmbeddedPlayer/v=2';
$is_video = true;
array_push( $argparts, "track={$track}" );
}
if ( isset( $attributes['album'] ) && is_numeric( $attributes['album'] ) ) {
$album = esc_attr( $attributes['album'] );
array_push( $argparts, "album={$album}" );
}
if ( 'tall' === $sizekey ) {
if ( isset( $attributes['album'] ) ) {
$sizekey .= '_album';
} else {
$sizekey .= '_track';
}
}
// 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 = $attributes['width'];
$csswidth = $attributes['width'];
if ( count( $matches ) < 3 ) {
$csswidth .= 'px';
}
}
if ( isset( $attributes['height'] ) && preg_match( '|^([0-9]+)(%)?$|', $attributes['height'], $matches ) ) {
$height = $attributes['height'];
$cssheight = $attributes['height'];
if ( count( $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'] ) ) {
array_push( $argparts, "layout={$attributes['layout']}" );
} elseif ( isset( $attributes['size'] ) && preg_match( '|^[a-zA-Z0-9]+$|', $attributes['size'] ) ) {
array_push( $argparts, "size={$attributes['size']}" );
}
if ( isset( $attributes['bgcol'] ) && preg_match( '|^[0-9A-Fa-f]+$|', $attributes['bgcol'] ) ) {
array_push( $argparts, "bgcol={$attributes['bgcol']}" );
}
if ( isset( $attributes['linkcol'] ) && preg_match( '|^[0-9A-Fa-f]+$|', $attributes['linkcol'] ) ) {
array_push( $argparts, "linkcol={$attributes['linkcol']}" );
}
if ( isset( $attributes['package'] ) && preg_match( '|^[0-9]+$|', $attributes['package'] ) ) {
array_push( $argparts, "package={$attributes['package']}" );
}
if ( isset( $attributes['t'] ) && preg_match( '|^[0-9]+$|', $attributes['t'] ) ) {
array_push( $argparts, "t={$attributes['t']}" );
}
if ( 'true' === $attributes['notracklist'] ) {
array_push( $argparts, 'notracklist=true' );
}
// 'tracklist' arg deprecates 'notracklist=true' to be less weird. note, behavior
// if both are specified is undefined
switch ( $attributes['tracklist'] ) {
case 'false':
case 'none':
array_push( $argparts, 'tracklist=false' );
break;
}
switch ( $attributes['artwork'] ) {
case 'false':
case 'none':
case 'small':
array_push( $argparts, 'artwork=' . $attributes['artwork'] );
break;
}
if ( 'true' === $attributes['minimal'] ) {
array_push( $argparts, 'minimal=true' );
}
if ( isset( $attributes['theme'] ) && preg_match( '|^[a-zA-Z_]+$|', $attributes['theme'] ) ) {
array_push( $argparts, "theme={$attributes['theme']}" );
}
// param 'tracks' is signed digest param 'esig'.
if ( isset( $attributes['tracks'] ) && preg_match( '|^[0-9\,]+$|', $attributes['tracks'] ) ) {
if ( isset( $attributes['esig'] ) && preg_match( '|^[0-9A-Fa-f]+$|', $attributes['esig'] ) ) {
array_push( $argparts, "tracks={$attributes['tracks']}" );
array_push( $argparts, "esig={$attributes['esig']}" );
}
}
if ( $is_video ) {
$url = '//bandcamp.com/VideoEmbed?' . implode( '&', $argparts );
$extra_attrs = " mozallowfullscreen='1' webkitallowfullscreen='1' allowfullscreen='1'";
} else {
$url = '//bandcamp.com/EmbeddedPlayer/v=2/' . implode( '/', $argparts ) . '/';
$extra_attrs = '';
}
$iframe = '<iframe width="%s" height="%s" style="position: relative; display: block; width: %s; height: %s;" src="%s" allowtransparency="true" frameborder="0"%s></iframe>';
$iframe = sprintf( $iframe, esc_attr( $width ), esc_attr( $height ), esc_attr( $csswidth ), esc_attr( $cssheight ), esc_url( $url ), $extra_attrs );
return $iframe;
}
Code file location:
jetpack/jetpack/modules/shortcodes/bandcamp.php
Jetpack [Jetpack_Brightcove_Shortcode] Shortcode
The Jetpack Brightcove shortcode is a tool that converts Brightcove video parameters into a usable format. It normalizes the attributes and checks if they are empty. If the attributes are empty, it returns a comment indicating missing parameters. Otherwise, it verifies if the attributes are in the legacy format and converts them accordingly.
Shortcode: [Jetpack_Brightcove_Shortcode]
Examples and Usage
Basic example – The shortcode enables the conversion of Brightcove parameters to display video content.
[Jetpack_Brightcove_Shortcode convert="12345"]
Advanced examples
Utilizing the shortcode to convert Brightcove parameters with multiple attributes. The code will normalize the attributes and depending on the parameters, it will convert to either legacy or new studio.
[Jetpack_Brightcove_Shortcode convert="12345" legacy="67890" new_studio="abcde"]
Using the shortcode to convert Brightcove parameters with an empty attribute. The code will return a comment indicating missing Brightcove parameters.
[Jetpack_Brightcove_Shortcode convert=""]
Implementing the shortcode to convert Brightcove parameters without specifying any attribute. The code will default to normalize the attributes and convert to either legacy or new studio.
[Jetpack_Brightcove_Shortcode]
PHP Function Code
In case you have difficulties debugging what causing issues with [Jetpack_Brightcove_Shortcode]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( Jetpack_Brightcove_Shortcode::$shortcode, array( 'Jetpack_Brightcove_Shortcode', 'convert' ) );
Shortcode PHP function:
function convert( $atts ) {
$normalized_atts = self::normalize_attributes( $atts );
if ( empty( $atts ) ) {
return '<!-- Missing Brightcove parameters -->';
}
return self::has_legacy_atts( $normalized_atts )
? self::convert_to_legacy_studio( $normalized_atts )
: self::convert_to_new_studio( $normalized_atts );
}
Code file location:
jetpack/jetpack/modules/shortcodes/brightcove.php
Jetpack [crowdsignal] Shortcode
The Jetpack plugin’s shortcode ‘crowdsignal’ allows you to embed polls, surveys, and ratings into your WordPress site. It enables customization of the display, alignment, colors, and more.
Shortcode: [crowdsignal]
Parameters
Here is a list of all possible crowdsignal shortcode parameters and attributes:
survey
– Identifier of the survey to be embeddedlink_text
– Text for the survey linkpoll
– Identifier of the poll to be embeddedrating
– Identifier of the rating to be displayedunique_id
– Unique ID for the ratingitem_id
– ID of the item to be ratedtitle
– Title of the poll, survey, or ratingpermalink
– Permanent link to the itemcb
– Cache buster value for testingtype
– Type of survey display (button, slider, etc.)body
– Body text for the surveybutton
– Text for the survey buttontext_color
– Color of the survey textback_color
– Background color of the surveyalign
– Alignment of the surveystyle
– Style of the surveywidth
– Width of the surveyheight
– Height of the surveydelay
– Delay time before the survey appearsvisit
– Visit type (single or multiple)domain
– Domain of the surveyid
– Identifier of the surveysite
– Website of the survey
Examples and Usage
Basic example – Displaying a Crowdsignal poll on your page.
[crowdsignal poll=12345678 /]
Advanced examples
Embedding a Crowdsignal survey with custom link text, alignment and colors.
[crowdsignal survey="abcdef123456" link_text="Take our survey!" align="left" text_color="FFFFFF" back_color="000000" /]
Embedding a Crowdsignal rating with a unique ID and item ID, and customizing the title and permalink.
[crowdsignal rating=5 unique_id="rating_id" item_id="item_id" title="Rate our product" permalink="https://yourwebsite.com/product-rating" /]
Embedding a Crowdsignal poll with a custom title, and specifying the site to use for the poll.
[crowdsignal poll=12345678 title="What's your favorite color?" site="crowdsignal.com" /]
Displaying a Crowdsignal survey in a slider with a delay.
[crowdsignal survey="abcdef123456" type="slider" delay=200 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [crowdsignal]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'crowdsignal', array( $this, 'crowdsignal_shortcode' ) );
Shortcode PHP function:
function crowdsignal_shortcode( $atts ) {
global $post;
global $content_width;
if ( ! is_array( $atts ) ) {
return '<!-- Crowdsignal shortcode passed invalid attributes -->';
}
$attributes = shortcode_atts(
array(
'survey' => null,
'link_text' => esc_html__( 'Take Our Survey', 'jetpack' ),
'poll' => 'empty',
'rating' => 'empty',
'unique_id' => null,
'item_id' => null,
'title' => null,
'permalink' => null,
'cb' => 0, // cache buster. Helps with testing.
'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' => '',
'site' => 'crowdsignal.com',
),
$atts,
'crowdsignal'
);
$inline = ! in_the_loop()
&& ! Constants::is_defined( 'TESTING_IN_JETPACK' );
$no_script = false;
$infinite_scroll = false;
if ( is_home() && current_theme_supports( 'infinite-scroll' ) ) {
$infinite_scroll = 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;
/*
* Rating embed.
*/
if ( (int) $attributes['rating'] > 0 && ! $no_script ) {
if ( empty( $attributes['unique_id'] ) ) {
$attributes['unique_id'] = is_page() ? 'wp-page-' . $post->ID : 'wp-post-' . $post->ID;
}
if ( empty( $attributes['item_id'] ) ) {
$attributes['item_id'] = is_page() ? '_page_' . $post->ID : '_post_' . $post->ID;
}
if ( empty( $attributes['title'] ) ) {
/** This filter is documented in core/src/wp-includes/general-template.php */
$attributes['title'] = apply_filters( 'wp_title', $post->post_title, '', '' );
}
if ( empty( $attributes['permalink'] ) ) {
$attributes['permalink'] = get_permalink( $post->ID );
}
$rating = (int) $attributes['rating'];
$unique_id = sanitize_key( wp_strip_all_tags( $attributes['unique_id'] ) );
$item_id = wp_strip_all_tags( $attributes['item_id'] );
$item_id = preg_replace( '/[^_a-z0-9]/i', '', $item_id );
$settings = wp_json_encode(
array(
'id' => $rating,
'unique_id' => $unique_id,
'title' => rawurlencode( trim( $attributes['title'] ) ),
'permalink' => esc_url( $attributes['permalink'] ),
'item_id' => $item_id,
)
);
$item_id = esc_js( $item_id );
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
) {
return sprintf(
'<a href="%s" target="_blank">%s</a>',
esc_url( $attributes['permalink'] ),
esc_html( trim( $attributes['title'] ) )
);
} elseif ( $inline ) {
$rating_js = "<!--//--><![CDATA[//><!--\n";
$rating_js .= "PDRTJS_settings_{$rating}{$item_id}={$settings};";
$rating_js .= "\n//--><!]]>";
wp_enqueue_script( 'crowdsignal-rating' );
wp_add_inline_script(
'crowdsignal-rating',
$rating_js,
'before'
);
return sprintf(
'<div class="cs-rating pd-rating" id="pd_rating_holder_%1$d%2$s"></div>',
absint( $rating ),
esc_attr( $item_id )
);
} else {
if ( false === self::$scripts ) {
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' ) );
if ( $infinite_scroll ) {
return sprintf(
'<div class="cs-rating pd-rating" id="pd_rating_holder_%1$d%2$s" data-settings="%3$s"></div>',
absint( $rating ),
esc_attr( $item_id ),
esc_attr( wp_json_encode( $data ) )
);
} else {
return sprintf(
'<div class="cs-rating pd-rating" id="pd_rating_holder_%1$d%2$s"></div>',
absint( $rating ),
esc_attr( $item_id )
);
}
}
} elseif ( (int) $attributes['poll'] > 0 ) {
/*
* Poll embed.
*/
if ( empty( $attributes['title'] ) ) {
$attributes['title'] = esc_html__( 'Take Our Poll', 'jetpack' );
}
$poll = (int) $attributes['poll'];
if ( 'crowdsignal.com' === $attributes['site'] ) {
$poll_url = sprintf( 'https://poll.fm/%d', $poll );
} else {
$poll_url = sprintf( 'https://polldaddy.com/p/%d', $poll );
}
$poll_js = sprintf( 'https://secure.polldaddy.com/p/%d.js', $poll );
$poll_link = sprintf(
'<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
esc_url( $poll_url ),
esc_html( $attributes['title'] )
);
if (
$no_script
|| ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() )
) {
return $poll_link;
} elseif ( 'slider' === $attributes['type'] && ! $inline ) { // Slider poll.
if ( ! in_array(
$attributes['visit'],
array( 'single', 'multiple' ),
true
) ) {
$attributes['visit'] = 'single';
}
$settings = array(
'type' => 'slider',
'embed' => 'poll',
'delay' => (int) $attributes['delay'],
'visit' => $attributes['visit'],
'id' => (int) $poll,
'site' => $attributes['site'],
);
return $this->get_async_code( $settings, $poll_link, $poll_url );
} else {
if ( 1 === $attributes['cb'] ) {
$attributes['cb'] = '?cb=' . time();
} else {
$attributes['cb'] = false;
}
$margins = '';
$float = '';
if ( in_array(
$attributes['align'],
array( 'right', 'left' ),
true
) ) {
$float = sprintf( 'float: %s;', $attributes['align'] );
if ( 'left' === $attributes['align'] ) {
$margins = 'margin: 0px 10px 0px 0px;';
} elseif ( 'right' === $attributes['align'] ) {
$margins = 'margin: 0px 0px 0px 10px';
}
}
/*
* Force the normal style embed on single posts/pages
* otherwise it's not rendered on infinite scroll themed blogs
* ('infinite_scroll_render' isn't fired)
*/
if ( is_singular() ) {
$inline = true;
}
if ( false === $attributes['cb'] && ! $inline ) {
if ( false === self::$scripts ) {
self::$scripts = array();
}
$data = array( 'url' => $poll_js );
self::$scripts['poll'][ (int) $poll ] = $data;
add_action( 'wp_footer', array( $this, 'generate_scripts' ) );
wp_enqueue_script( 'crowdsignal-shortcode' );
wp_localize_script(
'crowdsignal-shortcode',
'crowdsignal_shortcode_options',
array(
'script_url' => esc_url_raw(
Assets::get_file_url_for_environment(
'_inc/build/polldaddy-shortcode.min.js',
'_inc/polldaddy-shortcode.js'
)
),
)
);
/**
* Hook into the Crowdsignal shortcode before rendering.
*
* @since 8.4.0
*
* @param int $poll Poll ID.
*/
do_action( 'crowdsignal_shortcode_before', (int) $poll );
return sprintf(
'<a name="pd_a_%1$d"></a><div class="CSS_Poll PDS_Poll" id="PDI_container%1$d" data-settings="%2$s" style="%3$s%4$s"></div><div id="PD_superContainer"></div><noscript>%5$s</noscript>',
absint( $poll ),
esc_attr( wp_json_encode( $data ) ),
$float,
$margins,
$poll_link
);
} else {
if ( $inline ) {
$attributes['cb'] = '';
}
wp_enqueue_script(
'crowdsignal-' . absint( $poll ),
esc_url( $poll_js . $attributes['cb'] ),
array(),
JETPACK__VERSION,
true
);
/** This action is already documented in modules/shortcodes/crowdsignal.php */
do_action( 'crowdsignal_shortcode_before', (int) $poll );
return sprintf(
'<a id="pd_a_%1$s"></a><div class="CSS_Poll PDS_Poll" id="PDI_container%1$s" style="%2$s%3$s"></div><div id="PD_superContainer"></div><noscript>%4$s</noscript>',
absint( $poll ),
$float,
$margins,
$poll_link
);
}
}
} elseif ( ! empty( $attributes['survey'] ) ) {
/*
* Survey embed.
*/
if ( in_array(
$attributes['type'],
array( 'iframe', 'button', 'banner', 'slider' ),
true
) ) {
if ( empty( $attributes['title'] ) ) {
$attributes['title'] = esc_html__( 'Take Our Survey', 'jetpack' );
if ( ! empty( $attributes['link_text'] ) ) {
$attributes['title'] = $attributes['link_text'];
}
}
if (
'banner' === $attributes['type']
|| 'slider' === $attributes['type']
) {
$inline = false;
}
$survey_url = '';
if ( 'true' !== $attributes['survey'] ) {
$survey = preg_replace( '/[^a-f0-9]/i', '', $attributes['survey'] );
if ( 'crowdsignal.com' === $attributes['site'] ) {
$survey_url = 'https://survey.fm/' . $survey;
} else {
$survey_url = 'https://polldaddy.com/s/' . $survey;
}
} elseif ( isset( $attributes['domain'] ) && isset( $attributes['id'] ) ) {
$survey_domain = preg_replace( '/[^a-z0-9\-]/i', '', $attributes['domain'] );
$survey_id = preg_replace( '/[\/\?&\{\}]/', '', $attributes['id'] );
$survey_url = sprintf(
'https://%1$s.survey.fm/%2$s',
$survey_domain,
$survey_id
);
}
$survey_link = sprintf(
'<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
esc_url( $survey_url ),
esc_html( $attributes['title'] )
);
$settings = array();
if ( 'iframe' === $attributes['type'] ) {
if ( 'auto' !== $attributes['height'] ) {
if (
is_numeric( $content_width )
&& $content_width > 0
&& is_numeric( $attributes['width'] )
&& $attributes['width'] > $content_width
) {
$attributes['width'] = $content_width;
}
if ( ! $attributes['width'] ) {
$attributes['width'] = '100%';
} else {
$attributes['width'] = (int) $attributes['width'];
}
if ( ! $attributes['height'] ) {
$attributes['height'] = '600';
} else {
$attributes['height'] = (int) $attributes['height'];
}
return sprintf(
'<iframe src="%1$s?iframe=1" frameborder="0" width="%2$d" height="%3$d" scrolling="auto" allowtransparency="true" marginheight="0" marginwidth="0">%4$s</iframe>',
esc_url( $survey_url ),
absint( $attributes['width'] ),
absint( $attributes['height'] ),
$survey_link
);
} elseif (
! empty( $attributes['domain'] )
&& ! empty( $attributes['id'] )
) {
$domain = preg_replace( '/[^a-z0-9\-]/i', '', $attributes['domain'] );
$id = preg_replace( '/[\/\?&\{\}]/', '', $attributes['id'] );
$auto_src = esc_url( "https://{$domain}.survey.fm/{$id}" );
$auto_src = wp_parse_url( $auto_src );
if ( ! is_array( $auto_src ) || array() === $auto_src ) {
return '<!-- no crowdsignal output -->';
}
if ( ! isset( $auto_src['host'] ) || ! isset( $auto_src['path'] ) ) {
return '<!-- no crowdsignal output -->';
}
$domain = $auto_src['host'] . '/';
$id = ltrim( $auto_src['path'], '/' );
$settings = array(
'type' => $attributes['type'],
'auto' => true,
'domain' => $domain,
'id' => $id,
'site' => $attributes['site'],
);
}
} else {
$text_color = sanitize_hex_color_no_hash( $attributes['text_color'] );
$back_color = sanitize_hex_color_no_hash( $attributes['back_color'] );
if (
! in_array(
$attributes['align'],
array(
'right',
'left',
'top-left',
'top-right',
'middle-left',
'middle-right',
'bottom-left',
'bottom-right',
),
true
)
) {
$attributes['align'] = '';
}
if (
! in_array(
$attributes['style'],
array(
'inline',
'side',
'corner',
'rounded',
'square',
),
true
)
) {
$attributes['style'] = '';
}
$settings = array_filter(
array(
'title' => wp_strip_all_tags( $attributes['title'] ),
'type' => $attributes['type'],
'body' => wp_strip_all_tags( $attributes['body'] ),
'button' => wp_strip_all_tags( $attributes['button'] ),
'text_color' => $text_color,
'back_color' => $back_color,
'align' => $attributes['align'],
'style' => $attributes['style'],
'id' => $survey,
'site' => $attributes['site'],
)
);
}
if ( empty( $settings ) ) {
return '<!-- no crowdsignal output -->';
}
return $this->get_async_code( $settings, $survey_link, $survey_url );
}
} else {
return '<!-- no crowdsignal output -->';
}
}
Code file location:
jetpack/jetpack/modules/shortcodes/crowdsignal.php
Jetpack [polldaddy] Shortcode
The Polldaddy shortcode is a feature of the Jetpack plugin that enables embedding of Polldaddy polls on your WordPress site. The PHP function polldaddy_shortcode checks the validity of attributes. If they’re invalid, it returns an error comment. It assigns ‘polldaddy.com’ to the ‘site’ attribute and calls the crowdsignal_shortcode function.
Shortcode: [polldaddy]
Examples and Usage
Basic example – A simple usage of the Polldaddy shortcode to display a poll from polldaddy.com
[polldaddy id="123456" /]
Advanced examples
Using the Polldaddy shortcode with multiple attributes. In this example, we are specifying the poll ID, the site from which the poll is being pulled, and the size of the poll.
[polldaddy id="123456" site="polldaddy.com" size="medium" /]
Another advanced usage of the Polldaddy shortcode. This time we are specifying the poll ID, the site, and we are adding a title to the poll.
[polldaddy id="123456" site="polldaddy.com" title="My Poll" /]
Please note that the ‘id’ attribute is essential and must be a valid poll ID from polldaddy.com. The ‘site’ attribute is optional and if not provided, it will default to ‘polldaddy.com’. The ‘size’ attribute is also optional and defaults to ‘medium’. The ‘title’ attribute is likewise optional and if not provided, the poll will be displayed without a title.
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 ) {
if ( ! is_array( $atts ) ) {
return '<!-- Polldaddy shortcode passed invalid attributes -->';
}
$atts['site'] = 'polldaddy.com';
return $this->crowdsignal_shortcode( $atts );
}
Code file location:
jetpack/jetpack/modules/shortcodes/crowdsignal.php
Jetpack [dailymotion] Shortcode
The Jetpack plugin’s Dailymotion shortcode enables embedding of Dailymotion videos into WordPress posts. It takes parameters like video ID, width, height, autoplay, etc., to customize the video.
Shortcode: [dailymotion]
Parameters
Here is a list of all possible dailymotion shortcode parameters and attributes:
id
– Unique identifier of the Dailymotion video.width
– Determines the width of the video.height
– Determines the height of the video.title
– Sets the title for the video.user
– Specifies the Dailymotion username.video
– The specific video to be displayed.autoplay
– Autoplays the video when set to 1.endscreen-enable
– Enables the end screen when set to 1.mute
– Mutes the video when set to 1.sharing-enable
– Enables sharing when set to 1.start
– Starts the video at a specific time (in seconds).subtitles-default
– Sets the default subtitles for the video.ui-highlight
– Sets the highlight color in the user interface.ui-logo
– Shows the Dailymotion logo when set to 1.ui-start-screen-info
– Shows start screen info when set to 1.ui-theme
– Sets the user interface theme to either ‘dark’ or ‘light’.
Examples and Usage
Basic example – Embedding a Dailymotion video using its ID.
[dailymotion id="x7x2o3a" /]
Advanced examples
Embedding a Dailymotion video with a specified width and height, and enabling autoplay.
[dailymotion id="x7x2o3a" width="640" height="360" autoplay="1" /]
Embedding a Dailymotion video with a specified start time, disabling endscreen and sharing, and setting UI theme to dark.
[dailymotion id="x7x2o3a" start="30" endscreen-enable="0" sharing-enable="0" ui-theme="dark" /]
Embedding a Dailymotion video with a specified user and video title, and disabling the logo in the UI.
[dailymotion id="x7x2o3a" user="dailymotion" video="Amazing Video" ui-logo="0" /]
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_new );
foreach ( $atts_new as $k => $v ) {
$atts[ $k ] = $v;
}
}
$atts = shortcode_atts(
array(
'id' => '', // string.
'width' => '', // int.
'height' => '', // int.
'title' => '', // string.
'user' => '', // string.
'video' => '', // string.
'autoplay' => 0, // int.
'endscreen-enable' => 1, // int.
'mute' => 0, // int.
'sharing-enable' => 1, // int.
'start' => '', // int.
'subtitles-default' => '', // string.
'ui-highlight' => '', // string.
'ui-logo' => 1, // int.
'ui-start-screen-info' => 0, // int.
'ui-theme' => '', // string.
),
$atts,
'dailymotion'
);
if ( isset( $atts['id'] ) && ! empty( $atts['id'] ) ) {
$id = rawurlencode( $atts['id'] );
} else {
return '<!--Dailymotion error: bad or missing ID-->';
}
/*set width and height using provided parameters if any */
$width = isset( $atts['width'] ) ? (int) $atts['width'] : 0;
$height = isset( $atts['height'] ) ? (int) $atts['height'] : 0;
if ( ! $width && ! $height ) {
if ( ! empty( $content_width ) ) {
$width = absint( $content_width );
} else {
$width = 425;
}
$height = $width / 425 * 334;
} elseif ( ! $height ) {
$height = $width / 425 * 334;
} elseif ( ! $width ) {
$width = $height / 334 * 425;
}
if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
return sprintf(
'<amp-dailymotion data-videoid="%1$s" layout="responsive" width="%2$d" height="%3$d"></amp-dailymotion>',
esc_attr( $id ),
absint( $width ),
absint( $height )
);
}
/**
* Let's add parameters if needed.
*
* @see https://developer.dailymotion.com/player
*/
$player_params = array();
if ( isset( $atts['autoplay'] ) && '1' === $atts['autoplay'] ) {
$player_params['autoplay'] = '1';
}
if ( isset( $atts['endscreen-enable'] ) && '0' === $atts['endscreen-enable'] ) {
$player_params['endscreen-enable'] = '0';
}
if ( isset( $atts['mute'] ) && '1' === $atts['mute'] ) {
$player_params['mute'] = '1';
}
if ( isset( $atts['sharing-enable'] ) && '0' === $atts['sharing-enable'] ) {
$player_params['sharing-enable'] = '0';
}
if ( isset( $atts['start'] ) && ! empty( $atts['start'] ) ) {
$player_params['start'] = abs( (int) $atts['start'] );
}
if ( isset( $atts['subtitles-default'] ) && ! empty( $atts['subtitles-default'] ) ) {
$player_params['subtitles-default'] = esc_attr( $atts['subtitles-default'] );
}
if ( isset( $atts['ui-highlight'] ) && ! empty( $atts['ui-highlight'] ) ) {
$player_params['ui-highlight'] = esc_attr( $atts['ui-highlight'] );
}
if ( isset( $atts['ui-logo'] ) && '0' === $atts['ui-logo'] ) {
$player_params['ui-logo'] = '0';
}
if ( isset( $atts['ui-start-screen-info'] ) && '0' === $atts['ui-start-screen-info'] ) {
$player_params['ui-start-screen-info'] = '0';
}
if ( isset( $atts['ui-theme'] ) && in_array( strtolower( $atts['ui-theme'] ), array( 'dark', 'light' ), true ) ) {
$player_params['ui-theme'] = esc_attr( $atts['ui-theme'] );
}
// Add those parameters to the Video URL.
$video_url = add_query_arg(
$player_params,
'https://www.dailymotion.com/embed/video/' . $id
);
$output = '';
if ( preg_match( '/^[A-Za-z0-9]+$/', $id ) ) {
$output .= '<iframe width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" src="' . esc_url( $video_url ) . '" style="border:0;" allowfullscreen></iframe>';
$video = preg_replace( '/[^-a-z0-9_]/i', '', $atts['video'] );
$title = wp_kses( $atts['title'], array() );
if (
array_key_exists( 'video', $atts )
&& $video
&& array_key_exists( 'title', $atts )
&& $title
) {
$output .= '<br /><strong><a href="' . esc_url( 'https://www.dailymotion.com/video/' . $video ) . '" target="_blank">' . esc_html( $title ) . '</a></strong>';
}
$user = preg_replace( '/[^-a-z0-9_]/i', '', $atts['user'] );
if ( array_key_exists( 'user', $atts ) && $user ) {
/* translators: %s is a Dailymotion user name */
$output .= '<br /><em>' . wp_kses(
sprintf(
/* Translators: placeholder is a Dailymotion username, linking to a Dailymotion profile page. */
__( 'Uploaded by %s', 'jetpack' ),
'<a href="' . esc_url( 'https://www.dailymotion.com/' . $user ) . '" target="_blank">' . esc_html( $user ) . '</a>'
),
array(
'a' => array(
'href' => true,
'target' => true,
),
)
) . '</em>';
}
}
/**
* Calypso Helper
*
* Makes shortcode output responsive to the location it is loaded:
* Notifications, Reader, Email
*/
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
require_once WP_CONTENT_DIR . '/lib/display-context.php';
$context = A8C\Display_Context\get_current_context();
// Notifications.
if ( A8C\Display_Context\NOTIFICATIONS === $context ) {
return sprintf(
'<a href="%1$s" target="_blank" rel="noopener noreferrer">%1$s</a>',
esc_url( 'https://www.dailymotion.com/video/' . $id )
);
}
}
return $output;
}
Code file location:
jetpack/jetpack/modules/shortcodes/dailymotion.php
Jetpack [dailymotion-channel] Shortcode
The ‘dailymotion-channel’ shortcode is used to embed a Dailymotion channel on your WordPress site in a grid, carousel, or default layout. The PHP code takes the ‘user’ attribute to identify the Dailymotion channel and the ‘type’ attribute to determine the layout. It then returns an iframe with the corresponding Dailymotion badge URL.
Shortcode: [dailymotion-channel]
Parameters
Here is a list of all possible dailymotion-channel shortcode parameters and attributes:
user
– specifies the Dailymotion username to display content fromtype
– determines the layout of the displayed content: ‘grid’, ‘carousel’, or default view
Examples and Usage
Basic example – Display a Dailymotion channel in a grid layout
[dailymotion-channel user="yourusername" type="grid" /]
Advanced examples
Display a Dailymotion channel in a carousel layout
[dailymotion-channel user="yourusername" type="carousel" /]
Display a Dailymotion channel without specifying the type. By default, this will display the channel in a simple layout.
[dailymotion-channel user="yourusername" /]
In these examples, replace “yourusername” with the username of the Dailymotion channel you wish to display. The ‘type’ attribute is optional and determines the layout of the displayed channel. It can be either ‘grid’, ‘carousel’, or omitted for a simple layout.
PHP Function Code
In case you have difficulties debugging what causing issues with [dailymotion-channel]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'dailymotion-channel', 'dailymotion_channel_shortcode' );
Shortcode PHP function:
function dailymotion_channel_shortcode( $atts ) {
$username = $atts['user'];
switch ( $atts['type'] ) {
case 'grid':
$channel_iframe = '<iframe sandbox="allow-popups allow-scripts allow-same-origin allow-presentation" width="300px" height="264px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=grid' ) . '"></iframe>';
break;
case 'carousel':
$channel_iframe = '<iframe sandbox="allow-popups allow-scripts allow-same-origin allow-presentation" width="300px" height="360px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=carousel' ) . '"></iframe>';
break;
default:
$channel_iframe = '<iframe sandbox="allow-popups allow-scripts allow-same-origin allow-presentation" width="300px" height="78px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username ) . '"></iframe>';
}
return $channel_iframe;
}
Code file location:
jetpack/jetpack/modules/shortcodes/dailymotion.php
Jetpack [facebook] Shortcode
The Jetpack Facebook shortcode is used to embed Facebook posts, photos, or videos into your WordPress site. This shortcode checks if a URL is provided and matches specific Facebook embed patterns. If it matches, it will return an embedded Facebook post, photo, or video.
Shortcode: [facebook]
Examples and Usage
Basic example – A simple usage of the Facebook shortcode to embed a Facebook post by providing the URL of the post in the ‘url’ attribute.
[facebook url="https://www.facebook.com/YourPage/posts/YourPostID" /]
Advanced examples
Embedding a Facebook photo by providing the URL of the photo in the ‘url’ attribute. The photo will be displayed on the page where the shortcode is used.
[facebook url="https://www.facebook.com/YourPage/photos/a.YourAlbumID/YourPhotoID/" /]
Embedding a Facebook video by providing the URL of the video in the ‘url’ attribute. The video will be displayed on the page where the shortcode is used.
[facebook url="https://www.facebook.com/YourPage/videos/YourVideoID/" /]
Please note that in all the examples above, you need to replace ‘YourPage’, ‘YourPostID’, ‘YourAlbumID’, and ‘YourVideoID’ with the actual Facebook page name and the IDs of the post, photo, or video you want to embed.
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'] )
&& ! preg_match( JETPACK_FACEBOOK_VIDEO_EMBED_REGEX, $atts['url'] )
&& ! preg_match( JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX, $atts['url'] ) ) {
return;
}
return $wp_embed->shortcode( $atts, $atts['url'] );
}
Code file location:
jetpack/jetpack/modules/shortcodes/facebook.php
Jetpack [flickr] Shortcode
The Jetpack Flickr shortcode allows you to display content from Flickr. It supports both photos and videos, which can be specified through the ‘photo’ and ‘video’ attributes respectively. Additional attributes include ‘w’ and ‘h’ for width and height, ‘controls’ to display video controls, and ‘autoplay’ for automatic playback. The shortcode ensures secure content delivery by replacing ‘http://’ with ‘https://’. Depending on the content type, it either generates video markup or an iframe for photos. The iframe allows full-screen viewing, with adjustments for AMP requests.
Shortcode: [flickr]
Parameters
Here is a list of all possible flickr shortcode parameters and attributes:
video
– the URL of the Flickr video to displayphoto
– the URL of the Flickr photo to showw
– the width of the video or photoh
– the height of the video or photocontrols
– option to show video controls, default is ‘yes’autoplay
– option to autoplay video, no default value
Examples and Usage
Basic example – Show a Flickr photo using its URL
[flickr photo="https://www.flickr.com/photos/example/12345678" /]
Advanced examples
Display a Flickr video using its URL, with specific width and height
[flickr video="https://www.flickr.com/photos/example/12345678" w="500" h="300" /]
Display a Flickr photo with autoplay enabled and controls hidden
[flickr photo="https://www.flickr.com/photos/example/12345678" autoplay="yes" controls="no" /]
These shortcodes will enable you to embed Flickr photos or videos into your WordPress posts or pages, with the option to customize the size and playback controls. Please note that you need to replace the URL in the shortcode with the actual URL of the Flickr photo or video you want to display.
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,
'w' => '',
'h' => '',
'controls' => 'yes',
'autoplay' => '',
),
$atts,
'flickr'
);
if ( ! empty( $atts['video'] ) ) {
$showing = 'video';
$src = $atts['video'];
} elseif ( ! empty( $atts['photo'] ) ) {
$showing = 'photo';
$src = $atts['photo'];
} else {
return '';
}
$src = str_replace( 'http://', 'https://', $src );
if ( 'video' === $showing ) {
$video_id = flick_shortcode_video_id( $src );
if ( empty( $video_id ) ) {
return '';
}
$atts = array_map( 'esc_attr', $atts );
return flickr_shortcode_video_markup( $atts, $video_id, $src );
} elseif ( 'photo' === $showing ) {
if ( ! preg_match( '~^(https?:)?//([\da-z\-]+\.)*?((static)?flickr\.com|flic\.kr)/.*~i', $src ) ) {
return '';
}
$height = empty( $atts['h'] ) ? 'auto' : esc_attr( $atts['h'] );
$src = sprintf( '%s/player/', untrailingslashit( $src ) );
$allow_full_screen = 'allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen';
if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
$allow_full_screen = str_replace( ' oallowfullscreen msallowfullscreen', '', $allow_full_screen );
}
return sprintf( '<iframe src="%s" height="%s" width="%s" frameborder="0" %s></iframe>', esc_url( $src ), $height, esc_attr( $atts['w'] ), $allow_full_screen );
}
return false;
}
Code file location:
jetpack/jetpack/modules/shortcodes/flickr.php
Jetpack [gist] Shortcode
The Jetpack plugin shortcode is used to display GitHub Gists in WordPress posts. It validates and processes Gist URLs or IDs, and handles errors.
Shortcode: [gist]
Parameters
Here is a list of all possible gist shortcode parameters and attributes:
id
– The unique identifier of the Gist from GitHub.file
– The specific file name within the Gist.ts
– The tab size for the code within the Gist.
Examples and Usage
Basic example – Display a GitHub Gist by referencing its ID
[gist id="gistID" /]
Advanced examples
Display a GitHub Gist by referencing its URL. This is useful when you want to embed a gist without knowing its exact ID.
[gist url="https://gist.github.com/username/gistID" /]
Display a specific file within a GitHub Gist by using the ‘file’ attribute. This is particularly useful when the Gist contains multiple files and you only want to display one.
[gist id="gistID" file="fileName" /]
Set a custom tab size for the displayed Gist. This allows you to control the indentation of the code in the Gist.
[gist id="gistID" ts="4" /]
Display a GitHub Gist with a custom tab size and a specific file. This combines several of the attributes for maximum control over the displayed Gist.
[gist id="gistID" file="fileName" ts="4" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [gist]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'gist', 'github_gist_shortcode' );
Shortcode PHP function:
function github_gist_shortcode( $atts, $content = '' ) {
if ( empty( $atts[0] ) && empty( $content ) ) {
if ( current_user_can( 'edit_posts' ) ) {
return esc_html__( 'Please specify a Gist URL or ID.', 'jetpack' );
} else {
return '<!-- Missing Gist ID -->';
}
}
$id = ( ! empty( $content ) ) ? $content : $atts[0];
// Parse a URL to get an ID we can use.
$gist_info = jetpack_gist_get_shortcode_id( $id );
if ( empty( $gist_info['id'] ) ) {
if ( current_user_can( 'edit_posts' ) ) {
return esc_html__( 'The Gist ID you provided is not valid. Please try a different one.', 'jetpack' );
} else {
return '<!-- Invalid Gist ID -->';
}
} else {
// Add trailing .json to all unique gist identifiers.
$id = $gist_info['id'] . '.json';
}
// The file name can come from the URL passed, or from a shortcode attribute.
if ( ! empty( $gist_info['file'] ) ) {
$file = $gist_info['file'];
} elseif ( ! empty( $atts['file'] ) ) {
$file = $atts['file'];
} else {
$file = '';
}
// Replace - by . to get a real file name from slug.
if ( ! empty( $file ) ) {
// Find the last -.
$dash_position = strrpos( $file, '-' );
if ( false !== $dash_position ) {
// Replace the - by a period.
$file = substr_replace( $file, '.', $dash_position, 1 );
}
$file = rawurlencode( $file );
}
// Set the tab size, allowing attributes to override the query string.
$tab_size = $gist_info['ts'];
if ( ! empty( $atts['ts'] ) ) {
$tab_size = absint( $atts['ts'] );
}
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
) {
/*
* According to <https://www.ampproject.org/docs/reference/components/amp-gist#height-(required)>:
*
* > Note: You must find the height of the gist by inspecting it with your browser (e.g., Chrome Developer Tools).
*
* However, this does not seem to be the case any longer. The actual height of the content does get set in the
* page after loading. So this is just the initial height.
* See <https://github.com/ampproject/amphtml/pull/17738>.
*/
$height = 240;
$amp_tag = sprintf(
'<amp-gist layout="fixed-height" data-gistid="%s" height="%s"',
esc_attr( basename( $id, '.json' ) ),
esc_attr( $height )
);
if ( ! empty( $file ) ) {
$amp_tag .= sprintf( ' data-file="%s"', esc_attr( $file ) );
}
$amp_tag .= '></amp-gist>';
return $amp_tag;
}
// URL points to the entire gist, including the file name if there was one.
$id = ( ! empty( $file ) ? $id . '?file=' . $file : $id );
$return = false;
$request = wp_remote_get( esc_url_raw( 'https://gist.github.com/' . esc_attr( $id ) ) );
$request_code = wp_remote_retrieve_response_code( $request );
if ( 200 === $request_code ) {
$request_body = wp_remote_retrieve_body( $request );
$request_data = json_decode( $request_body );
wp_enqueue_style( 'jetpack-gist-styling', esc_url( $request_data->stylesheet ), array(), JETPACK__VERSION );
$gist = substr_replace( $request_data->div, sprintf( 'style="tab-size: %1$s" ', absint( $tab_size ) ), 5, 0 );
// Add inline styles for the tab style in the opening div of the gist.
$gist = preg_replace(
'#(\<div\s)+(id=\"gist[0-9]+\")+(\sclass=\"gist\"\>)?#',
sprintf( '$1style="tab-size: %1$s" $2$3', absint( $tab_size ) ),
$request_data->div,
1
);
// Add inline style to prevent the bottom margin to the embed that themes like TwentyTen, et al., add to tables.
$return = sprintf( '<style>.gist table { margin-bottom: 0; }</style>%1$s', $gist );
}
if (
// No need to check for a nonce here, that's already handled by Core further up.
// phpcs:disable WordPress.Security.NonceVerification.Missing
isset( $_POST['type'] )
&& 'embed' === $_POST['type']
&& isset( $_POST['action'] )
&& 'parse-embed' === $_POST['action']
// phpcs:enable WordPress.Security.NonceVerification.Missing
) {
return github_gist_simple_embed( $id, $tab_size );
}
return $return;
}
Code file location:
jetpack/jetpack/modules/shortcodes/gist.php
Jetpack [googleapps] Shortcode
The Jetpack Google Apps shortcode allows embedding Google Apps such as Docs, Sheets, or Calendar into your WordPress site. The function ‘googleapps_shortcode’ takes parameters like width, height, domain, directory, and source URL. It validates the URL and adjusts the dimensions according to the content width. It then generates an iframe to embed the Google App. If an unsupported URL is provided, it returns an error comment.
Shortcode: [googleapps]
Parameters
Here is a list of all possible googleapps shortcode parameters and attributes:
width
– Defines the width of the Google Apps embed, defaults to 100%.height
– Determines the height of the embed, default is 560.domain
– Specifies the Google service to use, default is ‘docs’.dir
– Sets the directory of the Google service, default is ‘document’.query
– Allows extra parameters to be passed in the URL.src
– Specifies the URL of the Google service to embed.
Examples and Usage
Basic example – Show a Google Doc by using the URL as the only parameter
[googleapps "https://docs.google.com/document/d/1j6_7X0i1mX3LgJyO2Ih4QnV1IjB8pFgqtu2Qe1XbKMM/edit"]
Advanced examples
Display a Google Spreadsheet with a specified width and height
[googleapps width="500" height="300" src="https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0"]
Embed a Google Calendar with a specific width and default height
[googleapps width="600" src="https://calendar.google.com/calendar/embed?src=en.usa%23holiday%40group.v.calendar.google.com&ctz=America%2FNew_York"]
Display a Google Doc from Google Drive with a specific width and height
[googleapps width="700" height="400" src="https://drive.google.com/file/d/1yogmGs_Hau3NAOnzQQmt3H1GjasuyZ9U/view"]
Note: In all the examples above, replace the URLs with the URL of your Google Doc, Spreadsheet, or Calendar. The width and height are optional and can be adjusted to fit your layout.
PHP Function Code
In case you have difficulties debugging what causing issues with [googleapps]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'googleapps', 'googleapps_shortcode' );
Shortcode PHP function:
function googleapps_shortcode( $atts ) {
global $content_width;
$attr = shortcode_atts(
array(
'width' => '100%',
'height' => '560',
'domain' => 'docs',
'dir' => 'document',
'query' => '',
'src' => '',
),
$atts
);
if ( is_numeric( $content_width ) && $content_width > 0 && is_numeric( $attr['width'] ) && $attr['width'] > $content_width ) {
$attr['width'] = $content_width;
}
if ( is_numeric( $content_width ) && $content_width > 0 && '560' === $attr['height'] ) {
$attr['height'] = floor( $content_width * 3 / 4 );
}
if ( isset( $atts[0] ) && $atts[0] ) {
$attr['src'] = $atts[0];
}
if ( $attr['src'] && preg_match( '!https?://(docs|drive|spreadsheets\d*|calendar|www)*\.google\.com/([-\w\./]+)\?([^"]+)!', $attr['src'], $matches ) ) {
$attr['domain'] = $matches[1];
$attr['dir'] = $matches[2];
parse_str( htmlspecialchars_decode( $matches[3], ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ), $query_ar );
$query_ar['chrome'] = 'false';
$query_ar['embedded'] = 'true';
$attr['query'] = http_build_query( $query_ar );
}
if ( ! googleapps_validate_domain_and_dir( $attr['domain'], $attr['dir'] ) ) {
return '<!-- Unsupported URL -->';
}
$attr['query'] = $attr['dir'] . '?' . $attr['query'];
/** This action is documented in modules/widgets/social-media-icons.php */
do_action( 'jetpack_bump_stats_extras', 'embeds', googleapps_service_name( $attr['domain'], $attr['dir'] ) );
return sprintf(
'<iframe src="%s" frameborder="0" width="%s" height="%s" marginheight="0" marginwidth="0" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>',
esc_url( 'https://' . $attr['domain'] . '.google.com/' . $attr['query'] ),
esc_attr( $attr['width'] ),
esc_attr( $attr['height'] )
);
}
Code file location:
jetpack/jetpack/modules/shortcodes/googleapps.php
Jetpack [googlemaps] Shortcode
The Jetpack Google Maps shortcode is a handy tool that allows the embedding of Google Maps into WordPress posts or pages. The shortcode parses the Google Maps URL and creates an iframe that displays the map. It also allows customization of the map’s width and height. Alignment options (left, center, right) are provided for better layout control. The shortcode ensures secure HTTPS protocol for map links and supports AMP requests for improved mobile experience.
Shortcode: [googlemaps]
Parameters
Here is a list of all possible googlemaps shortcode parameters and attributes:
0
– the URL of the Google map to be embeddedw
– the width of the embedded map, can be a percentage or pixel valueh
– the height of the embedded map in pixelsalign
– alignment of the map, can be ‘left’, ‘center’, or ‘right’hq
– a parameter that, if set, will be removed from the URL
Examples and Usage
Basic example – A simple usage of the shortcode to embed a Google Map into your post or page.
[googlemaps https://www.google.com/maps/place/Statue+of+Liberty/]
Advanced examples
Embedding a Google Map with a specific width and height. You can adjust the width and height by changing the ‘w’ and ‘h’ parameters respectively.
[googlemaps https://www.google.com/maps/place/Statue+of+Liberty/ w=500 h=400]
Aligning the embedded Google Map to the right of your post or page. You can change the alignment by adjusting the ‘align’ parameter to ‘left’, ‘center’, or ‘right’.
[googlemaps https://www.google.com/maps/place/Statue+of+Liberty/ align=right]
Embedding a Google Map with a specific width, height, and alignment. This is a combination of the previous advanced examples.
[googlemaps https://www.google.com/maps/place/Statue+of+Liberty/ w=500 h=400 align=center]
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] ) ) {
return '';
}
$params = ltrim( $atts[0], '=' );
$width = 425;
$height = 350;
if ( preg_match( '!^https?://(www|maps|mapsengine)\.google(\.co|\.com)?(\.[a-z]+)?/.*?(\?.+)!i', $params, $match ) ) {
$params = str_replace( '&amp;', '&', $params );
$params = str_replace( '&', '&', $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&" );
}
}
$url = substr( $url, 0, -5 );
$url = str_replace( 'http://', 'https://', $url );
$css_class = 'googlemaps';
if ( ! empty( $atts['align'] ) && in_array( strtolower( $atts['align'] ), array( 'left', 'center', 'right' ), true ) ) {
$atts['align'] = strtolower( $atts['align'] );
if ( 'left' === $atts['align'] ) {
$css_class .= ' alignleft';
} elseif ( 'center' === $atts['align'] ) {
$css_class .= ' aligncenter';
} elseif ( 'right' === $atts['align'] ) {
$css_class .= ' alignright';
}
}
$sandbox = class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request()
? 'sandbox="allow-popups allow-scripts allow-same-origin"'
: '';
return sprintf(
'<div class="%1$s">
<iframe width="%2$d" height="%3$d" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" %5$s src="%4$s"></iframe>
</div>',
esc_attr( $css_class ),
absint( $width ),
absint( $height ),
esc_url( $url ),
$sandbox
);
}
}
Code file location:
jetpack/jetpack/modules/shortcodes/googlemaps.php
Jetpack [googleplus] Shortcode
The Jetpack Googleplus shortcode is a tool that embeds Google+ posts into your WordPress site. It takes a Google+ post URL as its parameter and embeds the post within a paragraph tag.
Shortcode: [googleplus]
Parameters
Here is a list of all possible googleplus shortcode parameters and attributes:
url
– The link to the Google Plus post you want to embed.
Examples and Usage
Basic example – In this example, we are using the ‘googleplus’ shortcode to embed a Google+ post using its URL as a parameter.
[googleplus url="https://plus.google.com/+WordPress/posts/B3vLjEy1cWo" /]
Advanced examples
Embedding a Google+ post with additional parameters. In this case, we are using ‘width’ and ‘align’ parameters to customize the appearance of the embedded post. The ‘width’ parameter adjusts the width of the embedded post, while the ‘align’ parameter aligns the post to the left, right, or center of the page.
[googleplus url="https://plus.google.com/+WordPress/posts/B3vLjEy1cWo" width="500" align="center" /]
Please note that the ‘url’ parameter is mandatory and the shortcode will not work without it. The ‘width’ and ‘align’ parameters are optional and can be used to customize the appearance of the embedded post.
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 sprintf( '<p>%s</p>', $wp_embed->shortcode( $atts, $atts['url'] ) );
}
Code file location:
jetpack/jetpack/modules/shortcodes/googleplus.php
Jetpack [jetpack_gravatar_shortcode] Shortcode
The Jetpack Gravatar shortcode is a WordPress plugin that displays a Gravatar image based on the provided email address. This shortcode takes two parameters: ’email’ and ‘size’. If no valid email is provided, it returns false. The ‘size’ parameter adjusts the Gravatar’s size, and defaults to 96 pixels if not specified or if a negative value is given.
Shortcode: [jetpack_gravatar_shortcode]
Parameters
Here is a list of all possible jetpack_gravatar_shortcode shortcode parameters and attributes:
email
– The email address used to display the Gravatar image.size
– Defines the pixel size of the Gravatar image, default is 96.
Examples and Usage
Basic example – A simple usage of the gravatar shortcode to display a user’s gravatar with the default size.
[gravatar email="user@example.com" /]
Advanced examples
1. Displaying a user’s gravatar with a specific size. The size attribute controls the size of the gravatar in pixels. The default size is 96 pixels.
[gravatar email="user@example.com" size="128" /]
2. Displaying a user’s gravatar with a size that is larger than the default. This example shows how to display a gravatar that is 200 pixels in size.
[gravatar email="user@example.com" size="200" /]
3. Displaying a user’s gravatar with a size that is smaller than the default. This example shows how to display a gravatar that is 50 pixels in size.
[gravatar email="user@example.com" size="50" /]
Remember that the ’email’ attribute must be a valid email address, and the ‘size’ attribute must be an integer greater than 0. If the ’email’ attribute is not provided or is not a valid email address, the shortcode will return false. If the ‘size’ attribute is not provided, is not an integer, or is less than 0, it will be set to the default size of 96 pixels.
PHP Function Code
In case you have difficulties debugging what causing issues with [jetpack_gravatar_shortcode]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'gravatar', 'jetpack_gravatar_shortcode' );
Shortcode PHP function:
function jetpack_gravatar_shortcode( $atts ) {
$atts = shortcode_atts(
array(
'email' => '',
'size' => 96,
),
$atts
);
if ( empty( $atts['email'] ) || ! is_email( $atts['email'] ) ) {
return false;
}
$atts['size'] = (int) $atts['size'];
if ( 0 > $atts['size'] ) {
$atts['size'] = 96;
}
return get_avatar( $atts['email'], $atts['size'] );
}
Code file location:
jetpack/jetpack/modules/shortcodes/gravatar.php
Jetpack [gravatar_profile] Shortcode
The Jetpack Gravatar Profile shortcode displays a user’s Gravatar profile on your WordPress site. It accepts a username, user ID, or email address as input. This shortcode fetches the user’s Gravatar image, name, location, and bio, and generates a profile box. The profile box includes a link to the complete Gravatar profile. It supports AMP and non-AMP versions.
Shortcode: [gravatar_profile]
Parameters
Here is a list of all possible gravatar_profile shortcode parameters and attributes:
who
– specifies the user by username, user ID, or email address
Examples and Usage
Basic example – Display a user’s Gravatar profile by referencing their username.
[gravatar_profile who="username" /]
Advanced examples
Display a user’s Gravatar profile by referencing their user ID.
[gravatar_profile who=1 /]
Display a user’s Gravatar profile by referencing their email address. This can be useful if the user’s username or ID is unknown.
[gravatar_profile who="user@example.com" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [gravatar_profile]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'gravatar_profile', 'jetpack_gravatar_profile_shortcode' );
Shortcode PHP function:
function jetpack_gravatar_profile_shortcode( $atts ) {
// Give each use of the shortcode a unique ID.
static $instance = 0;
// Process passed attributes.
$atts = shortcode_atts(
array(
'who' => null,
),
$atts,
'jetpack_gravatar_profile'
);
// Can specify username, user ID, or email address.
if ( is_numeric( $atts['who'] ) ) {
$user = get_user_by( 'id', (int) $atts['who'] );
} elseif ( is_email( $atts['who'] ) ) {
$user = get_user_by( 'email', sanitize_email( $atts['who'] ) );
} elseif ( is_string( $atts['who'] ) ) {
$user = get_user_by( 'login', sanitize_user( $atts['who'] ) );
} else {
$user = false;
}
// Bail if we don't have a user.
if ( false === $user ) {
return false;
}
// Render the shortcode.
$gravatar_url = 'https://gravatar.com/' . $user->user_login;
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
$avatar_url = wpcom_get_avatar_url( $user->ID, 96 );
$avatar_url = $avatar_url[0];
$user_location = get_user_attribute( $user->ID, 'location' );
} else {
$avatar_url = get_avatar_url( $user->user_email, array( 'size' => 96 ) );
$user_location = get_user_meta( $user->ID, 'location', true );
}
ob_start();
if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
wp_enqueue_style( 'gravatar-style', plugins_url( '/css/gravatar-amp.css', __FILE__ ), array(), JETPACK__VERSION );
} else {
?>
<script type="text/javascript">
( function() {
if ( null === document.getElementById( 'gravatar-profile-embed-styles' ) ) {
var headID = document.getElementsByTagName( 'head' )[0];
var styleNode = document.createElement( 'style' );
styleNode.type = 'text/css';
styleNode.id = 'gravatar-profile-embed-styles';
var gCSS = '.grofile-wrap { border: solid 1px #f0f0f1; padding: 10px; } .grofile { padding: 0 0 5px 0; } .grofile-left { float: left; display: block; width: 96px; margin-right: 15px; } .grofile .gravatar { margin-bottom: 5px; } .grofile-clear { clear: left; font-size: 1px; height: 1px; } .grofile ul li a { text-indent: -99999px; } .grofile .grofile-left a:hover { text-decoration: none !important; border: none !important; } .grofile-name { margin-top: 0; }';
if ( document.all ) {
styleNode.innerText = gCSS;
} else {
styleNode.textContent = gCSS;
}
headID.appendChild( styleNode );
}
} )();
</script>
<?php
}
?>
<div class="grofile vcard" id="grofile-embed-<?php echo esc_attr( $instance ); ?>">
<div class="grofile-inner">
<div class="grofile-left">
<div class="grofile-img">
<a href="<?php echo esc_url( $gravatar_url ); ?>">
<img src="<?php echo esc_url( $avatar_url ); ?>" width="96" height="96" class="no-grav gravatar photo" />
</a>
</div>
</div>
<div class="grofile-right">
<p class="grofile-name fn">
<strong><?php echo esc_html( $user->display_name ); ?></strong>
<?php
if ( ! empty( $user_location ) ) :
?>
<br><span class="grofile-location adr"><?php echo esc_html( $user_location ); ?></span><?php endif; ?>
</p>
<p class="grofile-bio"><strong><?php esc_html_e( 'Bio:', 'jetpack' ); ?></strong> <?php echo wp_kses_post( $user->description ); ?></p>
<p class="grofile-view">
<a href="<?php echo esc_url( $gravatar_url ); ?>"><?php esc_html_e( 'View complete profile', 'jetpack' ); ?></a>
</p>
</div>
<span class="grofile-clear"> </span>
</div>
</div>
<?php
// Increment and return the rendered profile.
++$instance;
return ob_get_clean();
}
Code file location:
jetpack/jetpack/modules/shortcodes/gravatar.php
Jetpack [houzz] Shortcode
The Jetpack Houzz shortcode allows you to embed Houzz content into your WordPress site. Using ‘add_shortcode( ‘houzz’, ‘jetpack_houzz_shortcode’ )’, it extracts the URL from the shortcode attributes and generates an oEmbed HTML for it. It also enables you to specify the width and height of the embedded content using ‘w’ and ‘h’ parameters.
Shortcode: [houzz]
Parameters
Here is a list of all possible houzz shortcode parameters and attributes:
w
– sets the width of the embedded object in pixelsh
– sets the height of the embedded object in pixels
Examples and Usage
Basic example – Embeds a Houzz design idea using its URL as the parameter.
[houzz='https://www.houzz.com/photo/123456789'/]
Advanced examples
Specify the width and height of the embedded Houzz design idea. The width and height are specified in pixels.
[houzz='https://www.houzz.com/photo/123456789' w=500 h=300/]
Specify only the width of the embedded Houzz design idea. The height will be calculated automatically to maintain the aspect ratio of the design idea.
[houzz='https://www.houzz.com/photo/123456789' w=500 /]
Specify only the height of the embedded Houzz design idea. The width will be calculated automatically to maintain the aspect ratio of the design idea.
[houzz='https://www.houzz.com/photo/123456789' h=300 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [houzz]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'houzz', 'jetpack_houzz_shortcode' );
Shortcode PHP function:
function jetpack_houzz_shortcode( $atts ) {
$url = substr( $atts[0], 1 );
$args = array();
if ( isset( $atts['w'] ) && is_numeric( $atts['w'] ) ) {
$args['width'] = $atts['w'];
}
if ( isset( $atts['h'] ) && is_numeric( $atts['h'] ) ) {
$args['height'] = $atts['h'];
}
$oembed = _wp_oembed_get_object();
return $oembed->get_html( $url, $args );
}
Code file location:
jetpack/jetpack/modules/shortcodes/houzz.php
Jetpack [kickstarter] Shortcode
The Jetpack Kickstarter shortcode enables embedding of Kickstarter projects on your website. It checks the URL validity and if incorrect, returns an error message.
Shortcode: [kickstarter]
Parameters
Here is a list of all possible kickstarter shortcode parameters and attributes:
url
– The link to the specific Kickstarter project
Examples and Usage
Basic example – Embeds a Kickstarter project on your site by referencing its URL.
[kickstarter url="https://www.kickstarter.com/projects/xyz/abc" /]
Advanced examples
Embeds a Kickstarter project on your site by referencing its URL and specifying additional attributes.
[kickstarter url="https://www.kickstarter.com/projects/xyz/abc" width="500" height="400" /]
In this advanced example, the ‘width’ and ‘height’ attributes are used to specify the dimensions of the embedded Kickstarter project. If these attributes are not provided, the plugin will use default dimensions.
Note: The ‘kickstarter’ shortcode only accepts the ‘url’ attribute. Any additional attributes like ‘width’ and ‘height’ in the example above would need to be handled in your shortcode function ‘jetpack_kickstarter_shortcode’.
PHP Function Code
In case you have difficulties debugging what causing issues with [kickstarter]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'kickstarter', 'jetpack_kickstarter_shortcode' );
Shortcode PHP function:
function jetpack_kickstarter_shortcode( $atts ) {
if ( empty( $atts['url'] ) ) {
return '';
}
$url = esc_url_raw( $atts['url'] );
if ( ! preg_match( '#^(www\.)?kickstarter\.com$#i', wp_parse_url( $url, PHP_URL_HOST ) ) ) {
return '<!-- Invalid Kickstarter URL -->';
}
global $wp_embed;
return $wp_embed->shortcode( $atts, $url );
}
Code file location:
jetpack/jetpack/modules/shortcodes/kickstarter.php
Jetpack [medium] Shortcode
The Jetpack Medium shortcode allows users to embed Medium posts into their WordPress site. Upon execution, it checks for a valid Medium URL in the attributes. If the URL is valid, it returns the embedded post. If it’s invalid and the user has editing rights, an error message is displayed. Without editing rights, a comment indicating the missing URL is returned.
Shortcode: [medium]
Parameters
Here is a list of all possible medium shortcode parameters and attributes:
url
– The web address of the Medium post to embed.
Examples and Usage
Basic example – A simple usage of the Medium embed shortcode, where we only provide the URL of the Medium post we want to embed.
[medium url="https://medium.com/@username/post-title-123456" /]
Advanced examples
Embedding a Medium post with additional parameters. Here we add a ‘width’ and ‘height’ parameter to control the size of the embedded post. If the URL is not valid or missing, a message will be displayed to users with the ‘edit_posts’ capability, informing them of the error.
[medium url="https://medium.com/@username/post-title-123456" width="500" height="300" /]
When no URL is provided, the shortcode will return a comment indicating that the Medium URL is missing. This comment will only be visible in the page’s source code and not to the visitors of the page.
[medium /]
Please note that the ‘width’ and ‘height’ parameters in the advanced example are just for illustrative purposes. The actual shortcode does not support these parameters according to the provided PHP function.
PHP Function Code
In case you have difficulties debugging what causing issues with [medium]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'medium', 'jetpack_embed_medium_shortcode' );
Shortcode PHP function:
function jetpack_embed_medium_shortcode( $atts ) {
$atts = jetpack_embed_medium_args( $atts );
if ( ! empty( $atts['url'] ) ) {
global $wp_embed;
return $wp_embed->shortcode( $atts, $atts['url'] );
} elseif ( current_user_can( 'edit_posts' ) ) {
return esc_html__( 'You did not provide a valid Medium URL.', 'jetpack' );
} else {
return '<!-- Missing Medium URL -->';
}
}
Code file location:
jetpack/jetpack/modules/shortcodes/medium.php
Jetpack [mixcloud] Shortcode
The Jetpack Mixcloud shortcode embeds Mixcloud audio content on your site. It validates the resource’s ID and customizes the display. The shortcode checks for a valid Mixcloud resource. If invalid, it returns an error comment. It then creates a Mixcloud URL using the resource ID. The shortcode also allows customization of width, height, color, and visibility of tracklist, cover, followers, and artwork. It removes any falsey values from these attributes. It then sends a GET request to Mixcloud’s oEmbed endpoint. If the response is invalid, it returns an error comment. Finally, it adjusts the sandbox attribute in the returned HTML to ensure the embedded content displays correctly.
Shortcode: [mixcloud]
Parameters
Here is a list of all possible mixcloud shortcode parameters and attributes:
width
– Sets the width of the Mixcloud playerheight
– Defines the height of the Mixcloud playercolor
– Changes the color theme of the playerlight
– Sets the player’s theme to lightdark
– Sets the player’s theme to darkhide_tracklist
– Hides the tracklist from the playerhide_cover
– Removes the cover image from the playermini
– Enables the mini mode of the playerhide_followers
– Hides the follower count from the playerhide_artwork
– Removes the artwork from the player
Examples and Usage
Basic example – Embedding a Mixcloud audio resource using its resource ID.
[mixcloud resource_id="my-cool-mix"]
This shortcode will embed the Mixcloud audio resource with the ID “my-cool-mix” into your WordPress post or page.
Advanced examples
Embedding a Mixcloud audio resource with a specific width and height.
[mixcloud resource_id="my-cool-mix" width="500" height="300"]
This shortcode will embed the Mixcloud audio resource with the ID “my-cool-mix” into your WordPress post or page and set the width of the player to 500 pixels and the height to 300 pixels.
Embedding a Mixcloud audio resource with custom player attributes.
[mixcloud resource_id="my-cool-mix" light="true" hide_tracklist="true" hide_artwork="true"]
This shortcode will embed the Mixcloud audio resource with the ID “my-cool-mix” into your WordPress post or page with a light-themed player that hides the tracklist and the artwork.
PHP Function Code
In case you have difficulties debugging what causing issues with [mixcloud]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'mixcloud', 'mixcloud_shortcode' );
Shortcode PHP function:
function mixcloud_shortcode( $atts, $content = null ) {
if ( empty( $atts[0] ) && empty( $content ) ) {
return '<!-- mixcloud error: invalid mixcloud resource -->';
}
$regular_expression = '/((?<=mixcloud\.com\/)[\w\-\/]+$)|(^[\w\-\/]+$)/i';
preg_match( $regular_expression, $content, $match );
if ( ! empty( $match ) ) {
$resource_id = trim( $match[0] );
} else {
preg_match( $regular_expression, $atts[0], $match );
if ( ! empty( $match ) ) {
$resource_id = trim( $match[0] );
}
}
if ( empty( $resource_id ) ) {
return '<!-- mixcloud error: invalid mixcloud resource -->';
}
$mixcloud_url = 'https://mixcloud.com/' . $resource_id;
$atts = shortcode_atts(
array(
'width' => false,
'height' => false,
'color' => false,
'light' => false,
'dark' => false,
'hide_tracklist' => false,
'hide_cover' => false,
'mini' => false,
'hide_followers' => false,
'hide_artwork' => false,
),
$atts
);
// remove falsey values.
$atts = array_filter( $atts );
$query_args = array( 'url' => $mixcloud_url );
$query_args = array_merge( $query_args, $atts );
$url = add_query_arg( urlencode_deep( $query_args ), 'https://app.mixcloud.com/oembed/' );
$mixcloud_response = wp_remote_get( $url, array( 'redirection' => 0 ) );
if ( is_wp_error( $mixcloud_response ) || 200 !== $mixcloud_response['response']['code'] || empty( $mixcloud_response['body'] ) ) {
return '<!-- mixcloud error: invalid mixcloud resource -->';
}
$response_body = json_decode( $mixcloud_response['body'] );
$html = $response_body->html;
preg_match( '/sandbox="([^"]*)"/', $html, $matches );
if ( empty( $matches ) ) { // Mixcloud doesn't use sandbox attribute.
$html = preg_replace( '/>/', ' sandbox="allow-popups allow-scripts allow-same-origin allow-presentation">', $html, 1 );
} else { // Mixcloud uses sandbox attribute.
$allowed_values = array();
// Here we make sure that these string are not repeated in the sandbox attribute.
$attrs = array( 'allow-popups', 'allow-scripts', 'allow-same-origin', 'allow-presentation' );
foreach ( $attrs as $attr ) {
if ( false === strpos( $matches[1], $attr ) ) {
$allowed_values[] = $attr;
}
}
$sandbox_value = $matches[1] . ' ' . implode( ' ', $allowed_values );
$html = preg_replace( '/sandbox="([^"]*)"/', "sandbox=\"$sandbox_value\"", $html );
}
return $html;
}
Code file location:
jetpack/jetpack/modules/shortcodes/mixcloud.php
Jetpack [presentation] Shortcode
The Jetpack plugin’s shortcode, [presentation], is designed to create a customizable slideshow presentation on your WordPress site. This shortcode allows you to define attributes like duration, height, width, background color/image, autoplay, and various transition settings. It also includes a fallback message for unsupported browsers.
Shortcode: [presentation]
Parameters
Here is a list of all possible presentation shortcode parameters and attributes:
duration
– defines the duration of the presentation in secondsheight
– specifies the height of the presentation in pixelswidth
– sets the width of the presentation in pixelsbgcolor
– sets the background color of the presentationbgimg
– sets the background image for the presentationautoplay
– triggers the autoplay function of the presentationtransition
– sets the transition style between slidesscale
– adjusts the scale of the presentationrotate
– sets the rotation angle of the presentationfade
– controls the fade effect in the presentationfadebullets
– controls the fade effect on bullet points
Examples and Usage
Basic example – Display a presentation using the default settings.
[presentation /]
Advanced examples
Customize a presentation by setting the duration, width, and height. The duration is set in seconds, while the width and height are set in pixels.
[presentation duration=2 width=500 height=400 /]
Further customize a presentation by adding a transition effect, scale, rotation, and fade effect. The transition effect is set to ‘down’, the scale is set to 1.5, rotation is set to 30 degrees, and the fade effect is turned on.
[presentation transition='down' scale=1.5 rotate=30 fade='on' /]
Set a background color or a background image for the presentation. If both are set, the background image will take precedence.
[presentation bgcolor='#000000' bgimg='https://example.com/image.jpg' /]
Enable autoplay for the presentation. The autoplay duration is set in milliseconds.
[presentation autoplay=3000 /]
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,
'presentation'
);
$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'] = (float) $atts['scale'];
}
if ( '' !== trim( $atts['rotate'] ) ) {
$this->presentation_settings['rotate'] = (float) $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 = (float) $atts['duration'] . 's';
} else {
$duration = '1s';
}
// Autoplay durations are set in milliseconds.
if ( '' !== trim( $atts['autoplay'] ) ) {
$autoplay = (float) $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'] = (int) $atts['width'];
} else {
$this->presentation_settings['width'] = 480;
}
if ( '' !== trim( $atts['height'] ) ) {
$this->presentation_settings['height'] = (int) $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] ) . '");';
} elseif ( '' !== 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>';
$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:
jetpack/jetpack/modules/shortcodes/presentations.php
Jetpack [slide] Shortcode
The Jetpack Plugin ‘Slide’ shortcode is used to create presentations in WordPress. It allows users to customize transitions, scale, rotation, and more. The ‘slide’ shortcode function begins by checking if a presentation is initialized. If not, it returns the content unchanged. It then sets default attributes for the slide, such as transition, scale, rotation, fade, fadebullets, bgcolor, and bgimg. The function further adjusts the positioning, scale, rotation, and fade settings based on the provided attributes. For instance, if no transition is specified, it uses the default transition setting. The shortcode also handles background color and image settings. If a URL is provided, it sets that as the background image. If a color is specified, it sets that as the background color. If neither is provided, the background defaults to white. Finally, the shortcode assembles the slide with the specified settings and returns the output. This allows users to create customized, dynamic presentations in their WordPress posts or pages.
Shortcode: [slide]
Parameters
Here is a list of all possible slide shortcode parameters and attributes:
transition
– defines the slide transition stylescale
– adjusts the scale of the slide contentrotate
– sets the rotation angle of the slide contentfade
– enables or disables fade effect on the slide contentfadebullets
– controls whether bullets fade on step changesbgcolor
– sets the background color of the slidebgimg
– sets the background image URL of the slide
Examples and Usage
Basic example – Show a slide with default settings
[slide /]
Advanced examples
Display a slide with a specific transition, scale, and rotation parameters
[slide transition="zoom" scale="1.5" rotate="90" /]
Enable fading effect for the content and bullets on a slide
[slide fade="on" fadebullets="on" /]
Set a specific background color or image for a slide
[slide bgcolor="#ff0000" /]
Conclusion
Now that you’ve learned how to embed the 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.
Leave a Reply