Skip to content

Instantly share code, notes, and snippets.

💻
Fixing things

Jeffrey Pearce jeffikus

💻
Fixing things
Block or report user

Report or block jeffikus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jeffikus
jeffikus / example.js
Created Sep 8, 2015
Ajax Call to WP-API
View example.js
jQuery( function( $ ) {
$.ajax( {
url: 'http://wcct.dev/wp-json/wp/v2/posts?filter[order]=ASC&filter[category_name]=slides&filter[posts_per_page]=-1',
success: function ( data ) {
$.each( data, function( key, value ) {
urlstring = '';
if ( value.featured_image_thumbnail_url !== null ) {
urlstring = ' data-background="' + value.featured_image_thumbnail_url + '"';
}
View gist:1692931d8051ee267bc2

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.

View gist:b7ee8f385c8ac8ba40f5
<?php
/**
* I am adding this within a loop
**/
$current_user = wp_get_current_user();
// This is data that we get from the users profile, its auto-populated based on three fields.
$user_filter_criteria = get_field('user_filter_criteria', 'user_'. $current_user->ID);
@jeffikus
jeffikus / gist:ac62f41aecfdadf362b4
Created Feb 5, 2015
Multi Flexslider loader by class "myslider"
View gist:ac62f41aecfdadf362b4
<script type="text/javascript" charset="utf-8">
$(window).load(function() {
$('.myslider').each( function() {
$(this).flexslider({
directionNav: false,
smoothHeight: true
});
});
});
</script>
View woo.js
/*
* jQuery v1.9.1 included. Go allllll the way down
*/
$(document).ready(function() {
// Removes first 3 chars from Topics list - By Jeff Pearce
function setCharAt(str,index,chr) {
if(index > str.length-1) return str;
return str.substr(0,index) + chr + str.substr(index+1);
View gist:2fe1317fac638e8c3ab6
<?php
$wpdb->prepare( "SELECT post_title FROM $wpdb->posts WHERE ID = %d ", $ID );
$wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s ", 420, 'Europe' );
?>
View gist:7202d2d0a2b9b04c4b2b
<?php
// table, $where, $where_format
$wpdb->delete(
$wpdb->posts,
array(
'ID' => 5
),
array(
'%d'
)
View gist:3fa2f751515af3360316
<?php
// table, $data, $where, $format, $where_format
$wpdb->update(
$wpdb->postmeta,
array(
'meta_value' => 'false'
),
array(
'post_id' => 5,
'meta_key' => '_custom_meta_key',
View gist:98d9b6e5528d19c7f5f0
<?php
// table, $data, $format
$wpdb->insert(
$wpdb->postmeta,
array(
'post_id' => '5',
'meta_key' => '_custom_meta_key',
'meta_value' => 'true'
),
array(
View gist:c920cbcc1581b0d974d5
<?php
global $wpdb;
$ID = "'; SELECT * FROM wp_users WHERE 1 = '1";
$sql = "SELECT post_title from $wpdb->posts WHERE ID = '$ID';";
?>
You can’t perform that action at this time.