Skip to content

Instantly share code, notes, and snippets.

Avatar

Frankie Jarrett fjarrett

View GitHub Profile
@fjarrett
fjarrett / failed_login_attempts.php
Last active Aug 29, 2015
Adds a Failed Login Attempts action to the Users Connector
View failed_login_attempts.php
<?php
class WP_Stream_Connector_Failed_Login_Attempts extends WP_Stream_Connector_Users {
/**
* Actions registered for this connector
*
* @var array
*/
public static $actions = array(
@fjarrett
fjarrett / gist:3d5095fcfd39b55f639e
Last active Aug 29, 2015
Detect and format music chords in a document
View gist:3d5095fcfd39b55f639e
<?php
function fjarrett_format_chords( $content ) {
$new_content = null;
$pattern = '/\b[A-G](?:##?|bb?)?(?:min|m)?(?:maj|add|sus|aug|dim)?[0-9]*(?:\/[A-G](?:##?|bb?)?)?(?!\S)/';
// Iterate over each line in the document
foreach ( preg_split( '/((\r?\n)|(\r\n?))/', $content ) as $line ) {
// Find chords on this line
preg_match_all( $pattern, $line, $matches );
View keybase.md

Keybase proof

I hereby claim:

  • I am fjarrett on github.
  • I am fjarrett (https://keybase.io/fjarrett) on keybase.
  • I have a public key whose fingerprint is AA2E 1FEB F6D8 B4EC 26EA 0B1B 83E3 667D 96AF 72ED

To claim this, I am signing this object:

@fjarrett
fjarrett / .gitignore
Created Aug 9, 2014
Generic gitignore file for WP project repos
View .gitignore
# Env files #
###################
/www/wp-content/uploads/*
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
@fjarrett
fjarrett / comments.php
Last active Aug 29, 2015
Generic comments template
View comments.php
<?php
if ( post_password_required() ) {
return;
}
?>
<div id="comments">
<?php if ( have_comments() ) : ?>
@fjarrett
fjarrett / gist:e8cb7ee8a7012ec2ae7e
Created Sep 1, 2014
Alert original post author
View gist:e8cb7ee8a7012ec2ae7e
<?php
function ataylorme_alert_original_author( $post_id ) {
// Skip post revisions
if ( wp_is_post_revision( $post_id ) ) {
return;
}
// Get post data
$post = get_post( $post_id );
@fjarrett
fjarrett / gist:70d5ef34b527b54d1e7a
Created Sep 23, 2014
A Minimalist's Guide to WordPress Plugin Development
View gist:70d5ef34b527b54d1e7a
For some, the idea of writing a WordPress plugin is scary because there is so much that you can do with them, both good and bad. But plugins don't have to be complicated, there are some amazing things you can do with just a few lines!
In this session, we're going to examine just how simple a plugin can really be, and inspire one another to write more plugins, in less time, with less code.
@fjarrett
fjarrett / gist:12bd7b39b3efdd6d905e
Last active Aug 29, 2015
Stream record array filter example for John Sundberg
View gist:12bd7b39b3efdd6d905e
<?php
function bhww_filter_wp_stream_record_array( $recordarr ) {
if ( ! isset( $recordarr[0] ) ) {
return array();
}
// BackupBuddy (iThemes) entries
if (
'settings' === $recordarr[0]['connector']
@fjarrett
fjarrett / gist:1c4a5917fb180028d710
Last active Aug 29, 2015
Custom user registration via AJAX
View gist:1c4a5917fb180028d710
<?php
/**
* Process user registration via AJAX
*
* A custom user registration process that listens for a
* specific type POST request that will create a new user
* on the blog.
*
* @action wp_ajax_nopriv_fjarrett_user_registration
@fjarrett
fjarrett / gist:1c122226e56e6f352b4e
Last active Aug 29, 2015
Custom user registration form
View gist:1c122226e56e6f352b4e
<form method="post">
<p>
<label for="user_login">Username</label>
<input type="text" name="user_login" id="user_login" placeholder="Username" required>
</p>
<p>
<label for="user_pass">Password</label>
<input type="password" name="user_pass" id="user_pass" minlength="12" placeholder="Password" autocomplete="off" required>