Skip to content

Instantly share code, notes, and snippets.

@atwellpub
atwellpub / module.click-tracking.php
Created March 20, 2015 20:05
Customer support effort for click tracking
<?php
add_action('wp_footer', 'lp_click_callback');
function lp_click_callback() {
global $post;
if (!isset($post)) {
return;
}
@atwellpub
atwellpub / functions.php
Created March 16, 2015 21:50
Add leads to custom taxonomies. Work in progress.
/**
* Add taxonomy
*
*/
add_action('init', 'leads_add_taxonomies' , 1 );
function leads_add_taxonomies() {
register_taxonomy('wplead_list_agents','wp-lead', array(
'hierarchical' => true,
'label' => __( 'Agents' , 'cta' ),
@atwellpub
atwellpub / readme.md
Last active August 29, 2015 14:16
Tweet to download js enqueues and inline javascript within a call to action templat

Problems

wp_enqueue_script commands will not work in the admin_print_footer_scripts, but admin_print_footer_scripts is good for printing inline javascript code. wp_enqueue_script commands will work in the admin_enqueue_scripts hook, but get_current_screen() will not return any information from within the admin_enqueue_scripts hook.

Solutions

Break the enqueues and then inline js into two different hooks and methods using admin_print_footer_scripts for the inline js and admin_enqueue_scripts for the library enqueues.

In order to make sure we are only loading the js libraries on the call to action post type (without the use of get_current_screen()) we will have to use the global $post object, cause it is available inside the admin_enqueue_scripts hook:

@atwellpub
atwellpub / .htaccess
Created February 25, 2015 23:00
for customer
# BEGIN WordPress
<IfModule mod_rewrite.c>^M
RewriteEngine On^M
RewriteBase /^M
RewriteRule ^index\.php$ - [L]^M
RewriteCond %{QUERY_STRING} !lp-variation-id^M
RewriteRule ^go/([^/]*)? /wp-content/plugins/landing-pages/modules/module.redirect-ab-testing.php?permalink_name=$1 [QSA,L]^M
RewriteRule ^landing-page=([^/]*)? /wp-content/plugins/landing-pages/modules/module.redirect-ab-testing.php?permalink_name=$1 [QSA,L]^M
@atwellpub
atwellpub / functions.php
Created January 25, 2015 20:30
Sets the country dropdown fields to visitors IP's country
<?php
/**
* Adds geotargeting js capabilities to javascript
*/
add_action( 'wp_enqueue_scripts' , 'inbound_add_geotargeting_js' );
function inbound_add_geotargeting_js () {
wp_enqueue_script( 'geoplugin' , 'http://www.geoplugin.net/javascript.gp');
}
add_action( 'wp_footer' , 'inbound_set_correct_country' );
@atwellpub
atwellpub / example.php
Created January 22, 2015 08:33
This code example shows how to add an activity section to the activity tab of the Lead profile UI
<?php
/**
* Adds events section to a Lead's Activity tab
*/
class Leads_Extension_Practice_Add_Activity {
static $click_events;
/**
@atwellpub
atwellpub / example.php
Created January 22, 2015 08:24
Code example on how to add a tab content section to a lead profile
<?php
/**
* Adds events section to a Lead's Activity tab
*/
class Extension_Practice_Add_Lead_Tab {
static $click_events;
static $unsubscribe_events;
@atwellpub
atwellpub / index.php
Last active August 29, 2015 14:12
Aspire template with no wpautop
<?php
/**
* Template Name: aspire
* @package WordPress Landing Pages
* @author Inbound Template Generator!
*/
/* Declare Template Key */
$key = lp_get_parent_directory(dirname(__FILE__));
$path = LANDINGPAGES_UPLOADS_URLPATH ."$key/";
$url = plugins_url();
@atwellpub
atwellpub / functions.php
Created December 19, 2014 20:28
Reveals hidden submenus on page load for twentyfifteen theme.
/**
* Toggles the menu dropdowns to open state
*/
function mod_toggle_menus() {
?>
<script type='text/javascript'>
jQuery(document).ready( function() {
/* add toggled-on class to submenus */
@atwellpub
atwellpub / sweetalert.js
Last active August 29, 2015 14:11
sweetalert.js with placeholder and padding
// SweetAlert
// 2014 (c) - Tristan Edwards
// github.com/t4t5/sweetalert
;(function(window, document) {
var modalClass = '.sweet-alert',
overlayClass = '.sweet-overlay',
alertTypes = ['error', 'warning', 'info', 'success'],
defaultParams = {
title: '',