Current File : /home/pacjaorg/www/grants -mzee/wp-content/themes/wihelp/inc/template-functions.php |
<?php
if (!function_exists('wihelp_display_comments')) {
/**
* WiHelp display comments
*
* @since 1.0.0
*/
function wihelp_display_comments() {
// If comments are open or we have at least one comment, load up the comment template.
if (comments_open() || 0 !== intval(get_comments_number())) :
comments_template();
endif;
}
}
if (!function_exists('wihelp_comment')) {
/**
* WiHelp comment template
*
* @param array $comment the comment array.
* @param array $args the comment args.
* @param int $depth the comment depth.
*
* @since 1.0.0
*/
function wihelp_comment($comment, $args, $depth) {
if ('div' === $args['style']) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo esc_attr($tag) . ' '; ?><?php comment_class(empty($args['has_children']) ? '' : 'parent'); ?> id="comment-<?php comment_ID(); ?>">
<div class="comment-body">
<div class="comment-author vcard">
<?php echo get_avatar($comment, 50); ?>
</div>
<?php if ('div' !== $args['style']) : ?>
<div id="div-comment-<?php comment_ID(); ?>" class="comment-content">
<?php endif; ?>
<div class="comment-head">
<div class="comment-meta commentmetadata">
<?php printf('<cite class="fn">%s</cite>', get_comment_author_link()); ?>
<?php if ('0' === $comment->comment_approved) : ?>
<em class="comment-awaiting-moderation"><?php esc_attr_e('Your comment is awaiting moderation.', 'wihelp'); ?></em>
<br/>
<?php endif; ?>
<a href="<?php echo esc_url(htmlspecialchars(get_comment_link($comment->comment_ID))); ?>"
class="comment-date">
<?php echo '<time datetime="' . get_comment_date('c') . '">' . get_comment_date() . '</time>'; ?>
</a>
</div>
<div class="reply">
<?php
comment_reply_link(
array_merge(
$args, array(
'add_below' => $add_below,
'depth' => $depth,
'max_depth' => $args['max_depth'],
)
)
);
?>
<?php edit_comment_link(esc_html__('Edit', 'wihelp'), ' ', ''); ?>
</div>
</div>
<div class="comment-text">
<?php comment_text(); ?>
</div>
<?php if ('div' !== $args['style']) : ?>
</div>
<?php endif; ?>
</div>
<?php
}
}
if (!function_exists('wihelp_credit')) {
/**
* Display the theme credit
*
* @return void
* @since 1.0.0
*/
function wihelp_credit() {
?>
<div class="site-info">
<?php echo apply_filters('wihelp_copyright_text', $content = '© ' . date('Y') . ' ' . '<a class="site-url" href="' . esc_url(site_url()) . '">' . esc_html(get_bloginfo('name')) . '</a>' . esc_html__('. All Rights Reserved.', 'wihelp')); ?>
</div><!-- .site-info -->
<?php
}
}
if (!function_exists('wihelp_social')) {
function wihelp_social() {
$social_list = wihelp_get_theme_option('social_text', []);
if (empty($social_list)) {
return;
}
?>
<div class="wihelp-social">
<ul>
<?php
foreach ($social_list as $social_item) {
?>
<li><a href="<?php echo esc_url($social_item); ?>"></a></li>
<?php
}
?>
</ul>
</div>
<?php
}
}
if (!function_exists('wihelp_site_branding')) {
/**
* Site branding wrapper and display
*
* @return void
* @since 1.0.0
*/
function wihelp_site_branding() {
?>
<div class="site-branding">
<?php echo wihelp_site_title_or_logo(); ?>
</div>
<?php
}
}
if (!function_exists('wihelp_site_title_or_logo')) {
/**
* Display the site title or logo
*
* @param bool $echo Echo the string or return it.
*
* @return string
* @since 2.1.0
*/
function wihelp_site_title_or_logo() {
ob_start();
the_custom_logo(); ?>
<div class="site-branding-text">
<?php if (is_front_page()) : ?>
<h1 class="site-title"><a href="<?php echo esc_url(home_url('/')); ?>"
rel="home"><?php bloginfo('name'); ?></a></h1>
<?php else : ?>
<p class="site-title"><a href="<?php echo esc_url(home_url('/')); ?>"
rel="home"><?php bloginfo('name'); ?></a></p>
<?php endif; ?>
<?php
$description = get_bloginfo('description', 'display');
if ($description || is_customize_preview()) :
?>
<p class="site-description"><?php echo esc_html($description); ?></p>
<?php endif; ?>
</div><!-- .site-branding-text -->
<?php
$html = ob_get_clean();
return $html;
}
}
if (!function_exists('wihelp_primary_navigation')) {
/**
* Display Primary Navigation
*
* @return void
* @since 1.0.0
*/
function wihelp_primary_navigation() {
?>
<nav class="main-navigation" role="navigation"
aria-label="<?php esc_html_e('Primary Navigation', 'wihelp'); ?>">
<?php
$args = apply_filters('wihelp_nav_menu_args', [
'fallback_cb' => '__return_empty_string',
'theme_location' => 'primary',
'container_class' => 'primary-navigation',
]);
wp_nav_menu($args);
?>
</nav>
<?php
}
}
if (!function_exists('wihelp_mobile_navigation')) {
/**
* Display Handheld Navigation
*
* @return void
* @since 1.0.0
*/
function wihelp_mobile_navigation() {
?>
<div class="mobile-nav-tabs">
<ul>
<?php if (isset(get_nav_menu_locations()['handheld'])) { ?>
<li class="mobile-tab-title mobile-pages-title">
<i class="wihelp-icon-bars"></i>
<span><?php echo esc_html(get_term(get_nav_menu_locations()['handheld'], 'nav_menu')->name); ?></span>
</li>
<?php } ?>
</ul>
</div>
<nav class="mobile-menu-tab mobile-navigation mobile-pages-menu"
aria-label="<?php esc_html_e('Mobile Navigation', 'wihelp'); ?>">
<?php
wp_nav_menu(
array(
'theme_location' => 'handheld',
'container_class' => 'handheld-navigation',
)
);
?>
</nav>
<?php
}
}
if (!function_exists('wihelp_homepage_header')) {
/**
* Display the page header without the featured image
*
* @since 1.0.0
*/
function wihelp_homepage_header() {
edit_post_link(esc_html__('Edit this section', 'wihelp'), '', '', '', 'button wihelp-hero__button-edit');
?>
<header class="entry-header">
<?php
the_title('<h1 class="entry-title">', '</h1>');
?>
</header><!-- .entry-header -->
<?php
}
}
if (!function_exists('wihelp_page_header')) {
/**
* Display the page header
*
* @since 1.0.0
*/
function wihelp_page_header() {
if (is_front_page() || !is_page_template('default')) {
return;
}
if (wihelp_is_elementor_activated() && function_exists('hfe_init')) {
if (WiHelp_breadcrumb::get_template_id() !== '') {
return;
}
}
?>
<header class="entry-header">
<?php
if (has_post_thumbnail()) {
wihelp_post_thumbnail('full');
}
the_title('<h1 class="entry-title">', '</h1>');
?>
</header><!-- .entry-header -->
<?php
}
}
if (!function_exists('wihelp_page_content')) {
/**
* Display the post content
*
* @since 1.0.0
*/
function wihelp_page_content() {
?>
<div class="entry-content">
<?php the_content(); ?>
<?php
wp_link_pages(
array(
'before' => '<div class="page-links">' . esc_html__('Pages:', 'wihelp'),
'after' => '</div>',
)
);
?>
</div><!-- .entry-content -->
<?php
}
}
if (!function_exists('wihelp_post_header')) {
/**
* Display the post header with a link to the single post
*
* @since 1.0.0
*/
function wihelp_post_header() {
?>
<header class="entry-header">
<?php
$categories_list = get_the_category_list(' ');
if (is_single()) {
if ($categories_list) {
// Make sure there's more than one category before displaying.
echo '<div class="categories-link-box">' . $categories_list . '</div>';
}
the_title('<h1 class="alpha entry-title">', '</h1>');
?>
<div class="entry-meta">
<?php wihelp_post_meta(['show_cat' => false]); ?>
</div>
<?php
} else { ?>
<?php the_title('<h5 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h5>'); ?>
<?php if ('post' == get_post_type()) { ?>
<div class="entry-meta">
<?php wihelp_post_meta(); ?>
</div>
<?php } ?>
<?php } ?>
</header><!-- .entry-header -->
<?php
}
}
if (!function_exists('wihelp_post_content')) {
/**
* Display the post content with a link to the single post
*
* @since 1.0.0
*/
function wihelp_post_content() {
?>
<div class="entry-content">
<?php
/**
* Functions hooked in to wihelp_post_content_before action.
*
*/
do_action('wihelp_post_content_before');
if (is_single()) {
the_content(
sprintf(
/* translators: %s: post title */
esc_html__('Read More', 'wihelp') . ' %s',
'<span class="screen-reader-text">' . get_the_title() . '</span>'
)
);
} else {
the_excerpt();
echo '<div class="more-link-wrap"><a class="more-link" href="' . get_permalink() . '">' . esc_html__('Read more', 'wihelp') . '</a></div>';
}
/**
* Functions hooked in to wihelp_post_content_after action.
*
*/
do_action('wihelp_post_content_after');
wp_link_pages(
array(
'before' => '<div class="page-links">' . esc_html__('Pages:', 'wihelp'),
'after' => '</div>',
)
);
?>
</div><!-- .entry-content -->
<?php
}
}
if (!function_exists('wihelp_post_meta')) {
/**
* Display the post meta
*
* @since 1.0.0
*/
function wihelp_post_meta($atts = array()) {
global $post;
if ('post' !== get_post_type()) {
return;
}
extract(
shortcode_atts(
array(
'show_date' => true,
'show_cat' => true,
'show_author' => true,
'show_comment' => false,
),
$atts
)
);
$posted_on = '';
// Posted on.
if ($show_date) {
$posted_on = '<div class="posted-on">' . sprintf('<a href="%1$s" rel="bookmark">%2$s</a>', esc_url(get_permalink()), get_the_modified_date()) . '</div>';
}
$categories_list = get_the_category_list(', ');
$categories = '';
if ($show_cat && $categories_list) {
// Make sure there's more than one category before displaying.
$categories = '<div class="categories-link"><i class="wihelp-icon-folder-bold"></i><span class="screen-reader-text">' . esc_html__('Categories', 'wihelp') . '</span>' . $categories_list . '</div>';
}
$author = '';
// Author.
if ($show_author == 1) {
$author_id = $post->post_author;
$author = sprintf(
'<div class="post-author"><span>%1$s</span><a href="%2$s" class="url fn" rel="author">%3$s</a></div>',
esc_html__('By ', 'wihelp'),
esc_url(get_author_posts_url(get_the_author_meta('ID'))),
esc_html(get_the_author_meta('display_name', $author_id))
);
}
echo wp_kses(
sprintf('%1$s %2$s %3$s', $categories, $posted_on, $author), array(
'div' => array(
'class' => array(),
),
'span' => array(
'class' => array(),
),
'i' => array(
'class' => array(),
),
'a' => array(
'href' => array(),
'rel' => array(),
'class' => array(),
),
'time' => array(
'datetime' => array(),
'class' => array(),
)
)
);
if ($show_comment) { ?>
<div class="meta-reply">
<?php
comments_popup_link(esc_html__('0 comments', 'wihelp'), esc_html__('1 comment', 'wihelp'), esc_html__('% comments', 'wihelp'));
?>
</div>
<?php
}
}
}
if (!function_exists('wihelp_get_allowed_html')) {
function wihelp_get_allowed_html() {
return apply_filters(
'wihelp_allowed_html',
array(
'br' => array(),
'i' => array(),
'b' => array(),
'u' => array(),
'em' => array(),
'del' => array(),
'a' => array(
'href' => true,
'class' => true,
'title' => true,
'rel' => true,
),
'strong' => array(),
'span' => array(
'style' => true,
'class' => true,
),
)
);
}
}
if (!function_exists('wihelp_edit_post_link')) {
/**
* Display the edit link
*
* @since 2.5.0
*/
function wihelp_edit_post_link() {
edit_post_link(
sprintf(
wp_kses(__('Edit <span class="screen-reader-text">%s</span>', 'wihelp'),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
),
'<div class="edit-link">',
'</div>'
);
}
}
if (!function_exists('wihelp_categories_link')) {
/**
* Prints HTML with meta information for the current cateogries
*/
function wihelp_categories_link() {
// Get Categories for posts.
$categories_list = get_the_category_list('');
if ('post' === get_post_type() && $categories_list) {
// Make sure there's more than one category before displaying.
echo '<div class="categories-link"><span class="screen-reader-text">' . esc_html__('Categories', 'wihelp') . '</span>' . $categories_list . '</div>';
}
}
}
if (!function_exists('wihelp_post_taxonomy')) {
/**
* Display the post taxonomies
*
* @since 2.4.0
*/
function wihelp_post_taxonomy() {
/* translators: used between list items, there is a space after the comma */
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list('', ' ');
?>
<aside class="entry-taxonomy">
<?php if ($tags_list) : ?>
<div class="tags-links">
<span class="screen-reader-text"><?php echo esc_html(_n('Tag:', 'Tags:', count(get_the_tags()), 'wihelp')); ?></span>
<?php printf('%s', $tags_list); ?>
</div>
<?php endif;
?>
</aside>
<?php
}
}
if (!function_exists('wihelp_paging_nav')) {
/**
* Display navigation to next/previous set of posts when applicable.
*/
function wihelp_paging_nav() {
global $wp_query;
$args = array(
'type' => 'list',
'next_text' => '<span class="screen-reader-text">' . esc_html__('Next', 'wihelp') . '</span><i class="wihelp-icon wihelp-icon-drop-right"></i>',
'prev_text' => '<i class="wihelp-icon wihelp-icon-drop-left"></i><span class="screen-reader-text">' . esc_html__('Previous', 'wihelp') . '</span>',
);
the_posts_pagination($args);
}
}
if (!function_exists('wihelp_post_nav')) {
/**
* Display navigation to next/previous post when applicable.
*/
function wihelp_post_nav() {
$prev_post = get_previous_post();
$next_post = get_next_post();
$args = [];
if ($next_post) {
$args['next_text'] = '<span class="nav-content"><span class="reader-text">' . esc_html__('next', 'wihelp') . '</span><span class="title">%title</span></span>';
}
if ($prev_post) {
$args['prev_text'] = '<span class="nav-content"><span class="reader-text">' . esc_html__('prev', 'wihelp') . ' </span><span class="title">%title</span></span> ';
}
the_post_navigation($args);
}
}
if (!function_exists('wihelp_posted_on')) {
/**
* Prints HTML with meta information for the current post-date/time and author.
*
* @deprecated 2.4.0
*/
function wihelp_posted_on() {
_deprecated_function('wihelp_posted_on', '2.4.0');
}
}
if (!function_exists('wihelp_homepage_content')) {
/**
* Display homepage content
* Hooked into the `homepage` action in the homepage template
*
* @return void
* @since 1.0.0
*/
function wihelp_homepage_content() {
while (have_posts()) {
the_post();
get_template_part('content', 'homepage');
} // end of the loop.
}
}
if (!function_exists('wihelp_get_sidebar')) {
/**
* Display wihelp sidebar
*
* @uses get_sidebar()
* @since 1.0.0
*/
function wihelp_get_sidebar() {
get_sidebar();
}
}
if (!function_exists('wihelp_post_thumbnail')) {
/**
* Display post thumbnail
*
* @param string $size the post thumbnail size.
*
* @uses has_post_thumbnail()
* @uses the_post_thumbnail
* @var $size . thumbnail|medium|large|full|$custom
* @since 1.5.0
*/
function wihelp_post_thumbnail($size = 'post-thumbnail') {
if (has_post_thumbnail()) {
echo '<div class="post-thumbnail">';
the_post_thumbnail($size ? $size : 'post-thumbnail');
echo '</div>';
}
}
}
if (!function_exists('wihelp_primary_navigation_wrapper')) {
/**
* The primary navigation wrapper
*/
function wihelp_primary_navigation_wrapper() {
echo '<div class="wihelp-primary-navigation"><div class="col-full">';
}
}
if (!function_exists('wihelp_primary_navigation_wrapper_close')) {
/**
* The primary navigation wrapper close
*/
function wihelp_primary_navigation_wrapper_close() {
echo '</div></div>';
}
}
if (!function_exists('wihelp_header_container')) {
/**
* The header container
*/
function wihelp_header_container() {
echo '<div class="col-full">';
}
}
if (!function_exists('wihelp_header_container_close')) {
/**
* The header container close
*/
function wihelp_header_container_close() {
echo '</div>';
}
}
if (!function_exists('wihelp_header_custom_link')) {
function wihelp_header_custom_link() {
echo wihelp_get_theme_option('custom-link', '');
}
}
if (!function_exists('wihelp_header_contact_info')) {
function wihelp_header_contact_info() {
echo wihelp_get_theme_option('contact-info', '');
}
}
if (!function_exists('wihelp_header_account')) {
function wihelp_header_account() {
if (!wihelp_get_theme_option('show_header_account', true)) {
return;
}
if (wihelp_is_woocommerce_activated()) {
$account_link = get_permalink(get_option('woocommerce_myaccount_page_id'));
} else {
$account_link = wp_login_url();
}
?>
<div class="site-header-account">
<a href="<?php echo esc_url($account_link); ?>">
<i class="wihelp-icon-account"></i>
</a>
<div class="account-dropdown">
</div>
</div>
<?php
}
}
if (!function_exists('wihelp_template_account_dropdown')) {
function wihelp_template_account_dropdown() {
if (!wihelp_get_theme_option('show_header_account', true)) {
return;
}
?>
<div class="account-wrap d-none">
<div class="account-inner <?php if (is_user_logged_in()): echo "dashboard"; endif; ?>">
<?php if (!is_user_logged_in()) {
wihelp_form_login();
} else {
wihelp_account_dropdown();
}
?>
</div>
</div>
<?php
}
}
if (!function_exists('wihelp_form_login')) {
function wihelp_form_login() {
if (wihelp_is_woocommerce_activated() && 'yes' === get_option('woocommerce_enable_myaccount_registration')) {
$register_link = get_permalink(get_option('woocommerce_myaccount_page_id'));
} else {
$register_link = wp_registration_url();
}
?>
<div class="login-form-head">
<span class="login-form-title"><?php esc_attr_e('Sign in', 'wihelp') ?></span>
<span class="pull-right">
<a class="register-link" href="<?php echo esc_url($register_link); ?>"
title="<?php esc_attr_e('Register', 'wihelp'); ?>"><?php esc_attr_e('Create an Account', 'wihelp'); ?></a>
</span>
</div>
<form class="wihelp-login-form-ajax" data-toggle="validator">
<p>
<label><?php esc_attr_e('Username or email', 'wihelp'); ?> <span class="required">*</span></label>
<input name="username" type="text" required placeholder="<?php esc_attr_e('Username', 'wihelp') ?>">
</p>
<p>
<label><?php esc_attr_e('Password', 'wihelp'); ?> <span class="required">*</span></label>
<input name="password" type="password" required
placeholder="<?php esc_attr_e('Password', 'wihelp') ?>">
</p>
<button type="submit" data-button-action
class="btn btn-primary btn-block w-100 mt-1"><?php esc_html_e('Login', 'wihelp') ?></button>
<input type="hidden" name="action" value="wihelp_login">
<?php wp_nonce_field('ajax-wihelp-login-nonce', 'security-login'); ?>
</form>
<div class="login-form-bottom">
<a href="<?php echo wp_lostpassword_url(get_permalink()); ?>" class="lostpass-link"
title="<?php esc_attr_e('Lost your password?', 'wihelp'); ?>"><?php esc_attr_e('Lost your password?', 'wihelp'); ?></a>
</div>
<?php
}
}
if (!function_exists('')) {
function wihelp_account_dropdown() { ?>
<?php if (has_nav_menu('my-account')) : ?>
<nav class="social-navigation" role="navigation" aria-label="<?php esc_attr_e('Dashboard', 'wihelp'); ?>">
<?php
wp_nav_menu(array(
'theme_location' => 'my-account',
'menu_class' => 'account-links-menu',
'depth' => 1,
));
?>
</nav><!-- .social-navigation -->
<?php else: ?>
<ul class="account-dashboard">
<?php if (wihelp_is_woocommerce_activated()): ?>
<li>
<a href="<?php echo esc_url(wc_get_page_permalink('myaccount')); ?>"
title="<?php esc_html_e('Dashboard', 'wihelp'); ?>"><?php esc_html_e('Dashboard', 'wihelp'); ?></a>
</li>
<li>
<a href="<?php echo esc_url(wc_get_account_endpoint_url('orders')); ?>"
title="<?php esc_html_e('Orders', 'wihelp'); ?>"><?php esc_html_e('Orders', 'wihelp'); ?></a>
</li>
<li>
<a href="<?php echo esc_url(wc_get_account_endpoint_url('downloads')); ?>"
title="<?php esc_html_e('Downloads', 'wihelp'); ?>"><?php esc_html_e('Downloads', 'wihelp'); ?></a>
</li>
<li>
<a href="<?php echo esc_url(wc_get_account_endpoint_url('edit-address')); ?>"
title="<?php esc_html_e('Edit Address', 'wihelp'); ?>"><?php esc_html_e('Edit Address', 'wihelp'); ?></a>
</li>
<li>
<a href="<?php echo esc_url(wc_get_account_endpoint_url('edit-account')); ?>"
title="<?php esc_html_e('Account Details', 'wihelp'); ?>"><?php esc_html_e('Account Details', 'wihelp'); ?></a>
</li>
<?php else: ?>
<li>
<a href="<?php echo esc_url(get_dashboard_url(get_current_user_id())); ?>"
title="<?php esc_html_e('Dashboard', 'wihelp'); ?>"><?php esc_html_e('Dashboard', 'wihelp'); ?></a>
</li>
<?php endif; ?>
<li>
<a title="<?php esc_html_e('Log out', 'wihelp'); ?>" class="tips"
href="<?php echo esc_url(wp_logout_url(home_url())); ?>"><?php esc_html_e('Log Out', 'wihelp'); ?></a>
</li>
</ul>
<?php endif;
}
}
if (!function_exists('wihelp_header_search_popup')) {
function wihelp_header_search_popup() {
?>
<div class="site-search-popup">
<div class="site-search-popup-wrap">
<a href="#" class="site-search-popup-close"><i class="wihelp-icon-times-circle"></i></a>
<div class="site-search">
<?php get_search_form(); ?>
</div>
</div>
</div>
<div class="site-search-popup-overlay"></div>
<?php
}
}
if (!function_exists('wihelp_header_search_button')) {
function wihelp_header_search_button() {
add_action('wp_footer', 'wihelp_header_search_popup', 1);
?>
<div class="site-header-search">
<a href="#" class="button-search-popup"><i class="wihelp-icon-search"></i></a>
</div>
<?php
}
}
if (!function_exists('wihelp_header_sticky')) {
function wihelp_header_sticky() {
get_template_part('template-parts/header', 'sticky');
}
}
if (!function_exists('wihelp_mobile_nav')) {
function wihelp_mobile_nav() {
if (isset(get_nav_menu_locations()['handheld'])) {
?>
<div class="wihelp-mobile-nav">
<?php if (wihelp_is_elementor_activated()) { ?>
<div class="site-search">
<?php get_search_form(); ?>
</div>
<?php } ?>
<div class="menu-scroll-mobile">
<a href="#" class="mobile-nav-close"><i class="wihelp-icon-times"></i></a>
<?php wihelp_mobile_navigation(); ?>
</div>
</div>
<div class="wihelp-overlay"></div>
<?php
}
}
}
if (!function_exists('wihelp_mobile_nav_button')) {
function wihelp_mobile_nav_button() {
if (isset(get_nav_menu_locations()['handheld'])) {
?>
<a href="#" class="menu-mobile-nav-button">
<span
class="toggle-text screen-reader-text"><?php echo esc_attr(apply_filters('wihelp_menu_toggle_text', esc_html__('Menu', 'wihelp'))); ?></span>
<div class="wihelp-icon">
<span class="icon-1"></span>
<span class="icon-2"></span>
<span class="icon-3"></span>
</div>
</a>
<?php
}
}
}
if (!function_exists('wihelp_footer_default')) {
function wihelp_footer_default() {
get_template_part('template-parts/copyright');
}
}
if (!function_exists('wihelp_social_share')) {
function wihelp_social_share() {
get_template_part('template-parts/socials');
}
}
if (!function_exists('wihelp_pingback_header')) {
/**
* Add a pingback url auto-discovery header for single posts, pages, or attachments.
*/
function wihelp_pingback_header() {
if (is_singular() && pings_open()) {
echo '<link rel="pingback" href="', esc_url(get_bloginfo('pingback_url')), '">';
}
}
}
if (!function_exists('wihelp_update_comment_fields')) {
function wihelp_update_comment_fields($fields) {
$commenter = wp_get_current_commenter();
$req = get_option('require_name_email');
$aria_req = $req ? "aria-required='true'" : '';
$fields['author']
= '<p class="comment-form-author">
<input id="author" name="author" type="text" placeholder="' . esc_attr__('Your Name *', 'wihelp') . '" value="' . esc_attr($commenter['comment_author']) .
'" size="30" ' . $aria_req . ' />
</p>';
$fields['email']
= '<p class="comment-form-email">
<input id="email" name="email" type="email" placeholder="' . esc_attr__('Email Address *', 'wihelp') . '" value="' . esc_attr($commenter['comment_author_email']) .
'" size="30" ' . $aria_req . ' />
</p>';
$fields['url']
= '<p class="comment-form-url">
<input id="url" name="url" type="url" placeholder="' . esc_attr__('Your Website', 'wihelp') . '" value="' . esc_attr($commenter['comment_author_url']) .
'" size="30" />
</p>';
return $fields;
}
}
add_filter('comment_form_default_fields', 'wihelp_update_comment_fields');
if (!function_exists('wihelp_update_comment_review_fields')) {
function wihelp_update_comment_review_fields($comment_form) {
$commenter = wp_get_current_commenter();
$name_email_required = (bool)get_option('require_name_email', 1);
$fields = array(
'author' => array(
'label' => esc_html__('Name', 'wihelp'),
'type' => 'text',
'value' => $commenter['comment_author'],
'required' => $name_email_required,
),
'email' => array(
'label' => esc_html__('Email', 'wihelp'),
'type' => 'email',
'value' => $commenter['comment_author_email'],
'required' => $name_email_required,
),
);
$comment_form['fields'] = array();
foreach ($fields as $key => $field) {
$field_html = '<p class="comment-form-' . esc_attr($key) . '">';
$field_html .= '<input id="' . esc_attr($key) . '" name="' . esc_attr($key) . '" type="' . esc_attr($field['type']) . '" value="' . esc_attr($field['value']) . '" size="30" ' . ($field['required'] ? 'required' : '') . ' placeholder="' . esc_html($field['label']) . ' *"' . ' />';
$field_html .= '</p>';
$comment_form['fields'][$key] = $field_html;
}
if (wc_review_ratings_enabled()) {
$comment_form['comment_field'] = '<div class="comment-form-rating"><label for="rating">' . esc_html__('Your rating', 'wihelp') . (wc_review_ratings_required() ? ' <span class="required">*</span>' : '') . '</label><select name="rating" id="rating" required>
<option value="">' . esc_html__('Rate…', 'wihelp') . '</option>
<option value="5">' . esc_html__('Perfect', 'wihelp') . '</option>
<option value="4">' . esc_html__('Good', 'wihelp') . '</option>
<option value="3">' . esc_html__('Average', 'wihelp') . '</option>
<option value="2">' . esc_html__('Not that bad', 'wihelp') . '</option>
<option value="1">' . esc_html__('Very poor', 'wihelp') . '</option>
</select></div>';
}
$comment_form['comment_field'] .= '<p class="comment-form-comment"><textarea id="comment" name="comment" cols="45" rows="8" required placeholder="' . esc_html__('Your review *', 'wihelp') . '"></textarea></p>';
return $comment_form;
}
}
add_filter('woocommerce_product_review_comment_form_args', 'wihelp_update_comment_review_fields');
function wihelp_replace_categories_list($output, $args) {
if ($args['show_count'] = 1) {
$pattern = '#<li([^>]*)><a([^>]*)>(.*?)<\/a>\s*\(([0-9]*)\)\s*#i'; // removed ( and )
$replacement = '<li$1><a$2><span class="cat-name">$3</span> <span class="cat-count">($4)</span></a>';
return preg_replace($pattern, $replacement, $output);
}
return $output;
}
add_filter('wp_list_categories', 'wihelp_replace_categories_list', 10, 2);
function wihelp_replace_archive_list($link_html, $url, $text, $format, $before, $after, $selected) {
if ($format == 'html') {
$pattern = '#<li><a([^>]*)>(.*?)<\/a> \s*\(([0-9]*)\)\s*#i'; // removed ( and )
$replacement = '<li><a$1><span class="archive-name">$2</span> <span class="archive-count">($3)</span></a>';
return preg_replace($pattern, $replacement, $link_html);
}
return $link_html;
}
add_filter('get_archives_link', 'wihelp_replace_archive_list', 10, 7);
add_filter('bcn_breadcrumb_title', 'wihelp_breadcrumb_title_swapper', 3, 10);
function wihelp_breadcrumb_title_swapper($title, $type, $id) {
if (in_array('home', $type)) {
$title = esc_html__('Home', 'wihelp');
}
return $title;
}
function render_html_back_to_top() {
if (wihelp_get_theme_option('back_to_top', true) == true) {
echo <<<HTML
<a href="#" class="scrollup"><i class="wihelp-icon-angle-up"></i></a>
HTML;
}
}