' . $link . '';
}
return $link;
}
add_filter('wp_link_pages_link', 'blogbend_link_pages');
function blogbend_excerpt_length($length)
{
return 30;
}
add_filter('excerpt_length', 'blogbend_excerpt_length', 999);
function blogbend_validate_gravatar($email)
{
if (!empty($email)) {
// Craft a potential url and test the response
$email_hash = md5(strtolower(trim($email)));
if (is_ssl()) {
$host = 'https://secure.gravatar.com';
} else {
$host = sprintf("http://%d.gravatar.com", (hexdec($email_hash[0]) % 2));
}
$uri = $host . '/avatar/' . $email_hash . '?d=404';
//make request and test response
if (404 === wp_remote_retrieve_response_code(wp_remote_get($uri))) {
$has_valid_avatar = false;
} else {
$has_valid_avatar = true;
}
return $has_valid_avatar;
}
return false;
}
/**
* Wrap more link
*/
function blogbend_read_more_link($link)
{
return '
' . $link . '
';
}
add_filter('the_content_more_link', 'blogbend_read_more_link');
/**
* Add "Styles" drop-down
*/
function blogbend_mce_editor_buttons($buttons)
{
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'blogbend_mce_editor_buttons');
/**
* Fix skip link focus in IE11.
*
* This does not enqueue the script because it is tiny and because it is only for IE11,
* thus it does not warrant having an entire dedicated blocking script being loaded.
*
* @link https://git.io/vWdr2
*/
function blogbend_skip_link_focus_fix()
{
// The following is minified via `terser --compress --mangle -- js/skip-link-focus-fix.js`.
?>
show_toggles) && $args->show_toggles) {
// Wrap the menu item link contents in a div, used for positioning.
$args->before = '';
$args->after = '';
// Add a toggle to items with children.
if (in_array('menu-item-has-children', $item->classes, true)) {
$toggle_target_string = '.menu-modal .menu-item-' . $item->ID . ' > .sub-menu';
$toggle_duration = blogbend_toggle_duration();
// Add the sub menu toggle.
$args->after .= '';
}
// Close the wrapper.
$args->after .= '
';
// Add sub menu icons to the primary menu without toggles.
} elseif ('primary' === $args->theme_location) {
if (in_array('menu-item-has-children', $item->classes, true)) {
$args->link_after = '' . blogbend_get_theme_svg('chevron-down') . '';
} else {
$args->link_after = '';
}
}
return $args;
}
add_filter('nav_menu_item_args', 'blogbend_add_sub_toggles_to_main_menu', 10, 2);
/**
* Displays SVG icons in social links menu.
*
* @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.
* @since BlogBend 1.0
*
*/
function blogbend_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 = BlogBend_SVG_Icons::get_social_link_svg($item->url);
if (empty($svg)) {
$svg = blogbend_get_theme_svg('link');
}
$item_output = str_replace($args->link_after, '' . $svg, $item_output);
}
return $item_output;
}
add_filter('walker_nav_menu_start_el', 'blogbend_nav_menu_social_icons', 10, 4);
if (!function_exists('blogbend_get_social_links_styles')) :
/**
* Returns social links styles options.
*
* @return array Options array.
* @since 1.0.0
*
*/
function blogbend_get_social_links_styles()
{
$options = apply_filters(
'blogbend_social_links_styles',
array(
'style_1' => __('Style 1', 'blogbend'),
'style_2' => __('Style 2', 'blogbend'),
'style_3' => __('Style 3', 'blogbend'),
'style_4' => __('Style 4', 'blogbend'),
)
);
return $options;
}
endif;
/**
* Toggles animation duration in milliseconds.
*
* @return int Duration in milliseconds
* @since BlogBend 1.0
*
*/
function blogbend_toggle_duration()
{
/**
* Filters the animation duration/speed used usually for submenu toggles.
*
* @param int $duration Duration in milliseconds.
* @since BlogBend 1.0
*
*/
$duration = apply_filters('blogbend_toggle_duration', 250);
return $duration;
}
if (!function_exists('blogbend_archive_post_count')) {
/**
* Post Count in Archive Pages
*/
function blogbend_archive_post_count()
{
global $wp_query;
$found_posts = $wp_query->found_posts;
if ($found_posts > 0) {
?>
null,
'length' => 25,
'read_more_text' => 'Read More',
'before_read_more' => ' ',
'echo' => true
];
// Merge user-provided arguments with defaults
$args = wp_parse_args($args, $defaults);
// Get the post object
$post = get_post($args['post']);
if (!$post) {
return ''; // If no post is provided, return an empty string
}
// Generate output
$output = '';
if (has_excerpt($post)) {
// Use the full post excerpt with a read more link
$output = $post->post_excerpt
. $args['before_read_more']
. ''
. esc_html($args['read_more_text'])
. blogbend_get_theme_svg('arrow-right')
. '';
} else {
// Trim and use the post content with a read more link
$output = wp_trim_words(
$post->post_content,
$args['length'],
''
)
. $args['before_read_more']
. ''
. esc_html($args['read_more_text'])
. blogbend_get_theme_svg('arrow-right')
. '';
}
if ($args['echo']) {
echo $output;
} else {
return $output;
}
}
endif;