', esc_url( get_bloginfo( 'pingback_url' ) ) );
}
}
add_action( 'wp_head', 'blog_up_pingback_header' );
/**
* Add a dropdown icon to header menu.
*
* @since 1.0.0
*
* @param string $title The menu item's title.
* @param WP_Post $item The current menu item object.
* @param stdClass $args An object of wp_nav_menu() arguments.
* @param int $depth Depth of menu item. Used for padding.
* @return string Modified menu item's title.
*/
function blog_up_add_dropdown_icons( $title, $item, $args, $depth ) {
$icon = '';
if ( 'menu-1' === $args->theme_location && ( 0 === $depth || 1 === $depth ) ) {
foreach ( $item->classes as $value ) {
if ( 'menu-item-has-children' === $value || 'page_item_has_children' === $value ) {
$title = $title . '';
}
}
}
return $title;
}
add_filter( 'nav_menu_item_title', 'blog_up_add_dropdown_icons', 10, 4 );
/**
* Implement excerpt length.
*
* @since 1.0.0
*
* @param int $length The number of words.
* @return int Excerpt length.
*/
function blog_up_implement_excerpt_length( $length ) {
$excerpt_length = blog_up_get_option( 'excerpt_length' );
if ( absint( $excerpt_length ) > 0 ) {
$length = absint( $excerpt_length );
}
return $length;
}
/**
* Implement read more in content.
*
* @since 1.0.0
*
* @param string $more_link Read More link element.
* @param string $more_link_text Read More text.
* @return string Link.
*/
function blog_up_content_more_link( $more_link, $more_link_text ) {
$read_more_text = blog_up_get_option( 'readmore_text' );
if ( ! empty( $read_more_text ) ) {
$more_link = str_replace( $more_link_text, esc_html( $read_more_text ), $more_link );
}
return $more_link;
}
/**
* Implement read more in excerpt.
*
* @since 1.0.0
*
* @param string $more The string shown within the more link.
* @return string The excerpt.
*/
function blog_up_implement_read_more( $more ) {
$output = $more;
$read_more_text = blog_up_get_option( 'readmore_text' );
if ( ! empty( $read_more_text ) ) {
$output = '…' . esc_html( $read_more_text ) . '';
} else {
$output = '';
}
return $output;
}
/**
* Hook read more and excerpt length filters.
*
* @since 1.0.0
*/
function blog_up_hook_read_more_filters() {
add_filter( 'excerpt_length', 'blog_up_implement_excerpt_length', 999 );
add_filter( 'the_content_more_link', 'blog_up_content_more_link', 10, 2 );
add_filter( 'excerpt_more', 'blog_up_implement_read_more' );
}
add_action( 'wp', 'blog_up_hook_read_more_filters' );
/**
* Add admin notice.
*
* @since 1.0.0
*/
function blog_up_add_admin_notice() {
\Nilambar\AdminNotice\Notice::init(
array(
'slug' => BLOG_UP_SLUG,
'type' => 'theme',
'name' => esc_html__( 'Blog Up', 'blog-up' ),
)
);
}
add_action( 'admin_init', 'blog_up_add_admin_notice' );
/**
* Displays SVG icons in social links menu.
*
* @since 1.0.0
*
* @param string $item_output The menu item's starting HTML output.
* @param WP_Post $item Menu item data object.
* @param int $depth Depth of the menu. Used for padding.
* @param stdClass $args An object of wp_nav_menu() arguments.
* @return string The menu item output with social icon.
*/
function blog_up_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
// Change SVG icon inside social links menu if there is supported URL.
if ( 'social' === $args->theme_location ) {
$svg = Blog_Up_SVG_Icons::get_social_link_svg( $item->url );
if ( empty( $svg ) ) {
$svg = blog_up_get_theme_svg( 'link' );
}
$item_output = str_replace( $args->link_after, '' . $svg, $item_output );
}
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'blog_up_nav_menu_social_icons', 10, 4 );