Created
July 22, 2014 11:21
-
-
Save BrainCrumbz/c7d3676f885351605de5 to your computer and use it in GitHub Desktop.
Custom Pixelenity shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PeThemeShortcodeBrainCrumbzParallaxSeparator extends PeThemeShortcode { | |
/* | |
Syntax: | |
[parallax-sep imageurl="URL of parallax background image" | |
textcolor="font color code (optional)" | |
bgcolor="background color code (optional)" | |
padding_top="top padding (optional)" | |
padding_bottom="bottom padding (optional)" | |
subtitle="optional subtitle text (optional)"] | |
Formatted title here (optional) | |
[/parallax-sep] | |
Example: | |
[parallax-sep imageurl="http://yourdomain.com/yourpath/image.jpg" | |
textcolor="#F0F0F0" | |
bgcolor="#333333" | |
padding_top="10px" | |
padding_bottom="10px" | |
subtitle="Subtitle here"] | |
FORMATTED TITLE <em>HERE</em> | |
[/parallax-sep] | |
*/ | |
public function __construct($master) { | |
parent::__construct($master); | |
$this->trigger = "parallax-sep"; | |
$this->group = __("BrainCrumbz",'Pixelentity Theme/Plugin'); | |
$this->name = __("Parallax Separator",'Pixelentity Theme/Plugin'); | |
$this->description = __("Add a parallax full-width separator",'Pixelentity Theme/Plugin'); | |
$this->fields = array( | |
"imageurl" => array( | |
"label" => __("Image URL",'Pixelentity Theme/Plugin'), | |
"type" => "Text", | |
"description" => __("Enter the URL of parallax background image",'Pixelentity Theme/Plugin'), | |
), | |
"textcolor" => array( | |
"label" => __("Text color",'Pixelentity Theme/Plugin'), | |
"type" => "Text", | |
"description" => __("Enter the font color code (optional)",'Pixelentity Theme/Plugin'), | |
), | |
"bgcolor" => array( | |
"label" => __("Background color",'Pixelentity Theme/Plugin'), | |
"type" => "Text", | |
"description" => __("Enter the background color code (optional)",'Pixelentity Theme/Plugin'), | |
), | |
"padding_top" => array( | |
"label" => __("Top padding",'Pixelentity Theme/Plugin'), | |
"type" => "Text", | |
"description" => __("Enter the top padding (optional)",'Pixelentity Theme/Plugin'), | |
), | |
"padding_bottom" => array( | |
"label" => __("Bottom padding",'Pixelentity Theme/Plugin'), | |
"type" => "Text", | |
"description" => __("Enter the bottom padding (optional)",'Pixelentity Theme/Plugin'), | |
), | |
"subtitle" => array( | |
"label" => __("Subtitle",'Pixelentity Theme/Plugin'), | |
"type" => "Text", | |
"description" => __("Enter the subtitle text (optional)",'Pixelentity Theme/Plugin'), | |
), | |
); | |
// add block level cleaning | |
peTheme()->shortcode->blockLevel[] = $this->trigger; | |
} | |
public function output( $atts, $content = null, $code = "" ) { | |
extract( shortcode_atts( array( | |
'imageurl' => '', | |
'textcolor' => '', | |
'bgcolor' => '', | |
'subtitle' => '', | |
'padding_top' => '', | |
'padding_bottom' => '', | |
), $atts ) ); | |
$titleContent = ( $content ? $this->parseContent($content) : '' ); | |
$bgColorAttr = ( empty( $bgcolor ) ? "" : "background-color: $bgcolor;" ); | |
$hasPadding = FALSE; | |
$overlayStyle = ""; | |
if ( !empty( $padding_top ) ) { | |
$overlayStyle .= "padding-top: $padding_top; "; | |
$hasPadding = TRUE; | |
} | |
if ( !empty( $padding_bottom ) ) { | |
$overlayStyle .= "padding-bottom: $padding_bottom; "; | |
$hasPadding = TRUE; | |
} | |
$overlayStyle = ( !$hasPadding ? "" : <<<EOT | |
style="$overlayStyle" | |
EOT | |
); | |
$textStyle = ( empty( $textcolor ) ? "" : <<<EOT | |
style="color: $textcolor;" | |
EOT | |
); | |
$titleNode = ( empty( $titleContent ) ? "" : <<<EOT | |
<div class="title col-md-8 col-sm-10 col-xs-12"> | |
<h1 $textStyle>$titleContent</h1> | |
<hr> | |
</div> | |
EOT | |
); | |
$subtitleNode = ( empty( $subtitle ) ? "" : <<<EOT | |
<h4 class="center up" $textStyle>$subtitle</h4> | |
EOT | |
); | |
$output = <<<EOT | |
<p class="fullwidth-uncollapse-margins"></p> | |
<div class="section section-parallax parallax fullwidth" style="$bgColorAttr background-image: url('$imageurl');"> | |
<div class="parallax-overlay" $overlayStyle> | |
<div class="container"> | |
$titleNode | |
$subtitleNode | |
</div> | |
</div> | |
</div> | |
<div class="section section-parallax parallax placeholder"> | |
<div class="parallax-overlay" $overlayStyle> | |
<div class="container"> | |
$titleNode | |
$subtitleNode | |
</div> | |
</div> | |
</div> | |
EOT; | |
return trim( $output ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment