Skip to content

Instantly share code, notes, and snippets.

View eugenoprea's full-sized avatar

Eugen Oprea eugenoprea

View GitHub Profile
@eugenoprea
eugenoprea / 404.php
Last active August 27, 2019 16:34
Custom 404 Page for Genesis child themes
<?php
/**
* Handles display of 404 page.
*
* Edited by Eugen Oprea - http://www.eugenoprea.com/
*
* This file should be added in the directory of your child theme!
*
* @category Genesis
* @package Templates
@eugenoprea
eugenoprea / functions.php
Created February 19, 2013 18:36
Exclude DiggDigg From Specific Pages
/** Exclude DiggDigg from specific pages */
function eo_exclude_digg_digg() {
if(is_page(array(1, 2, 3, 4))) {
remove_filter('the_excerpt', 'dd_hook_wp_content');
remove_filter('the_content', 'dd_hook_wp_content');
}
}
add_action('template_redirect', 'eo_exclude_digg_digg');
@eugenoprea
eugenoprea / functions.php
Created March 13, 2013 14:41
Gravity Forms – Populate Name Field - Retrieving user meta information 1.
function eo_get_usermeta($meta_key)
{
$current_user = wp_get_current_user();
$ret = (($current_user instanceof WP_User) && (0 != $current_user->ID)) ?
$current_user->__get($meta_key) : '';
return $ret;
}
@eugenoprea
eugenoprea / functions.php
Created March 13, 2013 14:41
Gravity Forms – Populate Name Field - Retrieving user meta information 2.
first_name = eo_get_usermeta('first_name');
last_name = eo_get_usermeta('last_name');
@eugenoprea
eugenoprea / functions.php
Created March 13, 2013 14:43
Gravity Forms - Populate Name Field - Using Dynamic Population Parameters
add_filter('gform_field_value_first_name', 'eo_populate_name');
add_filter('gform_field_value_last_name', 'eo_populate_name');
function eo_populate_name($value)
{
// extract the parameter name from the current filter name
$param = str_replace('gform_field_value_', '', current_filter());
// we are interested only in the first_name and last_name parameters
if ( !in_array($param, array('first_name', 'last_name')) )
@eugenoprea
eugenoprea / functions.php
Created March 13, 2013 14:46
Gravity Forms - Populate Name Field - Setting Field Default Value Directly - Part 1.
/**
* Populate a Gravity Forms Name field.
*
* @param array $field Gravity Forms field object
* @param string|array $name Name components, pass either a string or array when the
* nameFormat is 'simple' or an array in all other cases
*/
function eo_populate_name_field(&$field, $name = array())
{
if ( !(is_array($field) && ('name' == rgar($field, 'type')) && !empty($name)) )
@eugenoprea
eugenoprea / functions.php
Created March 13, 2013 14:47
Gravity Forms - Populate Name Field - Setting Field Default Value Directly - Part 2.
// Adds a filter to form id 7. Replace 7 with your actual form id
add_filter('gform_pre_render_7', 'eo_form_pre_render');
function eo_form_pre_render($form)
{
// if no user is logged-in, do nothing
if ( !is_user_logged_in() )
return $form;
foreach ($form['fields'] as &$field)
@eugenoprea
eugenoprea / functions.php
Created June 7, 2013 14:36
Genesis Previous/Next Post Post Navigation
/** Genesis Previous/Next Post Post Navigation */
add_action( 'genesis_before_comments', 'eo_prev_next_post_nav' );
function eo_prev_next_post_nav() {
if ( is_single() ) {
echo '<div class="prev-next-navigation">';
previous_post_link( '<div class="previous">Previous article: %link</div>', '%title' );
@eugenoprea
eugenoprea / .htaccess
Created February 10, 2014 12:08
This code will redirect all pages to the homepage, while still allowing you to access the admin area.
# BEGIN redirect to homepage
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js|php)$
RewriteCond %{REQUEST_URI} !^/wp-admin [NC]
RewriteRule .* / [L,R=301]
#END redirect to homepage
@eugenoprea
eugenoprea / filter-traffic.html
Created February 18, 2016 09:53
Filter Admin Traffic in Google Analytics - Part 1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Excluding traffic by Cookie Content</title>
<meta name=”robots” content=”noindex” />