-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,389 additions
and
747 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
.acf-field-hidden, .acf-field-latest-posts{ | ||
display: none; | ||
} | ||
.acf-field-hidden, .acf-field-latest-posts{ display: none; } | ||
.acf-field .acf-label:empty{ display: none } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,39 @@ | ||
.acf-fc-layout-handle .thumbnail{ | ||
position: relative; display: inline-block; width: 36px; margin-right: 15px; height: 15px; margin-bottom: -10px; cursor: zoom-in; | ||
position: relative; display: inline-block; width: 44px; margin-right: 15px; height: 15px; margin-bottom: -20px; margin-left: 2px; | ||
} | ||
|
||
.acf-fc-layout-handle .thumbnail .small{ | ||
position: absolute; left: 0; bottom: 0; width: 100%; border: 1px solid #ddd; padding: 3px; background: #fff; | ||
position: absolute; left: 0; bottom: 0; width: 100%; border: 1px solid #ddd; padding: 2px; background: #fff; | ||
} | ||
|
||
.acf-fc-layout-handle .thumbnail .large{ | ||
position: absolute; left: 0; bottom: 0; pointer-events: none; display: none; transform: translateY(50%); z-index: 999; | ||
border: 1px solid #ddd; padding: 5px; background: #fff; max-width: 60vw; height: auto; box-shadow: 0 0 10px rgba(0,0,0,0.08); | ||
border: 1px solid #ddd; padding: 5px; background: #fff; max-width:600px; height: auto; box-shadow: 0 0 10px rgba(0,0,0,0.08); | ||
} | ||
|
||
.acf-fc-layout-handle .thumbnail:hover .large{ display: block } | ||
|
||
|
||
.acf-fc-popup [data-layout]+span{ | ||
position: absolute; right: 100%; top: 50%; transform: translateY(-50%); display: none; margin-right: 10px; | ||
border: 1px solid #ddd; padding: 5px; background: #fff; max-width:600px; box-shadow: 0 0 10px rgba(0,0,0,0.08); | ||
} | ||
|
||
.acf-fc-popup [data-layout]+span:after{ | ||
width: 0; height: 0; border-style: solid; border-width: 7.5px 0 7.5px 8px; border-color: transparent transparent transparent #ffffff; | ||
position: absolute; left: 100%; top: 50%; margin-top: -5px; content: ''; z-index: 1; | ||
} | ||
|
||
|
||
.acf-fc-popup [data-layout]+span:before{ | ||
width: 0; height: 0; border-style: solid; border-width: 8.5px 0 8.5px 10px; border-color: transparent transparent transparent #ddd; | ||
position: absolute; left: 100%; top: 50%; margin-top: -5.5px; content: ''; z-index: 0; | ||
} | ||
|
||
.acf-fc-popup li:hover [data-layout]+span{ | ||
display: block; | ||
} | ||
.acf-fc-popup [data-layout]+span img{ max-width:600px; width: auto; height: auto; display: block } | ||
|
||
.postbox{ box-shadow: none } | ||
.postbox.closed .hndle{ border-bottom: 0 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
if( ! class_exists('acf_field_better_link') ) : | ||
|
||
class acf_field_better_link { | ||
|
||
|
||
/** | ||
* Whan saving link, store post_id and boolean to know if the link title is the post title | ||
* @param $value | ||
* @param int $post_id | ||
* @param array $field | ||
* @return mixed | ||
*/ | ||
public function updateValue($value, $post_id=0, $field=array()){ | ||
|
||
if( $field['type'] == 'link' && isset($value['url'])){ | ||
|
||
$value['post_id'] = url_to_postid($value['url']); | ||
|
||
if( $value['post_id'] ){ | ||
$title = get_the_title($value['post_id']); | ||
$value['is_title'] = $title == $value['title']; | ||
} | ||
elseif( isset($value['is_title']) ){ | ||
unset($value['is_title']); | ||
} | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
/** | ||
* On load, check if link and title still belong to the post_id, else update | ||
* @param $value | ||
* @param int $post_id | ||
* @param array $field | ||
* @return mixed | ||
*/ | ||
public function loadValue($value, $post_id=0, $field=array()){ | ||
|
||
if( $field['type'] == 'link' && isset($value['post_id']) && $value['post_id']){ | ||
|
||
$url = get_permalink($value['post_id']); | ||
$update = false; | ||
|
||
if( isset($value['is_title']) && $value['is_title'] ) { | ||
$value['title'] = get_the_title($value['post_id']); | ||
$update = true; | ||
} | ||
|
||
if( $url != $value['url']) { | ||
$value['url'] = $url; | ||
$update = true; | ||
} | ||
|
||
if($update){ | ||
acf_update_metadata( $post_id, $field['name'], $value ); | ||
acf_update_metadata( $post_id, $field['name'], $field['key'], true ); | ||
acf_flush_value_cache( $post_id, $field['name'] ); | ||
} | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
public function __construct() | ||
{ | ||
add_filter('acf/update_value', [$this, 'updateValue'], 10, 3); | ||
add_filter('acf/load_value', [$this, 'loadValue'], 10, 3); | ||
} | ||
} | ||
|
||
new acf_field_better_link(); | ||
|
||
endif; // class_exists check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
if( ! class_exists('acf_field_better_map') ) : | ||
|
||
class acf_field_better_map { | ||
|
||
/** | ||
* When saving map, save also country and iso | ||
* todo: move to js | ||
* @param $value | ||
* @param int $post_id | ||
* @param array $field | ||
* @return mixed | ||
*/ | ||
public function updateValue($value, $post_id=0, $field=array()){ | ||
|
||
if( $field['type'] == 'google_map' && isset($value['address']) && !empty($value['address']) ){ | ||
|
||
$google_api_key = acf_get_setting('google_api_key'); | ||
|
||
$url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='.$value['lat'].','.$value['lng'].'&sensor=false&key='.$google_api_key.'&result_type=country'; | ||
$data = json_decode(file_get_contents($url), true); | ||
|
||
if($data && isset($data['results']) && count($data['results']) ){ | ||
|
||
$result = $data['results'][0]; | ||
|
||
if( isset($result['address_components']) && count( $result['address_components'])){ | ||
|
||
$address = $result['address_components'][0]; | ||
|
||
$value['country'] = $address['long_name']; | ||
$value['iso'] = $address['short_name']; | ||
} | ||
} | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
/** | ||
* On load, check if country and iso exists else get it from google | ||
* @param $value | ||
* @param int $post_id | ||
* @param array $field | ||
* @return mixed | ||
*/ | ||
public function loadValue($value, $post_id=0, $field=array()){ | ||
|
||
if( $field['type'] == 'google_map' && isset($value['address']) && !empty($value['address']) && !isset($value['country'])){ | ||
|
||
$google_api_key = acf_get_setting('google_api_key'); | ||
|
||
$url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='.$value['lat'].','.$value['lng'].'&sensor=false&key='.$google_api_key.'&result_type=country'; | ||
$data = json_decode(file_get_contents($url), true); | ||
|
||
if($data && isset($data['results']) && count($data['results']) ){ | ||
|
||
$result = $data['results'][0]; | ||
|
||
if( isset($result['address_components']) && count( $result['address_components'])){ | ||
|
||
$address = $result['address_components'][0]; | ||
|
||
$value['country'] = $address['long_name']; | ||
$value['iso'] = $address['short_name']; | ||
|
||
acf_update_metadata( $post_id, $field['name'], $value ); | ||
acf_update_metadata( $post_id, $field['name'], $field['key'], true ); | ||
acf_flush_value_cache( $post_id, $field['name'] ); | ||
} | ||
} | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
public function __construct() | ||
{ | ||
add_filter('acf/update_value', [$this, 'updateValue'], 10, 3); | ||
add_filter('acf/load_value', [$this, 'loadValue'], 10, 3); | ||
} | ||
} | ||
|
||
new acf_field_better_map(); | ||
|
||
endif; // class_exists check |
Oops, something went wrong.