Skip to content

Instantly share code, notes, and snippets.

@michaelwilhelmsen
michaelwilhelmsen / fluid_width_video.scss
Last active February 9, 2017 12:34
Fluid Width Video (Responsive video embeds)
.video-container {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
height: 0;
iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
@michaelwilhelmsen
michaelwilhelmsen / check_if_is_hash.js
Last active February 3, 2017 13:57
Check if navigation link is an internal (#hash) link.
$('.nav li a').on('click', function() {
if (/#/.test(this.href)) {
// CODE
}
});
@michaelwilhelmsen
michaelwilhelmsen / sp_language_selector_lang_code.php
Last active November 16, 2017 11:08
Custom WPML Language Selector
/* WPML */
function sp_language_selector_lang_code(){
$languages = icl_get_languages('skip_missing=0&orderby=code');
$i = 0;
$len = count($languages);
// If there is one or more languages
if(!empty($languages)){
echo '<div id="lang_sel_list_custom">';
@michaelwilhelmsen
michaelwilhelmsen / editor-capabilities.php
Created February 2, 2017 12:43
Allow additional Editor capabilities in Wordpress admin. Allow editors to manage Widgets and Menus. Allow editors to manage Users below Editor level.
/************* EDITOR ACCESS *****************/
// Allow editors to manage Widgets and Menus
function sp_editor_capabilities() {
$editor = get_role( 'editor' );
if (!$editor->has_cap( 'edit_theme_options' ) ) {
$editor->add_cap( 'edit_theme_options' );
}
@michaelwilhelmsen
michaelwilhelmsen / focus-search-input.js
Created November 21, 2016 07:40
Automatically focus input when toggling a hidden search.
$('.search-toggle').on('click', function(e) {
$('#search input').focus();
e.preventDefault();
});
@michaelwilhelmsen
michaelwilhelmsen / acf-export-2016-09-30.json
Last active September 30, 2016 07:23
ACF Simple Flexible Content Page Builder
[
{
"key": "group_57d2ab81d5362",
"title": "Page Builder",
"fields": [
{
"key": "field_57d2abe0157fc",
"label": "Content",
"name": "content",
"type": "flexible_content",
@michaelwilhelmsen
michaelwilhelmsen / get_featured_image_url.php
Last active January 27, 2017 13:05
Get the featured image url. For situations where you just need the img src of the featured image. Use the function provided for easy usage.
@michaelwilhelmsen
michaelwilhelmsen / copyright.php
Created April 27, 2016 12:52
Wordpress copyright snippet for Screenpartner.
@michaelwilhelmsen
michaelwilhelmsen / typekit_load.scss
Created April 27, 2016 11:34
Hide content until Typekit fonts are loaded or timed out.
.wf-loading {
body {
visibility: hidden;
}
}
.wf-active,
.wf-inactive {
body {
visibility: visible;
@michaelwilhelmsen
michaelwilhelmsen / is_post_type.php
Created October 7, 2015 10:25
Check if post is a $type custom post type, inside or outside of the loop. Ex: if ( is_post_type( 'book' ) ) {}
function is_post_type($type){
global $wp_query;
if($type == get_post_type($wp_query->post->ID)) return true;
return false;
}