Below, you’ll find a detailed guide on how to add the Perfect Pullquotes Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Perfect Pullquotes Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Perfect Pullquotes Plugin and the shortcodes it provides:
"Perfect Pullquotes is a user-friendly WordPress plugin that allows you to easily add beautifully styled pullquotes to your posts and pages, enhancing readability and design aesthetics."
- [perfectpullquote]
Perfect Pullquotes [perfectpullquote] Shortcode
The Perfect Pullquote shortcode is a customizable feature for enhancing the visual appeal of quotes. It offers alignment options, border location changes, citation addition, source linking, color customization, class addition, and text size definition.
Shortcode: [perfectpullquote]
Parameters
Here is a list of all possible perfectpullquote shortcode parameters and attributes:
align
– Aligns the pullquote left, right, or full width.bordertop
– Places border at the top, falls back to align location on mobile.cite
– Adds the name or source of the quote.link
– Adds a link to the cited source, must be http or https link.color
– Sets the border color using a HEX value, default is #EEEEEE.class
– Adds additional classes to the div.pullquote object.size
– Defines the font size of the text in pixels.
Examples and Usage
Basic example – In this example, we will use the ‘perfectpullquote’ shortcode to create a pullquote aligned to the left with default border color and placement.
[perfectpullquote]This is a basic pullquote[/perfectpullquote]
Advanced examples
Here, the ‘perfectpullquote’ shortcode is used to create a pullquote aligned to the right, with a top border, a citation, and a link to the source. The border color is set to a custom hex value, and an additional CSS class is added to the div. The font size of the text is also defined.
[perfectpullquote align="right" bordertop="true" cite="John Doe" link="http://example.com" color="#FF6347" class="custom-class" size="18"]This is an advanced pullquote[/perfectpullquote]
In another advanced example, the ‘perfectpullquote’ shortcode is used to create a full-width pullquote with a citation but without a link. The font size of the text is defined, but no additional CSS class or custom border color is added.
[perfectpullquote align="full" cite="Jane Doe" size="24"]This is another advanced pullquote[/perfectpullquote]
PHP Function Code
In case you have difficulties debugging what causing issues with [perfectpullquote]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'perfectpullquote', 'adamdehaven_perfectpullquote' );
Shortcode PHP function:
function adamdehaven_perfectpullquote( $atts, $content = null ) {
$a = shortcode_atts( array(
'align' => 'left', // (Required) Align pullquote to the left, right, or full (for width:100%). Default left.
'bordertop' => 'false', // (Optional) Change border location to the top, then fallback to align location on mobile.
'cite' => null, // (Optional) Add the name/source of the quote.
'link' => null, // (Optional) Add a link to the cited source, must be http or https link.
'color' => null, // (Optional) Provide the HEX value of the border-color. Default #EEEEEE
'class' => null, // (Optional) Add additional classes to the div.pullquote object.
'size' => null // (Optional) Define the font size of the text in pixels.
), $atts );
// Pullquote alignment (left, right, or full)
$alignment = '';
switch ( $a['align'] ) {
case 'full':
$alignment = ' pullquote-align-full';
break;
case 'right':
$alignment = ' pullquote-align-right';
break;
default:
$alignment = ' pullquote-align-left';
break;
}
//Check for border location options.
$border = '';
switch ($a['bordertop']){
case 'true':
$border = " pullquote-border-placement-top";
break;
default:
if ($a['align'] == 'left') {
$border = " pullquote-border-placement-right";
} else {
$border = " pullquote-border-placement-left";
}
break;
}
// Check for classes
if ( isset($a['class']) && strlen($a['class']) > 0 && preg_match('/[a-zA-Z0-9_ -]*/', $a['class']) ):
$classes = strip_tags($classes);
$classes = esc_attr($a['class']);
$classes = ' '.preg_replace('/[^a-z0-9_ -]+/i', '', $classes);
else:
$classes = null;
endif;
// Check for size
if ( isset($a['size']) && strlen($a['size']) > 0 && strlen($a['size']) < 3 && is_numeric($a['size']) ):
$size = 'font-size:'.$a['size'].'px !important;';
$paragraphSize = ' style="font-size:'.$a['size'].'px !important;"';
else:
$size = null;
$paragraphSize = null;
endif;
// border-color: HEX value
if ( isset($a['color']) && strlen($a['color']) > 1 && preg_match('/#([a-fA-F0-9]{3}){1,2}\b/',$a['color']) ):
$color = 'border-color:'.$a['color'].' !important;';
else:
$color = null;
endif;
if( !is_null($color) || !is_null($size)):
$styles = ' style="'.$color.$size.'"';
else:
$styles = null;
endif;
// Check for cite
if ( isset($a['cite']) && strlen($a['cite']) > 1 ):
$citeText = '<span itemprop="name">'.strip_tags( $a['cite'] ).'</span>';
else:
$citeText = null;
endif;
// Check for link
if ( isset($a['link']) && strlen($a['link']) > 1 && preg_match("/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/", $a['link']) ):
$citeLink = $a['link'];
$citeAttribute = ' cite="'.$citeLink.'"';
$citeLinkWithText = '<a href="'.$a['link'].'" class="url" target="_blank" itemprop="url">'.$citeText.'</a>';
else:
$citeLink = null;
$citeAttribute = null;
$citeLinkWithText = null;
endif;
// Create footer
if ($citeLink && $citeText):
$citeFooter = '<footer itemscope itemtype="http://schema.org/Person"><cite>'.$citeLinkWithText.'</cite></footer>';
elseif($citeText):
$citeFooter = '<footer itemscope itemtype="http://schema.org/Person"><cite>'.$citeText.'</cite></footer>';
else:
$citeFooter = null;
endif;
return '<div class="perfect-pullquote vcard'.$alignment.$border.$classes.'"'.$styles.'><blockquote'.$citeAttribute.'><p'.$paragraphSize.'>'.do_shortcode($content).'</p>'.$citeFooter.'</blockquote></div>';
}
Code file location:
perfect-pullquotes/perfect-pullquotes/perfect-pullquotes.php
Conclusion
Now that you’ve learned how to embed the Perfect Pullquotes Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply