Skip to content

Instantly share code, notes, and snippets.

View kailoon's full-sized avatar
🎯
Focusing

kailoon kailoon

🎯
Focusing
View GitHub Profile
@kailoon
kailoon / custom-body-class.php
Last active April 20, 2023 10:03
Theme authors should avoid and not to hardcode custom body_class. Main reason for this is being able to remove the class when needed i.e. child themes.
<?php
// if there's a namespace, add it the body class
$classes[] = esc_attr( $theme_options['themename_namespace'] );
if ( isset( $post ) ) {
$classes[] = esc_attr( $post->post_type . '_' . $post->post_name );
}
if (is_single() ) {
foreach((wp_get_post_terms( $post->ID)) as $term) {
<?php
// To be used by theme authors to avoid duplicate favicon code now that Site Icons have been added to WordPress 4.3
// If a Site Icon hasn't been set or if the `has_site_icon` function doesn't exist (ie older than WordPress 4.3)
if ( ! ( function_exists( 'has_site_icon' ) && has_site_icon() ) ) {
// your theme specific custom favicon code goes here
}
<?php
/**
* Escape all translations with
*/
__( ‘Some String’, ‘text-domain’ ); _e( ‘Some string’, ‘text-domain’ );.
/**
* When there is no HTML use:
*/
<?php
/*
Register Fonts
*/
function studio_fonts_url() {
$font_url = '';
/*
Translators: If there are characters in your language that are not supported
by chosen font(s), translate this to 'off'. Do not translate into your own language.