Cách lấy fontawesome svg lên website (ok)
https://github.com/FortAwesome/Font-Awesome
PreviousKhắc phục lỗi map do chưa bật javascript (Ok)NextHow to Add or Remove NVIDIA GPU Activity Notification Area Icon on Taskbar in Windows (ok)
Last updated
https://github.com/FortAwesome/Font-Awesome
Last updated
function lionel_pagi_get_svg( $args = array() ) {
if ( empty( $args ) ) {
return __( 'Please define default parameters in the form of an array.', 'lionel' );
}
if ( false === array_key_exists( 'icon', $args ) ) {
return __( 'Please define an SVG icon filename.', 'lionel' );
}
$defaults = array(
'icon' => '',
'title' => '',
'desc' => '',
'fallback' => false,
);
$args = wp_parse_args( $args, $defaults );
$aria_hidden = ' aria-hidden="true"';
$aria_labelledby = '';
if ( $args['title'] ) {
$aria_hidden = '';
$unique_id = lionel_unique_id();
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . '"';
if ( $args['desc'] ) {
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . ' desc-' . $unique_id . '"';
}
}
$svg = '<svg class="icon icon-' . esc_attr( $args['icon'] ) . '"' . $aria_hidden . $aria_labelledby . ' role="img">';
if ( $args['title'] ) {
$svg .= '<title id="title-' . $unique_id . '">' . esc_html( $args['title'] ) . '</title>';
// Display the desc only if the title is already set.
if ( $args['desc'] ) {
$svg .= '<desc id="desc-' . $unique_id . '">' . esc_html( $args['desc'] ) . '</desc>';
}
}
/*
* Display the icon.
*
* The whitespace around `<use>` is intentional - it is a work around to a keyboard navigation bug in Safari 10.
*
* See https://core.trac.wordpress.org/ticket/38387.
*/
$svg .= ' <use href="#icon-' . esc_html( $args['icon'] ) . '" xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use> ';
// Add some markup to use as a fallback for browsers that do not support SVGs.
if ( $args['fallback'] ) {
$svg .= '<span class="svg-fallback icon-' . esc_attr( $args['icon'] ) . '"></span>';
}
$svg .= '</svg>';
return $svg;
}
<?php
the_comments_pagination(
array(
'prev_text' => lionel_pagi_get_svg( array( 'icon' => 'chevron-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous', 'lionel' ) . '</span>',
'next_text' => '<span class="screen-reader-text">' . __( 'Next', 'lionel' ) . '</span>' . lionel_pagi_get_svg( array( 'icon' => 'chevron-right' ) ),
)
);