Skip to content

Instantly share code, notes, and snippets.

View alexandrascript's full-sized avatar

Alexandra Klepper alexandrascript

View GitHub Profile
@alexandrascript
alexandrascript / gist:1aa752722956eb72ea9d
Last active August 29, 2015 14:20
WP Transients - Get Transient Data
// Get any existing copy of our transient data
if ( false === ( $special_query_results = get_transient( 'special_query_results' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$special_query_results = new WP_Query( 'cat=5&order=random&tag=tech&post_meta_key=thumbnail' );
set_transient( 'special_query_results', $special_query_results, 12 * HOUR_IN_SECONDS );
}
// Use the data like you would have normally...
if ( false === ( $sidebar_popular_chartbeat = get_transient( 'sidebar_popular_chartbeat' ) ) ) {
$sidebar_popular_chartbeat = wp_remote_get("http://api.chartbeat.com/live/toppages/v3/?apikey=XXXXX&host=yourwebsite.com");
set_transient( 'sidebar_popular_chartbeat', $sidebar_popular_chartbeat, 600 );
}
@alexandrascript
alexandrascript / gist:a6fcb0198e462946b004
Last active August 29, 2015 14:20
WP Transients - Chartbeat
$sidebar_popular_chartbeat = wnet_get_transient_remote_json('sidebar_popular_chartbeat', 'http://api.chartbeat.com/live/toppages/v3/?apikey=XXXXX&host=yourwebsite.com', 600);
@alexandrascript
alexandrascript / gist:c565c7faa55e54e8154a
Last active July 28, 2017 15:38
WP Transients - Full Transient Code
function wnet_get_transient_remote_json($transientname, $url, $interval=1800) {
// those are the same arguments as 'set_transient()'
$stalecachename = 'stalecache_' . $transientname;
// we generate a consistent name for the backup data
if ( false === ( $json = get_transient($transientname) ) ) {
$response = wp_remote_get($url);
// get the remote data as before, but this time...
<?php
/*
* Plugin Name: Theme Settings
* Version: 1
* Plugin URI: http://ieg.wnet.org/
* Description: Create a theme settings page
* Author: Alexandra White
* Author URI: http://ieg.wnet.org/blog/author/whitea/
* Requires at least: 3.6
* Tested up to: 4.2.2

⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜📈📜📜📩⛅😰📩📜📈⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜📝⛅😱🍰😱😰🐹⛅⛅⛅⛅📩📜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜📈🐹🚌😱😰😰🌓💌😱📝⛅😱🚌🙊🐵🚌⛅📜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜📜🐹📔😱😰😱🚌📦🍝🍝🐹🐹🚌🍮🐵🎊🚀📺🚌🎂⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜🐹🚌😱🌓😱🍝🍮🍱🔒🍝📦📦📦📦🍝🍝🍝🍱💼🍮😱📜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜📈🍰🍝🍰😱🚌🚌🍮🔒🐹😱😱📦📦🍝🚌📦🐹🍰🍝🍱🍱🍝🐹📜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜📈🍝🍝🍝🍮🍱🍮🍱🎊🍱🍰😱📦🍝🍝🍝🔒🚌🐹📦🍝🍧🍝🍝🚌😰⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜

@alexandrascript
alexandrascript / enqueue-scripts-on-wp.php
Last active March 15, 2017 18:40
Add scripts to WP
<?php
/** General add scripts **/
function adding_scripts_to_footer() {
// jQuery is already a part of the WP library. See: https://developer.wordpress.org/reference/functions/wp_enqueue_script/
wp_enqueue_script('jquery');
// Additional scripts, it's best to always register and then enqueue
wp_register_script('my_amazing_script', plugins_url('../js/amazing_script.js', _FILE_), array('jquery'), '1.1', true);
wp_enqueue_script('my_amazing_script');
@alexandrascript
alexandrascript / basic-website-html
Created August 8, 2017 18:36
Basic Website HTML
<!DOCTYPE html>
<html>
<head>
<title>My website</title>
<!-- Normalize -->
<link rel='stylesheet' id='main' href='css/normalize.css' type='text/css' media='all' />
<!-- Custom CSS -->
<link rel='stylesheet' id='main' href='css/style.css' type='text/css' media='all' />
</head>
/************************************************************
NORMALIZE CSS
Do not touch the CSS between these line breaks
**********************************************************/
/*! normalize.css v7.0.0 | MIT License */
button,hr,input{overflow:visible}audio,canvas,progress,video{display:inline-block}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,
@alexandrascript
alexandrascript / prometheus-sandbox.md
Last active December 18, 2017 14:40
Create an Ubuntu infrastructure sandbox and add Docker tools

Create a Prometheus instance within an infrastructure container

Get into your Triton environment

$ eval "$(triton env)"

Create an ubuntu infrastructure container