Skip to content

Instantly share code, notes, and snippets.

🖥
Focusing

Mostafa Soufi mostafasoufi

🖥
Focusing
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
arubacao / latlong.php
Last active Jul 22, 2019
Latitude Longitude Regular Expression Validation PHP
View latlong.php
<?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
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
<?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
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
<?php
function json_response($message = null, $code = 200)
{
// clear the old headers
header_remove();
// set the actual code
http_response_code($code);
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");
@yaronguez
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
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
alexpchin / Add_Existing_Project_To_Git.md
Created Jun 1, 2014
Add Existing Project To Git Repo
View Add_Existing_Project_To_Git.md

#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
amacgregor / UserSingleton.php
Last active Feb 2, 2019
PHP Singleton pattern example
View UserSingleton.php
<?php
/** Example taken from http://www.webgeekly.com/tutorials/php/how-to-create-a-singleton-class-in-php/ **/
class User
{
// Hold an instance of the class
private static $instance;
// The singleton method
@reaneyk
reaneyk / gist:6604607
Created Sep 18, 2013
Example PHP Interface class
View gist:6604607
<?php
//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
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?
//http://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-the-front-end
//Forcing nickname as display_name in custom edit profile template
//http://wordpress.stackexchange.com/questions/35403/forcing-nickname-as-display-name-in-custom-edit-profile-template
///////
<?php
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: http://toscho.de
* License: GPL
* Text Domain: plugin_unique_name
You can’t perform that action at this time.