Merge pull request #765 from IanDelMar/site-info-hook

Added site info hook - Good idea! Thx @IanDelMar !
This commit is contained in:
Holger 2018-08-07 20:09:36 +02:00 committed by GitHub
commit 56bc68c30b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 13 deletions

View File

@ -7,7 +7,6 @@
* @package understrap
*/
$the_theme = wp_get_theme();
$container = get_theme_mod( 'understrap_container_type' );
?>
@ -25,18 +24,8 @@ $container = get_theme_mod( 'understrap_container_type' );
<div class="site-info">
<a href="<?php echo esc_url( __( 'http://wordpress.org/','understrap' ) ); ?>"><?php printf(
/* translators:*/
esc_html__( 'Proudly powered by %s', 'understrap' ),'WordPress' ); ?></a>
<span class="sep"> | </span>
<?php understrap_site_info(); ?>
<?php printf( // WPCS: XSS ok.
/* translators:*/
esc_html__( 'Theme: %1$s by %2$s.', 'understrap' ), $the_theme->get( 'Name' ), '<a href="'.esc_url( __('http://understrap.com', 'understrap')).'">understrap.com</a>' ); ?>
(<?php printf( // WPCS: XSS ok.
/* translators:*/
esc_html__( 'Version: %1$s', 'understrap' ), $the_theme->get( 'Version' ) ); ?>)
</div><!-- .site-info -->
</footer><!-- #colophon -->

45
inc/hooks.php Normal file
View File

@ -0,0 +1,45 @@
<?php
/**
* Custom hooks.
*
* @package understrap
*/
if ( ! function_exists( 'understrap_add_site_info' ) ) {
/**
* Add site info hook to WP hook library.
*/
function understrap_site_info() {
do_action( 'understrap_site_info' );
}
}
if ( ! function_exists( 'understrap_add_site_info' ) ) {
add_action( 'understrap_site_info', 'understrap_add_site_info' );
/**
* Add site info content.
*/
function understrap_add_site_info() {
$the_theme = wp_get_theme();
$site_info = sprintf(
'<a href="%1$s">%2$s</a><span class="sep"> | </span>%3$s(%4$s)',
esc_url( __( 'http://wordpress.org/', 'understrap' ) ),
sprintf(
/* translators:*/
esc_html__( 'Proudly powered by %s', 'understrap' ), 'WordPress'
),
sprintf( // WPCS: XSS ok.
/* translators:*/
esc_html__( 'Theme: %1$s by %2$s.', 'understrap' ), $the_theme->get( 'Name' ), '<a href="' . esc_url( __( 'http://understrap.com', 'understrap' ) ) . '">understrap.com</a>'
),
sprintf( // WPCS: XSS ok.
/* translators:*/
esc_html__( 'Version: %1$s', 'understrap' ), $the_theme->get( 'Version' )
)
);
echo apply_filters( understrap_site_info_content, $site_info ); // WPCS: XSS ok.
}
}