Initial commit: WordPress wp-content (themes, plugins, languages)
- Theme: momentry (custom theme with REST API routes) - Plugins: code-snippets (contains all API proxies) - Languages: zh_TW translations - Excludes: cache, backups, uploads, logs
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace WPForms\Vendor;
|
||||
|
||||
class Address
|
||||
{
|
||||
public $street;
|
||||
public $city;
|
||||
public function getGeoCoords()
|
||||
{
|
||||
$data = \file_get_contents('http://nominatim.openstreetmap.org/search?q=' . \urlencode($this->street) . ',' . \urlencode($this->city) . '&format=json&addressdetails=1');
|
||||
$json = \json_decode($data);
|
||||
return array('lat' => $json[0]->lat, 'lon' => $json[0]->lon);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace WPForms\Vendor;
|
||||
|
||||
class Contact
|
||||
{
|
||||
public $name;
|
||||
/**
|
||||
* @var Address
|
||||
*/
|
||||
public $address;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace WPForms\Vendor;
|
||||
|
||||
require_once __DIR__ . '/../src/JsonMapper.php';
|
||||
require_once 'Contact.php';
|
||||
require_once 'Address.php';
|
||||
$json = \json_decode(\file_get_contents(__DIR__ . '/single.json'));
|
||||
$mapper = new JsonMapper();
|
||||
$contact = $mapper->map($json, new Contact());
|
||||
$coords = $contact->address->getGeoCoords();
|
||||
echo $contact->name . ' lives at coordinates ' . $coords['lat'] . ',' . $coords['lon'] . "\n";
|
||||
Reference in New Issue
Block a user