Skip to content

Instantly share code, notes, and snippets.

View jcicero518's full-sized avatar

Jeff Cicero jcicero518

View GitHub Profile
@jcicero518
jcicero518 / WPConnection.php
Last active March 11, 2019 19:36
WPDB Abstraction
<?php
use Exception;
/**
* Class Connection
*
* Adds a layer of abstraction over WP's $wpdb global for
* DB operations
*
* @package Manager\WPDatabase
@jcicero518
jcicero518 / usortwp.php
Created November 10, 2017 20:02
PHP usort for WP total posts per author
<?php
function sort_objects_by_total($a, $b) {
if($a->total_posts == $b->total_posts){ return 0 ; }
return ($a->total_posts < $b->total_posts) ? -1 : 1;
}
// The function returns -1 (smaller than), 0 (equal to), or 1 (larger than)
// when doing the sort comparisons. The last is applying the sortation
// function to the array, which is done by usort:
usort($users, 'sort_objects_by_total');
<?php
/**
* mwcc Theme Customizer
*
* @package mwcc
*/
if ( class_exists( 'WP_Customize_Control' ) ):
class WP_Customize_Alert_Post_Control extends WP_Customize_Control {
@jcicero518
jcicero518 / 1) Main.blade.php
Created December 5, 2017 23:47 — forked from jacurtis/1) Main.blade.php
Laravel 5.4 Components & Slots
<!-- This is the main Blade file that you want your components to show up in -->
<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<?php
**
* Parse file size
*
* @param string $size File size
* @param string $default Default size
* @return string
*/
function ai1wm_parse_size( $size, $default = null ) {
$suffixes = array(
@jcicero518
jcicero518 / react-file-upload.js
Created February 10, 2018 19:36 — forked from AshikNesin/react-file-upload.js
Simple React File Upload
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
super(props);
this.state ={
file:null
}
@jcicero518
jcicero518 / appEntryPoint.js
Created March 20, 2018 16:52 — forked from markerikson/appEntryPoint.js
Webpack React/Redux Hot Module Reloading (HMR) example
import React from "react";
import ReactDOM from "react-dom";
import configureStore from "./store/configureStore";
const store = configureStore();
const rootEl = document.getElementById("root");
<h2>Craft Beers</h2>
<p>Doghead Superfish</p>
<h2>Summer Wine</h2>
<p>Red</p>
import React, { Fragment } from "react";
render() {
return (
<Fragment>
<h2>Craft Beers</h2>
<p>Doghead Superfish</p>
<h2>Summer Wine</h2>
<p>Red</p>
</Fragment>
render() {
return (
<h2>Craft Beers</h2>
<p>Doghead Superfish</p>
<h2>Summer Wine</h2>
<p>Red</p>
)
}