mirror of
https://github.com/10h30/trestle.git
synced 2026-06-05 15:09:35 +09:00
Add blockquote shortcode
This commit is contained in:
@@ -11,8 +11,17 @@
|
||||
* Shortcodes
|
||||
===========================================*/
|
||||
|
||||
// Fix for empty <p> tags around shortcodes
|
||||
function trestle_shortcode_empty_paragraph_fix($content)
|
||||
add_filter('the_content', 'trestle_shortcode_empty_paragraph_fix');
|
||||
/**
|
||||
* Fix for empty <p> tags around shortcodes
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param string $content HTML content.
|
||||
*
|
||||
* @return string Updated content.
|
||||
*/
|
||||
function trestle_shortcode_empty_paragraph_fix( $content )
|
||||
{
|
||||
$array = array (
|
||||
'<p>[' => '[',
|
||||
@@ -24,8 +33,8 @@ function trestle_shortcode_empty_paragraph_fix($content)
|
||||
|
||||
return $content;
|
||||
}
|
||||
add_filter('the_content', 'trestle_shortcode_empty_paragraph_fix');
|
||||
|
||||
add_shortcode( 'col', 'trestle_column' );
|
||||
/**
|
||||
* Columns
|
||||
*
|
||||
@@ -36,6 +45,10 @@ add_filter('the_content', 'trestle_shortcode_empty_paragraph_fix');
|
||||
* - width (one-half, one-third, etc - uses native Genesis column classes in style.css)
|
||||
* - first (used to specify the first column in a row)
|
||||
* - no-list-margin (will cause contained list elements to collapse as one on mobile sizes)
|
||||
*
|
||||
* @param array $atts Shortcode attributes.
|
||||
*
|
||||
* @return string Shortcode output.
|
||||
*/
|
||||
function trestle_column( $atts, $content = null ) {
|
||||
extract( shortcode_atts( array(
|
||||
@@ -43,13 +56,18 @@ function trestle_column( $atts, $content = null ) {
|
||||
), $atts ) );
|
||||
return '<div class="col ' . $class . '">' . do_shortcode( $content ) . '</div>';
|
||||
}
|
||||
add_shortcode( 'col', 'trestle_column' );
|
||||
|
||||
|
||||
|
||||
add_shortcode( 'button', 'trestle_button' );
|
||||
/**
|
||||
* Button
|
||||
*
|
||||
* Example:
|
||||
* [button href="url" title="title" target="target" class="class"]Text[/button]
|
||||
* Example: [button href="url" title="title" target="target" class="class"]Text[/button]
|
||||
*
|
||||
* @param array $atts Shortcode attributes.
|
||||
*
|
||||
* @return string Shortcode output.
|
||||
*/
|
||||
function trestle_button( $atts, $content = null ) {
|
||||
extract( shortcode_atts( array(
|
||||
@@ -60,13 +78,17 @@ function trestle_button( $atts, $content = null ) {
|
||||
), $atts ) );
|
||||
return '<a class="button ' . $class . '" href="' . $href . '" title="' . $title . '" target="' . $target . '">' . do_shortcode( $content ) . '</a>';
|
||||
}
|
||||
add_shortcode( 'button', 'trestle_button' );
|
||||
|
||||
|
||||
add_shortcode( 'date', 'trestle_date' );
|
||||
/**
|
||||
* Date
|
||||
*
|
||||
* Example: [date format="M d, Y"]
|
||||
*
|
||||
*
|
||||
* @param array $atts Shortcode attributes.
|
||||
*
|
||||
* @return string Shortcode output.
|
||||
*/
|
||||
function trestle_date( $atts ) {
|
||||
extract( shortcode_atts( array(
|
||||
@@ -79,4 +101,42 @@ function trestle_date( $atts ) {
|
||||
|
||||
return date( $format );
|
||||
}
|
||||
add_shortcode( 'date', 'trestle_date' );
|
||||
|
||||
add_shortcode( 'blockquote', 'igg_blockquote_shortcode' );
|
||||
/**
|
||||
* Blockquote
|
||||
*
|
||||
* Example: [blockquote citation=""]Content[/blockquote]
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @param array $atts Shortcode attributes.
|
||||
*
|
||||
* @return string Shortcode output.
|
||||
*/
|
||||
function igg_blockquote_shortcode( $atts, $content = null ) {
|
||||
|
||||
$atts = shortcode_atts( array(
|
||||
'citation' => '',
|
||||
), $atts );
|
||||
|
||||
ob_start(); ?>
|
||||
|
||||
<blockquote>
|
||||
|
||||
<?php if ( $content ) : ?>
|
||||
<?php echo $content; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $atts['citation'] ) : ?>
|
||||
<cite>- <?php echo $atts['citation']; ?></cite>
|
||||
<?php endif; ?>
|
||||
|
||||
</blockquote>
|
||||
|
||||
<?php
|
||||
|
||||
$output = ob_get_clean();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user