Skip to content

Instantly share code, notes, and snippets.

View onigetoc's full-sized avatar

Gino onigetoc

View GitHub Profile
/**
* Hide the addressbar on ios & android devices
* https://gist.github.com/yckart/5609969
*
* Based on the work from Nate Smith
* @see https://gist.github.com/nateps/1172490
*
* Copyright (c) 2013 Yannick Albert (http://yckart.com)
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
* 2013/05/20
@onigetoc
onigetoc / wp-api-user-meta.php
Last active April 24, 2016 03:44 — forked from scottopolis/wp-api-user-meta.php
Add user meta to the WP-API
<?php
/* Adds all user meta to the /wp-json/wp/v2/user/[id] endpoint */
function sb_user_meta( $data, $field_name, $request ) {
if( $data['id'] ){
$user_meta = get_user_meta( $data['id'] );
}
if ( !$user_meta ) {
return new WP_Error( 'No user meta found', 'No user meta found', array( 'status' => 404 ) );
}
@onigetoc
onigetoc / 0_reuse_code.js
Created July 22, 2016 07:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@onigetoc
onigetoc / oembed-in-comments.php
Created August 1, 2016 00:50 — forked from sheabunge/oembed-in-comments.php
Allows the use of oEmbed in WordPress comments
<?php
/**
* Plugin Name: oEmbed in Comments
* Description: Allow oEmbeds in comment text. A fork of http://wordpress.org/plugins/oembed-in-comments/
* Version: 1.2
* Author: Evan Solomon, modified by Shea Bunge
*/
class oEmbed_Comments {
@onigetoc
onigetoc / remote-image-cache.php
Created October 31, 2016 02:27 — forked from ScottPhillips/remote-image-cache.php
Cache remote image using PHP
<?php
function cache_image($image_url){
//replace with your cache directory
$image_path = 'path/to/cache/dir/';
//get the name of the file
$exploded_image_url = explode("/",$image_url);
$image_filename = end($exploded_image_url);
$exploded_image_filename = explode(".",$image_filename);
$extension = end($exploded_image_filename);
//make sure its an image
@onigetoc
onigetoc / php-regex-favicon.php
Created November 1, 2016 16:09
How to PHP regex match an HTML document's declared favicon
<?php
function parseFavicon($html) {
// Get the 'href' attribute value in a <link rel="icon" ... />
// Also works for IE style: <link rel="shortcut icon" href="http://www.example.com/myicon.ico" />
// And for iOS style: <link rel="apple-touch-icon" href="somepath/image.ico">
$matches = array();
// Search for <link rel="icon" type="image/png" href="http://example.com/icon.png" />
preg_match('/<link.*?rel=("|\').*icon("|\').*?href=("|\')(.*?)("|\')/i', $html, $matches);
if (count($matches) > 4) {
@onigetoc
onigetoc / get_hot_tag.html
Created December 1, 2016 08:34 — forked from hideokamoto/get_hot_tag.html
Get Plugin-Data fromWordPress.org API
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div class="wp_org_api"></div>
<script>
//setUp Post Data
var actionType = 'hot_tags';
var number = 10;
var timeout = 15;
//Parse Post Data
var postData = {
<?php
/**
* get_columns_array
*
* Columns for the loop, single function interface (limited)
*
* Copyright (c) 2011 hakre <http://hakre.wordpress.com/>, some rights reserved
*
* USAGE:
@onigetoc
onigetoc / remove-billing.php
Created January 3, 2017 16:04 — forked from jgalea/remove-billing.php
Remove billing details from WooCommerce checkout.
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
@onigetoc
onigetoc / autoembed-example.php
Created January 24, 2017 01:19 — forked from joshhartman/autoembed-example.php
AutoEmbed PHP Class to parse a string for URLs on their own line and use oEmbed to embed remote content based on the URL
<!DOCTYPE html>
<html>
<head>
<title>AutoEmbed Examples</title>
</head>
<body>
<h1>AutoEmbed Examples</h1>
<?php
$content = "
<p>Have a laugh...</p>