Skip to content

Instantly share code, notes, and snippets.

@tixxwp
tixxwp / functions.php
Last active June 19, 2017 11:54
Google Tag Manager snippet for Genesis Framework
/**
* Add Add Google Tag Manager script in the <head> section
*/
add_action('wp_head', 'google_tag_manager_head', 3 );
function google_tag_manager_head() { ?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
@tixxwp
tixxwp / functions.php
Created June 22, 2016 07:44
Esempio di funzione 01 inserita in functions.php
<?php
function includi_sottopost() {
global $post; ?>
<a class="linkfbshare" target="_blank" href="http://www.facebook.com/share.php?v=4&amp;amp;src=bm&amp;amp;u=<?php the_permalink(); ?>&amp;amp;t=<?php the_title(); ?>" rel="nofollow" class="external" title="Condividi su Facebook"><img src="<?php bloginfo('template_directory'); ?>/images/facebook_share.png" width="70" height="20" alt="Facebook Sharing"/></a>
<a class="linkcommenta" href="<?php the_permalink() ?>#respond" rel="nofollow">Commenta:</a> <?php comments_popup_link('0', '1', '%');
} ?>
@tixxwp
tixxwp / esempio.php
Last active June 22, 2016 07:43
Esempio codice 01
<a class="linkfbshare" target="_blank" href="http://www.facebook.com/share.php?v=4&amp;amp;src=bm&amp;amp;u=<?php the_permalink(); ?>&amp;amp;t=<?php the_title(); ?>" rel="nofollow" class="external" title="Condividi su Facebook">
<img src="<?php bloginfo('template_directory'); ?>/images/facebook_share.png" width="70" height="20" alt="Facebook Sharing"/></a>
<a class="linkcommenta" href="<?php the_permalink() ?>#respond" rel="nofollow">Commenta:</a> <?php comments_popup_link('0', '1', '%'); ?>
@tixxwp
tixxwp / functions.php
Created May 16, 2016 09:56
Esclusione del codice di Google Analytics su WordPress per gli utenti loggati
//* Google Analytics
add_action( 'wp_head', 'custom_google_analytics', 99);
function custom_google_analytics() {
if (!is_user_logged_in()) { ?>
<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-12345-6', 'auto');
@tixxwp
tixxwp / functions.php
Created May 16, 2016 09:50
Aggiunta del codice di Google Analytics in un sito WordPress
//* Google Analytics
add_action( 'wp_head', 'custom_google_analytics', 99);
function custom_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-12345-6', 'auto');
@tixxwp
tixxwp / blockrightclick.html
Created May 11, 2016 12:36
Block Mouse Right Click
<script>
jQuery( function($) {
$(this).bind("contextmenu", function(e) {
e.preventDefault();
});
});
</script>
@tixxwp
tixxwp / socialtracking01.html
Created April 28, 2016 12:12
Monitorare gli utenti loggati sui social con Google Analytics
<img style="display:none;"
onload="record_login_status(1, 'Google', true)"
onerror="record_login_status(1, 'Google', false)"
src="https://accounts.google.com/CheckCookie?continue=https://www.google.com/intl/en/images/logos/accounts_logo.png" />
<img style="display:none;"
onload="record_login_status(2, 'GooglePlus', true)"
onerror="record_login_status(2, 'GooglePlus', false)"
src="https://plus.google.com/up/?continue=https://www.google.com/intl/en/images/logos/accounts_logo.png&type=st&gpsrc=ogpy0" />
@tixxwp
tixxwp / socialtracking01.js
Created April 28, 2016 12:08
Monitorare gli utenti loggati sui social con Google Analytics
<script type="text/javascript">
function record_login_status(slot, network, status)
{
// This code is for the async version of Google Analytics; if you're still on
// the old code then you need to adjust it accordingly.
if (status)
{
_gaq.push(["_setCustomVar", slot, network + "_State", "LoggedIn", 1]);
// You may prefer to record this data with _trackEvent
// _gaq.push(['_trackEvent', network + '_State', 'status', "LoggedIn"]);