Skip to content

Instantly share code, notes, and snippets.

View devuri's full-sized avatar

uri devuri

  • Mexico
View GitHub Profile
@devuri
devuri / ecf-input-inc.php
Last active October 31, 2017 14:18
EASY CUSTOM FIELDS function (INPUT)
<?php
/*
* EASY CUSTOM FIELDS
* Input field
* EXAMPLE
* echo '<pre>'. ecf_input('email', 'Enter Your Email', 'InputName');
* echo ecf_input(); // defaults
* PARAMETERS
* @param string type
* @param string label
@devuri
devuri / newfunction.php
Created October 9, 2017 17:18
Author Credit
<?php
/*
* EASY CUSTOM FIELDS
* Input field
* EXAMPLE
* echo '<pre>'. ecf_input('email', 'Enter Your Email', 'InputName');
* echo ecf_input(); // defaults
* PARAMETERS
* @param string type
@devuri
devuri / url.php
Created October 9, 2017 17:37 — forked from cam-gists/url.php
PHP: Strict URL Validation
<?php
$url = 'http://example.com';
$validation = filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED);
if ( $validation )
{
$output = 'proper URL';
}
else
{
@devuri
devuri / post_meta_shortcode.php
Created October 13, 2017 16:10
a shortcode That Returns Post Meta (Custom Fields)
<?php
//https://wpexplorer-themes.com/total/snippets/meta-shortcode/
/**
* Returns a custom field value
*
* Usage [custom_field id="staff_position"]
*
* Available options... staff_position, staff_twitter, staff_facebook, staff_email...etc
@devuri
devuri / read-csv-array.php
Last active October 17, 2017 16:12
Read CSV to ARRAY
<?php
function get_csvarray($getcsvfile = 'test.csv'){
$row = 0;
$col = 0;
$gethandle = @fopen($getcsvfile, "r");
if ($gethandle) {
while (($row = fgetcsv($gethandle, 4096)) !== false) {
@devuri
devuri / remove files name
Created October 17, 2017 17:02
remove last 12 characters of a file name
You could use rename. From inside the directory:
rename -n 's/(.*).{12}/$1/' *
Remove -n after testing to actually rename the files. Replace {12} with {whatever number of characters you want to delete from the end of the name}
Explanation
s/old/new/' replaceoldwithnew`
@devuri
devuri / awesome-wp-config-file.php
Created October 19, 2017 15:31 — forked from ashfame/awesome-wp-config-file.php
awesome-wp-config-file
<?php
/**
* Define type of server
*
* Depending on the type other stuff can be configured
* Note: Define them all, don't skip one if other is already defined
*/
define( 'DB_CREDENTIALS_PATH', dirname( ABSPATH ) ); // cache it for multiple use
@devuri
devuri / wp-config.php
Created October 19, 2017 15:32 — forked from ifamily/wp-config.php
A universal WordPress wp-config.php which works on local development to staging and production server environments.
<?php
/*
One wp-config for local development to staging to production.
*/
// Define Environments
$environments = array(
@devuri
devuri / countries-array.php
Created October 21, 2017 08:33
Countries Array
<?php
$countries = array(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
@devuri
devuri / get-ip.php
Created October 21, 2017 08:37
get IP
<?php
function get_ip() {
$ip = '127.0.0.1';
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];