Skip to content

Instantly share code, notes, and snippets.

@ginocremer
ginocremer / Resize Images after Upload WordPress Media Library
Created March 21, 2014 07:36
Resize Images after Upload WordPress Media Library
add_filter('wp_generate_attachment_metadata','replace_uploaded_image');
function replace_uploaded_image($image_data)
{
// if there is no large image : return
if ( !isset($image_data['sizes']['large']) )
return $image_data;
// paths to the uploaded image and the large image
$upload_dir = wp_upload_dir();
add_action( 'wp_print_scripts', 'add_my_scripts', 100 );
function add_my_scripts() {
if ( !is_admin() ) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', ( 'http://www.PFAD-ZUR-EIGENEN-JQUERY-DATEI.com' ), false, null, true );
wp_enqueue_script( 'jquery' );
wp_register_script( 'eigenes-script', 'http://www.EIGENES-SCRIPT.com');
wp_enqueue_script( 'eigenes-script' );
} }
add_action('init', 'add_my_scripts');
add_action('wp_print_styles', 'add_my_styles', 100);
function add_my_styles() {
wp_register_style( 'eigene-css', 'http://www.PFAD-ZUR-EIGENEN-CSS-DATEI.com');
wp_enqueue_style( 'eigene-css' );
}
add_action('init', 'add_my_styles');
@ginocremer
ginocremer / gist:64b285fb79aeba49230dcf8ad0777a81
Created May 2, 2017 19:23
Cachify Snippet / .htaccess if WordPress is in a subdirectory/subfolder (e.g. "wordpress")
<IfModule mod_rewrite.c>
# ENGINE ON
RewriteEngine On
# GZIP FILE
<IfModule mod_mime.c>
RewriteCond %{REQUEST_URI} /$
RewriteCond %{REQUEST_URI} !^/wp-admin/.*
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
@ginocremer
ginocremer / Exotische Dateitypen in WordPress hochladen
Created March 6, 2014 14:20
Upload erlauben von .swf, .tiff, .rtf oder .zip
add_filter('upload_mimes', 'eigene_upload_mimes');
function eigene_upload_mimes( $vorhandene_mimes ){
$vorhandene_mimes['zip'] = 'application/zip';
$vorhandene_mimes['swf'] = 'application/x-shockwave-flash';
$vorhandene_mimes['rtf'] = 'text/richtext';
$vorhandene_mimes['tiff'] = 'image/tiff';
return $vorhandene_mimes;
}
@ginocremer
ginocremer / .htaccess Cachify
Created July 25, 2016 13:26
Original von Sergej Müller / Leider nicht mehr als Gist verfügbar, daher an dieser Stelle als neuer Gist.
# BEGINN CACHIFY
<IfModule mod_rewrite.c>
# ENGINE ON
RewriteEngine On
# GZIP FILE
<IfModule mod_mime.c>
RewriteCond %{REQUEST_URI} /$
RewriteCond %{REQUEST_URI} !^/wp-admin/.*
RewriteCond %{REQUEST_METHOD} !=POST
@ginocremer
ginocremer / Exotische Dateitypen in Mediathek hochladen
Created December 29, 2014 21:37
Mit einem kleinen Snippet können Sie WordPress anweisen auch exotischere Dateitypen anstandslos anzunehmen.
add_filter('upload_mimes', 'add_custom_upload_mimes');
function add_custom_upload_mimes( $existing_mimes ){
$existing_mimes['zip'] = 'application/zip';
$existing_mimes['eps'] = 'application/eps';
$existing_mimes['rtf'] = 'text/richtext';
$existing_mimes['tiff'] = 'image/tiff';
return $existing_mimes;
}
@ginocremer
ginocremer / Eigene Farben pro Seite über eine eigene Body-Klasse
Created December 28, 2014 10:26
In vielen Fällen kann eine Klasse auf dem Body-Element nützlich sein. Zum Beispiel wenn Sie jeder einzelnen Seite eine eigene Farbgebung via CSS spendieren möchten.
function add_top_parent_body_class( $classes ) {
if(is_page()):
$top_id = '';
$ancestors = get_ancestors(get_the_ID(),'page');
if ( !empty($ancestors)):
$top_id = end($ancestors);
$classes[] = 'top-parent-'.sanitize_title(get_the_title($top_id));
else:
$classes[] = 'top-parent-'.sanitize_title(get_the_title(get_the_ID()));
endif;
@ginocremer
ginocremer / gist:d911c7174bc0ade16f5e
Created November 22, 2014 21:32
SQL Anweisung Update Datenbank: Umzug WordPress
UPDATE wp_posts SET post_content = REPLACE ( post_content, 'http://127.0.0.1:8080/wordpress', 'http://www.mein-blog.info');
UPDATE wp_options SET option_value = REPLACE ( option_value, 'http://127.0.0.1:8080/wordpress', 'http://www.mein-blog.info');
@ginocremer
ginocremer / Aktivieren Sie die Beitragsbilder in der functions.php
Last active August 29, 2015 14:09
Praxis-Workshop: Theme-Entwicklung
add_theme_support( 'post-thumbnails' );