Skip to content

Instantly share code, notes, and snippets.

@ingozoell
ingozoell / wp_conditional__enqueue_js.php
Created November 13, 2016 16:19
WordPress - Enqueue scripts conditional IE
// WP 4.2+
wp_enqueue_script( 'html5shiv', '//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv.js' );
wp_script_add_data( 'html5shiv', 'conditional', 'lt IE 9' );
wp_enqueue_script( 'respond', get_template_directory_uri() . '/js/respond.min.js' );
wp_script_add_data( 'respond', 'conditional', 'lt IE 9' );
// WP 4.1
wp_enqueue_script( 'html5shiv', '//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv.js', array(), '3.7.2', false );
add_filter( 'script_loader_tag', function( $tag, $handle ) {
.line-break {
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
@ingozoell
ingozoell / touch-device-detection.js
Last active October 17, 2016 13:22
Touch Device Detection
var checkTouch = function(){
/* Touch Device Detection */
var isTouchDevice = 'ontouchstart' in document.documentElement;
var isTouchDeviceFireFoxBug = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; /* Fixed FireFox Bug */
var isTouch = isTouchDevice || isTouchDeviceFireFoxBug;
if( isTouch ) {
$('html').addClass('touch');
} else {
@ingozoell
ingozoell / to_top_btn..css
Last active March 11, 2017 17:33
To Top Button
.back-to-top {
position: fixed;
bottom: 18px;
right: 50px;
color: #282828;
-webkit-transition: all .3s ease;
transition: all .3s ease;
}
.back-to-top:hover {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
@ingozoell
ingozoell / doubleTapToGo.js
Last active December 20, 2017 15:08
Drop-Down Navigation: Responsive and Touch-Friendly (moseover, hover) https://osvaldas.info/drop-down-navigation-responsive-and-touch-friendly
/*
By Osvaldas Valutis, www.osvaldas.info
Available for use under the MIT License
*/
;(function( $, window, document, undefined ) {
$.fn.doubleTapToGo = function( params ) {
if( !( 'ontouchstart' in window ) &&
!navigator.msMaxTouchPoints &&
!navigator.userAgent.toLowerCase().match( /windows phone os 7/i ) ) return false;
@ingozoell
ingozoell / wp_aktuelles_jahr.php
Created September 29, 2016 17:09
WordPress Shortcode: Aktuelles Jahr, copyright, footer
/* Shortcode: Aktuelles Jahr
* copyright, footer
*
*/
function iz_aktuelles_jahr() {
return date('Y');
}
add_shortcode( 'aktuelles_jahr', 'iz_aktuelles_jahr' );
function iz_post_column_register_sortable( $columns )
{
$columns['author'] = 'author';
$columns['categories'] = 'categories';
$columns['tags'] = 'tags';
return $columns;
}
add_filter("manage_edit-post_sortable_columns", "iz_post_column_register_sortable" );
// add_filter("manage_edit-CPT_SLUG_sortable_columns", "iz_post_column_register_sortable" );
@ingozoell
ingozoell / wp_redirect_to_published_post_backend.php
Created September 28, 2016 20:41
Wordpress: Redirect to Published Posts (Backend)
function default_published_wpse_91299()
{
global $submenu;
// POSTS
foreach( $submenu['edit.php'] as $key => $value ) {
if( in_array( 'edit.php', $value ) ) {
$submenu['edit.php'][ $key ][2] = 'edit.php?post_status=publish&post_type=post';
}
}
add_filter('body_class','add_category_to_single');
function add_category_to_single($classes) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
// add category slug to the $classes array
$classes[] = $category->category_nicename;
}
}
// return the $classes array
add_action( 'admin_menu', 'default_published_wpse_91299' );
function default_published_wpse_91299()
{
global $submenu;
// POSTS
foreach( $submenu['edit.php'] as $key => $value ) {
if( in_array( 'edit.php', $value ) ) {
$submenu['edit.php'][ $key ][2] = 'edit.php?post_status=publish&post_type=post';
}