Skip to content

Instantly share code, notes, and snippets.

View wordpress-nginx-flush-cache.php
<?php
/**
* Plugin Name: NGINX FastCGI cache purge
* Version: 0.1
* Description: Flush NGINX FastCGI cache purge
* Author: The Shipyard Crew
* Author URI: https://theshipyard.se/
* Plugin URI: https://theshipyard.se/
* Text Domain: nginx-fastcgi-cache-purge
@waqasy
waqasy / nginx.conf
Created Dec 20, 2016 — forked from jrom/nginx.conf
nginx hack for multiple conditions
View nginx.conf
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@waqasy
waqasy / in_array_r.php
Created Dec 28, 2016 — forked from iftee/in_array_r.php
Since in_array() doesn't work for multidimensional arrays, this recursive in_array_r() does the trick
View in_array_r.php
<?php
/* Check if an item $search_item is in the multidimensional array $items */
function in_array_r( $search_item, $items, $strict = false ) {
foreach ( $items as $item ) {
if ( ( $strict ? $item === $search_item : $item == $search_item ) || ( is_array( $item ) && in_array_r( $search_item, $item, $strict ) ) ) {
return true;
}
}
@waqasy
waqasy / jt-related-posts.php
Created Apr 24, 2017 — forked from jtallant/jt-related-posts.php
Related Posts Function for WordPress
View jt-related-posts.php
@waqasy
waqasy / gist:3be6fe13e9cfe6966959e72eed7825a6
Created Sep 1, 2017 — forked from jcobb/gist:2993853
Combine multiple WordPress queries
View gist:3be6fe13e9cfe6966959e72eed7825a6
<?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 );
}
@waqasy
waqasy / upload.php
Created Oct 19, 2017 — forked from codingjester/upload.php
Working PHP example of uploading a photo with V2 api
View upload.php
<?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 / Version 1 (with static data).cs
Created Oct 26, 2017 — forked from DinisCruz/Version 1 (with static data).cs
O2 Script - Send data to Google Analytics via get request (of Image)
View Version 1 (with static data).cs
//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 / custom-search-acf-wordpress.php
Created May 18, 2018 — 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
View custom-search-acf-wordpress.php
<?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 / custom-search-acf-wordpress.php
Created May 18, 2018 — 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().
View custom-search-acf-wordpress.php
<?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 / simpleimage.php
Created May 21, 2018 — forked from miguelxt/simpleimage.php
SimpleImage PHP Class
View simpleimage.php
<?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