Skip to content

Instantly share code, notes, and snippets.

View jester1979's full-sized avatar

Floris Lof jester1979

View GitHub Profile
@jester1979
jester1979 / functions.php
Created January 6, 2018 10:47
Preview archive
<?php
add_action( 'pre_get_posts', 'fpl_maybe_alter_main_query' );
function fpl_maybe_alter_main_query( $query ) {
//only perform this action on the main query on the frontend
if ( $query->is_main_query() && ( ! is_admin() ) ) {
//only do this for logged in users
if ( is_user_logged_in() ) {
@jester1979
jester1979 / single.php
Last active August 31, 2017 08:48
Filter the content
add_filter( 'the_content', 'cv_the_content_filter' );
function cv_the_content_filter( $content ) {
$can_user_watch_videos = cv_can_user_watch_videos();
if ( $can_user_watch_videos !== true ) {
$content = $can_user_watch_videos;
}
@jester1979
jester1979 / functions.php
Last active March 14, 2017 09:13
Meta tags in the head
<?php
//Add this code below to your functions.php, replace 'name-of-tag' and 'value-of-tag'
add_action( 'wp_head', 'my_meta_tags' );
function my_meta_tags() {
?>
<meta name="name-of-tag" content="value-of-tag">
<?php
}
@jester1979
jester1979 / wp-head.php
Created June 5, 2015 09:49
Adding something to your WP head
add_action( 'wp_head', 'fpl_add_stuff_to_head' );
function fpl_add_stuff_to_head() {
?>
<!-- BEGIN add your <head> html below -->
<!-- END add your <head> html below -->
<?php
}
@jester1979
jester1979 / gform-validation-msg-filter.php
Created April 30, 2015 12:14
Filter GForm Validation message
add_filter( 'gform_validation_message', 'dd_gform_validation_message' , 10, 2 );
function dd_gform_validation_message( $message, $form ) {
return "<div class='validation_error'>" . __( 'There was a problem with your submission.', CHILD_THEME_TEXTDOMAIN ) . ' ' . __( 'Errors have been highlighted below.', CHILD_THEME_TEXTDOMAIN ) . '</div>';
}
@jester1979
jester1979 / shortcode.php
Last active August 29, 2015 14:14
Related posts by tagging
add_shortcode( 'tag-relations', 'posts_relations_by_tags' );
/**
*Renders all post relations defined by tags-relation
*
* @author Floris P. Lof
*/
function posts_relations_by_tags() {
$found_posts = false;
$found_posts_ids = array();
@jester1979
jester1979 / functions.php
Created January 27, 2015 20:26
oEmbed transparancy
add_filter( 'embed_oembed_html', 'oembed_transparency', 10, 4 );
/**
* oEmbed Transparency.
*
* Used so that menus can appear on top of videos.
*
* @since 1.0.0
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/oembed-transparency
@jester1979
jester1979 / functions.php
Created January 27, 2015 20:24
Favicon URL in multisite
add_filter( 'genesis_favicon_url', 'customize_favicon_url' );
/**
* Change location of favicon reference.
*
* @since 1.0.0
*
* @global int $blog_id Current blog ID.
*
* @return string Updated favicon URL.
*/
@jester1979
jester1979 / functions.php
Created January 27, 2015 20:23
IE compat header
add_filter( 'wp_headers', 'add_ie_compatibility_header' );
/**
* Disable IE compatibilty view modus.
*
* Not 100% guaranteed to have affect.
*
* @since 1.0.0
*/
function add_ie_compatibility_header( $headers ) {
@jester1979
jester1979 / functions.php
Created January 27, 2015 20:16
Javascript vars
add_action( 'wp_head', 'append_header_js_vars' );
/**
* Append some handy dandy JS vars to the head
*
* Adds necessary code to start the PE-application (on document ready),
* with the WP_DEBUG boolean as a parameter.
*
* @since 1.0.0
*/
function append_header_js_vars() {