Skip to content

Instantly share code, notes, and snippets.

@SiGaCode
SiGaCode / shortcodes-in-textwidget.php
Last active May 7, 2016 08:46
Use Shortcodes and PHP in Widgets Without a Plugin By Carrie Dils: http://www.carriedils.com/extend-wordpress-widgets-without-plugin/
// Enable shortcodes in widgets
add_filter('widget_text', 'do_shortcode');
// Enable PHP in widgets
// WARNING: Potential security vulnerability you open by enabling code execution from a widget!
add_filter('widget_text','execute_php',100);
function execute_php($html){
if(strpos($html,"<"."?php")!==false){
ob_start();
eval("?".">".$html);
@SiGaCode
SiGaCode / remove-default-widgets.php
Created May 7, 2016 08:40
Remove default/stock/standard Genesis widgets From: https://gist.github.com/JiveDig/5556796
<?php
// Remove eNews and Updates widget
add_action( 'widgets_init', 'remove_enews_updates_widget', 20 );
function remove_enews_updates_widget() {
unregister_widget( 'Genesis_eNews_Updates' );
}
// Remove Featured Page widget
add_action( 'widgets_init', 'remove_featured_page_widget', 20 );
function remove_featured_page_widget() {
unregister_widget( 'Genesis_Featured_Page' );
@SiGaCode
SiGaCode / image-rendering.css
Created May 4, 2016 12:22
The image-rendering CSS property provides a hint to the browser about the algorithm it should use to scale images (and therefore make them look less blurry when scaled). Experimental. Modern browsers only! https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering Another method for Firefox: http://stackoverflow.com/questions/5918595/why-i…
/* applies to GIF and PNG images; avoids blurry edges */
img[src$=".gif"], img[src$=".png"] {
image-rendering: -moz-crisp-edges; /* Firefox */
image-rendering: -o-crisp-edges; /* Opera */
image-rendering: -webkit-optimize-contrast;/* Webkit (non-standard naming) */
image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */
}
@SiGaCode
SiGaCode / hide-on-scroll-styles.css
Last active October 12, 2016 11:48
Hide header on scroll down, show again on scroll up - goes to Dynamik Custom - JS (or skin JS) Credits: https://medium.com/@mariusc23/hide-header-on-scroll-down-show-on-scroll-up-67bbaae9a78c#.uv231ifg1, bloxwp.com
.site-header {
position: fixed;
top: 0;
transition: top 0.4s ease-in-out 0s;
width: 100%;
z-index:9999;
}
.site-header.nav-up {
top: -80px; /*Adjust to your header height*/
@SiGaCode
SiGaCode / remove-empty-tags.php
Created April 23, 2016 11:17
Remove empty p tags from WordPress posts by ninnypants https://gist.github.com/ninnypants/1668216
<?php
// don´t add the opening php tag in your functions! Paste from here
add_filter( 'the_content', 'remove_empty_p', 20, 1 );
function remove_empty_p( $content ){
// clean up p tags around block elements
$content = preg_replace( array(
'#<p>\s*<(div|aside|section|article|header|footer)#',
'#</(div|aside|section|article|header|footer)>\s*</p>#',
'#</(div|aside|section|article|header|footer)>\s*<br ?/?>#',
@SiGaCode
SiGaCode / custom-header-styles.css
Last active April 10, 2016 17:06
Add custom header support to Genesis childtheme Dynamik in conjunction with plugin "Unique Headers" to have different header images on different pages/posts. It makes sure that "Dynamic text" or "Image logo" settings in Genesis Theme settings are accepted and match Dynamik CSS.
.custom-header .site-header {
background-color: transparent;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center center;
-o-background-size: cover!important;
-moz-background-size: cover!important;
-webkit-background-size: cover!important;
background-size: cover!important;
}
@SiGaCode
SiGaCode / move_mobile_navs.php
Created April 6, 2016 15:48
Move the mobile nav bars (hamburger bars) to a different position in Dynamik, when you moved primary nav or secondary nav, for example, so they will show up in the same places. http://cobaltapps.com/forum/forum/main-category/web-design-talk/27548-mobile-navigation-positioning-problem-using-custom-functions
//* Change genesis_after_header to genesis_before_header if that was the original position
//* Reposition the primary mobile nav inside header, for example
remove_action( 'genesis_after_header', 'dynamik_mobile_nav_1', 9 );
add_action( 'genesis_header', 'dynamik_mobile_nav_1', 10 );
//* Reposition the secondary mobile nav before footer, for example
remove_action( 'genesis_after_header', 'dynamik_mobile_nav_2' );
add_action( 'genesis_before_footer', 'dynamik_mobile_nav_2', 12 );
@SiGaCode
SiGaCode / even-odd-classes.js
Created March 3, 2016 17:26
Assign even and odd classes to an element with children elements using jQuery Credits: Sridhar Katakam, http://stackoverflow.com/questions/7679446/is-this-an-even-or-odd-element/7679481#7679481
$( '.front-page-5 .entry' ).each(function(i, el) {
// As a side note, this === el.
if ( i % 2 === 0 ) {
/* we are even */
$(el).addClass( 'even' );
}
else {
/* we are odd */
$(el).addClass( 'odd' );
}
@SiGaCode
SiGaCode / one-level-submenu.php
Created March 3, 2016 17:21
Reduce the secondary navigation menu to one level depth - from No Sidebar Pro's functions.php
//* Reduce the secondary navigation menu to one level depth
add_filter( 'wp_nav_menu_args', 'ns_secondary_menu_args' );
function ns_secondary_menu_args( $args ){
if( 'secondary' != $args['theme_location'] )
return $args;
$args['depth'] = 1;
return $args;
# ----------------------------------------------------------------------
# | Komprimierung und Caching |
# ----------------------------------------------------------------------
# Serve resources with far-future expires headers.
#
# (!) If you don't control versioning with filename-based
# cache busting, you should consider lowering the cache times
# to something like one week.
#