Skip to content

Instantly share code, notes, and snippets.

// Get user IP in WordPress
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'];
@tarikcayir
tarikcayir / get_daft_posts.php
Created August 30, 2015 09:02
WP_Query get draft posts!
<?php
// Query args.
$args = array(
'post_type' => array( 'post', 'page' ),
'post_status' => 'draft'
);
$query = new WP_Query( $args );