Skip to content

Instantly share code, notes, and snippets.

View nickcernis's full-sized avatar

Nick Cernis nickcernis

  • Innsbruck, Austria
  • 12:06 (UTC +02:00)
View GitHub Profile
<?php
/**
* Change the post order for listings
*
* @author Carrie Dils
* @link http://www.billerickson.net/customize-the-wordpress-query/
* @reference http://codex.wordpress.org/Class_Reference/WP_Query
*
*/
@nickcernis
nickcernis / style.css
Last active January 20, 2016 02:36
Simple Social Icons font conflict fix
@font-face {
font-family: 'ssi-fontello';
src: url('../font/fontello.eot?78492063');
src: url('../font/fontello.eot?78492063#iefix') format('embedded-opentype'),
url('../font/fontello.woff?78492063') format('woff'),
url('../font/fontello.ttf?78492063') format('truetype'),
url('../font/fontello.svg?78492063#fontello') format('svg');
font-weight: normal;
font-style: normal;
}
@nickcernis
nickcernis / functions.php
Last active August 29, 2015 14:21
Replace Genesis favicon with full favicon set
<?php // Copy everything except for this first line
// Favicons generated by realfavicongenerator.net
// These should be added in wp-content/themes/child-theme/images/favicons/
remove_action('wp_head', 'genesis_load_favicon');
add_action('wp_head', 'custom_favicon');
function custom_favicon(){
?>
@nickcernis
nickcernis / plugin.php
Created August 17, 2015 13:54
Don't process a WordPress shortcode in wp_head
<?php
global $wp_current_filter;
// Don't process this shortcode in wp_head. This typically happens if a plugin author
// uses apply_filters( 'the_content', $content ) for the meta description tag output,
// instead of using strip_shortcodes() like a sane person. Processing shortcodes in
// the head might be undesirable if your shortcode counts the number of times it's
// been used for the purpose of outputting unique class names or IDs, for example.
if ( in_array('wp_head', $wp_current_filter) ) {
@nickcernis
nickcernis / functions.php
Created August 18, 2015 18:56
Force the Page Builder plugin to include the correct class for Simple Social Icons to be rendered more accurately
<?php
// Force the Page Builder plugin to include 'simple-social-icons' in its widget wrapper class
add_filter( 'siteorigin_panels_widget_classes', 'ssi_add_widget_class' );
function ssi_add_widget_class( $classes ) {
if ( in_array( 'widget_simple-social-icons', $classes ) ) {
$classes[] = 'simple-social-icons';
}
return $classes;
}
@nickcernis
nickcernis / functions.php
Last active September 6, 2020 06:34
Genesis Simple Share Shortcode
<?php
// Adds a [social-icons] shortcode to output Genesis Simple Share icons in posts
// https://wordpress.org/plugins/genesis-simple-share/
// Add the code below to your active theme's functions.php file,
// or use in a site-specific plugin.
// The shortcode takes no attributes; change your icon settings via Genesis → Simple Share.
add_shortcode( 'social-icons', 'gss_shortcode' );
@nickcernis
nickcernis / functions.php
Last active August 6, 2020 14:39
Count widgets that are active for the current WPML language
<?php
/**
* Count widgets in a given sidebar, taking WPML language switching into account.
*
* Assumes widget languages are switched with the WPML String Translation or WPML Widgets plugins.
*
* @param string $id The sidebar ID.
*
* @return int The count of widgets in the sidebar.
@nickcernis
nickcernis / mailchimp-popup-for-wordpress.md
Last active July 28, 2022 14:49
MailChimp Popup Script that works with WordPress sites

MailChimp's default popup scripts can break on WordPress sites that use jQuery/jQuery UI unless you include their embed code as the final elements before the closing body tag.

Including them in this way isn't always possible or easy with WordPress.

The code below is an alternative implementation of the loader that forces MailChimp's popup scripts to appear below all other scripts upon page load.

To use it, modify the baseUrl, uuid, and lid attributes with the ones from the original popup script that MailChimp supplies.

@nickcernis
nickcernis / functions.php
Last active September 30, 2018 16:56
Remove Genesis custom layout metabox on pages with a set template
<?php
/* Remove Genesis post layouts metabox if template matches 'custom-layout.php'*/
add_action( 'admin_menu', 'custom_remove_custom_layouts' );
function custom_remove_custom_layouts() {
$template_file = get_post_meta( $_GET['post'], '_wp_page_template', true );
if ( $template_file == 'custom-layout.php' ) {
remove_action( 'admin_menu', 'genesis_add_inpost_layout_box' );
}
@nickcernis
nickcernis / parsing-urls.js
Created July 27, 2016 15:34
Parsing URLs in JavaScript
// From https://news.ycombinator.com/item?id=12172180
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"