Skip to content

Instantly share code, notes, and snippets.

View travismillerweb's full-sized avatar

Travis Miller travismillerweb

View GitHub Profile
@travismillerweb
travismillerweb / list-custom-post-type-posts-with-ajax.PHP
Created October 7, 2021 13:33 — forked from mikeschinkel/list-custom-post-type-posts-with-ajax.PHP
Shows how to create a widget with a dropdown list of posts for a given post type and then retrieve HTML specific to the selected post via AJAX to insert into the page.
<?php
/*
List_Custom_Post_Type_Posts_with_AJAX class.
Shows how to create a widget with a dropdown list of posts for a given post type and
then retrieve HTML specific to the selected post via AJAX to insert into the page.
Yes, the name of the class is insanely long in hopes that you'll be forced to think
about what would be a better name.
@travismillerweb
travismillerweb / SassMeister-input.scss
Created October 20, 2015 06:46
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$categories: (sell-sheets: #F1B261, trends-reports: #6BBCCF, insights: #A07BA8, recipe-cards: #91B97D, videos: #EA838C);
$properties: (text: color, bg: background-color, border: border-color);
@mixin category_theming($type) {
@each $label, $property in $properties {
<html>
<head></head>
<body>
<!-- NOTE: ?api=1 and player_id at the end of the URL -->
<iframe id="player" width="" height="" src="http://player.vimeo.com/video/62207569?api=1&player_id=player" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<script src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>
<script>
var player = $f(document.getElementById('player'));

PDO (PHP Data Objects)

######Cheat sheet for using PDO to interact with MySQL db's


Used to use MySQL then found out it was being depreciated, this is of course right after I got the hang of it and was almost finished with the project i was using to learn myself. So desided to make the switch to PDO way much easier especially if you have security in mind.

For instance instead of $var = mysql_real_escape_string($_POST['data'];, you just $var = $db->quote($_POST['data'];. Or even better use prepared staements and the underlying driver will not only escape but quote the string for you!

Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:

[
    { "keys": ["super+shift+l"],
      "command": "insert_snippet",
      "args": {
        "contents": "console.log(${1:}$SELECTION);${0}"
      }
 }
@travismillerweb
travismillerweb / headings-mixin.scss
Created October 14, 2014 15:00
SCSS - Sass Mixin for Headings
/*
SCSS - Sass Mixin for Headings
Reference Link: http://jsfiddle.net/jitendravyas/cxJtc/light/
Also Look at: http://www.elijahmanor.com/nested-maps-for-typesetting-in-sass/
*/
@mixin headings($from: 1, $to: 6){
@for $i from $from through $to{
@travismillerweb
travismillerweb / shortcode-custom-grid.php
Created October 7, 2014 15:05
PHP - Wordpress Shortcode Functions for Custom Sass Grid
<?php
// PHP - Wordpress Shortcode Functions for Custom Sass Grid
// A Working Shortcode Template for Custom Grid Layouts using Sass
/* =============================================================================
Row Block Shortcode
========================================================================== */
@travismillerweb
travismillerweb / detect-animation-end.js
Created September 16, 2014 12:18
JS - Detect Animation End
/*
Detect Animation End! (Thanks David Walsh)
Reference: http://davidwalsh.name/css-animation-callback
*/
/* From Modernizr */
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
@travismillerweb
travismillerweb / remove-empty-p.php
Created September 14, 2014 16:15
PHP - Remove Empty P Tags from WordPress
// Removes P Tags from the_content
// Reference Link: https://coderwall.com/p/vg-i0w
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
$content = force_balance_tags($content);
return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
}
@travismillerweb
travismillerweb / replace-text.css
Created September 11, 2014 18:56
CSS - Replace Text via CSS (Hack)
.class {
visibility:hidden;
color:white;
}
.class:before {
content: "[Replaced Content]";
color:black;
visibility:visible;
}