Skip to content

Instantly share code, notes, and snippets.

View amElnagdy's full-sized avatar

Ahmed Mohammed Nagdy amElnagdy

View GitHub Profile
_e('Hello World', 'theme_text_domain');
sprintf(__(‘This page contains %s posts.’ , 'theme_text_domain') , $num_posts) ;
sprintf(__(‘<h2>This page contains %s posts.</h2>’ , 'theme_text_domain') , $num_posts) ;
‘<h2>’.sprintf(__(‘This page contains %s posts.’ , 'theme_text_domain') , $num_posts).’</h2>’;
_n( $single, $plural, $number, $domain )
as
sprintf( _n('This page contains %d post.', 'This page contains %d posts.', $num_posts, 'theme_text_domain'), $num_posts );
/*
Theme Name: Your theme name
Theme URI: Your theme URL
Text Domain: theme_text_domain
*/
function setup_theme(){
load_theme_textdomain('theme_text_domain', get_template_directory() . '/languages');
}
add_action('after_setup_theme', 'setup_theme');
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule ^(wp-content/uploads.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
# http config block
map $http_accept $webp_ext {
default "";
"~*webp" ".webp";
}
# server config block
location ~* ^/wp-content/.+\.(png|jpg)$ {
add_header Vary Accept;
try_files $uri$webp_ext $uri =404;
// Source: https://wpcolt.com/fix-hentry-errors-wordpress/
add_filter( 'post_class', 'remove_hentry' );
function remove_hentry( $class ) {
$class = array_diff( $class, array( 'hentry' ) );
return $class;
}