Skip to content

Instantly share code, notes, and snippets.

@atwellpub
atwellpub / functions.php
Created August 5, 2014 17:29
Example on how to add custom fields to constant contact using Inbound Now's Constant Contact extension and hooks.
<?php
/**
* This code snippit will attempt to add 2 custom fields to the ConstantContact contact data array before being sent to the API
* @author Hudson Atwell
*/
add_filter( 'inboundnow_constantcontact_lead_data' , 'add_custom_field' , 10 , 1 );
function add_custom_field( $contact ) {
/* You may have to look at all the key/value pairs in the $_POST variable to discover the correct key name */
@atwellpub
atwellpub / functions.php
Created August 6, 2014 21:01
Fix for 301 redirect - Removes redirect_canonical for homepage only
<?php
/**
* Fix for 301 redirect - Removes redirect_canonical for homepage only
* @author Hudson Atwell (Inbound Now)
*
*/
function inbound_redirect_canonical($redirect_url, $requested_url) {
if ( is_front_page()) {
return $requested_url;
@atwellpub
atwellpub / functions.php
Created August 14, 2014 20:02
Example of how to hook into inbound_store_lead_post action hook
<?php
/**
* inbound_store_lead_post runs as an ajax call during a tracked form submission
*
* Use $lead data in crafting 3rd party connection
*/
add_action('inbound_store_lead_post','extension_send_data');
@atwellpub
atwellpub / functions.php
Created August 14, 2014 20:13
Example of how to hook into inboundnow_form_submit_actions
<?php
/**
* inboundnow_form_submit_actions after form validationa and before user redirection.
*/
add_action('inboundnow_form_submit_actions','extension_send_data' , 10 , 2 );
/**
* This method will perform additional actions during the inboundnow_form_submit_actions hook
@atwellpub
atwellpub / autofollow.php
Created August 21, 2014 20:01
Automatically follow a twitter user on post save
<?php
$Twitter_Auto_Follow = new Twitter_Auto_Follow();
class Twitter_Auto_Follow {
static $TwitterAPIExchange;
public function __construct() {
@atwellpub
atwellpub / functions.php
Last active August 29, 2015 14:06
Possible woocommerce + landing pages compatibility fix. Add this to your theme's functions.php file
<?php
/* Remove all tracking classes from cart page */
add_action('wp_footer' , 'inbound_remove_cart_tracking_class' );
/**
* Removes tracking classes from forms containing the name 'proceeed'
*/
function inbound_remove_cart_tracking_class() {
?>
@atwellpub
atwellpub / cta.reveal-variation.js
Created September 5, 2014 17:43
possible fix for delayed load
/* Record Impressions For Each Variation in CTA Object
* @param JSON ctas : a json string of {'cta':'vid'}
*/
function wp_cta_record_impressions(ctas) {
/* Add Impressions to loaded varations*/
jQuery.ajax({
type: 'POST',
url: cta_reveal.admin_url,
@atwellpub
atwellpub / functions.php
Last active August 29, 2015 14:06
Example on how to edit email header data before a new lead notification is sent.
<?php
add_filter( ‘inbound_lead_notification_email_headers’ , ‘some_function’ );
function some_function( $headers ) {
$headers = "From: Custom From Name <customfromemail@yoursite.com>\r\n";
return $headers;
}
@atwellpub
atwellpub / response.json
Last active August 29, 2015 14:06
Example Inbound API JSON Result: /leads/
{
"results_count": "800",
"results_per_page": "5",
"max_pages": 160,
"results": {
"96987": {
"ID": 96987,
"lists": {
"110": {
"term_id": 110,
@atwellpub
atwellpub / response.json
Last active August 29, 2015 14:06
Example JSON response after successfully adding a lead using the /leads/add endpoint
{
"results_count": 1,
"results_per_page": 50,
"max_pages": 0,
"results": {
"96988": {
"ID": 96988,
"lists": {
"110": {
"term_id": 110,