Skip to content

Instantly share code, notes, and snippets.

View onigetoc's full-sized avatar

Gino onigetoc

View GitHub Profile
<div class="wpuf-attachment-upload-filelist" data-type="file" data-required="yes">
<a id="wpuf-featured_image-pickfiles" data-form_id="61" class="button file-selector wpuf_featured_image_61" href="#" style="position: relative; z-index: 1; display: none;">Select Image</a>
<ul class="wpuf-attachment-list thumbnails">
<li class="wpuf-image-wrap thumbnail">
<div class="attachment-name"><img src="http://example.com/wp-content/uploads/2016/07/1400x1400_10808553-400x4001-1-150x150.jpg" alt="1400x1400_10808553-400x400[1]"></div>
<input type="hidden" name="wpuf_files[featured_image][]" value="100">
<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="100">Delete</a></div>
</li>
</ul>
@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 / How to use Readme.js
Last active July 23, 2016 06:27
readme.js | jQuery Readability plugin | Show web page content with the Readability API
// HOW TO USE
$('#target').readme({
url: readurl,
strip_tags: true, // default true: OPTIONAL
featured_image: true // default true: OPTIONAL
});
// HOW TO USE: SIMPLE
$('#target').readme({ url: readurl});
<?php
header('Content-Type: application/json; charset=utf-8');
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
include '../src/autoloader.php';
function get($name, $default = '')
{
@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 / pastekeyupsubmit.js
Created August 3, 2016 15:27
Better - on Paste, keyup, input, submit
jQuery(function($) {
var $input = $('#get_url');
$input.data('curr_val', $input.val()); //sets initial value
var count = 0;
setInterval(function() {
if ($input.data('curr_val') == $input.val()) //if it still has same value
return false; //returns false
$input.data('curr_val', $input.val()); //if val is !=, updates it and
//do your stuff
<?php
/*
Plugin Name: Readme Parser
Plugin URI: http://www.tomsdimension.de/wp-plugins/readme-parser
Description: Loads and formats (a little) readme files [readme-parser url="http://www.xyz.com/readme.txt"]
Version: 0.3
Author: Tom Braider
Author URI: http://www.tomsdimension.de
*/
<?php
echo "<h2>Get Domain and Base URL</h2>";
echo "- Example 1<br>";
$url = "https://francais.rt.com/international";
echo getBaseUrl($url) ;
echo "<br>- Example 2<br>";
echo getBaseUrl("https://techcrunch.com/2016/10/23/honeycombtv/?ncid=rss") ;
echo "<br>- Get Domain Only<br>";
echo getDomain("https://techcrunch.com/2016/10/23/honeycombtv/?ncid=rss") ;
<?php
//Write your PHP code here
$url = "http://stackoverflow.com/questions/6240414/add-http-prefix-to-url-when-missing";
$scheme = parse_url($url, PHP_URL_SCHEME);
if (empty($scheme)) {
$url = 'http://' . ltrim($url, '/');
}
$urlnohttp = preg_replace("(^https?://)", "", $url );
@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) {