Skip to content

Instantly share code, notes, and snippets.

<?php
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
@retgef
retgef / regex-schtuff.txt
Created September 18, 2013 21:03
A basic, basic primer for regex and PHP.
_______ ______ __ _ ___ ___
|_ __ \ .' ____ \ [ | / |_ .' ..] .' ..]
| |__) | .---. .--./) .---. _ __ | (___ \_| .---. | |--. `| |-'__ _ _| |_ _| |_
| __ / / /__\\/ /'`\;/ /__\\[ \ [ ] _.____`. / /'`\] | .-. | | | [ | | |'-| |-''-| |-'
_| | \ \_| \__.,\ \._//| \__., > ' < | \____) || \__. | | | | | |, | \_/ |, | | | |
|____| |___|'.__.'.',__` '.__.'[__]`\_] \______.''.___.'[___]|__]\__/ '.__.'_/[___] [___]
( ( __))
---------------------------------------------------------------------------------------------------------------
@wokamoto
wokamoto / post_meta_transient.php
Last active June 16, 2016 16:36
[WordPress] post meta transient
<?php
/**
* Delete a post meta transient.
*/
function delete_post_meta_transient( $post_id, $transient, $value = null ) {
global $_wp_using_ext_object_cache;
$post_id = (int) $post_id;
do_action( 'delete_post_meta_transient_' . $transient, $post_id, $transient );
@retgef
retgef / pug-bomb.php
Created June 24, 2012 07:46
Pug Bomb API Endpoint WordPress Plugin
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{