Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
<?php
/*
Plugin Name: UC Google Remarketing
Author: Dessalegne Chekol
Version: 1.0
Description: Adds Google AdWords Remarketing code on all pages
*/
add_action('wp_footer', 'google_script');
function google_script()
{
$regex = '/^\d+$/';
if ( preg_match($regex, get_option( 'my_google_id', '' ))&& (get_option( 'my_google_id', '' )!=null)) {
$x=get_option( 'my_google_id', '' );
?>
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = <?php echo $x;?>;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/<?php echo $x;?>/?value=0&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
<?php
}
}
function register_fields()
{
register_setting('general', 'my_google_id', 'esc_attr');
add_settings_field('my_google_id', '<label for="my_google_id">'.__('Google Remarketing ID' , 'my_google_id' ).'</label>' , 'print_custom_field', 'general');
}
function print_custom_field()
{
$regex = '/^\d+$/';
if ( preg_match($regex, get_option( 'my_google_id', '' )) ) {
$value = get_option( 'my_google_id', '' );
echo '<input type="text" id="my_google_id" name="my_google_id" value="' . esc_attr( $value ) . '" />';
}
else
echo '<input type="text" id="my_google_id" name="my_google_id" value="" />';
}
add_filter('admin_init', 'register_fields');