Skip to content

Instantly share code, notes, and snippets.

@aaroneaton
aaroneaton / om-editor.php
Created August 28, 2015 20:20
Allow editors to use the OptinMonster admin area
<?php // Make sure to remove this tag!
// Add this code to your theme's functions.php file.
add_filter( 'optin_monster_api_menu_cap', 'om_allow_editors_in_menu' );
function om_allow_editors_in_menu( $capability ) {
// The default capability is 'manage_options'. We can switch this out with an editor capability.
return 'publish_pages';
@aaroneaton
aaroneaton / new-site.sh
Last active August 29, 2015 13:57
Quickly add a new WP install to your server
#! /bin/sh
# This script assumes a few things
# 1. You are running Nginx
# 2. WP-CLI is installed
# 3. Your user is part of the www-data group
# 4. Nginx_ensite is installed (https://github.com/perusio/nginx_ensite)
# 5. nginx-wp-common.conf is installed at `/etc/nginx/nginx-wp-common.conf`
# How to use
@aaroneaton
aaroneaton / limit-optin-view.php
Last active August 29, 2015 14:03
Limits the number of times an optin can be viewed
<?php
add_filter( 'optinmonster_output', 'limit_views' );
function limit_views ( $optins ) {
// Replace this with your optin slug
$optin_slug = 'yf3rluqqcj-lightbox';
// Replace this with the number of views
$view_limit = 100;
@aaroneaton
aaroneaton / sample.php
Last active August 29, 2015 14:07
create addon
<?php
add_action( 'plugins_loaded', 'om_sample_plugins_loaded' );
function om_sample_plugins_loaded() {
// Bail if the main class does not exist.
if ( ! class_exists( 'Optin_Monster' ) ) {
return;
}
@aaroneaton
aaroneaton / sample.php
Created September 30, 2014 21:20
create plugin
<?php
/**
* Plugin Name: OptinMonster Sample Theme
* Plugin URI: http://optinmonster.com/
* Description: OptinMonster is the best lead generation plugin for WordPress.
* Author: OptinMonster Developers
* Author URI: http://optinmonster.com
* Version: 1.0
* Text Domain: optin-monster-sample-theme
* Domain Path: languages
@aaroneaton
aaroneaton / selector.php
Last active August 29, 2015 14:07
add theme to selector
<?php
function om_sample_add_lightbox_theme( $themes, $type ) {
// Let's make sure we're adding to the lightbox themes. If not, return early.
if ( 'lightbox' != $type ) {
return $themes;
}
$themes['sample'] = array(
'name' => __( 'Sample Theme', 'optin-monster-sample-themes' ),
@aaroneaton
aaroneaton / sample.php
Created September 30, 2014 22:04
theme class instance
<?php
function om_sample_lightbox_theme_api( $api, $theme, $optin_id, $type ) {
// Let's make sure we're adding to the lightbox themes. If not, return early.
if ( 'lightbox' != $type ) {
return $api;
}
// Also return if we're not using the Sample theme
if ( 'sample' != $theme ) {
@aaroneaton
aaroneaton / lightbox-sample.php
Last active August 29, 2015 14:07
Creating the theme class
<?php
class Optin_Monster_Lightbox_Theme_Sample extends Optin_Monster_Theme {
/**
* Path to the file.
*
* @var string
*/
public $file = __FILE__;
@aaroneaton
aaroneaton / lightbox-sample.php
Created October 2, 2014 14:09
optin wrapper
<?php
$provider = $this->get_email_setting( 'provider', '', false );
$html = '<div id="om-lightbox-sample-optin" class="om-lightbox-sample om-clearfix om-theme-sample' . ( $provider && 'custom' == $provider ? 'om-custom-html-form' : '' ) . '"';
$html .= '<div id="om-lightbox-theme-optin-wrap" class="om-clearfix">';
// Optin content will go here!
$html .= '</div>';
$html .= '</div>';
<?php
$html .= '<a href="#" class="om-close" title="' . esc_attr__( 'Close', 'optin-monster' ) . '">&times;</a>';