', esc_url(get_bloginfo('pingback_url')));
}
}
add_action('wp_head', 'navier_pingback_header');
/**
* Add custom body classes
*
* @param array $classes Body classes
* @return array Modified body classes
*/
function navier_body_class_filter($classes) {
// Add page slug as class
if (is_single() || is_page()) {
global $post;
if (isset($post)) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
}
// Add class if no sidebar
if (!is_active_sidebar('sidebar-1')) {
$classes[] = 'no-sidebar';
}
// Add class for sticky header
$classes[] = 'has-sticky-header';
return $classes;
}
add_filter('body_class', 'navier_body_class_filter');
/**
* Modify archive title
*
* @param string $title Archive title
* @return string Modified archive title
*/
function navier_archive_title($title) {
if (is_category()) {
$title = single_cat_title('', false);
} elseif (is_tag()) {
$title = single_tag_title('', false);
} elseif (is_author()) {
$title = '' . get_the_author() . '';
} elseif (is_post_type_archive()) {
$title = post_type_archive_title('', false);
} elseif (is_tax()) {
$title = single_term_title('', false);
}
return $title;
}
add_filter('get_the_archive_title', 'navier_archive_title');
/**
* Modify the "read more" link text
*
* @return string Modified read more link
*/
function navier_read_more_link() {
return '' . esc_html__('Read More', 'navier-instruments') . ' ';
}
add_filter('the_content_more_link', 'navier_read_more_link');
/**
* Custom comment template
*
* @param object $comment Comment object
* @param array $args Arguments
* @param int $depth Depth
*/
function navier_comment_callback($comment, $args, $depth) {
$tag = ('div' === $args['style']) ? 'div' : 'li';
?>
< id="comment-" >
'div-comment',
'depth' => $depth,
'max_depth' => $args['max_depth'],
'before' => '',
'after' => '
',
)));
?>
';
return $form;
}
add_filter('get_search_form', 'navier_search_form');
/**
* Add custom image sizes to media library
*
* @param array $sizes Image sizes
* @return array Modified image sizes
*/
function navier_custom_image_sizes($sizes) {
return array_merge($sizes, array(
'navier-hero' => __('Hero Image', 'navier-instruments'),
'navier-card' => __('Card Image', 'navier-instruments'),
'navier-thumbnail' => __('Custom Thumbnail', 'navier-instruments'),
'navier-product' => __('Product Image', 'navier-instruments'),
));
}
add_filter('image_size_names_choose', 'navier_custom_image_sizes');
/**
* Modify post class
*
* @param array $classes Post classes
* @return array Modified post classes
*/
function navier_post_class_filter($classes) {
// Add animation class
$classes[] = 'animate';
$classes[] = 'animate-fade-up';
return $classes;
}
add_filter('post_class', 'navier_post_class_filter');
/**
* Defer non-critical scripts
*
* @param string $tag Script tag
* @param string $handle Script handle
* @return string Modified script tag
*/
function navier_defer_scripts($tag, $handle) {
$defer_scripts = array('navier-main');
if (in_array($handle, $defer_scripts)) {
return str_replace(' src', ' defer src', $tag);
}
return $tag;
}
add_filter('script_loader_tag', 'navier_defer_scripts', 10, 2);
/**
* Add preload for critical assets
*/
function navier_preload_assets() {
// Preload main font
echo '' . "\n";
}
add_action('wp_head', 'navier_preload_assets', 1);
/**
* Remove default gallery styles
*/
add_filter('use_default_gallery_style', '__return_false');
/**
* Wrap oembeds in responsive container
*
* @param string $html Embed HTML
* @param string $url Embed URL
* @param array $attr Attributes
* @param int $post_id Post ID
* @return string Modified embed HTML
*/
function navier_embed_wrapper($html, $url, $attr, $post_id) {
return '
' . $html . '
';
}
add_filter('embed_oembed_html', 'navier_embed_wrapper', 10, 4);
/**
* Custom login logo
*/
function navier_login_logo() {
$custom_logo_id = get_theme_mod('custom_logo');
$logo = wp_get_attachment_image_src($custom_logo_id, 'full');
if ($logo) :
?>
'https://schema.org',
'@type' => 'Organization',
'name' => get_bloginfo('name'),
'url' => home_url(),
'logo' => '',
'address' => array(
'@type' => 'PostalAddress',
'addressLocality' => 'Senlis',
'addressRegion' => 'Oise',
'postalCode' => '60300',
'addressCountry' => 'FR',
),
'contactPoint' => array(
'@type' => 'ContactPoint',
'telephone' => get_theme_mod('navier_phone', '+33 3 44 00 00 00'),
'email' => get_theme_mod('navier_email', 'contact@navier-instruments.com'),
'contactType' => 'customer service',
),
);
$custom_logo_id = get_theme_mod('custom_logo');
if ($custom_logo_id) {
$logo = wp_get_attachment_image_src($custom_logo_id, 'full');
if ($logo) {
$schema['logo'] = $logo[0];
}
}
echo '' . "\n";
}
add_action('wp_head', 'navier_schema_organization');