Wordpress

Wenn ich Web-Development für Backend-Lösungen betreibe, dann am liebsten mit PHP & Wordpress. Viele Snippets kann man öfters gebrauchten und dann sammle ich die jetzt hier einfach. Einerseits tue ich das für selbst, falls ich wieder mal ein Wordpress-Theme programmieren muss, andererseits hilft es vielleicht auch dir weiter.

/*
 * S T Y L E S 
 */

function lh_theme_styles() {
	
	$theme_object = wp_get_theme();
	$version      = $theme_object["Version"];
	
	wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css',  array(), $version );	
}
add_action( 'wp_enqueue_scripts', 'lh_theme_styles' );

style.css Version mit WordPress-Theme Version gleich schalten

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# END WordPress



# === COMPRESSION & OPTIMIZATION (begin) ===
# Enable GZIP

AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html


# Expires Headers - 2678400s = 31 days

  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 7200 seconds"
  ExpiresByType image/gif "access plus 2678400 seconds"
  ExpiresByType image/jpeg "access plus 2678400 seconds"
  ExpiresByType image/png "access plus 2678400 seconds"
  ExpiresByType text/css "access plus 518400 seconds"
  ExpiresByType text/javascript "access plus 2678400 seconds"
  ExpiresByType application/x-javascript "access plus 2678400 seconds"


# Cache Headers

  # Cache specified files for 31 days
  
  Header set Cache-Control "max-age=2678400, public"
  
  # Cache HTML files for a couple hours
  
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  
  # Cache PDFs for a day
  
  Header set Cache-Control "max-age=86400, public"
  
  # Cache Javascripts for 31 days
  
  
 # === COMPRESSION & OPTIMIZATION (end) === 
  
  

GZIP, Caching & Header-Control über die .htaccess für WordPress aktivieren