Skip to content

Instantly share code, notes, and snippets.

View cbautista-dev's full-sized avatar

cbautista-dev

View GitHub Profile
/*=======================
Get the ID of default-language translation of any post. Note that currently this only works for 'post' type.
=========================*/
function get_default_post_ID( $post_ID )
{
global $wpdb;
// Get default language first
$options = get_option( 'icl_sitepress_settings' );
$default_language = $options['default_language'];
// Get 'trid' value for this post. Note the 'element_type'
<?php
// DLM
//
class RG_DLM {
public static function get_download($id) {
$cta = array();
<?php
/**
* @package _Plugin Name
* @version 1.6
*/
/*
Plugin Name: Name
Plugin URI: URI
Description: Description here.
Author: Chris Bautista
@cbautista-dev
cbautista-dev / geo_ip.php
Created May 22, 2016 17:14
GEOIP Function
function geoIp($ip = null) {
if ($ip == null) {
$ip = $_SERVER['REMOTE_ADDR'];
}
$geo_array = array();
$city = "";
$state = "";
$country = "";
function edebug() {
ini_set('display_errors', true);
error_reporting(E_ALL);
}
function vlog($v, $display = true) {
if ($display) {echo "<pre>";} else {echo "<!-- ";}
var_dump($v);
if ($display) {echo "</pre>";} else {echo " -->";}
}
@cbautista-dev
cbautista-dev / DOSCHEATSHEET
Created April 23, 2015 16:24
CHEAT: WINDOWS COMMAND LINE
x /? = provides syntax info and complete list of all parameters for x (a command, like “cd”)
cd = change directory
cd .. = move to the parent directory
cd\ = move to the root of current drive
cd x = move to the current\x directory
cd z: = change to the z root directory (as opposed to c:\)
copy x y = copy file x to directory y (Ex: D:\games\galaga.exe C:\programs[\awesome.exe]), [] = optional
copy file con = display file contents in console
copy con file.txt = create text file in the console window, end with ctrl+z (^z or F6)
date = change the date
@cbautista-dev
cbautista-dev / JS-GetComputedStyle.js
Created April 5, 2015 13:47
JS:GetComputedStyle
function getComputedStyle( dom ) {
var style;
var returns = {};
// FireFox and Chrome way
if(window.getComputedStyle){
style = window.getComputedStyle(dom, null);
for(var i = 0, l = style.length; i &lt; l; i++){
var prop = style[i];
var val = style.getPropertyValue(prop);
@cbautista-dev
cbautista-dev / .gitignore-sublimetext-nodejs
Created April 5, 2015 13:24
Git: .gitignore for node+sublimetext project
### Node ###
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
@cbautista-dev
cbautista-dev / ClassTemplate.js
Last active August 29, 2015 14:18
JS:ClassTemplate - prototype
//
// @Define
//
(function(){
"use strict";
function Class(){
this.variable = "";
}