Skip to content

Instantly share code, notes, and snippets.

View eugenoprea's full-sized avatar

Eugen Oprea eugenoprea

View GitHub Profile
@eugenoprea
eugenoprea / header.php
Created February 19, 2016 13:15
Google Analytics Social Button Tracking Script
<!–– Google Analytics Social Button Tracking Script ––>
<script type="text/javascript" src="https://s3.amazonaws.com/eo-storage/ga_social_tracking.js"></script>
@eugenoprea
eugenoprea / filter-traffic.html
Last active May 12, 2018 05:53
Filter Admin Traffic in Google Analytics - Part 3
</head>
<body onLoad="javascript:pageTracker._setVar('filter_traffic');">
<h1>Excluding traffic by Cookie Content</h1>
<p>This page will set a cookie in your browser that will help Google Analytics filter the traffic that comes from your computer when using this browser.</p>
<p>Once you have this setup, don't forget to set a filter in Google Analytics.</p>
<p>You will need to visit this page only once.</p>
<p>However, if you clear your browser cookies, reinstall the browser or operating system, make sure that you revisit this page, so the cookie will be set again.</p>
</body>
</html>
@eugenoprea
eugenoprea / filter-traffic.html
Created February 18, 2016 09:53
Filter Admin Traffic in Google Analytics - Part 2
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
@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” />
@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 / 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 / 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 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: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: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');