Skip to content

Instantly share code, notes, and snippets.

View kebase.md

Keybase proof

I hereby claim:

  • I am aaroneaton on github.
  • I am aaroneaton (https://keybase.io/aaroneaton) on keybase.
  • I have a public key whose fingerprint is D1D5 4ACA C40F E038 52C3 4307 F38C 5B43 ED0A E121

To claim this, I am signing this object:

View component.js
class MyComponent extends React.Component {
...
render() {
return (
<div className="parent">
<div className="child" ref={el => this.targetEl = el}>Content Here</div>
</div>
)
}
...
@aaroneaton
aaroneaton / disable-comments.php
Created Jan 4, 2017
Disables comments on all pages
View disable-comments.php
<?php // Remove this line
// Disable comments on all pages
add_action( 'init', function() {
remove_post_type_support( 'page', 'comments' );
}, 100 );
@aaroneaton
aaroneaton / phpspec-setup.php
Last active Sep 16, 2016
Using WP_Mock with PhpSpec
View phpspec-setup.php
<?php
class TodoSpec extends ObjectBehavior {
public function let() {
\WP_Mock::setUp();
}
public function letGo() {
\WP_Mock::tearDown();
}
@aaroneaton
aaroneaton / om-editor.php
Created Aug 28, 2015
Allow editors to use the OptinMonster admin area
View om-editor.php
<?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';
View foundation-genesis-layouts.scss
// Change the column widths to match your site
@media #{$large-up} {
.content-sidebar .content-sidebar-wrap {
main {
@include grid-column(9);
}
aside.sidebar-primary {
@include grid-column(3);
}
@aaroneaton
aaroneaton / track-optinmonster.js
Created Jun 15, 2015
Manually tracking OptinMonster impressions & conversions
View track-optinmonster.js
$(document).on('OptinMonsterOnShow', function(event, props, object) {
object.trackGoogleAnalytics('ga-[your-optin-slug]', 'impression');
});
$(document).on('OptinMonsterOptinSuccess', function(event, props, object) {
object.trackGoogleAnalytics('ga-[your-optin-slug]', 'conversion');
});
@aaroneaton
aaroneaton / Navigation.php
Last active Mar 7, 2017
Using the Zurb Foundation Top Bar with WordPress menus
View Navigation.php
<?php
class Navigation {
public function __construct() {
// Move the navigation to the header element
remove_action( 'genesis_after_header', 'genesis_do_nav' );
remove_action( 'genesis_site_title', 'genesis_seo_site_title' );
// remove_action( 'genesis_header', )
View track-mo-conversion.js
<script type="text/javascript">
// We want to store a global reference to the proper optin object to make use of tracking methods.
var om_ref;
jQuery(document).ready(function($){
// Gain access once the entire object is loaded.
$(document).on('OptinMonsterLoaded', function(e, props, obj){
// Replace jshdgfgshf with the unique optin slug you want to target.
if ( 'uv7nlvrd513vds1n' == obj.getProp('optin') ) {
om_ref = obj;
}
View gist:3d511b27ec063c2888b2
<?php
add_filter( 'optin_monster_api_output', 'tgm_om_filter_lightbox_by_tag', 10, 4 );
function tgm_om_filter_lightbox_by_tag( $optins, $optin, $fields, $post_id ) {
// If in a particular tag, remove the lightbox.
$cat_exc = 362; // Replace with the tag ID to target.
$slug = 'sjdfhsjakdkg'; // Replace with the unique slug for the lightbox you want to remove.
$tags = wp_get_object_terms( $post_id, 'post_tag', array( 'fields' => 'ids' ) );
foreach ( (array) $tags as $tag_id ) {
if ( $tag_id && $tag_id == $cat_exc && in_array( $slug, $optins ) ) {