Skip to content

Instantly share code, notes, and snippets.

View LateButEarly's full-sized avatar
💭
Gas so high, I didn't get far.

LateButEarly LateButEarly

💭
Gas so high, I didn't get far.
View GitHub Profile
@LateButEarly
LateButEarly / gravity-form-upload-as-attachment.php
Created October 3, 2014 18:26
Gravity Form upload as attachment
// gform_notification_FORMID, custom_function
add_filter('gform_notification_1', 'gfuaa_upload_attachment', 10, 3);
// http://gravityformspdfextended.com/topic/file-upload-as-attachments/
function gfuaa_upload_attachment( $notification, $form, $entry ) {
//There is no concept of user notifications anymore, so we will need to target notifications based on other criteria, such as name
if($notification["name"] == "Admin Notification"){
$fileupload_fields = GFCommon::get_fields_by_type($form, array("fileupload"));
@LateButEarly
LateButEarly / setup-cron
Created November 3, 2014 22:33
Setup Cron to force onTransientUpdate to check hourly
/**
* Building Cron-based hook to run periodic update checks and inject update info
* into WP data structures.
*/
public function setupCron(){
if ( $this->enableAutomaticChecking ) {
if ( !wp_next_scheduled('onTransientUpdate') ) {
wp_schedule_event(time(), 'hourly', array($this, 'onTransientUpdate'));
}
} else {
server {
server_name domain.com;
listen 443 ssl spdy;
root /home/webmaster/www/domain.com;
index index.php index.html;
# SSL configuration
ssl_certificate /home/webmaster/certs/domain.com.crt;
ssl_certificate_key /home/webmaster/certs/domain.com.key;
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=Nginx:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
listen 80;
server_name nginx.dev;
access_log /var/log/nginx/nginx.access.log;
root /var/www/nginx.dev/public/;
index index.html index.php;
<?php
/*
Plugin Name: GGA SSH2 Sample
Description: Sample SSH2 upload
Author: Pete Nelson (@GunGeekATX)
Version: 1.0
*/
if (!defined( 'ABSPATH' )) exit('restricted access');
@LateButEarly
LateButEarly / createComment
Created March 17, 2015 01:00
please create a comment D:
$scope.createComment = function() {
// Attach current Article Object
var article = $scope.article;
// Create new Comment object
var comment = new Comments ({
body: this.body
});
@LateButEarly
LateButEarly / testing-createComment
Created March 17, 2015 16:50
working on comment creation
/**
* Create a new Comment
*/
exports.create = function(req, res) {
var comment = new Comment(req.body);
comment.poll = req.poll._id;
// if user
@LateButEarly
LateButEarly / article.server.model.js
Last active June 10, 2016 03:09
working on comment creation v2
'use strict';
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
/**
* Article Schema
@LateButEarly
LateButEarly / mongodb.js
Created April 10, 2015 22:34
mongodb example for csc200
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var Cat = mongoose.model('Cat', { name: String });
var kitty = new Cat({ name: 'Zildjian' });
kitty.save(function (err) {
if (err)
console.log('meow');
});
@LateButEarly
LateButEarly / woocommerce-check-admin-access.php
Last active August 29, 2015 14:20
WooCommerce Role Redirect
add_filter( 'woocommerce_prevent_admin_access', 'sfwd_check_admin_access' );
function sfwd_check_admin_access( $redirect_to ) {
$user = wp_get_current_user();
$allowed_roles = array ( 'administrator', 'group_leader' );
if( is_array( $user->roles ) && in_array( $allowed_roles[0] , $user->roles ) || in_array( $allowed_roles[1] , $user->roles ) ) {
return false;
}