-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom shortcodes: aldine_page_section, aldine_call_to_action.
- Loading branch information
Ned Zimmerman
committed
Feb 4, 2018
1 parent
0351c3e
commit 2bb6dc0
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* Aldine Shortcodes | ||
* | ||
* @package Aldine | ||
*/ | ||
|
||
namespace Aldine\Shortcodes; | ||
|
||
/** | ||
* Shortcode for Page Section. | ||
* | ||
* @param array $atts | ||
* @param string $content | ||
* | ||
* @return string | ||
*/ | ||
function page_section( $atts, $content = null ) { | ||
$atts = shortcode_atts( | ||
[ | ||
'title' => 'Page Section', | ||
'variant' => '', | ||
], | ||
$atts, | ||
'aldine_page_section' | ||
); | ||
|
||
return sprintf( | ||
'<div class="page-section%1$s"><h2>%2$s</h2>%3$s</div>', | ||
( $atts['variant'] ) ? " page-section--{$atts['variant']}" : '', | ||
$atts['title'], | ||
$content | ||
); | ||
} | ||
|
||
/** | ||
* Shortcode for custom Call to Action. | ||
* | ||
* @param array $atts | ||
* | ||
* @return string | ||
*/ | ||
function call_to_action( $atts ) { | ||
$atts = shortcode_atts( | ||
[ | ||
'link' => '#', | ||
'text' => 'Call To Action', | ||
], | ||
$atts, | ||
'aldine_call_to_action' | ||
); | ||
|
||
return sprintf( | ||
'<a class="call-to-action" href="%1$s" title="%2$s">%2$s</a>', | ||
$atts['link'], | ||
$atts['text'] | ||
); | ||
} |