Skip to content

Instantly share code, notes, and snippets.

@waqasy
waqasy / handle_file_upload.php
Created May 23, 2018 03:56 — forked from ebidel/handle_file_upload.php
Uploading files using xhr.send(FormData) to PHP server
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@waqasy
waqasy / handle_file_upload.php
Created May 23, 2018 03:44 — forked from ladyquartermaine/handle_file_upload.php
Uploading files using xhr.send(FormData) to PHP server
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@waqasy
waqasy / index.html
Created May 23, 2018 03:35 — forked from poeticninja/index.html
base64 to file blob, very basic example.
<!doctype html>
<html>
<head>
<title>File Upload Page</title>
</head>
<body>
<h1 onClick="sendFormData()">Send it!</h1>
<script type="text/javascript">
@waqasy
waqasy / remove-feeds.php
Created May 22, 2018 06:54 — forked from chrisguitarguy/remove-feeds.php
Remove all feeds from WordPress
<?php
/*
Plugin Name: Remove All Feeds [for WPSE33072]
Description: Remove all feeds from WordPress
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2
*/
@waqasy
waqasy / simpleimage.php
Created May 21, 2018 10:56 — forked from miguelfrmn/simpleimage.php
SimpleImage PHP Class
<?php
/**
* File: SimpleImage.php
* Author: Simon Jarvis
* Modified by: Miguel Fermín
* Based in: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@waqasy
waqasy / custom-search-acf-wordpress.php
Created May 18, 2018 05:55 — forked from felthy/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request. Updated to use wpdb prepare() and esc_like().
<?php
/*
##############################
########### Search ###########
##############################
Included are steps to help make this script easier for other to follow
All you have to do is add custom ACF post types into Step 1 and custom taxonomies into Step 10
[list_searcheable_acf list all the custom fields we want to include in our search query]
@return [array] [list of custom fields]
@waqasy
waqasy / custom-search-acf-wordpress.php
Created May 18, 2018 05:47 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
@waqasy
waqasy / Version 1 (with static data).cs
Created October 26, 2017 21:09 — forked from DinisCruz/Version 1 (with static data).cs
O2 Script - Send data to Google Analytics via get request (of Image)
//descriptions from http://www.lunametrics.com/blog/2011/10/04/utmgif-request-parameters/
var utmwv = "5.3.8"; // Tracking code version
var utms = "1"; // Session requests. Updates every time a __utm.gif request is made. Stops incrementing at 500 (max number of GIF requests per session).
var utmn = "1797201820"; // Unique ID generated for each GIF request to prevent caching of the GIF image
var utmhn = "teammentor-33-ci"; // Host name, which is a URL-encoded string
var utmcs = "ISO-8859-1"; // Language encoding for the browser. Some browsers don’t set this, in which case it is set to “-”
var utmsr = "1440x852"; // Screen resolution
var utmvp = "1440x751"; // Size of Viewing Pane
var utmsc = "32-bit"; // Screen color depth
var utmul = "en-us"; // Browser language
@waqasy
waqasy / upload.php
Created October 19, 2017 07:38 — forked from codingjester/upload.php
Working PHP example of uploading a photo with V2 api
<?php
#Requires PHP 5.3.0
define("CONSUMER_KEY", "consumer_key");
define("CONSUMER_SECRET", "consumer_secret");
define("OAUTH_TOKEN", "access_token");
define("OAUTH_SECRET", "access_secret");
function oauth_gen($method, $url, $iparams, &$headers) {
@waqasy
waqasy / gist:3be6fe13e9cfe6966959e72eed7825a6
Created September 1, 2017 14:59 — forked from jcobb/gist:2993853
Combine multiple WordPress queries
<?php
// An example of creating two separate WP queries, combining the results,
// sorting by date and formatting the results for us in a loop like a regular query.
// order the posts by date in descending order (should go in functions.php to keep things tidy)
function order_by_date( $a, $b )
{
return strcmp( $b->post_date, $a->post_date );
}