Skip to content

Instantly share code, notes, and snippets.

View davidvandenbor's full-sized avatar

David van den Bor davidvandenbor

View GitHub Profile
@davidvandenbor
davidvandenbor / wordpress-wrap-flex-video-class.php
Last active November 11, 2015 22:53
WordPress: wrap videos with Zurb Foundation flex-video class
<?php
/**
* -------------------------------------------------------------------------------//
* wrap video's with Zurb Foundation flex-video class div
* @author @david
* -------------------------------------------------------------------------------//
*/
add_filter('embed_oembed_html', 'david_embed_oembed_html', 99, 4);
function david_embed_oembed_html($html, $url, $attr, $post_id) {
return '<div class="flex-video widescreen">' . $html . '</div>';
@davidvandenbor
davidvandenbor / wordpress-remove-width-height-img-html.php
Last active November 4, 2015 10:03
WordPress: remove width and height attributes from imh html
<?php
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
?>
@davidvandenbor
davidvandenbor / category-title.php
Last active October 15, 2015 10:21
WordPress: show the category title
<h1><?php //single_cat_title() ?></h1>
<?php //echo str_replace('Categorie: ','',get_the_archive_title()); ?>
<?php //echo '<h1 class="page-title">' . single_cat_title( '', false ) . '</h1>'; ?>
@davidvandenbor
davidvandenbor / filter-wordpress-comment-form-fileds.php
Last active October 2, 2015 00:32
WordPress: filter comment form fields
<?php
function alter_comment_form_fields($fields){
//$fields['author'] = ''; //removes name field
//$fields['email'] = ''; //removes email field
//$fields['url'] = ''; //removes website field
return $fields;
}
add_filter('comment_form_default_fields','alter_comment_form_fields');
@davidvandenbor
davidvandenbor / wp-mysql-url-replacement-queries.sql
Created September 26, 2015 13:17
WordPress MySql URL replacement queries
UPDATE wp_options SET option_value = replace(option_value, 'http://www.alpha-audio.nl', 'http://www.alpha-audio.dev') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.alpha-audio.nl','http://www.alpha-audio.dev');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.alpha-audio.nl', 'http://www.alpha-audio.dev');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.alpha-audio.nl','http://www.alpha-audio.dev');
@davidvandenbor
davidvandenbor / foundation-animated-accordion.js
Created September 7, 2015 10:26
Foundation animated accordion
//reflow after page load
$(document).foundation('accordion', 'reflow');
//animate open/close
$(".accordion li").on("click", "a:eq(0)", function (event) {
var dd_parent = $(this).parent();
if(dd_parent.hasClass('active')) {
$(".accordion li ul.content:visible").slideToggle("normal");
} else {
@davidvandenbor
davidvandenbor / auto-generate-wp-featured-image.php
Last active August 29, 2015 14:24
Auto generate featured WP image
@davidvandenbor
davidvandenbor / multiple-rss-feeds-wordpress.php
Created June 16, 2015 08:59
Multiple RSS feeds in WordPress
<?php
/**
* Class to return multiple RSS feeds in WordPress
* Instructions:
* 1. Upload this class to theme folder
* 2. Include this class in functions.php ie: include "mytheme/wow_rss.php";
*
* In theme template:
* 3. Create new object of class ie: $obj = new wow_Rss ("http://www.mywebsite.co.uk/feed","5");
* Enter feed url as 1st argument and how many items from that feed as the 2nd
@davidvandenbor
davidvandenbor / grav-cms-twig-loops.twig
Last active November 6, 2019 07:00
GRAV cms TWIG loops
{# find the children (subpages) of a parent page, in this case the "about" page #}
<ul>
{% for p in page.find('/about').children if p != page %}
<li><a href="{{p.url}}">{{ p.title }}</a></li>
{% endfor %}
</ul>
{# show all the pages with a certain category, in this case "cars" #}
<h2>All the CAR posts</h2>
<ul>
@davidvandenbor
davidvandenbor / add-css-to-html-jquery.js
Created May 1, 2015 12:19
Add CSS code or classes to html elements with jQuery
// @david: add or remove classes at certain scrolling distances
// the class names in this gist are meant as an example :-)
$(window).scroll(function() {
var y_scroll_pos = window.pageYOffset;
var scroll_pos_test = 300;
// set to whatever you want it to be
if (y_scroll_pos > scroll_pos_test) {
$(".menu").addClass("animated fadeInLeft");
// or add or remove pure CSS code: