Skip to content

Instantly share code, notes, and snippets.

View jester1979's full-sized avatar

Floris Lof jester1979

View GitHub Profile
@jester1979
jester1979 / fpl_anonymize_ga.js
Created August 26, 2012 12:17
Anonymize Google Analytics
var _gaq = _gaq || [];
_gaq.push (['_setAccount', 'UA-XXXXXXX-YY']);
_gaq.push (['_gat._anonymizeIp']);
_gaq.push (['_trackPageview']);
@jester1979
jester1979 / fpl_normal_tags.html
Created August 26, 2012 12:29
Normal usage of script and iframe tags
<script src="http://www.externaldomain.com/cookie_delivering.js" type="text/javascript"></script>
<iframe src="http://www.externaldomain.com/cookie_delivering_iframe.html"></iframe>
@jester1979
jester1979 / fpl_altered_tags.html
Created August 26, 2012 12:30
Altered usage of script and iframe tag
<script src="" data-src="http://www.externaldomain.com/cookie_delivering.js"></script>
<iframe src="" data-src="http://www.externaldomain.com/cookie_delivering_iframe.html"></iframe>
@jester1979
jester1979 / fpl_wp_filter_script_loader.php
Created August 26, 2012 12:32
Filter WP's script_loader_src
<?php
add_filter( 'script_loader_src', 'my_script_loader_filter' );
/**
* function for filter 'script_loader_src' it echo's a script-tag with it's src empty. the src is kept in data-src so javascript can put in the src-attr on a later moment. (e.g. after a cookie-check)
*
* @author Floris P. Lof
* @params String $src the current source of the scriptfile to be included
* @return Boolean false
*/
@jester1979
jester1979 / fpl_wp_embed_oembed_html.php
Last active October 9, 2015 09:28
Filter WP's oEmbed output
<?php
add_filter( 'embed_oembed_html', 'my_embed_filter', 10, 3 );
/**
* function for filter 'embed_oembed_html' it echo's a iframe-tag with it's src empty. the src is kept in data-src so javascript can put in the src-attr on a later moment. (e.g. after a cookie-check)
*
* @author Floris P. Lof
* @params String $html the ready made html received from an external API (like Twitter, Youtube, Vimeo)
* @params String $url the original URI with WP's oEmbed called the external API
* @params Array $attr extra attributes (width height)
@jester1979
jester1979 / fpl_activate_data_src_tags_jquery.js
Last active October 9, 2015 09:28
Activate html tags with a filled data-src-attr and an empty src-attr
$( 'iframe[data-src], script[data-src]' ).each( function() {
$this = $( this );
$this.attr( 'src', $this.attr( 'data-src' ) );
) ); //you should do this after a visitors approval
/* Note: the jQuery-selector above is not the best selector for performance, to use a class instead would be better */
@jester1979
jester1979 / fpl_DTAP_in_wp-config.php
Last active October 11, 2015 09:47
DTAP in wp-config.php
<?php
if ( stristr( $_SERVER['SERVER_NAME'], 'development' ) ) {
// ** MySQL settings DEVELOPMENT ** //
define( 'DB_NAME', 'projectname_dev' );
define( 'DB_USER', 'projectname_dev_user' );
define( 'DB_PASSWORD', '*****' );
define( 'DB_HOST', 'localhost' );
@jester1979
jester1979 / fpl_database_config.php
Last active October 11, 2015 22:38
A database 'switch' in your wp-config.php
<?php
if ( stristr( $_SERVER['SERVER_NAME'], 'development' ) ) {
// ** MySQL settings DEVELOPMENT ** //
define( 'DB_NAME', 'projectname_dev' ); // The name of the database
define( 'DB_USER', 'projectname_dev_user' ); // Your MySQL username
define( 'DB_PASSWORD', '12345' ); // ...and a password an idiot would have on his luggage
define( 'DB_HOST', 'localhost' ); // 99% chance you won't need to change this value
@jester1979
jester1979 / dtap-db-config.php
Last active August 29, 2015 14:00
DTAP-database-config.php
<?php
if ( false !== stripos( $_SERVER['SERVER_NAME'], 'development' ) ) {
//development config goes here
} elseif ( false !== stripos( $_SERVER['SERVER_NAME'], 'testing' ) ) {
//testing config goes here
@jester1979
jester1979 / dtap-varaties.php
Last active August 29, 2015 14:00
DTAP-variaties.config.php
<?php
if ( false !== stripos( $_SERVER['SERVER_NAME'], 'development' ) ) {
//development
define( 'WP_DEBUG', true ); //always develop with debugging on, or you are an idiot...
define( 'WP_CACHE', false ); //no caching of any fliles please
define( 'WP_LOCAL_DEV', true ); //for usage in Mark Jaquiths plugin
define( 'JETPACK_DEV_DEBUG', true ); //use Jetpack in Dev-mode
} else {
//production