Skip to content

Instantly share code, notes, and snippets.


Mostafa Soufi mostafasoufi

Block or report user

Report or block mostafasoufi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
arubacao / latlong.php
Last active Jul 22, 2019
Latitude Longitude Regular Expression Validation PHP
View latlong.php
* Validates a given latitude $lat
* @param float|int|string $lat Latitude
* @return bool `true` if $lat is valid, `false` if not
function validateLatitude($lat) {
return preg_match('/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/', $lat);
theMikeD / acf.php
Last active Dec 19, 2018
Changes the folder where ACF loads and saves the JSON file to and from
View acf.php
add_filter('acf/settings/save_json', 'cnmd_set_acf_json_save_folder');
add_filter('acf/settings/load_json', 'cnmd_add_acf_json_load_folder');
* Set a new location to save ACF field group JSON
* @param string $path
* @return string
james2doyle / simple-json-reponse.php
Last active Aug 14, 2019
A simple JSON response function for PHP. Used in various PhileCMS plugins.
View simple-json-reponse.php
function json_response($message = null, $code = 200)
// clear the old headers
// set the actual code
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");
yaronguez / ACF Country List
Created Feb 17, 2015
Country list formatted for Advanced Custom Fields select dropdown
View ACF Country List
afghanistan : Afghanistan
albania : Albania
algeria : Algeria
american_samoa : American Samoa
andorra : Andorra
angola : Angola
anguilla : Anguilla
antigua_and_barbuda : Antigua and Barbuda
argentina : Argentina
armenia : Armenia
rileypaulsen / functions.php
Created Aug 19, 2014
Add Advanced Custom Fields Fields to the WP REST API
View functions.php
function wp_api_encode_acf($data,$post,$context){
$data['meta'] = array_merge($data['meta'],get_fields($post['ID']));
return $data;
if( function_exists('get_fields') ){
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3);
alexpchin /
Created Jun 1, 2014
Add Existing Project To Git Repo

#Adding an existing project to GitHub using the command line

Simple steps to add existing project to Github.

1. Create a new repository on GitHub.

In Terminal, change the current working directory to your local project.

##2. Initialize the local directory as a Git repository.

git init
amacgregor / UserSingleton.php
Last active Feb 2, 2019
PHP Singleton pattern example
View UserSingleton.php
/** Example taken from **/
class User
// Hold an instance of the class
private static $instance;
// The singleton method
reaneyk / gist:6604607
Created Sep 18, 2013
Example PHP Interface class
View gist:6604607
//Define a new Interface for all 'shapes' to inherit
interface Shape {
//Define the methods required for classes to implement
public function getColor();
public function setColor($color);
chrisdigital / Frontend user profile in WordPress
Created May 6, 2013
Setting up a editable user profile in WordPress on the frontend.
View Frontend user profile in WordPress
//How to edit a user profile on the front end?
//Forcing nickname as display_name in custom edit profile template
View plugin-class-demo.php
<?php # -*- coding: utf-8 -*-
* Plugin Name: Plugin Class Demo
* Description: How I am using the base class in plugins.
* Plugin URI:
* Version: 2012.09.29
* Author: Thomas Scholz
* Author URI:
* License: GPL
* Text Domain: plugin_unique_name
You can’t perform that action at this time.