Files
Thuan Bui fd25f13a4f Initial
2018-06-26 11:09:22 +07:00

53 lines
1.7 KiB
PHP

<?php
/**
* Child Theme Library
*
* WARNING: This file is a part of the core Child Theme Library.
* DO NOT edit this file under any circumstances. Please use
* the functions.php file to make any theme modifications.
*
* @package SEOThemes\ChildThemeLibrary\Shortcodes
* @link https://github.com/seothemes/child-theme-library
* @author Thuan Bui
* @copyright Copyright © 2018 Thuan Bui
* @license GPL-2.0+
*/
add_shortcode( 'footer_backtotop', 'child_theme_footer_backtotop' );
/**
* Produces the "Return to Top" link.
*
* Supported shortcode attributes are:
*
* - after (output after link, default is empty string),
* - before (output before link, default is empty string),
* - href (link url, default is fragment identifier '#wrap'),
* - nofollow (boolean for whether to include rel="nofollow", default is true),
* - text (Link text, default is 'Return to top of page').
*
* Output passes through `child_theme_footer_backtotop` filter before returning.
*
* @since 1.0.0
*
* @param array|string $atts Shortcode attributes. Empty string if no attributes.
*
* @return string Output for `footer_backtotop` shortcode.
*/
function child_theme_footer_backtotop( $atts ) {
$defaults = array(
'after' => '',
'before' => '',
'href' => '#top',
'nofollow' => true,
'text' => __( 'Return to top', 'genesis' ),
);
$atts = shortcode_atts( $defaults, $atts, 'footer_backtotop' );
$nofollow = $atts['nofollow'] ? 'rel="nofollow"' : '';
$output = sprintf( '%s<a href="%s" %s>%s</a>%s', $atts['before'], esc_url( $atts['href'] ), $nofollow, $atts['text'], $atts['after'] );
return apply_filters( 'child_theme_footer_backtotop', $output, $atts );
}