Version Description
- Updating ACF4
- Adding support for Inbound Forms without redirect URLs (no ajax)
Download this release
Release Info
Developer | adbox |
Plugin | WordPress Landing Pages |
Version | 2.3.3 |
Comparing to | |
See all releases |
Code changes from version 2.3.2 to 2.3.3
- landing-pages.php +2 -2
- readme.txt +3 -2
- shared/assets/plugins/advanced-custom-fields/acf.php +58 -34
- shared/assets/plugins/advanced-custom-fields/core/api.php +276 -276
- shared/assets/plugins/advanced-custom-fields/core/controllers/addons.php +4 -4
- shared/assets/plugins/advanced-custom-fields/core/controllers/everything_fields.php +30 -13
- shared/assets/plugins/advanced-custom-fields/core/controllers/field_group.php +3 -1
- shared/assets/plugins/advanced-custom-fields/core/controllers/field_groups.php +1 -1
- shared/assets/plugins/advanced-custom-fields/core/controllers/revisions.php +3 -3
- shared/assets/plugins/advanced-custom-fields/core/fields/date_picker/date_picker.php +1 -1
- shared/assets/plugins/advanced-custom-fields/core/fields/file.php +1 -1
- shared/assets/plugins/advanced-custom-fields/core/fields/google-map.php +46 -0
- shared/assets/plugins/advanced-custom-fields/core/fields/image.php +1 -1
- shared/assets/plugins/advanced-custom-fields/core/fields/relationship.php +1 -7
- shared/assets/plugins/advanced-custom-fields/core/fields/select.php +1 -1
- shared/assets/plugins/advanced-custom-fields/core/fields/text.php +1 -1
- shared/assets/plugins/advanced-custom-fields/core/fields/textarea.php +1 -1
- shared/assets/plugins/advanced-custom-fields/core/fields/wysiwyg.php +2 -1
- shared/assets/plugins/advanced-custom-fields/css/field-group.css +3 -1
- shared/assets/plugins/advanced-custom-fields/css/input.css +8 -3
- shared/assets/plugins/advanced-custom-fields/images/add-ons/cf7-field-thumb.jpg +0 -0
- shared/assets/plugins/advanced-custom-fields/images/add-ons/date-time-field-thumb.jpg +0 -0
- shared/assets/plugins/advanced-custom-fields/images/add-ons/flexible-content-field-thumb.jpg +0 -0
- shared/assets/plugins/advanced-custom-fields/images/add-ons/gallery-field-thumb.jpg +0 -0
- shared/assets/plugins/advanced-custom-fields/images/add-ons/google-maps-field-thumb.jpg +0 -0
- shared/assets/plugins/advanced-custom-fields/images/add-ons/gravity-forms-field-thumb.jpg +0 -0
- shared/assets/plugins/advanced-custom-fields/images/add-ons/options-page-thumb.jpg +0 -0
- shared/assets/plugins/advanced-custom-fields/images/add-ons/repeater-field-thumb.jpg +0 -0
- shared/assets/plugins/advanced-custom-fields/js/field-group.js +78 -10
- shared/assets/plugins/advanced-custom-fields/js/field-group.min.js +1 -8
- shared/assets/plugins/advanced-custom-fields/js/input.js +221 -126
- shared/assets/plugins/advanced-custom-fields/js/input.min.js +2 -2
- shared/assets/plugins/advanced-custom-fields/js/input/_listener.js +0 -0
- shared/assets/plugins/advanced-custom-fields/js/input/_listener.min.js +0 -0
- shared/assets/plugins/advanced-custom-fields/js/input/acf.js +942 -0
- shared/assets/plugins/advanced-custom-fields/js/input/ajax.js +325 -0
- shared/assets/plugins/advanced-custom-fields/js/input/color-picker.js +79 -0
- shared/assets/plugins/advanced-custom-fields/js/input/date-picker.js +134 -0
- shared/assets/plugins/advanced-custom-fields/js/input/file.js +410 -0
- shared/assets/plugins/advanced-custom-fields/js/input/google-map.js +566 -0
- shared/assets/plugins/advanced-custom-fields/js/input/image.js +447 -0
- shared/assets/plugins/advanced-custom-fields/js/input/radio.js +70 -0
- shared/assets/plugins/advanced-custom-fields/js/input/relationship.js +361 -0
- shared/assets/plugins/advanced-custom-fields/js/input/tab.js +280 -0
- shared/assets/plugins/advanced-custom-fields/js/input/validation.js +432 -0
- shared/assets/plugins/advanced-custom-fields/js/input/wysiwyg.js +556 -0
- templates/simple-solid-lite/config.php +0 -18
landing-pages.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Landing Pages
|
4 |
Plugin URI: http://www.inboundnow.com/landing-pages/
|
5 |
Description: Landing page template framework with variant testing and lead capturing through cooperation with Inbound Now's Leads plugin. This is the stand alone version served through WordPress.org.
|
6 |
-
Version: 2.3.
|
7 |
Author: Inbound Now
|
8 |
Author URI: http://www.inboundnow.com/
|
9 |
|
@@ -37,7 +37,7 @@ if (!class_exists('Inbound_Landing_Pages_Plugin')) {
|
|
37 |
*/
|
38 |
private static function load_constants() {
|
39 |
|
40 |
-
define('LANDINGPAGES_CURRENT_VERSION', '2.3.
|
41 |
define('LANDINGPAGES_URLPATH', plugins_url( '/' , __FILE__ ) );
|
42 |
define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
43 |
define('LANDINGPAGES_PLUGIN_SLUG', 'landing-pages' );
|
3 |
Plugin Name: Landing Pages
|
4 |
Plugin URI: http://www.inboundnow.com/landing-pages/
|
5 |
Description: Landing page template framework with variant testing and lead capturing through cooperation with Inbound Now's Leads plugin. This is the stand alone version served through WordPress.org.
|
6 |
+
Version: 2.3.3
|
7 |
Author: Inbound Now
|
8 |
Author URI: http://www.inboundnow.com/
|
9 |
|
37 |
*/
|
38 |
private static function load_constants() {
|
39 |
|
40 |
+
define('LANDINGPAGES_CURRENT_VERSION', '2.3.3' );
|
41 |
define('LANDINGPAGES_URLPATH', plugins_url( '/' , __FILE__ ) );
|
42 |
define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
43 |
define('LANDINGPAGES_PLUGIN_SLUG', 'landing-pages' );
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
7 |
Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
|
8 |
Requires at least: 3.8
|
9 |
Tested up to: 4.6.0
|
10 |
-
Stable Tag: 2.3.
|
11 |
|
12 |
Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
|
13 |
|
@@ -70,7 +70,8 @@ The plugin is also fully extendable and has a number of actions, filters, and ho
|
|
70 |
|
71 |
== Changelog ==
|
72 |
|
73 |
-
= 2.3.
|
|
|
74 |
* Adding support for Inbound Forms without redirect URLs (no ajax)
|
75 |
|
76 |
= 2.2.9 =
|
7 |
Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
|
8 |
Requires at least: 3.8
|
9 |
Tested up to: 4.6.0
|
10 |
+
Stable Tag: 2.3.3
|
11 |
|
12 |
Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
|
13 |
|
70 |
|
71 |
== Changelog ==
|
72 |
|
73 |
+
= 2.3.3 =
|
74 |
+
* Updating ACF4
|
75 |
* Adding support for Inbound Forms without redirect URLs (no ajax)
|
76 |
|
77 |
= 2.2.9 =
|
shared/assets/plugins/advanced-custom-fields/acf.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://www.advancedcustomfields.com/
|
5 |
Description: Customise WordPress with powerful, professional and intuitive fields
|
6 |
-
Version: 4.4.
|
7 |
Author: Elliot Condon
|
8 |
Author URI: http://www.elliotcondon.com/
|
9 |
License: GPL
|
@@ -43,7 +43,7 @@ class acf
|
|
43 |
'path' => apply_filters('acf/helpers/get_path', __FILE__),
|
44 |
'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
|
45 |
'hook' => basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ),
|
46 |
-
'version' => '4.4.
|
47 |
'upgrade_version' => '3.4.1',
|
48 |
'include_3rd_party' => false
|
49 |
);
|
@@ -159,42 +159,63 @@ class acf
|
|
159 |
* @return {mixed} $post_id
|
160 |
*/
|
161 |
|
162 |
-
function get_post_id( $post_id )
|
163 |
-
|
164 |
-
//
|
165 |
-
if( !$post_id )
|
166 |
-
{
|
167 |
-
global $post;
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
|
|
173 |
}
|
174 |
|
175 |
|
176 |
-
//
|
177 |
-
if( $post_id
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
// object
|
184 |
-
if( is_object($post_id) )
|
185 |
-
{
|
186 |
-
if( isset($post_id->roles, $post_id->ID) )
|
187 |
-
{
|
188 |
$post_id = 'user_' . $post_id->ID;
|
189 |
-
|
190 |
-
|
191 |
-
{
|
|
|
192 |
$post_id = $post_id->taxonomy . '_' . $post_id->term_id;
|
193 |
-
|
194 |
-
|
195 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
$post_id = $post_id->ID;
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
}
|
199 |
|
200 |
|
@@ -209,13 +230,16 @@ class acf
|
|
209 |
* the user wants to load data from a completely different post_id
|
210 |
*/
|
211 |
|
212 |
-
if( isset($_GET['preview_id']) )
|
213 |
-
|
214 |
$autosave = wp_get_post_autosave( $_GET['preview_id'] );
|
215 |
-
|
216 |
-
{
|
217 |
-
|
|
|
|
|
218 |
}
|
|
|
219 |
}
|
220 |
|
221 |
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://www.advancedcustomfields.com/
|
5 |
Description: Customise WordPress with powerful, professional and intuitive fields
|
6 |
+
Version: 4.4.10
|
7 |
Author: Elliot Condon
|
8 |
Author URI: http://www.elliotcondon.com/
|
9 |
License: GPL
|
43 |
'path' => apply_filters('acf/helpers/get_path', __FILE__),
|
44 |
'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
|
45 |
'hook' => basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ),
|
46 |
+
'version' => '4.4.10',
|
47 |
'upgrade_version' => '3.4.1',
|
48 |
'include_3rd_party' => false
|
49 |
);
|
159 |
* @return {mixed} $post_id
|
160 |
*/
|
161 |
|
162 |
+
function get_post_id( $post_id ) {
|
163 |
+
|
164 |
+
// if not $post_id, load queried object
|
165 |
+
if( !$post_id ) {
|
|
|
|
|
166 |
|
167 |
+
// try for global post (needed for setup_postdata)
|
168 |
+
$post_id = (int) get_the_ID();
|
169 |
+
|
170 |
+
|
171 |
+
// try for current screen
|
172 |
+
if( !$post_id ) {
|
173 |
+
|
174 |
+
$post_id = get_queried_object();
|
175 |
+
|
176 |
}
|
177 |
+
|
178 |
}
|
179 |
|
180 |
|
181 |
+
// $post_id may be an object
|
182 |
+
if( is_object($post_id) ) {
|
183 |
+
|
184 |
+
// user
|
185 |
+
if( isset($post_id->roles, $post_id->ID) ) {
|
186 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
$post_id = 'user_' . $post_id->ID;
|
188 |
+
|
189 |
+
// term
|
190 |
+
} elseif( isset($post_id->taxonomy, $post_id->term_id) ) {
|
191 |
+
|
192 |
$post_id = $post_id->taxonomy . '_' . $post_id->term_id;
|
193 |
+
|
194 |
+
// comment
|
195 |
+
} elseif( isset($post_id->comment_ID) ) {
|
196 |
+
|
197 |
+
$post_id = 'comment_' . $post_id->comment_ID;
|
198 |
+
|
199 |
+
// post
|
200 |
+
} elseif( isset($post_id->ID) ) {
|
201 |
+
|
202 |
$post_id = $post_id->ID;
|
203 |
+
|
204 |
+
// default
|
205 |
+
} else {
|
206 |
+
|
207 |
+
$post_id = 0;
|
208 |
+
|
209 |
}
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
|
214 |
+
// allow for option == options
|
215 |
+
if( $post_id === 'option' ) {
|
216 |
+
|
217 |
+
$post_id = 'options';
|
218 |
+
|
219 |
}
|
220 |
|
221 |
|
230 |
* the user wants to load data from a completely different post_id
|
231 |
*/
|
232 |
|
233 |
+
if( isset($_GET['preview_id']) ) {
|
234 |
+
|
235 |
$autosave = wp_get_post_autosave( $_GET['preview_id'] );
|
236 |
+
|
237 |
+
if( $autosave && $autosave->post_parent == $post_id ) {
|
238 |
+
|
239 |
+
$post_id = (int) $autosave->ID;
|
240 |
+
|
241 |
}
|
242 |
+
|
243 |
}
|
244 |
|
245 |
|
shared/assets/plugins/advanced-custom-fields/core/api.php
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
*/
|
18 |
|
19 |
function get_field_reference( $field_name, $post_id ) {
|
20 |
-
|
21 |
// cache
|
22 |
$found = false;
|
23 |
$cache = wp_cache_get( 'field_reference/post_id=' . $post_id . '/name=' . $field_name, 'acf', false, $found );
|
@@ -26,33 +26,33 @@ function get_field_reference( $field_name, $post_id ) {
|
|
26 |
{
|
27 |
return $cache;
|
28 |
}
|
29 |
-
|
30 |
-
|
31 |
// vars
|
32 |
$return = '';
|
33 |
|
34 |
-
|
35 |
// get field key
|
36 |
if( is_numeric($post_id) )
|
37 |
{
|
38 |
-
$return = get_post_meta($post_id, '_' . $field_name, true);
|
39 |
}
|
40 |
elseif( strpos($post_id, 'user_') !== false )
|
41 |
{
|
42 |
$temp_post_id = str_replace('user_', '', $post_id);
|
43 |
-
$return = get_user_meta($temp_post_id, '_' . $field_name, true);
|
44 |
}
|
45 |
else
|
46 |
{
|
47 |
-
$return = get_option('_' . $post_id . '_' . $field_name);
|
48 |
}
|
49 |
-
|
50 |
-
|
51 |
// set cache
|
52 |
wp_cache_set( 'field_reference/post_id=' . $post_id . '/name=' . $field_name, $return, 'acf' );
|
53 |
-
|
54 |
-
|
55 |
-
// return
|
56 |
return $return;
|
57 |
}
|
58 |
|
@@ -73,11 +73,11 @@ function get_field_reference( $field_name, $post_id ) {
|
|
73 |
*/
|
74 |
|
75 |
function get_field_objects( $post_id = false, $options = array() ) {
|
76 |
-
|
77 |
// global
|
78 |
global $wpdb;
|
79 |
-
|
80 |
-
|
81 |
// filter post_id
|
82 |
$post_id = apply_filters('acf/get_post_id', $post_id );
|
83 |
|
@@ -85,8 +85,8 @@ function get_field_objects( $post_id = false, $options = array() ) {
|
|
85 |
// vars
|
86 |
$field_key = '';
|
87 |
$value = array();
|
88 |
-
|
89 |
-
|
90 |
// get field_names
|
91 |
if( is_numeric($post_id) )
|
92 |
{
|
@@ -100,7 +100,7 @@ function get_field_objects( $post_id = false, $options = array() ) {
|
|
100 |
elseif( strpos($post_id, 'user_') !== false )
|
101 |
{
|
102 |
$user_id = str_replace('user_', '', $post_id);
|
103 |
-
|
104 |
$keys = $wpdb->get_col($wpdb->prepare(
|
105 |
"SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d and meta_key LIKE %s AND meta_value LIKE %s",
|
106 |
$user_id,
|
@@ -112,7 +112,7 @@ function get_field_objects( $post_id = false, $options = array() ) {
|
|
112 |
{
|
113 |
$keys = $wpdb->get_col($wpdb->prepare(
|
114 |
"SELECT option_value FROM $wpdb->options WHERE option_name LIKE %s",
|
115 |
-
'_' . $post_id . '_%'
|
116 |
));
|
117 |
}
|
118 |
|
@@ -122,24 +122,24 @@ function get_field_objects( $post_id = false, $options = array() ) {
|
|
122 |
foreach( $keys as $key )
|
123 |
{
|
124 |
$field = get_field_object( $key, $post_id, $options );
|
125 |
-
|
126 |
if( !is_array($field) )
|
127 |
{
|
128 |
continue;
|
129 |
}
|
130 |
-
|
131 |
$value[ $field['name'] ] = $field;
|
132 |
}
|
133 |
}
|
134 |
-
|
135 |
-
|
136 |
// no value
|
137 |
if( empty($value) )
|
138 |
{
|
139 |
return false;
|
140 |
}
|
141 |
-
|
142 |
-
|
143 |
// return
|
144 |
return $value;
|
145 |
}
|
@@ -161,16 +161,16 @@ function get_field_objects( $post_id = false, $options = array() ) {
|
|
161 |
*/
|
162 |
|
163 |
function get_fields( $post_id = false, $format_value = true ) {
|
164 |
-
|
165 |
// vars
|
166 |
$options = array(
|
167 |
'load_value' => true,
|
168 |
'format_value' => $format_value
|
169 |
);
|
170 |
-
|
171 |
-
|
172 |
$fields = get_field_objects( $post_id, $options );
|
173 |
-
|
174 |
if( is_array($fields) )
|
175 |
{
|
176 |
foreach( $fields as $k => $field )
|
@@ -178,8 +178,8 @@ function get_fields( $post_id = false, $format_value = true ) {
|
|
178 |
$fields[ $k ] = $field['value'];
|
179 |
}
|
180 |
}
|
181 |
-
|
182 |
-
return $fields;
|
183 |
}
|
184 |
|
185 |
|
@@ -187,7 +187,7 @@ function get_fields( $post_id = false, $format_value = true ) {
|
|
187 |
* get_field()
|
188 |
*
|
189 |
* This function will return a custom field value for a specific field name/key + post_id.
|
190 |
-
* There is a 3rd parameter to turn on/off formating. This means that an Image field will not use
|
191 |
* its 'return option' to format the value but return only what was saved in the database
|
192 |
*
|
193 |
* @type function
|
@@ -200,9 +200,9 @@ function get_fields( $post_id = false, $format_value = true ) {
|
|
200 |
*
|
201 |
* @return mixed $value: the value found
|
202 |
*/
|
203 |
-
|
204 |
function get_field( $field_key, $post_id = false, $format_value = true ) {
|
205 |
-
|
206 |
// vars
|
207 |
$return = false;
|
208 |
$options = array(
|
@@ -210,18 +210,18 @@ function get_field( $field_key, $post_id = false, $format_value = true ) {
|
|
210 |
'format_value' => $format_value
|
211 |
);
|
212 |
|
213 |
-
|
214 |
$field = get_field_object( $field_key, $post_id, $options);
|
215 |
-
|
216 |
-
|
217 |
if( is_array($field) )
|
218 |
{
|
219 |
$return = $field['value'];
|
220 |
}
|
221 |
-
|
222 |
-
|
223 |
return $return;
|
224 |
-
|
225 |
}
|
226 |
|
227 |
|
@@ -244,41 +244,41 @@ function get_field( $field_key, $post_id = false, $format_value = true ) {
|
|
244 |
*/
|
245 |
|
246 |
function get_field_object( $field_key, $post_id = false, $options = array() ) {
|
247 |
-
|
248 |
// make sure add-ons are included
|
249 |
acf()->include_3rd_party();
|
250 |
-
|
251 |
-
|
252 |
// filter post_id
|
253 |
$post_id = apply_filters('acf/get_post_id', $post_id );
|
254 |
$field = false;
|
255 |
$orig_field_key = $field_key;
|
256 |
-
|
257 |
-
|
258 |
// defaults for options
|
259 |
$defaults = array(
|
260 |
'load_value' => true,
|
261 |
'format_value' => true,
|
262 |
);
|
263 |
-
|
264 |
$options = array_merge($defaults, $options);
|
265 |
-
|
266 |
-
|
267 |
// is $field_name a name? pre 3.4.0
|
268 |
if( substr($field_key, 0, 6) !== 'field_' )
|
269 |
{
|
270 |
// get field key
|
271 |
$field_key = get_field_reference( $field_key, $post_id );
|
272 |
}
|
273 |
-
|
274 |
-
|
275 |
// get field
|
276 |
if( substr($field_key, 0, 6) === 'field_' )
|
277 |
{
|
278 |
$field = apply_filters('acf/load_field', false, $field_key );
|
279 |
}
|
280 |
-
|
281 |
-
|
282 |
// validate field
|
283 |
if( !$field )
|
284 |
{
|
@@ -296,8 +296,8 @@ function get_field_object( $field_key, $post_id = false, $options = array() ) {
|
|
296 |
if( $options['load_value'] )
|
297 |
{
|
298 |
$field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
|
299 |
-
|
300 |
-
|
301 |
// format value
|
302 |
if( $options['format_value'] )
|
303 |
{
|
@@ -327,14 +327,14 @@ function get_field_object( $field_key, $post_id = false, $options = array() ) {
|
|
327 |
*/
|
328 |
|
329 |
function the_field( $field_name, $post_id = false ) {
|
330 |
-
|
331 |
$value = get_field($field_name, $post_id);
|
332 |
-
|
333 |
if( is_array($value) )
|
334 |
{
|
335 |
$value = @implode(', ',$value);
|
336 |
}
|
337 |
-
|
338 |
echo $value;
|
339 |
}
|
340 |
|
@@ -343,7 +343,7 @@ function the_field( $field_name, $post_id = false ) {
|
|
343 |
* have_rows
|
344 |
*
|
345 |
* This function will instantiate a global variable containing the rows of a repeater or flexible content field,
|
346 |
-
* afterwhich, it will
|
347 |
*
|
348 |
* @type function
|
349 |
* @date 2/09/13
|
@@ -354,29 +354,29 @@ function the_field( $field_name, $post_id = false ) {
|
|
354 |
*/
|
355 |
|
356 |
function have_rows( $field_name, $post_id = false ) {
|
357 |
-
|
358 |
// vars
|
359 |
$depth = 0;
|
360 |
$row = array();
|
361 |
$new_parent_loop = false;
|
362 |
$new_child_loop = false;
|
363 |
-
|
364 |
-
|
365 |
// reference
|
366 |
$_post_id = $post_id;
|
367 |
-
|
368 |
-
|
369 |
// filter post_id
|
370 |
$post_id = apply_filters('acf/get_post_id', $post_id );
|
371 |
-
|
372 |
-
|
373 |
// empty?
|
374 |
if( empty($GLOBALS['acf_field']) )
|
375 |
{
|
376 |
// reset
|
377 |
reset_rows( true );
|
378 |
-
|
379 |
-
|
380 |
// create a new loop
|
381 |
$new_parent_loop = true;
|
382 |
}
|
@@ -385,8 +385,8 @@ function have_rows( $field_name, $post_id = false ) {
|
|
385 |
// vars
|
386 |
$row = end( $GLOBALS['acf_field'] );
|
387 |
$prev = prev( $GLOBALS['acf_field'] );
|
388 |
-
|
389 |
-
|
390 |
// If post_id has changed, this is most likely an archive loop
|
391 |
if( $post_id != $row['post_id'] )
|
392 |
{
|
@@ -422,7 +422,7 @@ function have_rows( $field_name, $post_id = false ) {
|
|
422 |
// case: Change in $field_name was due to this being a nested loop
|
423 |
// action: move down one level into a new loop
|
424 |
$new_child_loop = true;
|
425 |
-
|
426 |
}
|
427 |
else
|
428 |
{
|
@@ -430,20 +430,20 @@ function have_rows( $field_name, $post_id = false ) {
|
|
430 |
// action: leave this current loop alone and create a new parent loop
|
431 |
$new_parent_loop = true;
|
432 |
}
|
433 |
-
|
434 |
-
|
435 |
}
|
436 |
}
|
437 |
-
|
438 |
-
|
439 |
if( $new_parent_loop )
|
440 |
{
|
441 |
// vars
|
442 |
$f = get_field_object( $field_name, $post_id );
|
443 |
$v = $f['value'];
|
444 |
unset( $f['value'] );
|
445 |
-
|
446 |
-
|
447 |
// add row
|
448 |
$GLOBALS['acf_field'][] = array(
|
449 |
'name' => $field_name,
|
@@ -452,14 +452,14 @@ function have_rows( $field_name, $post_id = false ) {
|
|
452 |
'i' => -1,
|
453 |
'post_id' => $post_id,
|
454 |
);
|
455 |
-
|
456 |
}
|
457 |
elseif( $new_child_loop )
|
458 |
{
|
459 |
// vars
|
460 |
$f = acf_get_child_field_from_parent_field( $field_name, $row['field'] );
|
461 |
$v = $row['value'][ $row['i'] ][ $field_name ];
|
462 |
-
|
463 |
$GLOBALS['acf_field'][] = array(
|
464 |
'name' => $field_name,
|
465 |
'value' => $v,
|
@@ -468,27 +468,27 @@ function have_rows( $field_name, $post_id = false ) {
|
|
468 |
'post_id' => $post_id,
|
469 |
);
|
470 |
|
471 |
-
}
|
472 |
-
|
473 |
-
|
474 |
// update vars
|
475 |
$row = end( $GLOBALS['acf_field'] );
|
476 |
-
|
477 |
-
|
478 |
if( is_array($row['value']) && array_key_exists( $row['i']+1, $row['value'] ) )
|
479 |
{
|
480 |
// next row exists
|
481 |
return true;
|
482 |
}
|
483 |
-
|
484 |
-
|
485 |
// no next row!
|
486 |
reset_rows();
|
487 |
-
|
488 |
-
|
489 |
// return
|
490 |
return false;
|
491 |
-
|
492 |
}
|
493 |
|
494 |
|
@@ -506,21 +506,21 @@ function have_rows( $field_name, $post_id = false ) {
|
|
506 |
*/
|
507 |
|
508 |
function the_row() {
|
509 |
-
|
510 |
// vars
|
511 |
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
512 |
|
513 |
-
|
514 |
-
|
515 |
// increase row
|
516 |
$GLOBALS['acf_field'][ $depth ]['i']++;
|
517 |
-
|
518 |
-
|
519 |
// get row
|
520 |
$value = $GLOBALS['acf_field'][ $depth ]['value'];
|
521 |
$i = $GLOBALS['acf_field'][ $depth ]['i'];
|
522 |
|
523 |
-
|
524 |
// return
|
525 |
return $value[ $i ];
|
526 |
}
|
@@ -541,7 +541,7 @@ function the_row() {
|
|
541 |
*/
|
542 |
|
543 |
function reset_rows( $hard_reset = false ) {
|
544 |
-
|
545 |
// completely destroy?
|
546 |
if( $hard_reset )
|
547 |
{
|
@@ -551,21 +551,21 @@ function reset_rows( $hard_reset = false ) {
|
|
551 |
{
|
552 |
// vars
|
553 |
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
554 |
-
|
555 |
-
|
556 |
// remove
|
557 |
unset( $GLOBALS['acf_field'][$depth] );
|
558 |
-
|
559 |
-
|
560 |
// refresh index
|
561 |
$GLOBALS['acf_field'] = array_values($GLOBALS['acf_field']);
|
562 |
}
|
563 |
-
|
564 |
-
|
565 |
// return
|
566 |
return true;
|
567 |
-
|
568 |
-
|
569 |
}
|
570 |
|
571 |
|
@@ -573,7 +573,7 @@ function reset_rows( $hard_reset = false ) {
|
|
573 |
* has_sub_field()
|
574 |
*
|
575 |
* This function is used inside a while loop to return either true or false (loop again or stop).
|
576 |
-
* When using a repeater or flexible content field, it will loop through the rows until
|
577 |
* there are none left or a break is detected
|
578 |
*
|
579 |
* @type function
|
@@ -587,18 +587,18 @@ function reset_rows( $hard_reset = false ) {
|
|
587 |
*/
|
588 |
|
589 |
function has_sub_field( $field_name, $post_id = false ) {
|
590 |
-
|
591 |
// vars
|
592 |
$r = have_rows( $field_name, $post_id );
|
593 |
-
|
594 |
-
|
595 |
// if has rows, progress through 1 row for the while loop to work
|
596 |
if( $r )
|
597 |
{
|
598 |
the_row();
|
599 |
}
|
600 |
-
|
601 |
-
|
602 |
// return
|
603 |
return $r;
|
604 |
}
|
@@ -640,25 +640,25 @@ function has_sub_fields( $field_name, $post_id = false )
|
|
640 |
*/
|
641 |
|
642 |
function get_sub_field( $field_name ) {
|
643 |
-
|
644 |
// no field?
|
645 |
if( empty($GLOBALS['acf_field']) )
|
646 |
{
|
647 |
return false;
|
648 |
}
|
649 |
-
|
650 |
-
|
651 |
// vars
|
652 |
$row = end( $GLOBALS['acf_field'] );
|
653 |
-
|
654 |
-
|
655 |
// return value
|
656 |
if( isset($row['value'][ $row['i'] ][ $field_name ]) )
|
657 |
{
|
658 |
return $row['value'][ $row['i'] ][ $field_name ];
|
659 |
}
|
660 |
-
|
661 |
-
|
662 |
// return false
|
663 |
return false;
|
664 |
}
|
@@ -681,12 +681,12 @@ function get_sub_field( $field_name ) {
|
|
681 |
function the_sub_field($field_name)
|
682 |
{
|
683 |
$value = get_sub_field($field_name);
|
684 |
-
|
685 |
if(is_array($value))
|
686 |
{
|
687 |
$value = implode(', ',$value);
|
688 |
}
|
689 |
-
|
690 |
echo $value;
|
691 |
}
|
692 |
|
@@ -702,7 +702,7 @@ function the_sub_field($field_name)
|
|
702 |
*
|
703 |
* @param string $field_name: the name of the field - 'sub_heading'
|
704 |
*
|
705 |
-
* @return array $sub_field
|
706 |
*/
|
707 |
|
708 |
function get_sub_field_object( $child_name )
|
@@ -721,7 +721,7 @@ function get_sub_field_object( $child_name )
|
|
721 |
|
722 |
// return
|
723 |
return acf_get_child_field_from_parent_field( $child_name, $parent );
|
724 |
-
|
725 |
}
|
726 |
|
727 |
|
@@ -737,15 +737,15 @@ function get_sub_field_object( $child_name )
|
|
737 |
* @param string $child_name: the name of the field - 'sub_heading'
|
738 |
* @param array $parent: the parent field object
|
739 |
*
|
740 |
-
* @return array $sub_field
|
741 |
*/
|
742 |
|
743 |
function acf_get_child_field_from_parent_field( $child_name, $parent )
|
744 |
{
|
745 |
// vars
|
746 |
$return = false;
|
747 |
-
|
748 |
-
|
749 |
// find child
|
750 |
if( isset($parent['sub_fields']) && is_array($parent['sub_fields']) )
|
751 |
{
|
@@ -756,7 +756,7 @@ function acf_get_child_field_from_parent_field( $child_name, $parent )
|
|
756 |
$return = $child;
|
757 |
break;
|
758 |
}
|
759 |
-
|
760 |
// perhaps child has grand children?
|
761 |
$grand_child = acf_get_child_field_from_parent_field( $child_name, $child );
|
762 |
if( $grand_child )
|
@@ -778,11 +778,11 @@ function acf_get_child_field_from_parent_field( $child_name, $parent )
|
|
778 |
}
|
779 |
}
|
780 |
}
|
781 |
-
|
782 |
|
783 |
// return
|
784 |
return $return;
|
785 |
-
|
786 |
}
|
787 |
|
788 |
|
@@ -810,7 +810,7 @@ function register_field_group( $array )
|
|
810 |
{
|
811 |
$array['id'] = uniqid();
|
812 |
}
|
813 |
-
|
814 |
|
815 |
// 3.2.5 - changed show_on_page option
|
816 |
if( !isset($array['options']['hide_on_screen']) && isset($array['options']['show_on_page']) )
|
@@ -820,45 +820,45 @@ function register_field_group( $array )
|
|
820 |
unset( $array['options']['show_on_page'] );
|
821 |
}
|
822 |
|
823 |
-
|
824 |
// 4.0.4 - changed location rules architecture
|
825 |
if( isset($array['location']['rules']) )
|
826 |
{
|
827 |
// vars
|
828 |
$groups = array();
|
829 |
$group_no = 0;
|
830 |
-
|
831 |
-
|
832 |
if( is_array($array['location']['rules']) )
|
833 |
{
|
834 |
foreach( $array['location']['rules'] as $rule )
|
835 |
{
|
836 |
$rule['group_no'] = $group_no;
|
837 |
-
|
838 |
// sperate groups?
|
839 |
if( $array['location']['allorany'] == 'any' )
|
840 |
{
|
841 |
$group_no++;
|
842 |
}
|
843 |
-
|
844 |
-
|
845 |
// add to group
|
846 |
$groups[ $rule['group_no'] ][ $rule['order_no'] ] = $rule;
|
847 |
-
|
848 |
-
|
849 |
// sort rules
|
850 |
ksort( $groups[ $rule['group_no'] ] );
|
851 |
-
|
852 |
}
|
853 |
-
|
854 |
// sort groups
|
855 |
ksort( $groups );
|
856 |
}
|
857 |
-
|
858 |
$array['location'] = $groups;
|
859 |
}
|
860 |
-
|
861 |
-
|
862 |
$GLOBALS['acf_register_field_group'][] = $array;
|
863 |
}
|
864 |
|
@@ -871,8 +871,8 @@ function api_acf_get_field_groups( $return )
|
|
871 |
{
|
872 |
return $return;
|
873 |
}
|
874 |
-
|
875 |
-
|
876 |
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
877 |
{
|
878 |
$return[] = array(
|
@@ -882,7 +882,7 @@ function api_acf_get_field_groups( $return )
|
|
882 |
);
|
883 |
}
|
884 |
|
885 |
-
|
886 |
// order field groups based on menu_order, title
|
887 |
// Obtain a list of columns
|
888 |
foreach( $return as $key => $row )
|
@@ -890,14 +890,14 @@ function api_acf_get_field_groups( $return )
|
|
890 |
$menu_order[ $key ] = $row['menu_order'];
|
891 |
$title[ $key ] = $row['title'];
|
892 |
}
|
893 |
-
|
894 |
// Sort the array with menu_order ascending
|
895 |
// Add $array as the last parameter, to sort by the common key
|
896 |
if(isset($menu_order))
|
897 |
{
|
898 |
array_multisort($menu_order, SORT_ASC, $title, SORT_ASC, $return);
|
899 |
}
|
900 |
-
|
901 |
return $return;
|
902 |
}
|
903 |
|
@@ -916,7 +916,7 @@ function api_acf_field_group_get_fields( $fields, $post_id )
|
|
916 |
{
|
917 |
$fields[] = apply_filters('acf/load_field', $f, $f['key']);
|
918 |
}
|
919 |
-
|
920 |
break;
|
921 |
}
|
922 |
}
|
@@ -984,7 +984,7 @@ function api_acf_field_group_get_options( $options, $post_id )
|
|
984 |
{
|
985 |
if( $acf['id'] == $post_id )
|
986 |
{
|
987 |
-
$options =
|
988 |
break;
|
989 |
}
|
990 |
}
|
@@ -1010,8 +1010,8 @@ function get_row_layout()
|
|
1010 |
{
|
1011 |
// vars
|
1012 |
$value = get_sub_field('acf_fc_layout');
|
1013 |
-
|
1014 |
-
|
1015 |
return $value;
|
1016 |
}
|
1017 |
|
@@ -1039,24 +1039,24 @@ function acf_shortcode( $atts )
|
|
1039 |
'field' => "",
|
1040 |
'post_id' => false,
|
1041 |
), $atts ) );
|
1042 |
-
|
1043 |
-
|
1044 |
// $field is requird
|
1045 |
if( !$field || $field == "" )
|
1046 |
{
|
1047 |
return "";
|
1048 |
}
|
1049 |
-
|
1050 |
-
|
1051 |
// get value and return it
|
1052 |
$value = get_field( $field, $post_id );
|
1053 |
-
|
1054 |
-
|
1055 |
if( is_array($value) )
|
1056 |
{
|
1057 |
$value = @implode( ', ',$value );
|
1058 |
}
|
1059 |
-
|
1060 |
return $value;
|
1061 |
}
|
1062 |
add_shortcode( 'acf', 'acf_shortcode' );
|
@@ -1080,21 +1080,21 @@ function acf_form_head()
|
|
1080 |
{
|
1081 |
// global vars
|
1082 |
global $post_id;
|
1083 |
-
|
1084 |
-
|
1085 |
// verify nonce
|
1086 |
if( isset($_POST['acf_nonce']) && wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
1087 |
{
|
1088 |
// $post_id to save against
|
1089 |
$post_id = $_POST['post_id'];
|
1090 |
-
|
1091 |
-
|
1092 |
// allow for custom save
|
1093 |
$post_id = apply_filters('acf/pre_save_post', $post_id);
|
1094 |
-
|
1095 |
-
|
1096 |
// save the data
|
1097 |
-
do_action('acf/save_post', $post_id);
|
1098 |
|
1099 |
|
1100 |
// redirect
|
@@ -1104,19 +1104,19 @@ function acf_form_head()
|
|
1104 |
exit;
|
1105 |
}
|
1106 |
}
|
1107 |
-
|
1108 |
-
|
1109 |
// need wp styling
|
1110 |
wp_enqueue_style(array(
|
1111 |
'colors-fresh'
|
1112 |
));
|
1113 |
-
|
1114 |
-
|
1115 |
// actions
|
1116 |
do_action('acf/input/admin_enqueue_scripts');
|
1117 |
|
1118 |
add_action('wp_head', 'acf_form_wp_head');
|
1119 |
-
|
1120 |
}
|
1121 |
|
1122 |
function acf_form_wp_head()
|
@@ -1136,7 +1136,7 @@ function acf_form_wp_head()
|
|
1136 |
*
|
1137 |
* @param array $options: an array containing many options to customize the form
|
1138 |
* string + post_id: post id to get field groups from and save data to. Default is false
|
1139 |
-
* array + field_groups: an array containing field group ID's. If this option is set,
|
1140 |
* the post_id will not be used to dynamically find the field groups
|
1141 |
* boolean + form: display the form tag or not. Defaults to true
|
1142 |
* array + form_attributes: an array containg attributes which will be added into the form tag
|
@@ -1144,7 +1144,7 @@ function acf_form_wp_head()
|
|
1144 |
* string + html_before_fields: html inside form before fields
|
1145 |
* string + html_after_fields: html inside form after fields
|
1146 |
* string + submit_value: value of submit button
|
1147 |
-
* string + updated_message: default updated message. Can be false
|
1148 |
*
|
1149 |
* @return N/A
|
1150 |
*/
|
@@ -1152,8 +1152,8 @@ function acf_form_wp_head()
|
|
1152 |
function acf_form( $options = array() )
|
1153 |
{
|
1154 |
global $post;
|
1155 |
-
|
1156 |
-
|
1157 |
// defaults
|
1158 |
$defaults = array(
|
1159 |
'post_id' => false,
|
@@ -1169,14 +1169,14 @@ function acf_form( $options = array() )
|
|
1169 |
'html_before_fields' => '',
|
1170 |
'html_after_fields' => '',
|
1171 |
'submit_value' => __("Update", 'acf'),
|
1172 |
-
'updated_message' => __("Post updated", 'acf'),
|
1173 |
);
|
1174 |
-
|
1175 |
-
|
1176 |
// merge defaults with options
|
1177 |
$options = array_merge($defaults, $options);
|
1178 |
-
|
1179 |
-
|
1180 |
// merge sub arrays
|
1181 |
foreach( $options as $k => $v )
|
1182 |
{
|
@@ -1185,17 +1185,17 @@ function acf_form( $options = array() )
|
|
1185 |
$options[ $k ] = array_merge($defaults[ $k ], $options[ $k ]);
|
1186 |
}
|
1187 |
}
|
1188 |
-
|
1189 |
-
|
1190 |
// filter post_id
|
1191 |
$options['post_id'] = apply_filters('acf/get_post_id', $options['post_id'] );
|
1192 |
-
|
1193 |
-
|
1194 |
// attributes
|
1195 |
$options['form_attributes']['class'] .= 'acf-form';
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
// register post box
|
1200 |
if( empty($options['field_groups']) )
|
1201 |
{
|
@@ -1203,8 +1203,8 @@ function acf_form( $options = array() )
|
|
1203 |
$filter = array(
|
1204 |
'post_id' => $options['post_id']
|
1205 |
);
|
1206 |
-
|
1207 |
-
|
1208 |
if( strpos($options['post_id'], 'user_') !== false )
|
1209 |
{
|
1210 |
$user_id = str_replace('user_', '', $options['post_id']);
|
@@ -1219,8 +1219,8 @@ function acf_form( $options = array() )
|
|
1219 |
'ef_taxonomy' => $taxonomy_id
|
1220 |
);
|
1221 |
}
|
1222 |
-
|
1223 |
-
|
1224 |
$options['field_groups'] = array();
|
1225 |
$options['field_groups'] = apply_filters( 'acf/location/match_field_groups', $options['field_groups'], $filter );
|
1226 |
}
|
@@ -1231,13 +1231,13 @@ function acf_form( $options = array() )
|
|
1231 |
{
|
1232 |
echo '<div id="message" class="updated"><p>' . $options['updated_message'] . '</p></div>';
|
1233 |
}
|
1234 |
-
|
1235 |
-
|
1236 |
// display form
|
1237 |
if( $options['form'] ): ?>
|
1238 |
<form <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
|
1239 |
<?php endif; ?>
|
1240 |
-
|
1241 |
<div style="display:none">
|
1242 |
<script type="text/javascript">
|
1243 |
acf.o.post_id = <?php echo is_numeric($options['post_id']) ? $options['post_id'] : '"' . $options['post_id'] . '"'; ?>;
|
@@ -1247,49 +1247,49 @@ function acf_form( $options = array() )
|
|
1247 |
<input type="hidden" name="return" value="<?php echo $options['return']; ?>" />
|
1248 |
<?php wp_editor('', 'acf_settings'); ?>
|
1249 |
</div>
|
1250 |
-
|
1251 |
<div id="poststuff">
|
1252 |
<?php
|
1253 |
-
|
1254 |
// html before fields
|
1255 |
echo $options['html_before_fields'];
|
1256 |
-
|
1257 |
-
|
1258 |
$acfs = apply_filters('acf/get_field_groups', array());
|
1259 |
-
|
1260 |
if( is_array($acfs) ){ foreach( $acfs as $acf ){
|
1261 |
-
|
1262 |
// only add the chosen field groups
|
1263 |
if( !in_array( $acf['id'], $options['field_groups'] ) )
|
1264 |
{
|
1265 |
continue;
|
1266 |
}
|
1267 |
-
|
1268 |
-
|
1269 |
// load options
|
1270 |
$acf['options'] = apply_filters('acf/field_group/get_options', array(), $acf['id']);
|
1271 |
-
|
1272 |
-
|
1273 |
// load fields
|
1274 |
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
1275 |
-
|
1276 |
-
|
1277 |
echo '<div id="acf_' . $acf['id'] . '" class="postbox acf_postbox ' . $acf['options']['layout'] . '">';
|
1278 |
echo '<h3 class="hndle"><span>' . $acf['title'] . '</span></h3>';
|
1279 |
echo '<div class="inside">';
|
1280 |
-
|
1281 |
do_action('acf/create_fields', $fields, $options['post_id']);
|
1282 |
-
|
1283 |
echo '</div></div>';
|
1284 |
-
|
1285 |
}}
|
1286 |
-
|
1287 |
-
|
1288 |
// html after fields
|
1289 |
echo $options['html_after_fields'];
|
1290 |
-
|
1291 |
?>
|
1292 |
-
|
1293 |
<?php if( $options['form'] ): ?>
|
1294 |
<!-- Submit -->
|
1295 |
<div class="field">
|
@@ -1297,9 +1297,9 @@ function acf_form( $options = array() )
|
|
1297 |
</div>
|
1298 |
<!-- / Submit -->
|
1299 |
<?php endif; ?>
|
1300 |
-
|
1301 |
</div><!-- <div id="poststuff"> -->
|
1302 |
-
|
1303 |
<?php if( $options['form'] ): ?>
|
1304 |
</form>
|
1305 |
<?php endif;
|
@@ -1326,17 +1326,17 @@ function update_field( $field_key, $value, $post_id = false )
|
|
1326 |
{
|
1327 |
// filter post_id
|
1328 |
$post_id = apply_filters('acf/get_post_id', $post_id );
|
1329 |
-
|
1330 |
-
|
1331 |
// vars
|
1332 |
$options = array(
|
1333 |
'load_value' => false,
|
1334 |
'format_value' => false
|
1335 |
);
|
1336 |
-
|
1337 |
$field = get_field_object( $field_key, $post_id, $options);
|
1338 |
|
1339 |
-
|
1340 |
// sub fields? They need formatted data
|
1341 |
if( $field['type'] == 'repeater' )
|
1342 |
{
|
@@ -1352,14 +1352,14 @@ function update_field( $field_key, $value, $post_id = false )
|
|
1352 |
}
|
1353 |
}
|
1354 |
}
|
1355 |
-
|
1356 |
-
|
1357 |
// save
|
1358 |
do_action('acf/update_value', $value, $post_id, $field );
|
1359 |
-
|
1360 |
-
|
1361 |
return true;
|
1362 |
-
|
1363 |
}
|
1364 |
|
1365 |
|
@@ -1426,7 +1426,7 @@ function acf_convert_field_names_to_keys( $value, $field )
|
|
1426 |
{
|
1427 |
return $value;
|
1428 |
}
|
1429 |
-
|
1430 |
|
1431 |
// define sub field keys
|
1432 |
$sub_fields = array();
|
@@ -1437,8 +1437,8 @@ function acf_convert_field_names_to_keys( $value, $field )
|
|
1437 |
$sub_fields[ $sub_field['name'] ] = $sub_field;
|
1438 |
}
|
1439 |
}
|
1440 |
-
|
1441 |
-
|
1442 |
// loop through the values and format the array to use sub field keys
|
1443 |
if( is_array($value) )
|
1444 |
{
|
@@ -1453,21 +1453,21 @@ function acf_convert_field_names_to_keys( $value, $field )
|
|
1453 |
{
|
1454 |
continue;
|
1455 |
}
|
1456 |
-
|
1457 |
-
|
1458 |
// vars
|
1459 |
$sub_field = $sub_fields[ $sub_field_name ];
|
1460 |
$sub_field_value = acf_convert_field_names_to_keys( $sub_field_value, $sub_field );
|
1461 |
-
|
1462 |
-
|
1463 |
// set new value
|
1464 |
$value[$row_i][ $sub_field['key'] ] = $sub_field_value;
|
1465 |
-
|
1466 |
-
|
1467 |
// unset old value
|
1468 |
unset( $value[$row_i][$sub_field_name] );
|
1469 |
-
|
1470 |
-
|
1471 |
}
|
1472 |
// foreach( $row as $sub_field_name => $sub_field_value )
|
1473 |
}
|
@@ -1476,8 +1476,8 @@ function acf_convert_field_names_to_keys( $value, $field )
|
|
1476 |
// foreach( $value as $row_i => $row)
|
1477 |
}
|
1478 |
// if( $value )
|
1479 |
-
|
1480 |
-
|
1481 |
return $value;
|
1482 |
|
1483 |
}
|
@@ -1497,34 +1497,34 @@ function acf_convert_field_names_to_keys( $value, $field )
|
|
1497 |
*/
|
1498 |
|
1499 |
function acf_force_type_array( $var ) {
|
1500 |
-
|
1501 |
// is array?
|
1502 |
if( is_array($var) ) {
|
1503 |
-
|
1504 |
return $var;
|
1505 |
-
|
1506 |
}
|
1507 |
-
|
1508 |
-
|
1509 |
// bail early if empty
|
1510 |
if( empty($var) && !is_numeric($var) ) {
|
1511 |
-
|
1512 |
return array();
|
1513 |
-
|
1514 |
}
|
1515 |
-
|
1516 |
-
|
1517 |
-
// string
|
1518 |
if( is_string($var) ) {
|
1519 |
-
|
1520 |
return explode(',', $var);
|
1521 |
-
|
1522 |
}
|
1523 |
-
|
1524 |
-
|
1525 |
// place in array
|
1526 |
return array( $var );
|
1527 |
-
}
|
1528 |
|
1529 |
|
1530 |
/*
|
@@ -1542,59 +1542,59 @@ function acf_force_type_array( $var ) {
|
|
1542 |
*/
|
1543 |
|
1544 |
function acf_get_valid_terms( $terms = false, $taxonomy = 'category' ) {
|
1545 |
-
|
1546 |
// bail early if function does not yet exist or
|
1547 |
if( !function_exists('wp_get_split_term') || empty($terms) ) {
|
1548 |
-
|
1549 |
return $terms;
|
1550 |
-
|
1551 |
}
|
1552 |
-
|
1553 |
-
|
1554 |
// vars
|
1555 |
$is_array = is_array($terms);
|
1556 |
-
|
1557 |
-
|
1558 |
// force into array
|
1559 |
$terms = acf_force_type_array( $terms );
|
1560 |
-
|
1561 |
-
|
1562 |
// force ints
|
1563 |
$terms = array_map('intval', $terms);
|
1564 |
-
|
1565 |
-
|
1566 |
// attempt to find new terms
|
1567 |
foreach( $terms as $i => $term_id ) {
|
1568 |
-
|
1569 |
$new_term_id = wp_get_split_term($term_id, $taxonomy);
|
1570 |
-
|
1571 |
if( $new_term_id ) {
|
1572 |
-
|
1573 |
$terms[ $i ] = $new_term_id;
|
1574 |
-
|
1575 |
}
|
1576 |
-
|
1577 |
}
|
1578 |
-
|
1579 |
-
|
1580 |
// revert array if needed
|
1581 |
if( !$is_array ) {
|
1582 |
-
|
1583 |
$terms = $terms[0];
|
1584 |
-
|
1585 |
}
|
1586 |
-
|
1587 |
-
|
1588 |
// return
|
1589 |
return $terms;
|
1590 |
-
|
1591 |
}
|
1592 |
|
1593 |
|
1594 |
/*
|
1595 |
* Depreceated Functions
|
1596 |
*
|
1597 |
-
* @description:
|
1598 |
* @created: 23/07/12
|
1599 |
*/
|
1600 |
|
@@ -1606,7 +1606,7 @@ function acf_get_valid_terms( $terms = false, $taxonomy = 'category' ) {
|
|
1606 |
* @author Elliot Condon
|
1607 |
* @depreciated: 3.3.4 - now use has_sub_field
|
1608 |
* @since 1.0.3
|
1609 |
-
*
|
1610 |
*-------------------------------------------------------------------------------------*/
|
1611 |
|
1612 |
function reset_the_repeater_field()
|
@@ -1622,7 +1622,7 @@ function reset_the_repeater_field()
|
|
1622 |
* @author Elliot Condon
|
1623 |
* @depreciated: 3.3.4 - now use has_sub_field
|
1624 |
* @since 1.0.3
|
1625 |
-
*
|
1626 |
*-------------------------------------------------------------------------------------*/
|
1627 |
|
1628 |
function the_repeater_field($field_name, $post_id = false)
|
@@ -1638,7 +1638,7 @@ function the_repeater_field($field_name, $post_id = false)
|
|
1638 |
* @author Elliot Condon
|
1639 |
* @depreciated: 3.3.4 - now use has_sub_field
|
1640 |
* @since 3.?.?
|
1641 |
-
*
|
1642 |
*-------------------------------------------------------------------------------------*/
|
1643 |
|
1644 |
function the_flexible_field($field_name, $post_id = false)
|
17 |
*/
|
18 |
|
19 |
function get_field_reference( $field_name, $post_id ) {
|
20 |
+
|
21 |
// cache
|
22 |
$found = false;
|
23 |
$cache = wp_cache_get( 'field_reference/post_id=' . $post_id . '/name=' . $field_name, 'acf', false, $found );
|
26 |
{
|
27 |
return $cache;
|
28 |
}
|
29 |
+
|
30 |
+
|
31 |
// vars
|
32 |
$return = '';
|
33 |
|
34 |
+
|
35 |
// get field key
|
36 |
if( is_numeric($post_id) )
|
37 |
{
|
38 |
+
$return = get_post_meta($post_id, '_' . $field_name, true);
|
39 |
}
|
40 |
elseif( strpos($post_id, 'user_') !== false )
|
41 |
{
|
42 |
$temp_post_id = str_replace('user_', '', $post_id);
|
43 |
+
$return = get_user_meta($temp_post_id, '_' . $field_name, true);
|
44 |
}
|
45 |
else
|
46 |
{
|
47 |
+
$return = get_option('_' . $post_id . '_' . $field_name);
|
48 |
}
|
49 |
+
|
50 |
+
|
51 |
// set cache
|
52 |
wp_cache_set( 'field_reference/post_id=' . $post_id . '/name=' . $field_name, $return, 'acf' );
|
53 |
+
|
54 |
+
|
55 |
+
// return
|
56 |
return $return;
|
57 |
}
|
58 |
|
73 |
*/
|
74 |
|
75 |
function get_field_objects( $post_id = false, $options = array() ) {
|
76 |
+
|
77 |
// global
|
78 |
global $wpdb;
|
79 |
+
|
80 |
+
|
81 |
// filter post_id
|
82 |
$post_id = apply_filters('acf/get_post_id', $post_id );
|
83 |
|
85 |
// vars
|
86 |
$field_key = '';
|
87 |
$value = array();
|
88 |
+
|
89 |
+
|
90 |
// get field_names
|
91 |
if( is_numeric($post_id) )
|
92 |
{
|
100 |
elseif( strpos($post_id, 'user_') !== false )
|
101 |
{
|
102 |
$user_id = str_replace('user_', '', $post_id);
|
103 |
+
|
104 |
$keys = $wpdb->get_col($wpdb->prepare(
|
105 |
"SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d and meta_key LIKE %s AND meta_value LIKE %s",
|
106 |
$user_id,
|
112 |
{
|
113 |
$keys = $wpdb->get_col($wpdb->prepare(
|
114 |
"SELECT option_value FROM $wpdb->options WHERE option_name LIKE %s",
|
115 |
+
'_' . $post_id . '_%'
|
116 |
));
|
117 |
}
|
118 |
|
122 |
foreach( $keys as $key )
|
123 |
{
|
124 |
$field = get_field_object( $key, $post_id, $options );
|
125 |
+
|
126 |
if( !is_array($field) )
|
127 |
{
|
128 |
continue;
|
129 |
}
|
130 |
+
|
131 |
$value[ $field['name'] ] = $field;
|
132 |
}
|
133 |
}
|
134 |
+
|
135 |
+
|
136 |
// no value
|
137 |
if( empty($value) )
|
138 |
{
|
139 |
return false;
|
140 |
}
|
141 |
+
|
142 |
+
|
143 |
// return
|
144 |
return $value;
|
145 |
}
|
161 |
*/
|
162 |
|
163 |
function get_fields( $post_id = false, $format_value = true ) {
|
164 |
+
|
165 |
// vars
|
166 |
$options = array(
|
167 |
'load_value' => true,
|
168 |
'format_value' => $format_value
|
169 |
);
|
170 |
+
|
171 |
+
|
172 |
$fields = get_field_objects( $post_id, $options );
|
173 |
+
|
174 |
if( is_array($fields) )
|
175 |
{
|
176 |
foreach( $fields as $k => $field )
|
178 |
$fields[ $k ] = $field['value'];
|
179 |
}
|
180 |
}
|
181 |
+
|
182 |
+
return $fields;
|
183 |
}
|
184 |
|
185 |
|
187 |
* get_field()
|
188 |
*
|
189 |
* This function will return a custom field value for a specific field name/key + post_id.
|
190 |
+
* There is a 3rd parameter to turn on/off formating. This means that an Image field will not use
|
191 |
* its 'return option' to format the value but return only what was saved in the database
|
192 |
*
|
193 |
* @type function
|
200 |
*
|
201 |
* @return mixed $value: the value found
|
202 |
*/
|
203 |
+
|
204 |
function get_field( $field_key, $post_id = false, $format_value = true ) {
|
205 |
+
|
206 |
// vars
|
207 |
$return = false;
|
208 |
$options = array(
|
210 |
'format_value' => $format_value
|
211 |
);
|
212 |
|
213 |
+
|
214 |
$field = get_field_object( $field_key, $post_id, $options);
|
215 |
+
|
216 |
+
|
217 |
if( is_array($field) )
|
218 |
{
|
219 |
$return = $field['value'];
|
220 |
}
|
221 |
+
|
222 |
+
|
223 |
return $return;
|
224 |
+
|
225 |
}
|
226 |
|
227 |
|
244 |
*/
|
245 |
|
246 |
function get_field_object( $field_key, $post_id = false, $options = array() ) {
|
247 |
+
|
248 |
// make sure add-ons are included
|
249 |
acf()->include_3rd_party();
|
250 |
+
|
251 |
+
|
252 |
// filter post_id
|
253 |
$post_id = apply_filters('acf/get_post_id', $post_id );
|
254 |
$field = false;
|
255 |
$orig_field_key = $field_key;
|
256 |
+
|
257 |
+
|
258 |
// defaults for options
|
259 |
$defaults = array(
|
260 |
'load_value' => true,
|
261 |
'format_value' => true,
|
262 |
);
|
263 |
+
|
264 |
$options = array_merge($defaults, $options);
|
265 |
+
|
266 |
+
|
267 |
// is $field_name a name? pre 3.4.0
|
268 |
if( substr($field_key, 0, 6) !== 'field_' )
|
269 |
{
|
270 |
// get field key
|
271 |
$field_key = get_field_reference( $field_key, $post_id );
|
272 |
}
|
273 |
+
|
274 |
+
|
275 |
// get field
|
276 |
if( substr($field_key, 0, 6) === 'field_' )
|
277 |
{
|
278 |
$field = apply_filters('acf/load_field', false, $field_key );
|
279 |
}
|
280 |
+
|
281 |
+
|
282 |
// validate field
|
283 |
if( !$field )
|
284 |
{
|
296 |
if( $options['load_value'] )
|
297 |
{
|
298 |
$field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
|
299 |
+
|
300 |
+
|
301 |
// format value
|
302 |
if( $options['format_value'] )
|
303 |
{
|
327 |
*/
|
328 |
|
329 |
function the_field( $field_name, $post_id = false ) {
|
330 |
+
|
331 |
$value = get_field($field_name, $post_id);
|
332 |
+
|
333 |
if( is_array($value) )
|
334 |
{
|
335 |
$value = @implode(', ',$value);
|
336 |
}
|
337 |
+
|
338 |
echo $value;
|
339 |
}
|
340 |
|
343 |
* have_rows
|
344 |
*
|
345 |
* This function will instantiate a global variable containing the rows of a repeater or flexible content field,
|
346 |
+
* afterwhich, it will determine if another row exists to loop through
|
347 |
*
|
348 |
* @type function
|
349 |
* @date 2/09/13
|
354 |
*/
|
355 |
|
356 |
function have_rows( $field_name, $post_id = false ) {
|
357 |
+
|
358 |
// vars
|
359 |
$depth = 0;
|
360 |
$row = array();
|
361 |
$new_parent_loop = false;
|
362 |
$new_child_loop = false;
|
363 |
+
|
364 |
+
|
365 |
// reference
|
366 |
$_post_id = $post_id;
|
367 |
+
|
368 |
+
|
369 |
// filter post_id
|
370 |
$post_id = apply_filters('acf/get_post_id', $post_id );
|
371 |
+
|
372 |
+
|
373 |
// empty?
|
374 |
if( empty($GLOBALS['acf_field']) )
|
375 |
{
|
376 |
// reset
|
377 |
reset_rows( true );
|
378 |
+
|
379 |
+
|
380 |
// create a new loop
|
381 |
$new_parent_loop = true;
|
382 |
}
|
385 |
// vars
|
386 |
$row = end( $GLOBALS['acf_field'] );
|
387 |
$prev = prev( $GLOBALS['acf_field'] );
|
388 |
+
|
389 |
+
|
390 |
// If post_id has changed, this is most likely an archive loop
|
391 |
if( $post_id != $row['post_id'] )
|
392 |
{
|
422 |
// case: Change in $field_name was due to this being a nested loop
|
423 |
// action: move down one level into a new loop
|
424 |
$new_child_loop = true;
|
425 |
+
|
426 |
}
|
427 |
else
|
428 |
{
|
430 |
// action: leave this current loop alone and create a new parent loop
|
431 |
$new_parent_loop = true;
|
432 |
}
|
433 |
+
|
434 |
+
|
435 |
}
|
436 |
}
|
437 |
+
|
438 |
+
|
439 |
if( $new_parent_loop )
|
440 |
{
|
441 |
// vars
|
442 |
$f = get_field_object( $field_name, $post_id );
|
443 |
$v = $f['value'];
|
444 |
unset( $f['value'] );
|
445 |
+
|
446 |
+
|
447 |
// add row
|
448 |
$GLOBALS['acf_field'][] = array(
|
449 |
'name' => $field_name,
|
452 |
'i' => -1,
|
453 |
'post_id' => $post_id,
|
454 |
);
|
455 |
+
|
456 |
}
|
457 |
elseif( $new_child_loop )
|
458 |
{
|
459 |
// vars
|
460 |
$f = acf_get_child_field_from_parent_field( $field_name, $row['field'] );
|
461 |
$v = $row['value'][ $row['i'] ][ $field_name ];
|
462 |
+
|
463 |
$GLOBALS['acf_field'][] = array(
|
464 |
'name' => $field_name,
|
465 |
'value' => $v,
|
468 |
'post_id' => $post_id,
|
469 |
);
|
470 |
|
471 |
+
}
|
472 |
+
|
473 |
+
|
474 |
// update vars
|
475 |
$row = end( $GLOBALS['acf_field'] );
|
476 |
+
|
477 |
+
|
478 |
if( is_array($row['value']) && array_key_exists( $row['i']+1, $row['value'] ) )
|
479 |
{
|
480 |
// next row exists
|
481 |
return true;
|
482 |
}
|
483 |
+
|
484 |
+
|
485 |
// no next row!
|
486 |
reset_rows();
|
487 |
+
|
488 |
+
|
489 |
// return
|
490 |
return false;
|
491 |
+
|
492 |
}
|
493 |
|
494 |
|
506 |
*/
|
507 |
|
508 |
function the_row() {
|
509 |
+
|
510 |
// vars
|
511 |
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
512 |
|
513 |
+
|
514 |
+
|
515 |
// increase row
|
516 |
$GLOBALS['acf_field'][ $depth ]['i']++;
|
517 |
+
|
518 |
+
|
519 |
// get row
|
520 |
$value = $GLOBALS['acf_field'][ $depth ]['value'];
|
521 |
$i = $GLOBALS['acf_field'][ $depth ]['i'];
|
522 |
|
523 |
+
|
524 |
// return
|
525 |
return $value[ $i ];
|
526 |
}
|
541 |
*/
|
542 |
|
543 |
function reset_rows( $hard_reset = false ) {
|
544 |
+
|
545 |
// completely destroy?
|
546 |
if( $hard_reset )
|
547 |
{
|
551 |
{
|
552 |
// vars
|
553 |
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
554 |
+
|
555 |
+
|
556 |
// remove
|
557 |
unset( $GLOBALS['acf_field'][$depth] );
|
558 |
+
|
559 |
+
|
560 |
// refresh index
|
561 |
$GLOBALS['acf_field'] = array_values($GLOBALS['acf_field']);
|
562 |
}
|
563 |
+
|
564 |
+
|
565 |
// return
|
566 |
return true;
|
567 |
+
|
568 |
+
|
569 |
}
|
570 |
|
571 |
|
573 |
* has_sub_field()
|
574 |
*
|
575 |
* This function is used inside a while loop to return either true or false (loop again or stop).
|
576 |
+
* When using a repeater or flexible content field, it will loop through the rows until
|
577 |
* there are none left or a break is detected
|
578 |
*
|
579 |
* @type function
|
587 |
*/
|
588 |
|
589 |
function has_sub_field( $field_name, $post_id = false ) {
|
590 |
+
|
591 |
// vars
|
592 |
$r = have_rows( $field_name, $post_id );
|
593 |
+
|
594 |
+
|
595 |
// if has rows, progress through 1 row for the while loop to work
|
596 |
if( $r )
|
597 |
{
|
598 |
the_row();
|
599 |
}
|
600 |
+
|
601 |
+
|
602 |
// return
|
603 |
return $r;
|
604 |
}
|
640 |
*/
|
641 |
|
642 |
function get_sub_field( $field_name ) {
|
643 |
+
|
644 |
// no field?
|
645 |
if( empty($GLOBALS['acf_field']) )
|
646 |
{
|
647 |
return false;
|
648 |
}
|
649 |
+
|
650 |
+
|
651 |
// vars
|
652 |
$row = end( $GLOBALS['acf_field'] );
|
653 |
+
|
654 |
+
|
655 |
// return value
|
656 |
if( isset($row['value'][ $row['i'] ][ $field_name ]) )
|
657 |
{
|
658 |
return $row['value'][ $row['i'] ][ $field_name ];
|
659 |
}
|
660 |
+
|
661 |
+
|
662 |
// return false
|
663 |
return false;
|
664 |
}
|
681 |
function the_sub_field($field_name)
|
682 |
{
|
683 |
$value = get_sub_field($field_name);
|
684 |
+
|
685 |
if(is_array($value))
|
686 |
{
|
687 |
$value = implode(', ',$value);
|
688 |
}
|
689 |
+
|
690 |
echo $value;
|
691 |
}
|
692 |
|
702 |
*
|
703 |
* @param string $field_name: the name of the field - 'sub_heading'
|
704 |
*
|
705 |
+
* @return array $sub_field
|
706 |
*/
|
707 |
|
708 |
function get_sub_field_object( $child_name )
|
721 |
|
722 |
// return
|
723 |
return acf_get_child_field_from_parent_field( $child_name, $parent );
|
724 |
+
|
725 |
}
|
726 |
|
727 |
|
737 |
* @param string $child_name: the name of the field - 'sub_heading'
|
738 |
* @param array $parent: the parent field object
|
739 |
*
|
740 |
+
* @return array $sub_field
|
741 |
*/
|
742 |
|
743 |
function acf_get_child_field_from_parent_field( $child_name, $parent )
|
744 |
{
|
745 |
// vars
|
746 |
$return = false;
|
747 |
+
|
748 |
+
|
749 |
// find child
|
750 |
if( isset($parent['sub_fields']) && is_array($parent['sub_fields']) )
|
751 |
{
|
756 |
$return = $child;
|
757 |
break;
|
758 |
}
|
759 |
+
|
760 |
// perhaps child has grand children?
|
761 |
$grand_child = acf_get_child_field_from_parent_field( $child_name, $child );
|
762 |
if( $grand_child )
|
778 |
}
|
779 |
}
|
780 |
}
|
781 |
+
|
782 |
|
783 |
// return
|
784 |
return $return;
|
785 |
+
|
786 |
}
|
787 |
|
788 |
|
810 |
{
|
811 |
$array['id'] = uniqid();
|
812 |
}
|
813 |
+
|
814 |
|
815 |
// 3.2.5 - changed show_on_page option
|
816 |
if( !isset($array['options']['hide_on_screen']) && isset($array['options']['show_on_page']) )
|
820 |
unset( $array['options']['show_on_page'] );
|
821 |
}
|
822 |
|
823 |
+
|
824 |
// 4.0.4 - changed location rules architecture
|
825 |
if( isset($array['location']['rules']) )
|
826 |
{
|
827 |
// vars
|
828 |
$groups = array();
|
829 |
$group_no = 0;
|
830 |
+
|
831 |
+
|
832 |
if( is_array($array['location']['rules']) )
|
833 |
{
|
834 |
foreach( $array['location']['rules'] as $rule )
|
835 |
{
|
836 |
$rule['group_no'] = $group_no;
|
837 |
+
|
838 |
// sperate groups?
|
839 |
if( $array['location']['allorany'] == 'any' )
|
840 |
{
|
841 |
$group_no++;
|
842 |
}
|
843 |
+
|
844 |
+
|
845 |
// add to group
|
846 |
$groups[ $rule['group_no'] ][ $rule['order_no'] ] = $rule;
|
847 |
+
|
848 |
+
|
849 |
// sort rules
|
850 |
ksort( $groups[ $rule['group_no'] ] );
|
851 |
+
|
852 |
}
|
853 |
+
|
854 |
// sort groups
|
855 |
ksort( $groups );
|
856 |
}
|
857 |
+
|
858 |
$array['location'] = $groups;
|
859 |
}
|
860 |
+
|
861 |
+
|
862 |
$GLOBALS['acf_register_field_group'][] = $array;
|
863 |
}
|
864 |
|
871 |
{
|
872 |
return $return;
|
873 |
}
|
874 |
+
|
875 |
+
|
876 |
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
877 |
{
|
878 |
$return[] = array(
|
882 |
);
|
883 |
}
|
884 |
|
885 |
+
|
886 |
// order field groups based on menu_order, title
|
887 |
// Obtain a list of columns
|
888 |
foreach( $return as $key => $row )
|
890 |
$menu_order[ $key ] = $row['menu_order'];
|
891 |
$title[ $key ] = $row['title'];
|
892 |
}
|
893 |
+
|
894 |
// Sort the array with menu_order ascending
|
895 |
// Add $array as the last parameter, to sort by the common key
|
896 |
if(isset($menu_order))
|
897 |
{
|
898 |
array_multisort($menu_order, SORT_ASC, $title, SORT_ASC, $return);
|
899 |
}
|
900 |
+
|
901 |
return $return;
|
902 |
}
|
903 |
|
916 |
{
|
917 |
$fields[] = apply_filters('acf/load_field', $f, $f['key']);
|
918 |
}
|
919 |
+
|
920 |
break;
|
921 |
}
|
922 |
}
|
984 |
{
|
985 |
if( $acf['id'] == $post_id )
|
986 |
{
|
987 |
+
$options = $acf['options'];
|
988 |
break;
|
989 |
}
|
990 |
}
|
1010 |
{
|
1011 |
// vars
|
1012 |
$value = get_sub_field('acf_fc_layout');
|
1013 |
+
|
1014 |
+
|
1015 |
return $value;
|
1016 |
}
|
1017 |
|
1039 |
'field' => "",
|
1040 |
'post_id' => false,
|
1041 |
), $atts ) );
|
1042 |
+
|
1043 |
+
|
1044 |
// $field is requird
|
1045 |
if( !$field || $field == "" )
|
1046 |
{
|
1047 |
return "";
|
1048 |
}
|
1049 |
+
|
1050 |
+
|
1051 |
// get value and return it
|
1052 |
$value = get_field( $field, $post_id );
|
1053 |
+
|
1054 |
+
|
1055 |
if( is_array($value) )
|
1056 |
{
|
1057 |
$value = @implode( ', ',$value );
|
1058 |
}
|
1059 |
+
|
1060 |
return $value;
|
1061 |
}
|
1062 |
add_shortcode( 'acf', 'acf_shortcode' );
|
1080 |
{
|
1081 |
// global vars
|
1082 |
global $post_id;
|
1083 |
+
|
1084 |
+
|
1085 |
// verify nonce
|
1086 |
if( isset($_POST['acf_nonce']) && wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
1087 |
{
|
1088 |
// $post_id to save against
|
1089 |
$post_id = $_POST['post_id'];
|
1090 |
+
|
1091 |
+
|
1092 |
// allow for custom save
|
1093 |
$post_id = apply_filters('acf/pre_save_post', $post_id);
|
1094 |
+
|
1095 |
+
|
1096 |
// save the data
|
1097 |
+
do_action('acf/save_post', $post_id);
|
1098 |
|
1099 |
|
1100 |
// redirect
|
1104 |
exit;
|
1105 |
}
|
1106 |
}
|
1107 |
+
|
1108 |
+
|
1109 |
// need wp styling
|
1110 |
wp_enqueue_style(array(
|
1111 |
'colors-fresh'
|
1112 |
));
|
1113 |
+
|
1114 |
+
|
1115 |
// actions
|
1116 |
do_action('acf/input/admin_enqueue_scripts');
|
1117 |
|
1118 |
add_action('wp_head', 'acf_form_wp_head');
|
1119 |
+
|
1120 |
}
|
1121 |
|
1122 |
function acf_form_wp_head()
|
1136 |
*
|
1137 |
* @param array $options: an array containing many options to customize the form
|
1138 |
* string + post_id: post id to get field groups from and save data to. Default is false
|
1139 |
+
* array + field_groups: an array containing field group ID's. If this option is set,
|
1140 |
* the post_id will not be used to dynamically find the field groups
|
1141 |
* boolean + form: display the form tag or not. Defaults to true
|
1142 |
* array + form_attributes: an array containg attributes which will be added into the form tag
|
1144 |
* string + html_before_fields: html inside form before fields
|
1145 |
* string + html_after_fields: html inside form after fields
|
1146 |
* string + submit_value: value of submit button
|
1147 |
+
* string + updated_message: default updated message. Can be false
|
1148 |
*
|
1149 |
* @return N/A
|
1150 |
*/
|
1152 |
function acf_form( $options = array() )
|
1153 |
{
|
1154 |
global $post;
|
1155 |
+
|
1156 |
+
|
1157 |
// defaults
|
1158 |
$defaults = array(
|
1159 |
'post_id' => false,
|
1169 |
'html_before_fields' => '',
|
1170 |
'html_after_fields' => '',
|
1171 |
'submit_value' => __("Update", 'acf'),
|
1172 |
+
'updated_message' => __("Post updated", 'acf'),
|
1173 |
);
|
1174 |
+
|
1175 |
+
|
1176 |
// merge defaults with options
|
1177 |
$options = array_merge($defaults, $options);
|
1178 |
+
|
1179 |
+
|
1180 |
// merge sub arrays
|
1181 |
foreach( $options as $k => $v )
|
1182 |
{
|
1185 |
$options[ $k ] = array_merge($defaults[ $k ], $options[ $k ]);
|
1186 |
}
|
1187 |
}
|
1188 |
+
|
1189 |
+
|
1190 |
// filter post_id
|
1191 |
$options['post_id'] = apply_filters('acf/get_post_id', $options['post_id'] );
|
1192 |
+
|
1193 |
+
|
1194 |
// attributes
|
1195 |
$options['form_attributes']['class'] .= 'acf-form';
|
1196 |
+
|
1197 |
+
|
1198 |
+
|
1199 |
// register post box
|
1200 |
if( empty($options['field_groups']) )
|
1201 |
{
|
1203 |
$filter = array(
|
1204 |
'post_id' => $options['post_id']
|
1205 |
);
|
1206 |
+
|
1207 |
+
|
1208 |
if( strpos($options['post_id'], 'user_') !== false )
|
1209 |
{
|
1210 |
$user_id = str_replace('user_', '', $options['post_id']);
|
1219 |
'ef_taxonomy' => $taxonomy_id
|
1220 |
);
|
1221 |
}
|
1222 |
+
|
1223 |
+
|
1224 |
$options['field_groups'] = array();
|
1225 |
$options['field_groups'] = apply_filters( 'acf/location/match_field_groups', $options['field_groups'], $filter );
|
1226 |
}
|
1231 |
{
|
1232 |
echo '<div id="message" class="updated"><p>' . $options['updated_message'] . '</p></div>';
|
1233 |
}
|
1234 |
+
|
1235 |
+
|
1236 |
// display form
|
1237 |
if( $options['form'] ): ?>
|
1238 |
<form <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
|
1239 |
<?php endif; ?>
|
1240 |
+
|
1241 |
<div style="display:none">
|
1242 |
<script type="text/javascript">
|
1243 |
acf.o.post_id = <?php echo is_numeric($options['post_id']) ? $options['post_id'] : '"' . $options['post_id'] . '"'; ?>;
|
1247 |
<input type="hidden" name="return" value="<?php echo $options['return']; ?>" />
|
1248 |
<?php wp_editor('', 'acf_settings'); ?>
|
1249 |
</div>
|
1250 |
+
|
1251 |
<div id="poststuff">
|
1252 |
<?php
|
1253 |
+
|
1254 |
// html before fields
|
1255 |
echo $options['html_before_fields'];
|
1256 |
+
|
1257 |
+
|
1258 |
$acfs = apply_filters('acf/get_field_groups', array());
|
1259 |
+
|
1260 |
if( is_array($acfs) ){ foreach( $acfs as $acf ){
|
1261 |
+
|
1262 |
// only add the chosen field groups
|
1263 |
if( !in_array( $acf['id'], $options['field_groups'] ) )
|
1264 |
{
|
1265 |
continue;
|
1266 |
}
|
1267 |
+
|
1268 |
+
|
1269 |
// load options
|
1270 |
$acf['options'] = apply_filters('acf/field_group/get_options', array(), $acf['id']);
|
1271 |
+
|
1272 |
+
|
1273 |
// load fields
|
1274 |
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
1275 |
+
|
1276 |
+
|
1277 |
echo '<div id="acf_' . $acf['id'] . '" class="postbox acf_postbox ' . $acf['options']['layout'] . '">';
|
1278 |
echo '<h3 class="hndle"><span>' . $acf['title'] . '</span></h3>';
|
1279 |
echo '<div class="inside">';
|
1280 |
+
|
1281 |
do_action('acf/create_fields', $fields, $options['post_id']);
|
1282 |
+
|
1283 |
echo '</div></div>';
|
1284 |
+
|
1285 |
}}
|
1286 |
+
|
1287 |
+
|
1288 |
// html after fields
|
1289 |
echo $options['html_after_fields'];
|
1290 |
+
|
1291 |
?>
|
1292 |
+
|
1293 |
<?php if( $options['form'] ): ?>
|
1294 |
<!-- Submit -->
|
1295 |
<div class="field">
|
1297 |
</div>
|
1298 |
<!-- / Submit -->
|
1299 |
<?php endif; ?>
|
1300 |
+
|
1301 |
</div><!-- <div id="poststuff"> -->
|
1302 |
+
|
1303 |
<?php if( $options['form'] ): ?>
|
1304 |
</form>
|
1305 |
<?php endif;
|
1326 |
{
|
1327 |
// filter post_id
|
1328 |
$post_id = apply_filters('acf/get_post_id', $post_id );
|
1329 |
+
|
1330 |
+
|
1331 |
// vars
|
1332 |
$options = array(
|
1333 |
'load_value' => false,
|
1334 |
'format_value' => false
|
1335 |
);
|
1336 |
+
|
1337 |
$field = get_field_object( $field_key, $post_id, $options);
|
1338 |
|
1339 |
+
|
1340 |
// sub fields? They need formatted data
|
1341 |
if( $field['type'] == 'repeater' )
|
1342 |
{
|
1352 |
}
|
1353 |
}
|
1354 |
}
|
1355 |
+
|
1356 |
+
|
1357 |
// save
|
1358 |
do_action('acf/update_value', $value, $post_id, $field );
|
1359 |
+
|
1360 |
+
|
1361 |
return true;
|
1362 |
+
|
1363 |
}
|
1364 |
|
1365 |
|
1426 |
{
|
1427 |
return $value;
|
1428 |
}
|
1429 |
+
|
1430 |
|
1431 |
// define sub field keys
|
1432 |
$sub_fields = array();
|
1437 |
$sub_fields[ $sub_field['name'] ] = $sub_field;
|
1438 |
}
|
1439 |
}
|
1440 |
+
|
1441 |
+
|
1442 |
// loop through the values and format the array to use sub field keys
|
1443 |
if( is_array($value) )
|
1444 |
{
|
1453 |
{
|
1454 |
continue;
|
1455 |
}
|
1456 |
+
|
1457 |
+
|
1458 |
// vars
|
1459 |
$sub_field = $sub_fields[ $sub_field_name ];
|
1460 |
$sub_field_value = acf_convert_field_names_to_keys( $sub_field_value, $sub_field );
|
1461 |
+
|
1462 |
+
|
1463 |
// set new value
|
1464 |
$value[$row_i][ $sub_field['key'] ] = $sub_field_value;
|
1465 |
+
|
1466 |
+
|
1467 |
// unset old value
|
1468 |
unset( $value[$row_i][$sub_field_name] );
|
1469 |
+
|
1470 |
+
|
1471 |
}
|
1472 |
// foreach( $row as $sub_field_name => $sub_field_value )
|
1473 |
}
|
1476 |
// foreach( $value as $row_i => $row)
|
1477 |
}
|
1478 |
// if( $value )
|
1479 |
+
|
1480 |
+
|
1481 |
return $value;
|
1482 |
|
1483 |
}
|
1497 |
*/
|
1498 |
|
1499 |
function acf_force_type_array( $var ) {
|
1500 |
+
|
1501 |
// is array?
|
1502 |
if( is_array($var) ) {
|
1503 |
+
|
1504 |
return $var;
|
1505 |
+
|
1506 |
}
|
1507 |
+
|
1508 |
+
|
1509 |
// bail early if empty
|
1510 |
if( empty($var) && !is_numeric($var) ) {
|
1511 |
+
|
1512 |
return array();
|
1513 |
+
|
1514 |
}
|
1515 |
+
|
1516 |
+
|
1517 |
+
// string
|
1518 |
if( is_string($var) ) {
|
1519 |
+
|
1520 |
return explode(',', $var);
|
1521 |
+
|
1522 |
}
|
1523 |
+
|
1524 |
+
|
1525 |
// place in array
|
1526 |
return array( $var );
|
1527 |
+
}
|
1528 |
|
1529 |
|
1530 |
/*
|
1542 |
*/
|
1543 |
|
1544 |
function acf_get_valid_terms( $terms = false, $taxonomy = 'category' ) {
|
1545 |
+
|
1546 |
// bail early if function does not yet exist or
|
1547 |
if( !function_exists('wp_get_split_term') || empty($terms) ) {
|
1548 |
+
|
1549 |
return $terms;
|
1550 |
+
|
1551 |
}
|
1552 |
+
|
1553 |
+
|
1554 |
// vars
|
1555 |
$is_array = is_array($terms);
|
1556 |
+
|
1557 |
+
|
1558 |
// force into array
|
1559 |
$terms = acf_force_type_array( $terms );
|
1560 |
+
|
1561 |
+
|
1562 |
// force ints
|
1563 |
$terms = array_map('intval', $terms);
|
1564 |
+
|
1565 |
+
|
1566 |
// attempt to find new terms
|
1567 |
foreach( $terms as $i => $term_id ) {
|
1568 |
+
|
1569 |
$new_term_id = wp_get_split_term($term_id, $taxonomy);
|
1570 |
+
|
1571 |
if( $new_term_id ) {
|
1572 |
+
|
1573 |
$terms[ $i ] = $new_term_id;
|
1574 |
+
|
1575 |
}
|
1576 |
+
|
1577 |
}
|
1578 |
+
|
1579 |
+
|
1580 |
// revert array if needed
|
1581 |
if( !$is_array ) {
|
1582 |
+
|
1583 |
$terms = $terms[0];
|
1584 |
+
|
1585 |
}
|
1586 |
+
|
1587 |
+
|
1588 |
// return
|
1589 |
return $terms;
|
1590 |
+
|
1591 |
}
|
1592 |
|
1593 |
|
1594 |
/*
|
1595 |
* Depreceated Functions
|
1596 |
*
|
1597 |
+
* @description:
|
1598 |
* @created: 23/07/12
|
1599 |
*/
|
1600 |
|
1606 |
* @author Elliot Condon
|
1607 |
* @depreciated: 3.3.4 - now use has_sub_field
|
1608 |
* @since 1.0.3
|
1609 |
+
*
|
1610 |
*-------------------------------------------------------------------------------------*/
|
1611 |
|
1612 |
function reset_the_repeater_field()
|
1622 |
* @author Elliot Condon
|
1623 |
* @depreciated: 3.3.4 - now use has_sub_field
|
1624 |
* @since 1.0.3
|
1625 |
+
*
|
1626 |
*-------------------------------------------------------------------------------------*/
|
1627 |
|
1628 |
function the_repeater_field($field_name, $post_id = false)
|
1638 |
* @author Elliot Condon
|
1639 |
* @depreciated: 3.3.4 - now use has_sub_field
|
1640 |
* @since 3.?.?
|
1641 |
+
*
|
1642 |
*-------------------------------------------------------------------------------------*/
|
1643 |
|
1644 |
function the_flexible_field($field_name, $post_id = false)
|
shared/assets/plugins/advanced-custom-fields/core/controllers/addons.php
CHANGED
@@ -172,11 +172,11 @@ class acf_addons
|
|
172 |
'url' => 'http://wordpress.org/extend/plugins/acf-field-date-time-picker/'
|
173 |
);
|
174 |
$free[] = array(
|
175 |
-
'title' => __("
|
176 |
'description' => __("Find addresses and coordinates of a desired location",'acf'),
|
177 |
'thumbnail' => $dir . 'images/add-ons/google-maps-field-thumb.jpg',
|
178 |
-
'active' => class_exists('
|
179 |
-
'url' => 'https://
|
180 |
);
|
181 |
$free[] = array(
|
182 |
'title' => __("Contact Form 7 Field",'acf'),
|
@@ -253,7 +253,7 @@ class acf_addons
|
|
253 |
<script type="text/javascript">
|
254 |
(function($) {
|
255 |
|
256 |
-
$(window).load
|
257 |
|
258 |
$('#add-ons .add-on-group').each(function(){
|
259 |
|
172 |
'url' => 'http://wordpress.org/extend/plugins/acf-field-date-time-picker/'
|
173 |
);
|
174 |
$free[] = array(
|
175 |
+
'title' => __("Google Map Extended",'acf'),
|
176 |
'description' => __("Find addresses and coordinates of a desired location",'acf'),
|
177 |
'thumbnail' => $dir . 'images/add-ons/google-maps-field-thumb.jpg',
|
178 |
+
'active' => class_exists('acf_field_google_map_extended'),
|
179 |
+
'url' => 'https://wordpress.org/plugins/advanced-custom-fields-google-map-extended/'
|
180 |
);
|
181 |
$free[] = array(
|
182 |
'title' => __("Contact Form 7 Field",'acf'),
|
253 |
<script type="text/javascript">
|
254 |
(function($) {
|
255 |
|
256 |
+
$(window).on('load', function(){
|
257 |
|
258 |
$('#add-ons .add-on-group').each(function(){
|
259 |
|
shared/assets/plugins/advanced-custom-fields/core/controllers/everything_fields.php
CHANGED
@@ -209,7 +209,7 @@ if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input'
|
|
209 |
|
210 |
|
211 |
// validate page
|
212 |
-
if( in_array( $pagenow, array( 'edit-tags.php', 'profile.php', 'user-new.php', 'user-edit.php', 'media.php' ) ) )
|
213 |
{
|
214 |
$return = true;
|
215 |
}
|
@@ -275,26 +275,43 @@ if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input'
|
|
275 |
$this->data['option_name'] = "shopp_category_" . $_GET['id'];
|
276 |
}
|
277 |
|
278 |
-
}
|
279 |
-
if( $pagenow == "edit-tags.php" && isset($_GET['taxonomy']) )
|
280 |
-
{
|
281 |
-
// filter
|
282 |
-
$_GET['taxonomy'] = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
|
283 |
|
|
|
|
|
|
|
284 |
|
285 |
-
$this->data['page_type'] = "taxonomy";
|
286 |
-
$filter['ef_taxonomy'] = $_GET['taxonomy'];
|
287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
$this->data['page_action'] = "add";
|
289 |
$this->data['option_name'] = "";
|
290 |
|
291 |
-
if( isset($_GET['action']) && $_GET['action'] == "edit" )
|
292 |
-
{
|
293 |
-
// filter
|
294 |
-
$_GET['tag_ID'] = filter_var($_GET['tag_ID'], FILTER_SANITIZE_NUMBER_INT);
|
295 |
|
|
|
|
|
|
|
296 |
$this->data['page_action'] = "edit";
|
297 |
-
$this->data['option_name'] = $
|
|
|
298 |
}
|
299 |
|
300 |
}
|
209 |
|
210 |
|
211 |
// validate page
|
212 |
+
if( in_array( $pagenow, array( 'edit-tags.php', 'term.php', 'profile.php', 'user-new.php', 'user-edit.php', 'media.php' ) ) )
|
213 |
{
|
214 |
$return = true;
|
215 |
}
|
275 |
$this->data['option_name'] = "shopp_category_" . $_GET['id'];
|
276 |
}
|
277 |
|
278 |
+
} elseif( $pagenow == "edit-tags.php" || $pagenow == "term.php" ) {
|
|
|
|
|
|
|
|
|
279 |
|
280 |
+
// vars
|
281 |
+
$taxonomy = 'post_tag';
|
282 |
+
$term_id = 0;
|
283 |
|
|
|
|
|
284 |
|
285 |
+
// $_GET
|
286 |
+
if( !empty($_GET['taxonomy']) ) {
|
287 |
+
|
288 |
+
$taxonomy = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
|
289 |
+
|
290 |
+
}
|
291 |
+
|
292 |
+
if( !empty($_GET['tag_ID']) ) {
|
293 |
+
|
294 |
+
$term_id = filter_var($_GET['tag_ID'], FILTER_SANITIZE_NUMBER_INT);
|
295 |
+
|
296 |
+
}
|
297 |
+
|
298 |
+
|
299 |
+
// update filter
|
300 |
+
$filter['ef_taxonomy'] = $taxonomy;
|
301 |
+
|
302 |
+
|
303 |
+
// add
|
304 |
+
$this->data['page_type'] = "taxonomy";
|
305 |
$this->data['page_action'] = "add";
|
306 |
$this->data['option_name'] = "";
|
307 |
|
|
|
|
|
|
|
|
|
308 |
|
309 |
+
// edit
|
310 |
+
if( $term_id ) {
|
311 |
+
|
312 |
$this->data['page_action'] = "edit";
|
313 |
+
$this->data['option_name'] = $taxonomy . "_" . $term_id;
|
314 |
+
|
315 |
}
|
316 |
|
317 |
}
|
shared/assets/plugins/advanced-custom-fields/core/controllers/field_group.php
CHANGED
@@ -350,7 +350,8 @@ class acf_field_group
|
|
350 |
|
351 |
function admin_head()
|
352 |
{
|
353 |
-
global
|
|
|
354 |
|
355 |
|
356 |
// l10n
|
@@ -378,6 +379,7 @@ class acf_field_group
|
|
378 |
acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>";
|
379 |
acf.admin_url = "<?php echo admin_url(); ?>";
|
380 |
acf.ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
|
|
|
381 |
|
382 |
|
383 |
// l10n
|
350 |
|
351 |
function admin_head()
|
352 |
{
|
353 |
+
// global
|
354 |
+
global $wp_version, $post;
|
355 |
|
356 |
|
357 |
// l10n
|
379 |
acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>";
|
380 |
acf.admin_url = "<?php echo admin_url(); ?>";
|
381 |
acf.ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
|
382 |
+
acf.wp_version = "<?php echo $wp_version; ?>";
|
383 |
|
384 |
|
385 |
// l10n
|
shared/assets/plugins/advanced-custom-fields/core/controllers/field_groups.php
CHANGED
@@ -358,7 +358,7 @@ class acf_field_groups
|
|
358 |
<p><?php _e("Absolutely <strong>no</strong> changes have been made to the database between versions 3 and 4. This means you can roll back to version 3 without any issues.",'acf'); ?></p>
|
359 |
|
360 |
<h4><?php _e("Potential Issues",'acf'); ?></h4>
|
361 |
-
<p><?php printf(__('Due to the sizable changes
|
362 |
|
363 |
<div class="acf-alert acf-alert-error">
|
364 |
<p><strong><?php _e("Really Important!",'acf'); ?></strong> <?php printf(__('If you updated the ACF plugin without prior knowledge of such changes, please roll back to the latest %sversion 3%s of this plugin.','acf'),'<a href="http://wordpress.org/extend/plugins/advanced-custom-fields/developers/">','</a>'); ?></p>
|
358 |
<p><?php _e("Absolutely <strong>no</strong> changes have been made to the database between versions 3 and 4. This means you can roll back to version 3 without any issues.",'acf'); ?></p>
|
359 |
|
360 |
<h4><?php _e("Potential Issues",'acf'); ?></h4>
|
361 |
+
<p><?php printf(__('Due to the sizable changes surrounding Add-ons, field types and action/filters, your website may not operate correctly. It is important that you read the full %sMigrating from v3 to v4%s guide to view the full list of changes.','acf'),'<a href="http://www.advancedcustomfields.com/resources/getting-started/migrating-from-v3-to-v4/" target="_blank">','</a>'); ?></p>
|
362 |
|
363 |
<div class="acf-alert acf-alert-error">
|
364 |
<p><strong><?php _e("Really Important!",'acf'); ?></strong> <?php printf(__('If you updated the ACF plugin without prior knowledge of such changes, please roll back to the latest %sversion 3%s of this plugin.','acf'),'<a href="http://wordpress.org/extend/plugins/advanced-custom-fields/developers/">','</a>'); ?></p>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/revisions.php
CHANGED
@@ -115,7 +115,7 @@ class acf_revisions
|
|
115 |
$post_id = 0;
|
116 |
|
117 |
|
118 |
-
//
|
119 |
if( isset($_POST['post_id']) )
|
120 |
{
|
121 |
$post_id = $_POST['post_id'];
|
@@ -154,7 +154,7 @@ class acf_revisions
|
|
154 |
|
155 |
|
156 |
// WP 3.5: left vs right
|
157 |
-
// Add a value of the revision ID (as there is no way to
|
158 |
if( isset($_GET['action'], $_GET['left'], $_GET['right']) && $_GET['action'] == 'diff' )
|
159 |
{
|
160 |
global $left_revision, $right_revision;
|
@@ -193,7 +193,7 @@ class acf_revisions
|
|
193 |
$post_id = 0;
|
194 |
|
195 |
|
196 |
-
//
|
197 |
if( isset($post->ID) )
|
198 |
{
|
199 |
// WP 3.6
|
115 |
$post_id = 0;
|
116 |
|
117 |
|
118 |
+
// determine $post_id
|
119 |
if( isset($_POST['post_id']) )
|
120 |
{
|
121 |
$post_id = $_POST['post_id'];
|
154 |
|
155 |
|
156 |
// WP 3.5: left vs right
|
157 |
+
// Add a value of the revision ID (as there is no way to determine this within the '_wp_post_revision_field_' filter!)
|
158 |
if( isset($_GET['action'], $_GET['left'], $_GET['right']) && $_GET['action'] == 'diff' )
|
159 |
{
|
160 |
global $left_revision, $right_revision;
|
193 |
$post_id = 0;
|
194 |
|
195 |
|
196 |
+
// determine $post_id
|
197 |
if( isset($post->ID) )
|
198 |
{
|
199 |
// WP 3.6
|
shared/assets/plugins/advanced-custom-fields/core/fields/date_picker/date_picker.php
CHANGED
@@ -124,7 +124,7 @@ class acf_field_date_picker extends acf_field
|
|
124 |
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
125 |
<td class="label">
|
126 |
<label><?php _e("Save format",'acf'); ?></label>
|
127 |
-
<p class="description"><?php _e("This format will
|
128 |
<p><?php _e("\"yymmdd\" is the most versatile save format. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate"><?php _e("jQuery date formats",'acf'); ?></a></p>
|
129 |
</td>
|
130 |
<td>
|
124 |
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
125 |
<td class="label">
|
126 |
<label><?php _e("Save format",'acf'); ?></label>
|
127 |
+
<p class="description"><?php _e("This format will determine the value saved to the database and returned via the API",'acf'); ?></p>
|
128 |
<p><?php _e("\"yymmdd\" is the most versatile save format. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate"><?php _e("jQuery date formats",'acf'); ?></a></p>
|
129 |
</td>
|
130 |
<td>
|
shared/assets/plugins/advanced-custom-fields/core/fields/file.php
CHANGED
@@ -26,7 +26,7 @@ class acf_field_file extends acf_field
|
|
26 |
'select' => __("Select File",'acf'),
|
27 |
'edit' => __("Edit File",'acf'),
|
28 |
'update' => __("Update File",'acf'),
|
29 |
-
'uploadedTo' => __("
|
30 |
);
|
31 |
|
32 |
|
26 |
'select' => __("Select File",'acf'),
|
27 |
'edit' => __("Edit File",'acf'),
|
28 |
'update' => __("Update File",'acf'),
|
29 |
+
'uploadedTo' => __("Uploaded to this post",'acf'),
|
30 |
);
|
31 |
|
32 |
|
shared/assets/plugins/advanced-custom-fields/core/fields/google-map.php
CHANGED
@@ -265,6 +265,52 @@ class acf_field_google_map extends acf_field
|
|
265 |
return $value;
|
266 |
}
|
267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
new acf_field_google_map();
|
265 |
return $value;
|
266 |
}
|
267 |
|
268 |
+
|
269 |
+
/*
|
270 |
+
* input_admin_footer
|
271 |
+
*
|
272 |
+
* description
|
273 |
+
*
|
274 |
+
* @type function
|
275 |
+
* @date 6/03/2014
|
276 |
+
* @since 5.0.0
|
277 |
+
*
|
278 |
+
* @param $post_id (int)
|
279 |
+
* @return $post_id (int)
|
280 |
+
*/
|
281 |
+
|
282 |
+
function input_admin_head() {
|
283 |
+
|
284 |
+
add_action( 'admin_footer', array( $this, 'input_admin_footer') );
|
285 |
+
|
286 |
+
}
|
287 |
+
|
288 |
+
function input_admin_footer() {
|
289 |
+
|
290 |
+
// vars
|
291 |
+
$api = array(
|
292 |
+
'libraries' => 'places',
|
293 |
+
'key' => '',
|
294 |
+
'client' => ''
|
295 |
+
);
|
296 |
+
|
297 |
+
|
298 |
+
// filter
|
299 |
+
$api = apply_filters('acf/fields/google_map/api', $api);
|
300 |
+
|
301 |
+
|
302 |
+
// remove empty
|
303 |
+
if( empty($api['key']) ) unset($api['key']);
|
304 |
+
if( empty($api['client']) ) unset($api['client']);
|
305 |
+
|
306 |
+
|
307 |
+
?>
|
308 |
+
<script type="text/javascript">
|
309 |
+
acf.fields.google_map.api = <?php echo json_encode($api); ?>;
|
310 |
+
</script>
|
311 |
+
<?php
|
312 |
+
|
313 |
+
}
|
314 |
}
|
315 |
|
316 |
new acf_field_google_map();
|
shared/assets/plugins/advanced-custom-fields/core/fields/image.php
CHANGED
@@ -27,7 +27,7 @@ class acf_field_image extends acf_field
|
|
27 |
'select' => __("Select Image",'acf'),
|
28 |
'edit' => __("Edit Image",'acf'),
|
29 |
'update' => __("Update Image",'acf'),
|
30 |
-
'uploadedTo' => __("
|
31 |
);
|
32 |
|
33 |
|
27 |
'select' => __("Select Image",'acf'),
|
28 |
'edit' => __("Edit Image",'acf'),
|
29 |
'update' => __("Update Image",'acf'),
|
30 |
+
'uploadedTo' => __("Uploaded to this post",'acf'),
|
31 |
);
|
32 |
|
33 |
|
shared/assets/plugins/advanced-custom-fields/core/fields/relationship.php
CHANGED
@@ -26,13 +26,7 @@ class acf_field_relationship extends acf_field
|
|
26 |
'return_format' => 'object'
|
27 |
);
|
28 |
$this->l10n = array(
|
29 |
-
'max' => __("Maximum values reached ( {max} values )",'acf')
|
30 |
-
'tmpl_li' => '
|
31 |
-
<li>
|
32 |
-
<a href="#" data-post_id="<%= post_id %>"><%= title %><span class="acf-button-remove"></span></a>
|
33 |
-
<input type="hidden" name="<%= name %>[]" value="<%= post_id %>" />
|
34 |
-
</li>
|
35 |
-
'
|
36 |
);
|
37 |
|
38 |
|
26 |
'return_format' => 'object'
|
27 |
);
|
28 |
$this->l10n = array(
|
29 |
+
'max' => __("Maximum values reached ( {max} values )",'acf')
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
);
|
31 |
|
32 |
|
shared/assets/plugins/advanced-custom-fields/core/fields/select.php
CHANGED
@@ -54,7 +54,7 @@ class acf_field_select extends acf_field
|
|
54 |
$optgroup = false;
|
55 |
|
56 |
|
57 |
-
//
|
58 |
if( is_array($field['choices']) )
|
59 |
{
|
60 |
foreach( $field['choices'] as $k => $v )
|
54 |
$optgroup = false;
|
55 |
|
56 |
|
57 |
+
// determine if choices are grouped (2 levels of array)
|
58 |
if( is_array($field['choices']) )
|
59 |
{
|
60 |
foreach( $field['choices'] as $k => $v )
|
shared/assets/plugins/advanced-custom-fields/core/fields/text.php
CHANGED
@@ -174,7 +174,7 @@ class acf_field_text extends acf_field
|
|
174 |
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
175 |
<td class="label">
|
176 |
<label><?php _e("Formatting",'acf'); ?></label>
|
177 |
-
<p><?php _e("
|
178 |
</td>
|
179 |
<td>
|
180 |
<?php
|
174 |
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
175 |
<td class="label">
|
176 |
<label><?php _e("Formatting",'acf'); ?></label>
|
177 |
+
<p><?php _e("Affects value on front end",'acf') ?></p>
|
178 |
</td>
|
179 |
<td>
|
180 |
<?php
|
shared/assets/plugins/advanced-custom-fields/core/fields/textarea.php
CHANGED
@@ -162,7 +162,7 @@ class acf_field_textarea extends acf_field
|
|
162 |
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
163 |
<td class="label">
|
164 |
<label><?php _e("Formatting",'acf'); ?></label>
|
165 |
-
<p><?php _e("
|
166 |
</td>
|
167 |
<td>
|
168 |
<?php
|
162 |
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
163 |
<td class="label">
|
164 |
<label><?php _e("Formatting",'acf'); ?></label>
|
165 |
+
<p><?php _e("Affects value on front end",'acf') ?></p>
|
166 |
</td>
|
167 |
<td>
|
168 |
<?php
|
shared/assets/plugins/advanced-custom-fields/core/fields/wysiwyg.php
CHANGED
@@ -215,6 +215,7 @@ class acf_field_wysiwyg extends acf_field
|
|
215 |
|
216 |
|
217 |
// vars
|
|
|
218 |
$id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
|
219 |
$default_editor = 'tinymce';
|
220 |
|
@@ -245,7 +246,7 @@ class acf_field_wysiwyg extends acf_field
|
|
245 |
$field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor );
|
246 |
|
247 |
?>
|
248 |
-
<div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-core-ui wp-editor-wrap" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>">
|
249 |
<div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
|
250 |
<?php if( user_can_richedit() && $field['media_upload'] == 'yes' ): ?>
|
251 |
<div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons">
|
215 |
|
216 |
|
217 |
// vars
|
218 |
+
//$id = uniqid('acf-editor-');
|
219 |
$id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
|
220 |
$default_editor = 'tinymce';
|
221 |
|
246 |
$field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor );
|
247 |
|
248 |
?>
|
249 |
+
<div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-core-ui wp-editor-wrap tmce-active" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>">
|
250 |
<div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
|
251 |
<?php if( user_can_richedit() && $field['media_upload'] == 'yes' ): ?>
|
252 |
<div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons">
|
shared/assets/plugins/advanced-custom-fields/css/field-group.css
CHANGED
@@ -64,7 +64,7 @@
|
|
64 |
display: none;
|
65 |
}
|
66 |
|
67 |
-
.postbox#acf_fields
|
68 |
display: none;
|
69 |
}
|
70 |
|
@@ -75,6 +75,8 @@
|
|
75 |
|
76 |
.postbox#acf_fields a {
|
77 |
text-decoration: none;
|
|
|
|
|
78 |
}
|
79 |
|
80 |
|
64 |
display: none;
|
65 |
}
|
66 |
|
67 |
+
.postbox#acf_fields > .hndle {
|
68 |
display: none;
|
69 |
}
|
70 |
|
75 |
|
76 |
.postbox#acf_fields a {
|
77 |
text-decoration: none;
|
78 |
+
box-shadow: none;
|
79 |
+
transition: none;
|
80 |
}
|
81 |
|
82 |
|
shared/assets/plugins/advanced-custom-fields/css/input.css
CHANGED
@@ -24,7 +24,7 @@
|
|
24 |
box-shadow: none;
|
25 |
}
|
26 |
|
27 |
-
.acf_postbox.no_box >
|
28 |
.acf_postbox.no_box > .handlediv {
|
29 |
display: none;
|
30 |
}
|
@@ -508,17 +508,21 @@ not needed in WP 3.8
|
|
508 |
|
509 |
.media-modal.acf-media-modal .media-frame-router,
|
510 |
.media-modal.acf-media-modal .attachments,
|
511 |
-
.media-modal.acf-media-modal .media-frame-content .media-toolbar
|
|
|
512 |
display: none;
|
513 |
}
|
514 |
|
515 |
.media-modal.acf-media-modal .media-frame-content {
|
516 |
-
top:
|
|
|
517 |
}
|
518 |
|
|
|
519 |
.media-modal.acf-media-modal .media-frame-title {
|
520 |
border-bottom: 1px solid #DFDFDF;
|
521 |
box-shadow: 0 4px 4px -4px rgba(0, 0, 0, 0.1);
|
|
|
522 |
}
|
523 |
|
524 |
.media-modal.acf-media-modal .media-frame-content .media-sidebar {
|
@@ -528,6 +532,7 @@ not needed in WP 3.8
|
|
528 |
|
529 |
.media-modal.acf-media-modal .media-toolbar {
|
530 |
right: 0;
|
|
|
531 |
}
|
532 |
|
533 |
|
24 |
box-shadow: none;
|
25 |
}
|
26 |
|
27 |
+
.acf_postbox.no_box > .hndle,
|
28 |
.acf_postbox.no_box > .handlediv {
|
29 |
display: none;
|
30 |
}
|
508 |
|
509 |
.media-modal.acf-media-modal .media-frame-router,
|
510 |
.media-modal.acf-media-modal .attachments,
|
511 |
+
.media-modal.acf-media-modal .media-frame-content .media-toolbar,
|
512 |
+
.media-modal.acf-media-modal .media-frame-menu {
|
513 |
display: none;
|
514 |
}
|
515 |
|
516 |
.media-modal.acf-media-modal .media-frame-content {
|
517 |
+
top: 50px;
|
518 |
+
left: 0;
|
519 |
}
|
520 |
|
521 |
+
|
522 |
.media-modal.acf-media-modal .media-frame-title {
|
523 |
border-bottom: 1px solid #DFDFDF;
|
524 |
box-shadow: 0 4px 4px -4px rgba(0, 0, 0, 0.1);
|
525 |
+
left: 0;
|
526 |
}
|
527 |
|
528 |
.media-modal.acf-media-modal .media-frame-content .media-sidebar {
|
532 |
|
533 |
.media-modal.acf-media-modal .media-toolbar {
|
534 |
right: 0;
|
535 |
+
left: 0;
|
536 |
}
|
537 |
|
538 |
|
shared/assets/plugins/advanced-custom-fields/images/add-ons/cf7-field-thumb.jpg
ADDED
Binary file
|
shared/assets/plugins/advanced-custom-fields/images/add-ons/date-time-field-thumb.jpg
ADDED
Binary file
|
shared/assets/plugins/advanced-custom-fields/images/add-ons/flexible-content-field-thumb.jpg
ADDED
Binary file
|
shared/assets/plugins/advanced-custom-fields/images/add-ons/gallery-field-thumb.jpg
ADDED
Binary file
|
shared/assets/plugins/advanced-custom-fields/images/add-ons/google-maps-field-thumb.jpg
ADDED
Binary file
|
shared/assets/plugins/advanced-custom-fields/images/add-ons/gravity-forms-field-thumb.jpg
ADDED
Binary file
|
shared/assets/plugins/advanced-custom-fields/images/add-ons/options-page-thumb.jpg
ADDED
Binary file
|
shared/assets/plugins/advanced-custom-fields/images/add-ons/repeater-field-thumb.jpg
ADDED
Binary file
|
shared/assets/plugins/advanced-custom-fields/js/field-group.js
CHANGED
@@ -135,22 +135,90 @@ var acf = {
|
|
135 |
* @return N/A
|
136 |
*/
|
137 |
|
138 |
-
|
139 |
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
146 |
|
147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
-
|
152 |
|
153 |
-
});
|
154 |
|
155 |
|
156 |
/*
|
135 |
* @return N/A
|
136 |
*/
|
137 |
|
138 |
+
var acf_submit = {
|
139 |
|
140 |
+
init: function(){
|
141 |
+
|
142 |
+
// events
|
143 |
+
$(document).on('submit', '#post', this.submit);
|
144 |
+
|
145 |
+
|
146 |
+
// return
|
147 |
+
return this;
|
148 |
+
|
149 |
+
|
150 |
+
},
|
151 |
|
152 |
+
submit: function( e ){
|
153 |
+
|
154 |
+
// validate post title
|
155 |
+
var $title = $('#titlewrap #title'),
|
156 |
+
$spinner = $('#submitdiv .spinner').last(),
|
157 |
+
$submit = $('#submitdiv input[type="submit"]').last();
|
158 |
|
159 |
+
|
160 |
+
// title empty
|
161 |
+
if( !$title.val() ) {
|
162 |
+
|
163 |
+
// prevent default
|
164 |
+
e.preventDefault();
|
165 |
+
|
166 |
+
|
167 |
+
// hide spinner
|
168 |
+
acf_submit.hide_spinner( $spinner );
|
169 |
+
acf_submit.enable_submit( $submit );
|
170 |
+
|
171 |
+
|
172 |
+
// alert
|
173 |
+
alert( acf.l10n.title );
|
174 |
+
|
175 |
+
|
176 |
+
// focus
|
177 |
+
$title.focus();
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
},
|
182 |
|
183 |
+
hide_spinner: function( $spinner ){
|
184 |
+
|
185 |
+
// bail early if no spinner
|
186 |
+
if( !$spinner.exists() ) return;
|
187 |
+
|
188 |
+
|
189 |
+
// vars
|
190 |
+
var wp_version = acf.wp_version;
|
191 |
+
|
192 |
+
|
193 |
+
// hide
|
194 |
+
if( parseFloat(wp_version) >= 4.2 ) {
|
195 |
+
|
196 |
+
$spinner.removeClass('is-active');
|
197 |
+
|
198 |
+
} else {
|
199 |
+
|
200 |
+
$spinner.css('display', 'none');
|
201 |
+
|
202 |
+
}
|
203 |
+
|
204 |
+
},
|
205 |
+
|
206 |
+
enable_submit: function( $submit ){
|
207 |
+
|
208 |
+
// bail early if no submit
|
209 |
+
if( !$submit.exists() ) {
|
210 |
+
|
211 |
+
return;
|
212 |
+
|
213 |
+
}
|
214 |
+
|
215 |
+
|
216 |
+
// remove class
|
217 |
+
$submit.removeClass('disabled button-disabled button-primary-disabled');
|
218 |
+
|
219 |
}
|
|
|
220 |
|
221 |
+
}.init();
|
222 |
|
223 |
|
224 |
/*
|
shared/assets/plugins/advanced-custom-fields/js/field-group.min.js
CHANGED
@@ -1,8 +1 @@
|
|
1 |
-
/*
|
2 |
-
* field-group.js
|
3 |
-
*
|
4 |
-
* All javascript needed to create a field group
|
5 |
-
*
|
6 |
-
* @type JS
|
7 |
-
* @date 1/08/13
|
8 |
-
*/var acf={ajaxurl:"",admin_url:"",post_id:0,nonce:"",l10n:{},text:{},helpers:{uniqid:null,sortable:null,create_field:null},conditional_logic:null,location:null};(function(e){function t(){e("#acf_fields .fields").each(function(){e(this).children(".field").each(function(t){e(this).find("td.field_order .circle").first().html(t+1)})})}e.fn.exists=function(){return e(this).length>0};acf.helpers.sortable=function(t,n){n.children().each(function(){e(this).width(e(this).width())});return n};acf.helpers.uniqid=function(e,t){typeof e=="undefined"&&(e="");var n,r=function(e,t){e=parseInt(e,10).toString(16);return t<e.length?e.slice(e.length-t):t>e.length?Array(1+(t-e.length)).join("0")+e:e};this.php_js||(this.php_js={});this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(Math.random()*123456789));this.php_js.uniqidSeed++;n=e;n+=r(parseInt((new Date).getTime()/1e3,10),8);n+=r(this.php_js.uniqidSeed,5);t&&(n+=(Math.random()*10).toFixed(8).toString());return n};e(document).on("submit","#post",function(){var t=e("#titlewrap #title");if(!t.val()){alert(acf.l10n.title);t.focus();return!1}});e(document).on("click","#submit-delete",function(){var e=confirm(acf.l10n.move_to_trash);if(!e)return!1});e(document).on("change","#acf_fields tr.field_type select",function(){var t=e(this),n=t.closest("tbody"),r=n.closest(".field"),i=r.attr("data-type"),s=r.attr("data-id"),o=t.val();r.removeClass("field_type-"+i).addClass("field_type-"+o);r.attr("data-type",o);(o=="tab"||o=="message")&&n.find('tr.field_name input[type="text"]').val("").trigger("keyup");if(n.children("tr.field_option_"+o).exists()){n.children("tr.field_option").hide().find("[name]").attr("disabled","true");n.children("tr.field_option_"+o).show().find("[name]").removeAttr("disabled")}else{var u=e('<tr"><td class="label"></td><td><div class="acf-loading"></div></td></tr>');n.children("tr.field_option").hide().find("[name]").attr("disabled","true");n.children("tr.conditional-logic").exists()?n.children("tr.conditional-logic").before(u):n.children("tr.field_save").before(u);var a={action:"acf/field_group/render_options",post_id:acf.post_id,field_key:t.attr("name"),field_type:o,nonce:acf.nonce};e.ajax({url:ajaxurl,data:a,type:"post",dataType:"html",success:function(e){if(!e){u.remove();return}u.replaceWith(e)}})}});e.fn.update_names=function(){var t=e(this),n=t.attr("data-id"),r="field_"+acf.helpers.uniqid();t.attr("data-id",r);t.attr("class",t.attr("class").replace(n,r));t.find(".field_meta td.field_key").text(r);t.find('[id*="'+n+'"]').each(function(){e(this).attr("id",e(this).attr("id").replace(n,r))});t.find('[name*="'+n+'"]').each(function(){e(this).attr("name",e(this).attr("name").replace(n,r))})};e(document).on("click","#acf_fields a.acf_edit_field",function(){var t=e(this).closest(".field");if(t.hasClass("form_open")){t.removeClass("form_open");e(document).trigger("acf/field_form-close",[t])}else{t.addClass("form_open");e(document).trigger("acf/field_form-open",[t])}t.children(".field_form_mask").animate({height:"toggle"},250)});e(document).on("click","#acf_fields a.acf_delete_field",function(){var n=e(this),r=n.closest(".field"),i=r.closest(".fields"),s=e('<div style="height:'+r.height()+'px"></div>');r.animate({left:"50px",opacity:0},250,function(){r.before(s);r.remove();if(i.children(".field").length<=1){s.remove();i.children(".no_fields_message").show()}else s.animate({height:0},250,function(){s.remove()});t()})});e(document).on("click","#acf_fields a.acf_duplicate_field",function(){var n=e(this),r=n.closest(".field"),i=null;r.find("select").each(function(){e(this).attr("data-val",e(this).val())});i=r.clone();i.update_names();i.find(".field:not(.field_key-field_clone)").each(function(){e(this).update_names()});r.after(i);i.find("select").each(function(){e(this).val(e(this).attr("data-val")).trigger("change")});r.hasClass("form_open")?r.find(".acf_edit_field").first().trigger("click"):i.find(".acf_edit_field").first().trigger("click");var s=i.find('tr.field_label:first input[type="text"]'),o=i.find('tr.field_name:first input[type="text"]');o.val("");s.val(s.val()+" ("+acf.l10n.copy+")");s.trigger("blur").trigger("keyup");t()});e(document).on("click","#acf_fields #add_field",function(){var n=e(this).closest(".table_footer").siblings(".fields"),r=n.children(".field_key-field_clone").clone();r.update_names();r.show();n.children(".field_key-field_clone").before(r);n.children(".no_fields_message").exists()&&n.children(".no_fields_message").hide();r.find("tr.field_type select").trigger("change");r.find('.field_form input[type="text"]').val("");setTimeout(function(){r.find('.field_form input[type="text"]').first().focus()},500);r.find("a.acf_edit_field").first().trigger("click");t();return!1});e(document).on("blur","#acf_fields tr.field_label input.label",function(){var t=e(this),n=t.closest(".field"),r=n.find('tr.field_name:first input[type="text"]'),i=n.attr("data-type");if(i=="tab"||i=="message"){r.val("").trigger("keyup");return}if(r.val()==""){var s=t.val(),o={"ä":"a","æ":"a","å":"a","ö":"o","ø":"o","é":"e","ë":"e","ü":"u","ó":"o","ő":"o","ú":"u","é":"e","á":"a","ű":"u","í":"i"," ":"_","'":"","\\?":""};e.each(o,function(e,t){var n=new RegExp(e,"g");s=s.replace(n,t)});s=s.toLowerCase();r.val(s);r.trigger("keyup")}});e(document).on("keyup","#acf_fields .field_form tr.field_label input.label",function(){var t=e(this).val(),n=e(this).closest(".field").find("td.field_label strong a").first().html(t)});e(document).on("keyup","#acf_fields .field_form tr.field_name input.name",function(){var t=e(this).val(),n=e(this).closest(".field").find("td.field_name").first().html(t)});e(document).on("change","#acf_fields .field_form tr.field_type select",function(){var t=e(this).val(),n=e(this).find('option[value="'+t+'"]').html();e(this).closest(".field").find("td.field_type").first().html(n)});e(document).on("mouseover","#acf_fields td.field_order",function(){var n=e(this).closest(".fields");if(n.hasClass("sortable"))return!1;n.addClass("sortable").sortable({update:function(e,n){t()},handle:"td.field_order"})});e(document).ready(function(){acf.location.init();acf.conditional_logic.init()});acf.location={$el:null,init:function(){var t=this;t.$el=e("#acf_location");t.$el.on("click",".location-add-rule",function(){t.add_rule(e(this).closest("tr"));return!1});t.$el.on("click",".location-remove-rule",function(){t.remove_rule(e(this).closest("tr"));return!1});t.$el.on("click",".location-add-group",function(){t.add_group();return!1});t.$el.on("change",".param select",function(){var t=e(this).closest("tr"),n=t.attr("data-id"),r=t.closest(".location-group"),i=r.attr("data-id"),s={action:"acf/field_group/render_location",nonce:acf.nonce,rule_id:n,group_id:i,value:"",param:e(this).val()},o=e('<div class="acf-loading"></div>');t.find("td.value").html(o);e.ajax({url:acf.ajaxurl,data:s,type:"post",dataType:"html",success:function(e){o.replaceWith(e)}})})},add_rule:function(t){var n=t.clone(),r=n.attr("data-id"),i=acf.helpers.uniqid();n.find("[name]").each(function(){e(this).attr("name",e(this).attr("name").replace(r,i));e(this).attr("id",e(this).attr("id").replace(r,i))});n.attr("data-id",i);t.after(n);return!1},remove_rule:function(e){var t=e.siblings("tr").length;t==0?this.remove_group(e.closest(".location-group")):e.remove()},add_group:function(){var t=this.$el.find(".location-group:last"),n=t.clone(),r=n.attr("data-id"),i=acf.helpers.uniqid();n.find("[name]").each(function(){e(this).attr("name",e(this).attr("name").replace(r,i));e(this).attr("id",e(this).attr("id").replace(r,i))});n.attr("data-id",i);n.find("h4").text(acf.l10n.or);n.find("tr:not(:first)").remove();t.after(n)},remove_group:function(e){e.remove()}};e(document).ready(function(){e("#submitdiv #publish").attr("class","acf-button large");e("#submitdiv a.submitdelete").attr("class","delete-field-group").attr("id","submit-delete");var t=e("#hide-on-screen ul.acf-checkbox-list"),n=e('<li><label><input type="checkbox" value="" name="" >'+acf.l10n.hide_show_all+"</label></li>");t.find("input:not(:checked)").length==0&&n.find("input").attr("checked","checked");n.on("change","input",function(){var n=e(this).is(":checked");t.find("input").attr("checked",n)});t.prepend(n)});e(document).on("change",'#adv-settings input[name="show-field_key"]',function(){e(this).val()=="1"?e("#acf_fields table.acf").addClass("show-field_key"):e("#acf_fields table.acf").removeClass("show-field_key")});acf.helpers.create_field=function(t){var n={type:"text",classname:"",name:"",value:""};t=e.extend(!0,n,t);var r="";if(t.type=="text")r+='<input class="text '+t.classname+'" type="text" id="'+t.name+'" name="'+t.name+'" value="'+t.value+'" />';else if(t.type=="select"){var i={};e.each(t.choices,function(e,t){t.group===undefined&&(t.group=0);i[t.group]===undefined&&(i[t.group]=[]);i[t.group].push(t)});r+='<select class="select '+t.classname+'" id="'+t.name+'" name="'+t.name+'">';e.each(i,function(n,i){n!=0&&(r+='<optgroup label="'+n+'">');e.each(i,function(e,n){var i="";n.value==t.value&&(i='selected="selected"');r+="<option "+i+' value="'+n.value+'">'+n.label+"</option>"});n!=0&&(r+="</optgroup>")});r+="</select>"}r=e(r);return r};acf.conditional_logic={triggers:null,init:function(){var t=this;e(document).on("acf/field_form-open",function(e,n){t.render(n)});e(document).on("change","#acf_fields tr.field_label input.label",function(){e("#acf_fields .field.form_open").each(function(){t.render(e(this))})});e(document).on("change",'tr.conditional-logic input[type="radio"]',function(n){n.preventDefault();t.change_toggle(e(this))});e(document).on("change","select.conditional-logic-field",function(n){n.preventDefault();t.change_trigger(e(this))});e(document).on("click","tr.conditional-logic .acf-button-add",function(n){n.preventDefault();t.add(e(this).closest("tr"))});e(document).on("click","tr.conditional-logic .acf-button-remove",function(n){n.preventDefault();t.remove(e(this).closest("tr"))})},render:function(t){var n=this,r=[],i=t.attr("data-id"),s=t.parents(".fields"),o=t.find("> .field_form_mask > .field_form > table > tbody > tr.conditional-logic");e.each(s,function(t){var n=t==0?acf.l10n.sibling_fields:acf.l10n.parent_fields;e(this).children(".field").each(function(){var t=e(this),s=t.attr("data-id"),o=t.attr("data-type"),u=t.find("tr.field_label input").val();if(s=="field_clone")return;if(s==i)return;(o=="select"||o=="checkbox"||o=="true_false"||o=="radio")&&r.push({value:s,label:u,group:n})})});r.length==0&&r.push({value:"null",label:acf.l10n.no_fields});o.find(".conditional-logic-field").each(function(){var t=e(this).val(),n=e(this).attr("name"),i=acf.helpers.create_field({type:"select",classname:"conditional-logic-field",name:n,value:t,choices:r});e(this).replaceWith(i);i.trigger("change")})},change_toggle:function(e){var t=e.val(),n=e.closest("tr.conditional-logic");t=="1"?n.find(".contional-logic-rules-wrapper").show():n.find(".contional-logic-rules-wrapper").hide()},change_trigger:function(t){var n=t.val(),r=e(".field_key-"+n),i=r.attr("data-type"),s=t.closest("tr").find(".conditional-logic-value"),o=[];if(i=="true_false")o=[{value:1,label:acf.l10n.checked}];else if(i=="select"||i=="checkbox"||i=="radio"){var u=r.find(".field_option-choices").val().split("\n");if(u)for(var a=0;a<u.length;a++){var f=u[a].split(":"),l=f[0];f[1]&&(l=f[1]);o.push({value:e.trim(f[0]),label:e.trim(l)})}}var t=acf.helpers.create_field({type:"select",classname:"conditional-logic-value",name:s.attr("name"),value:s.val(),choices:o});s.replaceWith(t);t.trigger("change")},add:function(t){var n=t.clone(),r=parseFloat(t.attr("data-i")),i=acf.helpers.uniqid();n.find("[name]").each(function(){var t="[conditional_logic][rules]["+r+"]",n="[conditional_logic][rules]["+i+"]";e(this).attr("name",e(this).attr("name").replace(t,n));e(this).attr("id",e(this).attr("id").replace(t,n))});n.attr("data-i",i);t.after(n);t.closest("table").removeClass("remove-disabled")},remove:function(e){var t=e.closest("table");if(t.hasClass("remove-disabled"))return!1;e.remove();t.find("tr").length<=1&&t.addClass("remove-disabled")}};e(document).on("change",".radio-option-other_choice input",function(){var t=e(this),n=t.closest("td");if(t.is(":checked"))n.find(".radio-option-save_other_choice").show();else{n.find(".radio-option-save_other_choice").hide();n.find(".radio-option-save_other_choice input").removeAttr("checked")}})})(jQuery);
|
1 |
+
var acf={ajaxurl:"",admin_url:"",post_id:0,nonce:"",l10n:{},text:{},helpers:{uniqid:null,sortable:null,create_field:null},conditional_logic:null,location:null};!function($){function e(){$("#acf_fields .fields").each(function(){$(this).children(".field").each(function(e){$(this).find("td.field_order .circle").first().html(e+1)})})}$.fn.exists=function(){return $(this).length>0},acf.helpers.sortable=function(e,t){return t.children().each(function(){$(this).width($(this).width())}),t},acf.helpers.uniqid=function(e,t){"undefined"==typeof e&&(e="");var i,a=function(e,t){return e=parseInt(e,10).toString(16),t<e.length?e.slice(e.length-t):t>e.length?Array(1+(t-e.length)).join("0")+e:e};return this.php_js||(this.php_js={}),this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())),this.php_js.uniqidSeed++,i=e,i+=a(parseInt((new Date).getTime()/1e3,10),8),i+=a(this.php_js.uniqidSeed,5),t&&(i+=(10*Math.random()).toFixed(8).toString()),i};var t={init:function(){return $(document).on("submit","#post",this.submit),this},submit:function(e){var i=$("#titlewrap #title"),a=$("#submitdiv .spinner").last(),n=$('#submitdiv input[type="submit"]').last();i.val()||(e.preventDefault(),t.hide_spinner(a),t.enable_submit(n),alert(acf.l10n.title),i.focus())},hide_spinner:function(e){if(e.exists()){var t=acf.wp_version;parseFloat(t)>=4.2?e.removeClass("is-active"):e.css("display","none")}},enable_submit:function(e){e.exists()&&e.removeClass("disabled button-disabled button-primary-disabled")}}.init();$(document).on("click","#submit-delete",function(){var e=confirm(acf.l10n.move_to_trash);return e?void 0:!1}),$(document).on("change","#acf_fields tr.field_type select",function(){var e=$(this),t=e.closest("tbody"),i=t.closest(".field"),a=i.attr("data-type"),n=i.attr("data-id"),l=e.val();if(i.removeClass("field_type-"+a).addClass("field_type-"+l),i.attr("data-type",l),("tab"==l||"message"==l)&&t.find('tr.field_name input[type="text"]').val("").trigger("keyup"),t.children("tr.field_option_"+l).exists())t.children("tr.field_option").hide().find("[name]").attr("disabled","true"),t.children("tr.field_option_"+l).show().find("[name]").removeAttr("disabled");else{var o=$('<tr"><td class="label"></td><td><div class="acf-loading"></div></td></tr>');t.children("tr.field_option").hide().find("[name]").attr("disabled","true"),t.children("tr.conditional-logic").exists()?t.children("tr.conditional-logic").before(o):t.children("tr.field_save").before(o);var c={action:"acf/field_group/render_options",post_id:acf.post_id,field_key:e.attr("name"),field_type:l,nonce:acf.nonce};$.ajax({url:ajaxurl,data:c,type:"post",dataType:"html",success:function(e){return e?void o.replaceWith(e):void o.remove()}})}}),$.fn.update_names=function(){var e=$(this),t=e.attr("data-id"),i="field_"+acf.helpers.uniqid();e.attr("data-id",i),e.attr("class",e.attr("class").replace(t,i)),e.find(".field_meta td.field_key").text(i),e.find('[id*="'+t+'"]').each(function(){$(this).attr("id",$(this).attr("id").replace(t,i))}),e.find('[name*="'+t+'"]').each(function(){$(this).attr("name",$(this).attr("name").replace(t,i))})},$(document).on("click","#acf_fields a.acf_edit_field",function(){var e=$(this).closest(".field");e.hasClass("form_open")?(e.removeClass("form_open"),$(document).trigger("acf/field_form-close",[e])):(e.addClass("form_open"),$(document).trigger("acf/field_form-open",[e])),e.children(".field_form_mask").animate({height:"toggle"},250)}),$(document).on("click","#acf_fields a.acf_delete_field",function(){var t=$(this),i=t.closest(".field"),a=i.closest(".fields"),n=$('<div style="height:'+i.height()+'px"></div>');i.animate({left:"50px",opacity:0},250,function(){i.before(n),i.remove(),a.children(".field").length<=1?(n.remove(),a.children(".no_fields_message").show()):n.animate({height:0},250,function(){n.remove()}),e()})}),$(document).on("click","#acf_fields a.acf_duplicate_field",function(){var t=$(this),i=t.closest(".field"),a=null;i.find("select").each(function(){$(this).attr("data-val",$(this).val())}),a=i.clone(),a.update_names(),a.find(".field:not(.field_key-field_clone)").each(function(){$(this).update_names()}),i.after(a),a.find("select").each(function(){$(this).val($(this).attr("data-val")).trigger("change")}),i.hasClass("form_open")?i.find(".acf_edit_field").first().trigger("click"):a.find(".acf_edit_field").first().trigger("click");var n=a.find('tr.field_label:first input[type="text"]'),l=a.find('tr.field_name:first input[type="text"]');l.val(""),n.val(n.val()+" ("+acf.l10n.copy+")"),n.trigger("blur").trigger("keyup"),e()}),$(document).on("click","#acf_fields #add_field",function(){var t=$(this).closest(".table_footer").siblings(".fields"),i=t.children(".field_key-field_clone").clone();return i.update_names(),i.show(),t.children(".field_key-field_clone").before(i),t.children(".no_fields_message").exists()&&t.children(".no_fields_message").hide(),i.find("tr.field_type select").trigger("change"),i.find('.field_form input[type="text"]').val(""),setTimeout(function(){i.find('.field_form input[type="text"]').first().focus()},500),i.find("a.acf_edit_field").first().trigger("click"),e(),!1}),$(document).on("blur","#acf_fields tr.field_label input.label",function(){var e=$(this),t=e.closest(".field"),i=t.find('tr.field_name:first input[type="text"]'),a=t.attr("data-type");if("tab"==a||"message"==a)return void i.val("").trigger("keyup");if(""==i.val()){var n=e.val(),l={"ä":"a","æ":"a","å":"a","ö":"o","ø":"o","é":"e","ë":"e","ü":"u","ó":"o","ő":"o","ú":"u","é":"e","á":"a","ű":"u","í":"i"," ":"_","'":"","\\?":""};$.each(l,function(e,t){var i=new RegExp(e,"g");n=n.replace(i,t)}),n=n.toLowerCase(),i.val(n),i.trigger("keyup")}}),$(document).on("keyup","#acf_fields .field_form tr.field_label input.label",function(){var e=$(this).val(),t=$(this).closest(".field").find("td.field_label strong a").first().html(e)}),$(document).on("keyup","#acf_fields .field_form tr.field_name input.name",function(){var e=$(this).val(),t=$(this).closest(".field").find("td.field_name").first().html(e)}),$(document).on("change","#acf_fields .field_form tr.field_type select",function(){var e=$(this).val(),t=$(this).find('option[value="'+e+'"]').html();$(this).closest(".field").find("td.field_type").first().html(t)}),$(document).on("mouseover","#acf_fields td.field_order",function(){var t=$(this).closest(".fields");return t.hasClass("sortable")?!1:void t.addClass("sortable").sortable({update:function(t,i){e()},handle:"td.field_order"})}),$(document).ready(function(){acf.location.init(),acf.conditional_logic.init()}),acf.location={$el:null,init:function(){var e=this;e.$el=$("#acf_location"),e.$el.on("click",".location-add-rule",function(){return e.add_rule($(this).closest("tr")),!1}),e.$el.on("click",".location-remove-rule",function(){return e.remove_rule($(this).closest("tr")),!1}),e.$el.on("click",".location-add-group",function(){return e.add_group(),!1}),e.$el.on("change",".param select",function(){var e=$(this).closest("tr"),t=e.attr("data-id"),i=e.closest(".location-group"),a=i.attr("data-id"),n={action:"acf/field_group/render_location",nonce:acf.nonce,rule_id:t,group_id:a,value:"",param:$(this).val()},l=$('<div class="acf-loading"></div>');e.find("td.value").html(l),$.ajax({url:acf.ajaxurl,data:n,type:"post",dataType:"html",success:function(e){l.replaceWith(e)}})})},add_rule:function(e){var t=e.clone(),i=t.attr("data-id"),a=acf.helpers.uniqid();return t.find("[name]").each(function(){$(this).attr("name",$(this).attr("name").replace(i,a)),$(this).attr("id",$(this).attr("id").replace(i,a))}),t.attr("data-id",a),e.after(t),!1},remove_rule:function(e){var t=e.siblings("tr").length;0==t?this.remove_group(e.closest(".location-group")):e.remove()},add_group:function(){var e=this.$el.find(".location-group:last"),t=e.clone(),i=t.attr("data-id"),a=acf.helpers.uniqid();t.find("[name]").each(function(){$(this).attr("name",$(this).attr("name").replace(i,a)),$(this).attr("id",$(this).attr("id").replace(i,a))}),t.attr("data-id",a),t.find("h4").text(acf.l10n.or),t.find("tr:not(:first)").remove(),e.after(t)},remove_group:function(e){e.remove()}},$(document).ready(function(){$("#submitdiv #publish").attr("class","acf-button large"),$("#submitdiv a.submitdelete").attr("class","delete-field-group").attr("id","submit-delete");var e=$("#hide-on-screen ul.acf-checkbox-list"),t=$('<li><label><input type="checkbox" value="" name="" >'+acf.l10n.hide_show_all+"</label></li>");0==e.find("input:not(:checked)").length&&t.find("input").attr("checked","checked"),t.on("change","input",function(){var t=$(this).is(":checked");e.find("input").attr("checked",t)}),e.prepend(t)}),$(document).on("change",'#adv-settings input[name="show-field_key"]',function(){"1"==$(this).val()?$("#acf_fields table.acf").addClass("show-field_key"):$("#acf_fields table.acf").removeClass("show-field_key")}),acf.helpers.create_field=function(e){var t={type:"text",classname:"",name:"",value:""};e=$.extend(!0,t,e);var i="";if("text"==e.type)i+='<input class="text '+e.classname+'" type="text" id="'+e.name+'" name="'+e.name+'" value="'+e.value+'" />';else if("select"==e.type){var a={};$.each(e.choices,function(e,t){void 0===t.group&&(t.group=0),void 0===a[t.group]&&(a[t.group]=[]),a[t.group].push(t)}),i+='<select class="select '+e.classname+'" id="'+e.name+'" name="'+e.name+'">',$.each(a,function(t,a){0!=t&&(i+='<optgroup label="'+t+'">'),$.each(a,function(t,a){var n="";a.value==e.value&&(n='selected="selected"'),i+="<option "+n+' value="'+a.value+'">'+a.label+"</option>"}),0!=t&&(i+="</optgroup>")}),i+="</select>"}return i=$(i)},acf.conditional_logic={triggers:null,init:function(){var e=this;$(document).on("acf/field_form-open",function(t,i){e.render(i)}),$(document).on("change","#acf_fields tr.field_label input.label",function(){$("#acf_fields .field.form_open").each(function(){e.render($(this))})}),$(document).on("change",'tr.conditional-logic input[type="radio"]',function(t){t.preventDefault(),e.change_toggle($(this))}),$(document).on("change","select.conditional-logic-field",function(t){t.preventDefault(),e.change_trigger($(this))}),$(document).on("click","tr.conditional-logic .acf-button-add",function(t){t.preventDefault(),e.add($(this).closest("tr"))}),$(document).on("click","tr.conditional-logic .acf-button-remove",function(t){t.preventDefault(),e.remove($(this).closest("tr"))})},render:function(e){var t=this,i=[],a=e.attr("data-id"),n=e.parents(".fields"),l=e.find("> .field_form_mask > .field_form > table > tbody > tr.conditional-logic");$.each(n,function(e){var t=0==e?acf.l10n.sibling_fields:acf.l10n.parent_fields;$(this).children(".field").each(function(){var e=$(this),n=e.attr("data-id"),l=e.attr("data-type"),o=e.find("tr.field_label input").val();"field_clone"!=n&&n!=a&&("select"==l||"checkbox"==l||"true_false"==l||"radio"==l)&&i.push({value:n,label:o,group:t})})}),0==i.length&&i.push({value:"null",label:acf.l10n.no_fields}),l.find(".conditional-logic-field").each(function(){var e=$(this).val(),t=$(this).attr("name"),a=acf.helpers.create_field({type:"select",classname:"conditional-logic-field",name:t,value:e,choices:i});$(this).replaceWith(a),a.trigger("change")})},change_toggle:function(e){var t=e.val(),i=e.closest("tr.conditional-logic");"1"==t?i.find(".contional-logic-rules-wrapper").show():i.find(".contional-logic-rules-wrapper").hide()},change_trigger:function(e){var t=e.val(),i=$(".field_key-"+t),a=i.attr("data-type"),n=e.closest("tr").find(".conditional-logic-value"),l=[];if("true_false"==a)l=[{value:1,label:acf.l10n.checked}];else if("select"==a||"checkbox"==a||"radio"==a){var o=i.find(".field_option-choices").val().split("\n");if(o)for(var c=0;c<o.length;c++){var r=o[c].split(":"),d=r[0];r[1]&&(d=r[1]),l.push({value:$.trim(r[0]),label:$.trim(d)})}}var e=acf.helpers.create_field({type:"select",classname:"conditional-logic-value",name:n.attr("name"),value:n.val(),choices:l});n.replaceWith(e),e.trigger("change")},add:function(e){var t=e.clone(),i=parseFloat(e.attr("data-i")),a=acf.helpers.uniqid();t.find("[name]").each(function(){var e="[conditional_logic][rules]["+i+"]",t="[conditional_logic][rules]["+a+"]";$(this).attr("name",$(this).attr("name").replace(e,t)),$(this).attr("id",$(this).attr("id").replace(e,t))}),t.attr("data-i",a),e.after(t),e.closest("table").removeClass("remove-disabled")},remove:function(e){var t=e.closest("table");return t.hasClass("remove-disabled")?!1:(e.remove(),void(t.find("tr").length<=1&&t.addClass("remove-disabled")))}},$(document).on("change",".radio-option-other_choice input",function(){var e=$(this),t=e.closest("td");e.is(":checked")?t.find(".radio-option-save_other_choice").show():(t.find(".radio-option-save_other_choice").hide(),t.find(".radio-option-save_other_choice input").removeAttr("checked"))})}(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shared/assets/plugins/advanced-custom-fields/js/input.js
CHANGED
@@ -884,7 +884,7 @@ var acf = {
|
|
884 |
* @created: 22/12/12
|
885 |
*/
|
886 |
|
887 |
-
$(window).load
|
888 |
|
889 |
// init
|
890 |
acf.media.init();
|
@@ -1573,11 +1573,8 @@ var acf = {
|
|
1573 |
div.closest('.field').removeClass('error');
|
1574 |
|
1575 |
},
|
1576 |
-
|
1577 |
-
|
1578 |
-
// vars
|
1579 |
-
var id = this.$input.val();
|
1580 |
-
|
1581 |
|
1582 |
// set global var
|
1583 |
_media.div = this.$el;
|
@@ -1587,23 +1584,77 @@ var acf = {
|
|
1587 |
_media.clear_frame();
|
1588 |
|
1589 |
|
1590 |
-
//
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1596 |
|
1597 |
|
1598 |
-
//
|
1599 |
-
|
1600 |
-
acf.media.frame.on('all', function(e){
|
1601 |
|
1602 |
-
|
1603 |
|
1604 |
-
}
|
1605 |
-
|
1606 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1607 |
|
1608 |
// open
|
1609 |
_media.frame.on('open',function() {
|
@@ -1670,25 +1721,11 @@ var acf = {
|
|
1670 |
var t = this;
|
1671 |
|
1672 |
|
1673 |
-
//
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
_media.clear_frame();
|
1679 |
-
|
1680 |
-
|
1681 |
-
// Create the media frame
|
1682 |
-
_media.frame = wp.media({
|
1683 |
-
states : [
|
1684 |
-
new wp.media.controller.Library({
|
1685 |
-
library : wp.media.query( t.o.query ),
|
1686 |
-
multiple : t.o.multiple,
|
1687 |
-
title : acf.l10n.file.select,
|
1688 |
-
priority : 20,
|
1689 |
-
filterable : 'all'
|
1690 |
-
})
|
1691 |
-
]
|
1692 |
});
|
1693 |
|
1694 |
|
@@ -1876,6 +1913,10 @@ var acf = {
|
|
1876 |
$input : null,
|
1877 |
|
1878 |
o : {},
|
|
|
|
|
|
|
|
|
1879 |
|
1880 |
ready : false,
|
1881 |
geocoder : false,
|
@@ -1889,7 +1930,7 @@ var acf = {
|
|
1889 |
|
1890 |
|
1891 |
// find input
|
1892 |
-
this.$input = this.$el.find('.
|
1893 |
|
1894 |
|
1895 |
// get options
|
@@ -2267,37 +2308,46 @@ var acf = {
|
|
2267 |
|
2268 |
$(document).on('acf/setup_fields', function(e, el){
|
2269 |
|
|
|
|
|
|
|
|
|
2270 |
// vars
|
2271 |
-
$fields = $(el).find('.acf-google-map');
|
2272 |
|
2273 |
|
2274 |
// validate
|
2275 |
-
if( ! $fields.exists() )
|
2276 |
-
{
|
2277 |
-
return;
|
2278 |
-
}
|
2279 |
|
2280 |
|
2281 |
-
//
|
2282 |
-
if(
|
2283 |
-
{
|
2284 |
-
$.getScript('https://www.google.com/jsapi', function(){
|
2285 |
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
|
|
|
|
|
|
|
|
2289 |
|
2290 |
acf.fields.google_map.set({ $el : $(this) }).init();
|
2291 |
|
2292 |
});
|
2293 |
|
2294 |
}});
|
|
|
2295 |
});
|
2296 |
|
|
|
|
|
2297 |
}
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
|
|
|
|
|
|
2301 |
|
2302 |
$fields.each(function(){
|
2303 |
|
@@ -2306,9 +2356,23 @@ var acf = {
|
|
2306 |
});
|
2307 |
|
2308 |
}});
|
|
|
|
|
2309 |
|
2310 |
}
|
2311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2312 |
});
|
2313 |
|
2314 |
|
@@ -2486,11 +2550,8 @@ var acf = {
|
|
2486 |
div.closest('.field').removeClass('error');
|
2487 |
|
2488 |
},
|
2489 |
-
|
2490 |
-
|
2491 |
-
// vars
|
2492 |
-
var id = this.$input.val();
|
2493 |
-
|
2494 |
|
2495 |
// set global var
|
2496 |
_media.div = this.$el;
|
@@ -2500,23 +2561,78 @@ var acf = {
|
|
2500 |
_media.clear_frame();
|
2501 |
|
2502 |
|
2503 |
-
//
|
2504 |
-
|
2505 |
-
title : acf.l10n.image.edit,
|
2506 |
-
multiple : false,
|
2507 |
-
button : { text : acf.l10n.image.update }
|
2508 |
-
});
|
2509 |
|
2510 |
|
2511 |
-
//
|
2512 |
-
|
2513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2514 |
|
2515 |
-
|
2516 |
|
2517 |
-
}
|
2518 |
-
|
2519 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2520 |
|
2521 |
// open
|
2522 |
_media.frame.on('open',function() {
|
@@ -2559,7 +2675,7 @@ var acf = {
|
|
2559 |
|
2560 |
|
2561 |
// Finally, open the modal
|
2562 |
-
|
2563 |
|
2564 |
},
|
2565 |
remove : function()
|
@@ -2580,37 +2696,16 @@ var acf = {
|
|
2580 |
var t = this;
|
2581 |
|
2582 |
|
2583 |
-
//
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
_media.clear_frame();
|
2589 |
-
|
2590 |
-
|
2591 |
-
// Create the media frame
|
2592 |
-
_media.frame = wp.media({
|
2593 |
-
states : [
|
2594 |
-
new wp.media.controller.Library({
|
2595 |
-
library : wp.media.query( t.o.query ),
|
2596 |
-
multiple : t.o.multiple,
|
2597 |
-
title : acf.l10n.image.select,
|
2598 |
-
priority : 20,
|
2599 |
-
filterable : 'all'
|
2600 |
-
})
|
2601 |
-
]
|
2602 |
});
|
2603 |
|
2604 |
|
2605 |
-
/*acf.media.frame.on('all', function(e){
|
2606 |
-
|
2607 |
-
console.log( e );
|
2608 |
-
|
2609 |
-
});*/
|
2610 |
-
|
2611 |
-
|
2612 |
// customize model / view
|
2613 |
-
|
2614 |
|
2615 |
// vars
|
2616 |
var toolbar = null,
|
@@ -3099,17 +3194,17 @@ var acf = {
|
|
3099 |
|
3100 |
|
3101 |
// template
|
3102 |
-
var
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
|
3109 |
|
3110 |
|
3111 |
// add new li
|
3112 |
-
this.$right.find('.relationship_list').append(
|
3113 |
|
3114 |
|
3115 |
// trigger change on new_li
|
@@ -3978,12 +4073,12 @@ var acf = {
|
|
3978 |
|
3979 |
var _wysiwyg = acf.fields.wysiwyg = {
|
3980 |
|
3981 |
-
$el
|
3982 |
-
$textarea
|
3983 |
|
3984 |
-
o
|
3985 |
|
3986 |
-
set
|
3987 |
|
3988 |
// merge in new option
|
3989 |
$.extend( this, o );
|
@@ -3995,9 +4090,6 @@ var acf = {
|
|
3995 |
|
3996 |
// get options
|
3997 |
this.o = acf.helpers.get_atts( this.$el );
|
3998 |
-
|
3999 |
-
|
4000 |
-
// add ID
|
4001 |
this.o.id = this.$textarea.attr('id');
|
4002 |
|
4003 |
|
@@ -4005,6 +4097,7 @@ var acf = {
|
|
4005 |
return this;
|
4006 |
|
4007 |
},
|
|
|
4008 |
has_tinymce : function(){
|
4009 |
|
4010 |
var r = false;
|
@@ -4043,7 +4136,8 @@ var acf = {
|
|
4043 |
|
4044 |
|
4045 |
// vars
|
4046 |
-
var
|
|
|
4047 |
command = 'mceAddControl',
|
4048 |
setting = 'theme_advanced_buttons{i}';
|
4049 |
|
@@ -4087,15 +4181,19 @@ var acf = {
|
|
4087 |
|
4088 |
|
4089 |
// add editor
|
4090 |
-
tinyMCE.execCommand( command, false,
|
4091 |
|
4092 |
|
4093 |
// events - load
|
4094 |
-
$(document).trigger('acf/wysiwyg/load',
|
4095 |
|
4096 |
|
4097 |
// add events (click, focus, blur) for inserting image into correct editor
|
4098 |
-
|
|
|
|
|
|
|
|
|
4099 |
|
4100 |
|
4101 |
// restore tinyMCE.settings
|
@@ -4106,18 +4204,15 @@ var acf = {
|
|
4106 |
wpActiveEditor = null;
|
4107 |
|
4108 |
},
|
4109 |
-
add_events : function(){
|
4110 |
|
|
|
|
|
4111 |
// vars
|
4112 |
-
var
|
4113 |
-
editor = tinyMCE.get( id );
|
4114 |
|
4115 |
|
4116 |
// validate
|
4117 |
-
if( !editor )
|
4118 |
-
{
|
4119 |
-
return;
|
4120 |
-
}
|
4121 |
|
4122 |
|
4123 |
// vars
|
@@ -4437,7 +4532,7 @@ var acf = {
|
|
4437 |
* @created: 22/12/12
|
4438 |
*/
|
4439 |
|
4440 |
-
$(window).load
|
4441 |
|
4442 |
// validate
|
4443 |
if( ! _wysiwyg.has_tinymce() )
|
@@ -4485,7 +4580,7 @@ var acf = {
|
|
4485 |
// Add events to content editor
|
4486 |
if( wp_content )
|
4487 |
{
|
4488 |
-
_wysiwyg.
|
4489 |
}
|
4490 |
|
4491 |
|
884 |
* @created: 22/12/12
|
885 |
*/
|
886 |
|
887 |
+
$(window).on('load', function(){
|
888 |
|
889 |
// init
|
890 |
acf.media.init();
|
1573 |
div.closest('.field').removeClass('error');
|
1574 |
|
1575 |
},
|
1576 |
+
|
1577 |
+
new_frame: function( attributes ){
|
|
|
|
|
|
|
1578 |
|
1579 |
// set global var
|
1580 |
_media.div = this.$el;
|
1584 |
_media.clear_frame();
|
1585 |
|
1586 |
|
1587 |
+
// vars
|
1588 |
+
attributes.states = [];
|
1589 |
+
|
1590 |
+
// append states
|
1591 |
+
attributes.states.push(
|
1592 |
+
new wp.media.controller.Library({
|
1593 |
+
library : wp.media.query( this.o.query ),
|
1594 |
+
multiple : attributes.multiple,
|
1595 |
+
title : attributes.title,
|
1596 |
+
priority : 20,
|
1597 |
+
filterable : 'all'
|
1598 |
+
})
|
1599 |
+
);
|
1600 |
|
1601 |
|
1602 |
+
// edit image functionality (added in WP 3.9)
|
1603 |
+
if( acf.helpers.isset(wp, 'media', 'controller', 'EditImage') ) {
|
|
|
1604 |
|
1605 |
+
attributes.states.push( new wp.media.controller.EditImage() );
|
1606 |
|
1607 |
+
}
|
1608 |
+
|
1609 |
|
1610 |
+
// Create the media frame
|
1611 |
+
_media.frame = wp.media( attributes );
|
1612 |
+
|
1613 |
+
|
1614 |
+
// edit image view
|
1615 |
+
// source: media-views.js:2410 editImageContent()
|
1616 |
+
_media.frame.on('content:render:edit-image', function(){
|
1617 |
+
|
1618 |
+
var image = this.state().get('image'),
|
1619 |
+
view = new wp.media.view.EditImage( { model: image, controller: this } ).render();
|
1620 |
+
|
1621 |
+
this.content.set( view );
|
1622 |
+
|
1623 |
+
// after creating the wrapper view, load the actual editor via an ajax call
|
1624 |
+
view.loadEditor();
|
1625 |
+
|
1626 |
+
}, _media.frame);
|
1627 |
+
|
1628 |
+
|
1629 |
+
// update toolbar button
|
1630 |
+
_media.frame.on( 'toolbar:create:select', function( toolbar ) {
|
1631 |
+
|
1632 |
+
toolbar.view = new wp.media.view.Toolbar.Select({
|
1633 |
+
text: attributes.button.text,
|
1634 |
+
controller: this
|
1635 |
+
});
|
1636 |
+
|
1637 |
+
}, _media.frame );
|
1638 |
+
|
1639 |
+
|
1640 |
+
// return
|
1641 |
+
return _media.frame;
|
1642 |
+
|
1643 |
+
},
|
1644 |
+
|
1645 |
+
edit : function(){
|
1646 |
+
|
1647 |
+
// vars
|
1648 |
+
var id = this.$input.val();
|
1649 |
+
|
1650 |
+
|
1651 |
+
// create frame
|
1652 |
+
this.new_frame({
|
1653 |
+
title : acf.l10n.file.edit,
|
1654 |
+
multiple : false,
|
1655 |
+
button : { text : acf.l10n.file.update }
|
1656 |
+
});
|
1657 |
+
|
1658 |
|
1659 |
// open
|
1660 |
_media.frame.on('open',function() {
|
1721 |
var t = this;
|
1722 |
|
1723 |
|
1724 |
+
// create frame
|
1725 |
+
this.new_frame({
|
1726 |
+
title : acf.l10n.file.select,
|
1727 |
+
multiple : t.o.multiple,
|
1728 |
+
button : { text : acf.l10n.file.select }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1729 |
});
|
1730 |
|
1731 |
|
1913 |
$input : null,
|
1914 |
|
1915 |
o : {},
|
1916 |
+
api: {
|
1917 |
+
sensor: false,
|
1918 |
+
libraries: 'places'
|
1919 |
+
},
|
1920 |
|
1921 |
ready : false,
|
1922 |
geocoder : false,
|
1930 |
|
1931 |
|
1932 |
// find input
|
1933 |
+
this.$input = this.$el.find('.input-address');
|
1934 |
|
1935 |
|
1936 |
// get options
|
2308 |
|
2309 |
$(document).on('acf/setup_fields', function(e, el){
|
2310 |
|
2311 |
+
// reference
|
2312 |
+
var self = acf.fields.google_map;
|
2313 |
+
|
2314 |
+
|
2315 |
// vars
|
2316 |
+
var $fields = $(el).find('.acf-google-map');
|
2317 |
|
2318 |
|
2319 |
// validate
|
2320 |
+
if( ! $fields.exists() ) return false;
|
|
|
|
|
|
|
2321 |
|
2322 |
|
2323 |
+
// no google
|
2324 |
+
if( !acf.helpers.isset(window, 'google', 'load') ) {
|
|
|
|
|
2325 |
|
2326 |
+
// load API
|
2327 |
+
$.getScript('https://www.google.com/jsapi', function(){
|
2328 |
+
|
2329 |
+
// load maps
|
2330 |
+
google.load('maps', '3', { other_params: $.param(self.api), callback: function(){
|
2331 |
+
|
2332 |
+
$fields.each(function(){
|
2333 |
|
2334 |
acf.fields.google_map.set({ $el : $(this) }).init();
|
2335 |
|
2336 |
});
|
2337 |
|
2338 |
}});
|
2339 |
+
|
2340 |
});
|
2341 |
|
2342 |
+
return false;
|
2343 |
+
|
2344 |
}
|
2345 |
+
|
2346 |
+
|
2347 |
+
// no maps or places
|
2348 |
+
if( !acf.helpers.isset(window, 'google', 'maps', 'places') ) {
|
2349 |
+
|
2350 |
+
google.load('maps', '3', { other_params: $.param(self.api), callback: function(){
|
2351 |
|
2352 |
$fields.each(function(){
|
2353 |
|
2356 |
});
|
2357 |
|
2358 |
}});
|
2359 |
+
|
2360 |
+
return false;
|
2361 |
|
2362 |
}
|
2363 |
|
2364 |
+
|
2365 |
+
// google exists
|
2366 |
+
$fields.each(function(){
|
2367 |
+
|
2368 |
+
acf.fields.google_map.set({ $el : $(this) }).init();
|
2369 |
+
|
2370 |
+
});
|
2371 |
+
|
2372 |
+
|
2373 |
+
// return
|
2374 |
+
return true;
|
2375 |
+
|
2376 |
});
|
2377 |
|
2378 |
|
2550 |
div.closest('.field').removeClass('error');
|
2551 |
|
2552 |
},
|
2553 |
+
|
2554 |
+
new_frame: function( attributes ){
|
|
|
|
|
|
|
2555 |
|
2556 |
// set global var
|
2557 |
_media.div = this.$el;
|
2561 |
_media.clear_frame();
|
2562 |
|
2563 |
|
2564 |
+
// vars
|
2565 |
+
attributes.states = [];
|
|
|
|
|
|
|
|
|
2566 |
|
2567 |
|
2568 |
+
// append states
|
2569 |
+
attributes.states.push(
|
2570 |
+
new wp.media.controller.Library({
|
2571 |
+
library : wp.media.query( this.o.query ),
|
2572 |
+
multiple : attributes.multiple,
|
2573 |
+
title : attributes.title,
|
2574 |
+
priority : 20,
|
2575 |
+
filterable : 'all'
|
2576 |
+
})
|
2577 |
+
);
|
2578 |
+
|
2579 |
+
|
2580 |
+
// edit image functionality (added in WP 3.9)
|
2581 |
+
if( acf.helpers.isset(wp, 'media', 'controller', 'EditImage') ) {
|
2582 |
|
2583 |
+
attributes.states.push( new wp.media.controller.EditImage() );
|
2584 |
|
2585 |
+
}
|
2586 |
+
|
2587 |
|
2588 |
+
// Create the media frame
|
2589 |
+
_media.frame = wp.media( attributes );
|
2590 |
+
|
2591 |
+
|
2592 |
+
// edit image view
|
2593 |
+
// source: media-views.js:2410 editImageContent()
|
2594 |
+
_media.frame.on('content:render:edit-image', function(){
|
2595 |
+
|
2596 |
+
var image = this.state().get('image'),
|
2597 |
+
view = new wp.media.view.EditImage( { model: image, controller: this } ).render();
|
2598 |
+
|
2599 |
+
this.content.set( view );
|
2600 |
+
|
2601 |
+
// after creating the wrapper view, load the actual editor via an ajax call
|
2602 |
+
view.loadEditor();
|
2603 |
+
|
2604 |
+
}, _media.frame);
|
2605 |
+
|
2606 |
+
|
2607 |
+
// update toolbar button
|
2608 |
+
_media.frame.on( 'toolbar:create:select', function( toolbar ) {
|
2609 |
+
|
2610 |
+
toolbar.view = new wp.media.view.Toolbar.Select({
|
2611 |
+
text: attributes.button.text,
|
2612 |
+
controller: this
|
2613 |
+
});
|
2614 |
+
|
2615 |
+
}, _media.frame );
|
2616 |
+
|
2617 |
+
|
2618 |
+
// return
|
2619 |
+
return _media.frame;
|
2620 |
+
|
2621 |
+
},
|
2622 |
+
|
2623 |
+
edit : function(){
|
2624 |
+
|
2625 |
+
// vars
|
2626 |
+
var id = this.$input.val();
|
2627 |
+
|
2628 |
+
|
2629 |
+
// create frame
|
2630 |
+
this.new_frame({
|
2631 |
+
title : acf.l10n.image.edit,
|
2632 |
+
multiple : false,
|
2633 |
+
button : { text : acf.l10n.image.update }
|
2634 |
+
});
|
2635 |
+
|
2636 |
|
2637 |
// open
|
2638 |
_media.frame.on('open',function() {
|
2675 |
|
2676 |
|
2677 |
// Finally, open the modal
|
2678 |
+
_media.frame.open();
|
2679 |
|
2680 |
},
|
2681 |
remove : function()
|
2696 |
var t = this;
|
2697 |
|
2698 |
|
2699 |
+
// create frame
|
2700 |
+
this.new_frame({
|
2701 |
+
title : acf.l10n.image.select,
|
2702 |
+
multiple : t.o.multiple,
|
2703 |
+
button : { text : acf.l10n.image.select }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2704 |
});
|
2705 |
|
2706 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2707 |
// customize model / view
|
2708 |
+
_media.frame.on('content:activate', function(){
|
2709 |
|
2710 |
// vars
|
2711 |
var toolbar = null,
|
3194 |
|
3195 |
|
3196 |
// template
|
3197 |
+
var html = [
|
3198 |
+
'<li>',
|
3199 |
+
'<a href="#" data-post_id="' + $a.attr('data-post_id') + '">',
|
3200 |
+
$a.html() + '<span class="acf-button-remove"></span>',
|
3201 |
+
'</a>',
|
3202 |
+
'<input type="hidden" name="' + this.$input.attr('name') + '[]" value="' + $a.attr('data-post_id') + '" />',
|
3203 |
+
'</li>'].join('');
|
3204 |
|
3205 |
|
3206 |
// add new li
|
3207 |
+
this.$right.find('.relationship_list').append( html )
|
3208 |
|
3209 |
|
3210 |
// trigger change on new_li
|
4073 |
|
4074 |
var _wysiwyg = acf.fields.wysiwyg = {
|
4075 |
|
4076 |
+
$el: null,
|
4077 |
+
$textarea: null,
|
4078 |
|
4079 |
+
o: {},
|
4080 |
|
4081 |
+
set: function( o ){
|
4082 |
|
4083 |
// merge in new option
|
4084 |
$.extend( this, o );
|
4090 |
|
4091 |
// get options
|
4092 |
this.o = acf.helpers.get_atts( this.$el );
|
|
|
|
|
|
|
4093 |
this.o.id = this.$textarea.attr('id');
|
4094 |
|
4095 |
|
4097 |
return this;
|
4098 |
|
4099 |
},
|
4100 |
+
|
4101 |
has_tinymce : function(){
|
4102 |
|
4103 |
var r = false;
|
4136 |
|
4137 |
|
4138 |
// vars
|
4139 |
+
var id = this.o.id,
|
4140 |
+
toolbar = this.get_toolbar(),
|
4141 |
command = 'mceAddControl',
|
4142 |
setting = 'theme_advanced_buttons{i}';
|
4143 |
|
4181 |
|
4182 |
|
4183 |
// add editor
|
4184 |
+
tinyMCE.execCommand( command, false, id);
|
4185 |
|
4186 |
|
4187 |
// events - load
|
4188 |
+
$(document).trigger('acf/wysiwyg/load', id);
|
4189 |
|
4190 |
|
4191 |
// add events (click, focus, blur) for inserting image into correct editor
|
4192 |
+
setTimeout(function(){
|
4193 |
+
|
4194 |
+
_wysiwyg.add_events( id );
|
4195 |
+
|
4196 |
+
}, 100);
|
4197 |
|
4198 |
|
4199 |
// restore tinyMCE.settings
|
4204 |
wpActiveEditor = null;
|
4205 |
|
4206 |
},
|
|
|
4207 |
|
4208 |
+
add_events: function( id ){
|
4209 |
+
|
4210 |
// vars
|
4211 |
+
var editor = tinyMCE.get( id );
|
|
|
4212 |
|
4213 |
|
4214 |
// validate
|
4215 |
+
if( !editor ) return;
|
|
|
|
|
|
|
4216 |
|
4217 |
|
4218 |
// vars
|
4532 |
* @created: 22/12/12
|
4533 |
*/
|
4534 |
|
4535 |
+
$(window).on('load', function(){
|
4536 |
|
4537 |
// validate
|
4538 |
if( ! _wysiwyg.has_tinymce() )
|
4580 |
// Add events to content editor
|
4581 |
if( wp_content )
|
4582 |
{
|
4583 |
+
_wysiwyg.add_events('content');
|
4584 |
}
|
4585 |
|
4586 |
|
shared/assets/plugins/advanced-custom-fields/js/input.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
var acf={ajaxurl:"",admin_url:"",wp_version:"",post_id:0,nonce:"",l10n:null,o:null,helpers:{get_atts:null,version_compare:null,uniqid:null,sortable:null,add_message:null,is_clone_field:null,url_to_object:null},validation:null,conditional_logic:null,media:null,fields:{date_picker:null,color_picker:null,Image:null,file:null,wysiwyg:null,gallery:null,relationship:null}};!function($){acf.helpers.isset=function(){var e=arguments,t=e.length,a=null,n;if(0===t)throw new Error("Empty isset");for(a=e[0],i=1;i<t;i++){if(e[i]===n||a[e[i]]===n)return!1;a=a[e[i]]}return!0},acf.helpers.get_atts=function(e){var t={};return $.each(e[0].attributes,function(e,i){"data-"==i.name.substr(0,5)&&(t[i.name.replace("data-","")]=i.value)}),t},acf.helpers.version_compare=function(e,t){if(typeof e+typeof t!="stringstring")return!1;for(var i=e.split("."),a=t.split("."),n=0,s=Math.max(i.length,a.length);s>n;n++){if(i[n]&&!a[n]&&parseInt(i[n])>0||parseInt(i[n])>parseInt(a[n]))return 1;if(a[n]&&!i[n]&&parseInt(a[n])>0||parseInt(i[n])<parseInt(a[n]))return-1}return 0},acf.helpers.uniqid=function(){var e=new Date;return e.getTime()},acf.helpers.url_to_object=function(e){var t={},a=e.split("&");for(i in a){var n=a[i].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t},acf.helpers.sortable=function(e,t){return t.children().each(function(){$(this).width($(this).width())}),t},acf.helpers.is_clone_field=function(e){return e.attr("name")&&-1!=e.attr("name").indexOf("[acfcloneindex]")?!0:!1},acf.helpers.add_message=function(e,t){var e=$('<div class="acf-message-wrapper"><div class="message updated"><p>'+e+"</p></div></div>");t.prepend(e),setTimeout(function(){e.animate({opacity:0},250,function(){e.remove()})},1500)},$.fn.exists=function(){return $(this).length>0},acf.media={div:null,frame:null,render_timout:null,clear_frame:function(){this.frame&&(this.frame.detach(),this.frame.dispose(),this.frame=null)},type:function(){var e="thickbox";return"undefined"!=typeof wp&&(e="backbone"),e},init:function(){if("backbone"!==this.type())return!1;if(!acf.helpers.isset(wp,"media","view","AttachmentCompat","prototype"))return!1;var e=wp.media.view.AttachmentCompat.prototype;e.orig_render=e.render,e.orig_dispose=e.dispose,e.className="compat-item acf_postbox no_box",e.render=function(){var e=this;return e.ignore_render?this:(this.orig_render(),setTimeout(function(){var t=e.$el.closest(".media-modal");if(!t.hasClass("acf-media-modal")&&!t.find(".media-frame-router .acf-expand-details").exists()){var i=$(['<a href="#" class="acf-expand-details">','<span class="icon"></span>','<span class="is-closed">'+acf.l10n.core.expand_details+"</span>",'<span class="is-open">'+acf.l10n.core.collapse_details+"</span>","</a>"].join(""));i.on("click",function(e){e.preventDefault(),t.hasClass("acf-expanded")?t.removeClass("acf-expanded"):t.addClass("acf-expanded")}),t.find(".media-frame-router").append(i)}},0),clearTimeout(acf.media.render_timout),acf.media.render_timout=setTimeout(function(){$(document).trigger("acf/setup_fields",[e.$el])},50),this)},e.dispose=function(){$(document).trigger("acf/remove_fields",[this.$el]),this.orig_dispose()},e.save=function(e){var t={},i={};e&&e.preventDefault(),_.each(this.$el.serializeArray(),function(e){"[]"===e.name.slice(-2)&&(e.name=e.name.replace("[]",""),"undefined"==typeof i[e.name]&&(i[e.name]=-1),i[e.name]++,e.name+="["+i[e.name]+"]"),t[e.name]=e.value}),this.ignore_render=!0,this.model.saveCompat(t)}}},acf.conditional_logic={items:[],init:function(){var e=this;$(document).on("change",".field input, .field textarea, .field select",function(){$("#acf-has-changed").exists()&&$("#acf-has-changed").val(1),e.change($(this))}),$(document).on("acf/setup_fields",function(t,i){e.refresh($(i))}),e.refresh()},change:function(e){var t=this,i=e.closest(".field"),a=i.attr("data-field_key");$.each(this.items,function(e,i){$.each(i.rules,function(e,n){n.field==a&&t.refresh_field(i)})})},refresh_field:function(e){var t=this,i=$(".field_key-"+e.field);i.each(function(){var i=!0;"any"==e.allorany&&(i=!1);var a=$(this),n=!0;$.each(e.rules,function(s,o){var l=$(".field_key-"+o.field);l.hasClass("sub_field")&&(l=a.siblings(".field_key-"+o.field),n=!1,l.exists()||(a.parents("tr").each(function(){return l=$(this).find(".field_key-"+o.field),l.exists()?!1:void 0}),n=!0));var r=a.parent("tr").parent().parent("table").parent(".layout");r.exists()&&(n=!0,a.is("th")&&l.is("th")&&(l=a.closest(".layout").find("td.field_key-"+o.field)));var r=a.parent("tr").parent().parent("table").parent(".repeater");r.exists()&&"1"==r.attr("data-max_rows")&&(n=!0,a.is("th")&&l.is("th")&&(l=a.closest("table").find("td.field_key-"+o.field)));var c=t.calculate(o,l,a);if("all"==e.allorany){if(0==c)return i=!1,!1}else if(1==c)return i=!0,!1}),a.removeClass("acf-conditional_logic-hide acf-conditional_logic-show acf-show-blank"),i?(a.find("input, textarea, select").removeAttr("disabled"),a.addClass("acf-conditional_logic-show"),$(document).trigger("acf/conditional_logic/show",[a,e])):(a.find("input, textarea, select").attr("disabled","disabled"),a.addClass("acf-conditional_logic-hide"),n||a.addClass("acf-show-blank"),$(document).trigger("acf/conditional_logic/hide",[a,e]))})},refresh:function(e){e=e||$("body");var t=this;$.each(this.items,function(i,a){$.each(a.rules,function(i,n){e.find('.field[data-field_key="'+a.field+'"]').exists()&&t.refresh_field(a)})})},calculate:function(e,t,i){var a=!1;if(t.hasClass("field_type-true_false")||t.hasClass("field_type-checkbox")||t.hasClass("field_type-radio")){var n=t.find('input[value="'+e.value+'"]:checked').exists();"=="==e.operator?n&&(a=!0):n||(a=!0)}else{var s=t.find("input, textarea, select").last().val();$.isArray(s)||(s=[s]),"=="==e.operator?$.inArray(e.value,s)>-1&&(a=!0):$.inArray(e.value,s)<0&&(a=!0)}return a}},$(document).ready(function(){acf.conditional_logic.init(),$(".acf_postbox > .inside > .options").each(function(){$(this).closest(".acf_postbox").addClass($(this).attr("data-layout"))}),$('#metakeyselect option[value^="field_"]').remove()}),$(window).load(function(){acf.media.init(),setTimeout(function(){try{$.isNumeric(acf.o.post_id)&&(wp.media.view.settings.post.id=acf.o.post_id)}catch(e){}$(document).trigger("acf/setup_fields",[$("#poststuff")])},10)}),acf.fields.gallery={add:function(){},edit:function(){},update_count:function(){},hide_selected_items:function(){},text:{title_add:"Select Images"}}}(jQuery),function($){function e(){var e=[];$(".categorychecklist input:checked, .acf-taxonomy-field input:checked, .acf-taxonomy-field option:selected").each(function(){$(this).is(":hidden")||$(this).is(":disabled")||$(this).closest(".media-frame").exists()||$(this).closest(".acf-taxonomy-field").exists()&&"0"==$(this).closest(".acf-taxonomy-field").attr("data-load_save")||-1===e.indexOf($(this).val())&&e.push($(this).val())}),acf.screen.post_category=e,acf.screen.taxonomy=e,$(document).trigger("acf/update_field_groups")}acf.screen={action:"acf/location/match_field_groups_ajax",post_id:0,page_template:0,page_parent:0,page_type:0,post_category:0,post_format:0,taxonomy:0,lang:0,nonce:0},$(document).ready(function(){if(acf.screen.post_id=acf.o.post_id,acf.screen.nonce=acf.o.nonce,$("#icl-als-first").length>0){var e=$("#icl-als-first").children("a").attr("href"),t=new RegExp("lang=([^&#]*)"),i=t.exec(e);acf.screen.lang=i[1]}}),$(document).on("acf/update_field_groups",function(){return acf.screen.post_id&&$.isNumeric(acf.screen.post_id)?void $.ajax({url:ajaxurl,data:acf.screen,type:"post",dataType:"json",success:function(e){return e?($(".acf_postbox").addClass("acf-hidden"),$(".acf_postbox-toggle").addClass("acf-hidden"),0==e.length?!1:($.each(e,function(e,t){var i=$("#acf_"+t),a=$('#adv-settings .acf_postbox-toggle[for="acf_'+t+'-hide"]');i.removeClass("acf-hidden hide-if-js"),a.removeClass("acf-hidden"),a.find('input[type="checkbox"]').attr("checked","checked"),i.find(".acf-replace-with-fields").each(function(){var e=$(this);$.ajax({url:ajaxurl,data:{action:"acf/post/render_fields",acf_id:t,post_id:acf.o.post_id,nonce:acf.o.nonce},type:"post",dataType:"html",success:function(t){e.replaceWith(t),$(document).trigger("acf/setup_fields",i)}})})}),void $.ajax({url:ajaxurl,data:{action:"acf/post/get_style",acf_id:e[0],nonce:acf.o.nonce},type:"post",dataType:"html",success:function(e){$("#acf_style").html(e)}}))):!1}}):!1}),$(document).on("change","#page_template",function(){acf.screen.page_template=$(this).val(),$(document).trigger("acf/update_field_groups")}),$(document).on("change","#parent_id",function(){var e=$(this).val();""!=e?(acf.screen.page_type="child",acf.screen.page_parent=e):(acf.screen.page_type="parent",acf.screen.page_parent=0),$(document).trigger("acf/update_field_groups")}),$(document).on("change",'#post-formats-select input[type="radio"]',function(){var e=$(this).val();"0"==e&&(e="standard"),acf.screen.post_format=e,$(document).trigger("acf/update_field_groups")}),$(document).on("change",".categorychecklist input, .acf-taxonomy-field input, .acf-taxonomy-field select",function(){$(this).closest(".acf-taxonomy-field").exists()&&"0"==$(this).closest(".acf-taxonomy-field").attr("data-save")||$(this).closest(".media-frame").exists()||setTimeout(function(){e()},1)})}(jQuery),function($){var e=acf.fields.color_picker={$el:null,$input:null,set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="text"]'),this},init:function(){var e=this.$input;acf.helpers.is_clone_field(e)||this.$input.wpColorPicker()}};$(document).on("acf/setup_fields",function(t,i){$(i).find(".acf-color_picker").each(function(){e.set({$el:$(this)}).init()})})}(jQuery),function($){acf.fields.date_picker={$el:null,$input:null,$hidden:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="text"]'),this.$hidden=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this},init:function(){if(!acf.helpers.is_clone_field(this.$hidden)){this.$input.val(this.$hidden.val());var e=$.extend({},acf.l10n.date_picker,{dateFormat:this.o.save_format,altField:this.$hidden,altFormat:this.o.save_format,changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day});this.$input.addClass("active").datepicker(e),this.$input.datepicker("option","dateFormat",this.o.display_format),$("body > #ui-datepicker-div").length>0&&$("#ui-datepicker-div").wrap('<div class="ui-acf" />')}},blur:function(){this.$input.val()||this.$hidden.val("")}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf-date_picker").each(function(){acf.fields.date_picker.set({$el:$(this)}).init()})}),$(document).on("blur",'.acf-date_picker input[type="text"]',function(e){acf.fields.date_picker.set({$el:$(this).parent()}).blur()})}(jQuery),function($){var e=acf.media;acf.fields.file={$el:null,$input:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this.o.multiple=this.$el.closest(".repeater").exists()?!0:!1,this.o.query={},"uploadedTo"==this.o.library&&(this.o.query.uploadedTo=acf.o.post_id),this},init:function(){acf.helpers.is_clone_field(this.$input)},add:function(t){var i=e.div;i.find(".acf-file-icon").attr("src",t.icon),i.find(".acf-file-title").text(t.title),i.find(".acf-file-name").text(t.name).attr("href",t.url),i.find(".acf-file-size").text(t.size),i.find(".acf-file-value").val(t.id).trigger("change"),i.addClass("active"),i.closest(".field").removeClass("error")},edit:function(){var t=this.$input.val();e.div=this.$el,e.clear_frame(),e.frame=wp.media({title:acf.l10n.file.edit,multiple:!1,button:{text:acf.l10n.file.update}}),e.frame.on("open",function(){"browse"!=e.frame.content._mode&&e.frame.content.mode("browse"),e.frame.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var i=e.frame.state().get("selection"),a=wp.media.attachment(t);$.isEmptyObject(a.changed)&&a.fetch(),i.add(a)}),e.frame.on("close",function(){e.frame.$el.closest(".media-modal").removeClass("acf-media-modal")}),acf.media.frame.open()},remove:function(){this.$el.find(".acf-file-icon").attr("src",""),this.$el.find(".acf-file-title").text(""),this.$el.find(".acf-file-name").text("").attr("href",""),this.$el.find(".acf-file-size").text(""),this.$el.find(".acf-file-value").val("").trigger("change"),this.$el.removeClass("active")},popup:function(){var t=this;return e.div=this.$el,e.clear_frame(),e.frame=wp.media({states:[new wp.media.controller.Library({library:wp.media.query(t.o.query),multiple:t.o.multiple,title:acf.l10n.file.select,priority:20,filterable:"all"})]}),acf.media.frame.on("content:activate",function(){var e=null,i=null;try{e=acf.media.frame.content.get().toolbar,i=e.get("filters")}catch(a){}return i?void("uploadedTo"==t.o.library&&(i.$el.find('option[value="uploaded"]').remove(),i.$el.after("<span>"+acf.l10n.file.uploadedTo+"</span>"),$.each(i.filters,function(e,t){t.props.uploadedTo=acf.o.post_id}))):!1}),acf.media.frame.on("select",function(){if(selection=e.frame.state().get("selection"),selection){var t=0;selection.each(function(i){if(t++,t>1){var a=e.div.closest("td"),n=a.closest(".row"),s=n.closest(".repeater"),o=a.attr("data-field_key"),l="td .acf-file-uploader:first";o&&(l='td[data-field_key="'+o+'"] .acf-file-uploader'),n.next(".row").exists()||s.find(".add-row-end").trigger("click"),e.div=n.next(".row").find(l)}var r={id:i.id,title:i.attributes.title,name:i.attributes.filename,url:i.attributes.url,icon:i.attributes.icon,size:i.attributes.filesize};acf.fields.file.add(r)})}}),acf.media.frame.open(),!1}},$(document).on("click",".acf-file-uploader .acf-button-edit",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).edit()}),$(document).on("click",".acf-file-uploader .acf-button-delete",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).remove()}),$(document).on("click",".acf-file-uploader .add-file",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).popup()})}(jQuery),function($){acf.fields.google_map={$el:null,$input:null,o:{},ready:!1,geocoder:!1,map:!1,maps:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find(".value"),this.o=acf.helpers.get_atts(this.$el),this.maps[this.o.id]&&(this.map=this.maps[this.o.id]),this},init:function(){this.geocoder||(this.geocoder=new google.maps.Geocoder),this.ready=!0,acf.helpers.is_clone_field(this.$input)||this.render()},render:function(){var e=this,t=this.$el,i={zoom:parseInt(this.o.zoom),center:new google.maps.LatLng(this.o.lat,this.o.lng),mapTypeId:google.maps.MapTypeId.ROADMAP};this.map=new google.maps.Map(this.$el.find(".canvas")[0],i);var a=new google.maps.places.Autocomplete(this.$el.find(".search")[0]);a.map=this.map,a.bindTo("bounds",this.map),this.map.marker=new google.maps.Marker({draggable:!0,raiseOnDrag:!0,map:this.map}),this.map.$el=this.$el;var n=this.$el.find(".input-lat").val(),s=this.$el.find(".input-lng").val();n&&s&&this.update(n,s).center(),google.maps.event.addListener(a,"place_changed",function(t){var i=this.map.$el,a=i.find(".search").val();i.find(".input-address").val(a),i.find(".title h4").text(a);var n=this.getPlace();if(n.geometry){var s=n.geometry.location.lat(),o=n.geometry.location.lng();e.set({$el:i}).update(s,o).center()}else e.geocoder.geocode({address:a},function(t,a){if(a!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+a);if(!t[0])return void console.log("No results found");n=t[0];var s=n.geometry.location.lat(),o=n.geometry.location.lng();e.set({$el:i}).update(s,o).center()})}),google.maps.event.addListener(this.map.marker,"dragend",function(){var t=this.map.$el,i=this.map.marker.getPosition(),a=i.lat(),n=i.lng();e.set({$el:t}).update(a,n).sync()}),google.maps.event.addListener(this.map,"click",function(t){var i=this.$el,a=t.latLng.lat(),n=t.latLng.lng();e.set({$el:i}).update(a,n).sync()}),this.maps[this.o.id]=this.map},update:function(e,t){var i=new google.maps.LatLng(e,t);return this.$el.find(".input-lat").val(e),this.$el.find(".input-lng").val(t).trigger("change"),this.map.marker.setPosition(i),this.map.marker.setVisible(!0),this.$el.addClass("active"),this.$el.closest(".field").removeClass("error"),this},center:function(){var e=this.map.marker.getPosition(),t=this.o.lat,i=this.o.lng;e&&(t=e.lat(),i=e.lng());var a=new google.maps.LatLng(t,i);this.map.setCenter(a)},sync:function(){var e=this.$el,t=this.map.marker.getPosition(),i=new google.maps.LatLng(t.lat(),t.lng());return this.geocoder.geocode({latLng:i},function(t,i){if(i!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+i);if(!t[0])return void console.log("No results found");var a=t[0];e.find(".title h4").text(a.formatted_address),e.find(".input-address").val(a.formatted_address).trigger("change")}),this},locate:function(){var e=this,t=this.$el;return navigator.geolocation?(t.find(".title h4").text(acf.l10n.google_map.locating+"..."),t.addClass("active"),void navigator.geolocation.getCurrentPosition(function(i){var a=i.coords.latitude,n=i.coords.longitude;e.set({$el:t}).update(a,n).sync().center()})):(alert(acf.l10n.google_map.browser_support),this)},clear:function(){this.$el.removeClass("active"),this.$el.find(".search").val(""),this.$el.find(".input-address").val(""),this.$el.find(".input-lat").val(""),this.$el.find(".input-lng").val(""),this.map.marker.setVisible(!1)},edit:function(){this.$el.removeClass("active");var e=this.$el.find(".title h4").text();this.$el.find(".search").val(e).focus()},refresh:function(){google.maps.event.trigger(this.map,"resize"),this.center()}},$(document).on("acf/setup_fields",function(e,t){$fields=$(t).find(".acf-google-map"),$fields.exists()&&("undefined"==typeof google?$.getScript("https://www.google.com/jsapi",function(){google.load("maps","3",{other_params:"sensor=false&libraries=places",callback:function(){$fields.each(function(){acf.fields.google_map.set({$el:$(this)}).init()})}})}):google.load("maps","3",{other_params:"sensor=false&libraries=places",callback:function(){$fields.each(function(){acf.fields.google_map.set({$el:$(this)}).init()})}}))}),$(document).on("click",".acf-google-map .acf-sprite-remove",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).clear(),$(this).blur()}),$(document).on("click",".acf-google-map .acf-sprite-locate",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).locate(),$(this).blur()}),$(document).on("click",".acf-google-map .title h4",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).edit()}),$(document).on("keydown",".acf-google-map .search",function(e){return 13==e.which?!1:void 0}),$(document).on("blur",".acf-google-map .search",function(e){var t=$(this).closest(".acf-google-map");t.find(".input-lat").val()&&t.addClass("active")}),$(document).on("acf/fields/tab/show acf/conditional_logic/show",function(e,t){acf.fields.google_map.ready&&"google_map"==t.attr("data-field_type")&&acf.fields.google_map.set({$el:t.find(".acf-google-map")}).refresh()})}(jQuery),function($){var e=acf.media;acf.fields.image={$el:null,$input:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this.o.multiple=this.$el.closest(".repeater").exists()?!0:!1,this.o.query={type:"image"},"uploadedTo"==this.o.library&&(this.o.query.uploadedTo=acf.o.post_id),this},init:function(){acf.helpers.is_clone_field(this.$input)},add:function(t){var i=e.div;i.find(".acf-image-image").attr("src",t.url),i.find(".acf-image-value").val(t.id).trigger("change"),i.addClass("active"),i.closest(".field").removeClass("error")},edit:function(){var t=this.$input.val();e.div=this.$el,e.clear_frame(),e.frame=wp.media({title:acf.l10n.image.edit,multiple:!1,button:{text:acf.l10n.image.update}}),e.frame.on("open",function(){"browse"!=e.frame.content._mode&&e.frame.content.mode("browse"),e.frame.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var i=e.frame.state().get("selection"),a=wp.media.attachment(t);$.isEmptyObject(a.changed)&&a.fetch(),i.add(a)}),e.frame.on("close",function(){e.frame.$el.closest(".media-modal").removeClass("acf-media-modal")}),acf.media.frame.open()},remove:function(){this.$el.find(".acf-image-image").attr("src",""),this.$el.find(".acf-image-value").val("").trigger("change"),this.$el.removeClass("active")},popup:function(){var t=this;return e.div=this.$el,e.clear_frame(),e.frame=wp.media({states:[new wp.media.controller.Library({library:wp.media.query(t.o.query),multiple:t.o.multiple,title:acf.l10n.image.select,priority:20,filterable:"all"})]}),acf.media.frame.on("content:activate",function(){var e=null,i=null;try{e=acf.media.frame.content.get().toolbar,i=e.get("filters")}catch(a){}return i?($.each(i.filters,function(e,t){t.props.type="image"}),"uploadedTo"==t.o.library&&(i.$el.find('option[value="uploaded"]').remove(),i.$el.after("<span>"+acf.l10n.image.uploadedTo+"</span>"),$.each(i.filters,function(e,t){t.props.uploadedTo=acf.o.post_id})),i.$el.find("option").each(function(){var e=$(this).attr("value");("uploaded"!=e||"all"!=t.o.library)&&-1===e.indexOf("image")&&$(this).remove()}),void i.$el.val("image").trigger("change")):!1}),acf.media.frame.on("select",function(){if(selection=e.frame.state().get("selection"),selection){var i=0;selection.each(function(a){if(i++,i>1){var n=e.div.closest("td"),s=n.closest(".row"),o=s.closest(".repeater"),l=n.attr("data-field_key"),r="td .acf-image-uploader:first";l&&(r='td[data-field_key="'+l+'"] .acf-image-uploader'),s.next(".row").exists()||o.find(".add-row-end").trigger("click"),e.div=s.next(".row").find(r)}var c={id:a.id,url:a.attributes.url};a.attributes.sizes&&a.attributes.sizes[t.o.preview_size]&&(c.url=a.attributes.sizes[t.o.preview_size].url),acf.fields.image.add(c)})}}),acf.media.frame.open(),!1},text:{title_add:"Select Image",title_edit:"Edit Image"}},$(document).on("click",".acf-image-uploader .acf-button-edit",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).edit()}),$(document).on("click",".acf-image-uploader .acf-button-delete",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).remove()}),$(document).on("click",".acf-image-uploader .add-image",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).popup()})}(jQuery),function($){acf.fields.radio={$el:null,$input:null,$other:null,farbtastic:null,set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="radio"]:checked'),this.$other=this.$el.find('input[type="text"]'),this},change:function(){"other"==this.$input.val()?(this.$other.attr("name",this.$input.attr("name")),this.$other.show()):(this.$other.attr("name",""),this.$other.hide())}},$(document).on("change",'.acf-radio-list input[type="radio"]',function(e){acf.fields.radio.set({$el:$(this).closest(".acf-radio-list")}).change()})}(jQuery),function($){acf.fields.relationship={$el:null,$input:null,$left:null,$right:null,o:{},timeout:null,set:function(e){return $.extend(this,e),this.$input=this.$el.children('input[type="hidden"]'),this.$left=this.$el.find(".relationship_left"),this.$right=this.$el.find(".relationship_right"),this.o=acf.helpers.get_atts(this.$el),this},init:function(){var e=this;if(!acf.helpers.is_clone_field(this.$input)){this.$right.find(".relationship_list").height(this.$left.height()-2),this.$right.find(".relationship_list").sortable({axis:"y",items:"> li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:function(){e.$input.trigger("change")}});var t=this.$el;this.$left.find(".relationship_list").scrollTop(0).on("scroll",function(i){if(!t.hasClass("loading")&&!t.hasClass("no-results")&&$(this).scrollTop()+$(this).innerHeight()>=$(this).get(0).scrollHeight){var a=parseInt(t.attr("data-paged"));t.attr("data-paged",a+1),e.set({$el:t}).fetch()}}),this.fetch()}},fetch:function(){var e=this,t=this.$el;t.addClass("loading"),$.ajax({url:acf.o.ajaxurl,type:"post",dataType:"json",data:$.extend({action:"acf/fields/relationship/query_posts",post_id:acf.o.post_id,nonce:acf.o.nonce},this.o),success:function(i){e.set({$el:t}).render(i)}})},render:function(e){var t=this;return this.$el.removeClass("no-results").removeClass("loading"),1==this.o.paged&&this.$el.find(".relationship_left li:not(.load-more)").remove(),e&&e.html?(this.$el.find(".relationship_left .load-more").before(e.html),e.next_page_exists||this.$el.addClass("no-results"),void this.$left.find("a").each(function(){var e=$(this).attr("data-post_id");t.$right.find('a[data-post_id="'+e+'"]').exists()&&$(this).parent().addClass("hide")})):void this.$el.addClass("no-results")},add:function(e){var t=e.attr("data-post_id"),i=e.html();if(this.$right.find("a").length>=this.o.max)return alert(acf.l10n.relationship.max.replace("{max}",this.o.max)),!1;if(e.parent().hasClass("hide"))return!1;e.parent().addClass("hide");var a={post_id:e.attr("data-post_id"),title:e.html(),name:this.$input.attr("name")},n=_.template(acf.l10n.relationship.tmpl_li,a);this.$right.find(".relationship_list").append(n),this.$input.trigger("change"),this.$el.closest(".field").removeClass("error")},remove:function(e){e.parent().remove(),this.$left.find('a[data-post_id="'+e.attr("data-post_id")+'"]').parent("li").removeClass("hide"),this.$input.trigger("change")}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf_relationship").each(function(){acf.fields.relationship.set({$el:$(this)}).init()})}),$(document).on("change",".acf_relationship .select-post_type",function(e){var t=$(this).val(),i=$(this).closest(".acf_relationship");i.attr("data-post_type",t),i.attr("data-paged",1),acf.fields.relationship.set({$el:i}).fetch()}),$(document).on("click",".acf_relationship .relationship_left .relationship_list a",function(e){e.preventDefault(),acf.fields.relationship.set({$el:$(this).closest(".acf_relationship")}).add($(this)),$(this).blur()}),$(document).on("click",".acf_relationship .relationship_right .relationship_list a",function(e){e.preventDefault(),acf.fields.relationship.set({$el:$(this).closest(".acf_relationship")}).remove($(this)),$(this).blur()}),$(document).on("keyup",".acf_relationship input.relationship_search",function(e){var t=$(this).val(),i=$(this).closest(".acf_relationship");i.attr("data-s",t),i.attr("data-paged",1),clearTimeout(acf.fields.relationship.timeout),acf.fields.relationship.timeout=setTimeout(function(){acf.fields.relationship.set({$el:i}).fetch()},500)}),$(document).on("keypress",".acf_relationship input.relationship_search",function(e){13==e.which&&e.preventDefault()})}(jQuery),function($){acf.fields.tab={add_group:function(e){var t="";t=e.is("tbody")?'<tr class="acf-tab-wrap"><td colspan="2"><ul class="hl clearfix acf-tab-group"></ul></td></tr>':'<div class="acf-tab-wrap"><ul class="hl clearfix acf-tab-group"></ul></div>',e.children(".field_type-tab:first").before(t)},add_tab:function(e){var t=e.closest(".field"),i=t.parent(),a=t.attr("data-field_key"),n=e.text();i.children(".acf-tab-wrap").exists()||this.add_group(i),i.children(".acf-tab-wrap").find(".acf-tab-group").append('<li><a class="acf-tab-button" href="#" data-key="'+a+'">'+n+"</a></li>")},toggle:function(e){var t=this,i=e.closest(".acf-tab-wrap").parent(),a=e.attr("data-key");e.parent("li").addClass("active").siblings("li").removeClass("active"),i.children(".field_type-tab").each(function(){var e=$(this);e.attr("data-field_key")==a?t.show_tab_fields($(this)):t.hide_tab_fields($(this))})},show_tab_fields:function(e){e.nextUntil(".field_type-tab").each(function(){$(this).removeClass("acf-tab_group-hide").addClass("acf-tab_group-show"),$(document).trigger("acf/fields/tab/show",[$(this)])})},hide_tab_fields:function(e){e.nextUntil(".field_type-tab").each(function(){$(this).removeClass("acf-tab_group-show").addClass("acf-tab_group-hide"),$(document).trigger("acf/fields/tab/hide",[$(this)])})},refresh:function(e){var t=this;e.find(".acf-tab-group").each(function(){$(this).find(".acf-tab-button:first").each(function(){t.toggle($(this))})})}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf-tab").each(function(){acf.fields.tab.add_tab($(this))}),acf.fields.tab.refresh($(t))}),$(document).on("click",".acf-tab-button",function(e){e.preventDefault(),acf.fields.tab.toggle($(this)),$(this).trigger("blur")}),$(document).on("acf/conditional_logic/hide",function(e,t,i){if("tab"==t.attr("data-field_type")){var a=t.siblings(".acf-tab-wrap").find('a[data-key="'+t.attr("data-field_key")+'"]');a.is(":hidden")||(a.parent().hide(),a.parent().siblings(":visible").exists()?a.parent().siblings(":visible").first().children("a").trigger("click"):acf.fields.tab.hide_tab_fields(t))}}),$(document).on("acf/conditional_logic/show",function(e,t,i){if("tab"==t.attr("data-field_type")){var a=t.siblings(".acf-tab-wrap").find('a[data-key="'+t.attr("data-field_key")+'"]');if(!a.is(":visible"))return a.parent().show(),a.parent().hasClass("active")?void a.trigger("click"):a.parent().siblings(".active").is(":hidden")?void a.trigger("click"):void 0}})}(jQuery),function($){acf.validation={status:!0,disabled:!1,run:function(){var e=this;e.status=!0,$(".field.required, .form-field.required").each(function(){e.validate($(this))})},show_spinner:function(e){if(e.exists()){var t=acf.o.wp_version;parseFloat(t)>=4.2?e.addClass("is-active"):e.css("display","inline-block")}},hide_spinner:function(e){if(e.exists()){var t=acf.o.wp_version;parseFloat(t)>=4.2?e.removeClass("is-active"):e.css("display","none")}},validate:function(e){var t=!1,i=null;if(e.data("validation",!0),e.is(":hidden")&&(t=!0,e.hasClass("acf-tab_group-hide"))){t=!1;var a=e.prevAll(".field_type-tab:first"),n=e.prevAll(".acf-tab-wrap:first");a.hasClass("acf-conditional_logic-hide")?t=!0:i=n.find('.acf-tab-button[data-key="'+a.attr("data-field_key")+'"]')}if(e.hasClass("acf-conditional_logic-hide")&&(t=!0),e.closest(".postbox.acf-hidden").exists()&&(t=!0),!t){if(""==e.find('input[type="text"], input[type="email"], input[type="number"], input[type="hidden"], textarea').val()&&e.data("validation",!1),e.find(".acf_wysiwyg").exists()&&"object"==typeof tinyMCE){e.data("validation",!0);var s=e.find(".wp-editor-area").attr("id"),o=tinyMCE.get(s);o&&!o.getContent()&&e.data("validation",!1)}if(e.find("select").exists()&&(e.data("validation",!0),"null"!=e.find("select").val()&&e.find("select").val()||e.data("validation",!1)),e.find('input[type="radio"]').exists()&&(e.data("validation",!1),e.find('input[type="radio"]:checked').exists()&&e.data("validation",!0)),e.find('input[type="checkbox"]').exists()&&(e.data("validation",!1),e.find('input[type="checkbox"]:checked').exists()&&e.data("validation",!0)),e.find(".acf_relationship").exists()&&(e.data("validation",!1),e.find(".acf_relationship .relationship_right input").exists()&&e.data("validation",!0)),e.find(".repeater").exists()&&(e.data("validation",!1),e.find(".repeater tr.row").exists()&&e.data("validation",!0)),e.find(".acf-gallery").exists()&&(e.data("validation",!1),e.find(".acf-gallery .thumbnail").exists()&&e.data("validation",!0)),$(document).trigger("acf/validate_field",[e]),!e.data("validation")){if(this.status=!1,e.closest(".field").addClass("error"),e.data("validation_message")){var l=e.find("p.label:first"),r=null;l.children(".acf-error-message").remove(),l.append('<span class="acf-error-message"><i class="bit"></i>'+e.data("validation_message")+"</span>")}i&&i.trigger("click")}}}},$(document).on("focus click",".field.required input, .field.required textarea, .field.required select",function(e){$(this).closest(".field").removeClass("error")}),$(document).on("click","#save-post",function(){acf.validation.disabled=!0}),$(document).on("submit","#post",function(){if(acf.validation.disabled)return!0;if(acf.validation.run(),
|
2 |
-
!acf.validation.status){var e=$(this);return e.siblings("#message").remove(),e.before('<div id="message" class="error"><p>'+acf.l10n.validation.error+"</p></div>"),$("#submitdiv").exists()&&($("#submitdiv").find(".disabled").removeClass("disabled"),$("#submitdiv").find(".button-disabled").removeClass("button-disabled"),$("#submitdiv").find(".button-primary-disabled").removeClass("button-primary-disabled"),acf.validation.hide_spinner($("#submitdiv .spinner"))),!1}return $(".acf_postbox.acf-hidden").remove(),!0})}(jQuery),function($){var e=acf.fields.wysiwyg={$el:null,$textarea:null,o:{},set:function(e){return $.extend(this,e),this.$textarea=this.$el.find("textarea"),this.o=acf.helpers.get_atts(this.$el),this.o.id=this.$textarea.attr("id"),this},has_tinymce:function(){var e=!1;return"object"==typeof tinyMCE&&(e=!0),e},get_toolbar:function(){return acf.helpers.isset(this,"toolbars",this.o.toolbar)?this.toolbars[this.o.toolbar]:!1},init:function(){if(!acf.helpers.is_clone_field(this.$textarea)){var
|
1 |
+
var acf={ajaxurl:"",admin_url:"",wp_version:"",post_id:0,nonce:"",l10n:null,o:null,helpers:{get_atts:null,version_compare:null,uniqid:null,sortable:null,add_message:null,is_clone_field:null,url_to_object:null},validation:null,conditional_logic:null,media:null,fields:{date_picker:null,color_picker:null,Image:null,file:null,wysiwyg:null,gallery:null,relationship:null}};!function($){acf.helpers.isset=function(){var e=arguments,t=e.length,a=null,n;if(0===t)throw new Error("Empty isset");for(a=e[0],i=1;i<t;i++){if(e[i]===n||a[e[i]]===n)return!1;a=a[e[i]]}return!0},acf.helpers.get_atts=function(e){var t={};return $.each(e[0].attributes,function(e,i){"data-"==i.name.substr(0,5)&&(t[i.name.replace("data-","")]=i.value)}),t},acf.helpers.version_compare=function(e,t){if(typeof e+typeof t!="stringstring")return!1;for(var i=e.split("."),a=t.split("."),n=0,s=Math.max(i.length,a.length);s>n;n++){if(i[n]&&!a[n]&&parseInt(i[n])>0||parseInt(i[n])>parseInt(a[n]))return 1;if(a[n]&&!i[n]&&parseInt(a[n])>0||parseInt(i[n])<parseInt(a[n]))return-1}return 0},acf.helpers.uniqid=function(){var e=new Date;return e.getTime()},acf.helpers.url_to_object=function(e){var t={},a=e.split("&");for(i in a){var n=a[i].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t},acf.helpers.sortable=function(e,t){return t.children().each(function(){$(this).width($(this).width())}),t},acf.helpers.is_clone_field=function(e){return!(!e.attr("name")||-1==e.attr("name").indexOf("[acfcloneindex]"))},acf.helpers.add_message=function(e,t){var e=$('<div class="acf-message-wrapper"><div class="message updated"><p>'+e+"</p></div></div>");t.prepend(e),setTimeout(function(){e.animate({opacity:0},250,function(){e.remove()})},1500)},$.fn.exists=function(){return $(this).length>0},acf.media={div:null,frame:null,render_timout:null,clear_frame:function(){this.frame&&(this.frame.detach(),this.frame.dispose(),this.frame=null)},type:function(){var e="thickbox";return"undefined"!=typeof wp&&(e="backbone"),e},init:function(){if("backbone"!==this.type())return!1;if(!acf.helpers.isset(wp,"media","view","AttachmentCompat","prototype"))return!1;var e=wp.media.view.AttachmentCompat.prototype;e.orig_render=e.render,e.orig_dispose=e.dispose,e.className="compat-item acf_postbox no_box",e.render=function(){var e=this;return e.ignore_render?this:(this.orig_render(),setTimeout(function(){var t=e.$el.closest(".media-modal");if(!t.hasClass("acf-media-modal")&&!t.find(".media-frame-router .acf-expand-details").exists()){var i=$(['<a href="#" class="acf-expand-details">','<span class="icon"></span>','<span class="is-closed">'+acf.l10n.core.expand_details+"</span>",'<span class="is-open">'+acf.l10n.core.collapse_details+"</span>","</a>"].join(""));i.on("click",function(e){e.preventDefault(),t.hasClass("acf-expanded")?t.removeClass("acf-expanded"):t.addClass("acf-expanded")}),t.find(".media-frame-router").append(i)}},0),clearTimeout(acf.media.render_timout),acf.media.render_timout=setTimeout(function(){$(document).trigger("acf/setup_fields",[e.$el])},50),this)},e.dispose=function(){$(document).trigger("acf/remove_fields",[this.$el]),this.orig_dispose()},e.save=function(e){var t={},i={};e&&e.preventDefault(),_.each(this.$el.serializeArray(),function(e){"[]"===e.name.slice(-2)&&(e.name=e.name.replace("[]",""),"undefined"==typeof i[e.name]&&(i[e.name]=-1),i[e.name]++,e.name+="["+i[e.name]+"]"),t[e.name]=e.value}),this.ignore_render=!0,this.model.saveCompat(t)}}},acf.conditional_logic={items:[],init:function(){var e=this;$(document).on("change",".field input, .field textarea, .field select",function(){$("#acf-has-changed").exists()&&$("#acf-has-changed").val(1),e.change($(this))}),$(document).on("acf/setup_fields",function(t,i){e.refresh($(i))}),e.refresh()},change:function(e){var t=this,i=e.closest(".field"),a=i.attr("data-field_key");$.each(this.items,function(e,i){$.each(i.rules,function(e,n){n.field==a&&t.refresh_field(i)})})},refresh_field:function(e){var t=this,i=$(".field_key-"+e.field);i.each(function(){var i=!0;"any"==e.allorany&&(i=!1);var a=$(this),n=!0;$.each(e.rules,function(s,o){var l=$(".field_key-"+o.field);l.hasClass("sub_field")&&(l=a.siblings(".field_key-"+o.field),n=!1,l.exists()||(a.parents("tr").each(function(){return l=$(this).find(".field_key-"+o.field),l.exists()?!1:void 0}),n=!0));var r=a.parent("tr").parent().parent("table").parent(".layout");r.exists()&&(n=!0,a.is("th")&&l.is("th")&&(l=a.closest(".layout").find("td.field_key-"+o.field)));var r=a.parent("tr").parent().parent("table").parent(".repeater");r.exists()&&"1"==r.attr("data-max_rows")&&(n=!0,a.is("th")&&l.is("th")&&(l=a.closest("table").find("td.field_key-"+o.field)));var c=t.calculate(o,l,a);if("all"==e.allorany){if(0==c)return i=!1,!1}else if(1==c)return i=!0,!1}),a.removeClass("acf-conditional_logic-hide acf-conditional_logic-show acf-show-blank"),i?(a.find("input, textarea, select").removeAttr("disabled"),a.addClass("acf-conditional_logic-show"),$(document).trigger("acf/conditional_logic/show",[a,e])):(a.find("input, textarea, select").attr("disabled","disabled"),a.addClass("acf-conditional_logic-hide"),n||a.addClass("acf-show-blank"),$(document).trigger("acf/conditional_logic/hide",[a,e]))})},refresh:function(e){e=e||$("body");var t=this;$.each(this.items,function(i,a){$.each(a.rules,function(i,n){e.find('.field[data-field_key="'+a.field+'"]').exists()&&t.refresh_field(a)})})},calculate:function(e,t,i){var a=!1;if(t.hasClass("field_type-true_false")||t.hasClass("field_type-checkbox")||t.hasClass("field_type-radio")){var n=t.find('input[value="'+e.value+'"]:checked').exists();"=="==e.operator?n&&(a=!0):n||(a=!0)}else{var s=t.find("input, textarea, select").last().val();$.isArray(s)||(s=[s]),"=="==e.operator?$.inArray(e.value,s)>-1&&(a=!0):$.inArray(e.value,s)<0&&(a=!0)}return a}},$(document).ready(function(){acf.conditional_logic.init(),$(".acf_postbox > .inside > .options").each(function(){$(this).closest(".acf_postbox").addClass($(this).attr("data-layout"))}),$('#metakeyselect option[value^="field_"]').remove()}),$(window).on("load",function(){acf.media.init(),setTimeout(function(){try{$.isNumeric(acf.o.post_id)&&(wp.media.view.settings.post.id=acf.o.post_id)}catch(e){}$(document).trigger("acf/setup_fields",[$("#poststuff")])},10)}),acf.fields.gallery={add:function(){},edit:function(){},update_count:function(){},hide_selected_items:function(){},text:{title_add:"Select Images"}}}(jQuery),function($){function e(){var e=[];$(".categorychecklist input:checked, .acf-taxonomy-field input:checked, .acf-taxonomy-field option:selected").each(function(){$(this).is(":hidden")||$(this).is(":disabled")||$(this).closest(".media-frame").exists()||$(this).closest(".acf-taxonomy-field").exists()&&"0"==$(this).closest(".acf-taxonomy-field").attr("data-load_save")||-1===e.indexOf($(this).val())&&e.push($(this).val())}),acf.screen.post_category=e,acf.screen.taxonomy=e,$(document).trigger("acf/update_field_groups")}acf.screen={action:"acf/location/match_field_groups_ajax",post_id:0,page_template:0,page_parent:0,page_type:0,post_category:0,post_format:0,taxonomy:0,lang:0,nonce:0},$(document).ready(function(){if(acf.screen.post_id=acf.o.post_id,acf.screen.nonce=acf.o.nonce,$("#icl-als-first").length>0){var e=$("#icl-als-first").children("a").attr("href"),t=new RegExp("lang=([^&#]*)"),i=t.exec(e);acf.screen.lang=i[1]}}),$(document).on("acf/update_field_groups",function(){return acf.screen.post_id&&$.isNumeric(acf.screen.post_id)?void $.ajax({url:ajaxurl,data:acf.screen,type:"post",dataType:"json",success:function(e){return e?($(".acf_postbox").addClass("acf-hidden"),$(".acf_postbox-toggle").addClass("acf-hidden"),0==e.length?!1:($.each(e,function(e,t){var i=$("#acf_"+t),a=$('#adv-settings .acf_postbox-toggle[for="acf_'+t+'-hide"]');i.removeClass("acf-hidden hide-if-js"),a.removeClass("acf-hidden"),a.find('input[type="checkbox"]').attr("checked","checked"),i.find(".acf-replace-with-fields").each(function(){var e=$(this);$.ajax({url:ajaxurl,data:{action:"acf/post/render_fields",acf_id:t,post_id:acf.o.post_id,nonce:acf.o.nonce},type:"post",dataType:"html",success:function(t){e.replaceWith(t),$(document).trigger("acf/setup_fields",i)}})})}),void $.ajax({url:ajaxurl,data:{action:"acf/post/get_style",acf_id:e[0],nonce:acf.o.nonce},type:"post",dataType:"html",success:function(e){$("#acf_style").html(e)}}))):!1}}):!1}),$(document).on("change","#page_template",function(){acf.screen.page_template=$(this).val(),$(document).trigger("acf/update_field_groups")}),$(document).on("change","#parent_id",function(){var e=$(this).val();""!=e?(acf.screen.page_type="child",acf.screen.page_parent=e):(acf.screen.page_type="parent",acf.screen.page_parent=0),$(document).trigger("acf/update_field_groups")}),$(document).on("change",'#post-formats-select input[type="radio"]',function(){var e=$(this).val();"0"==e&&(e="standard"),acf.screen.post_format=e,$(document).trigger("acf/update_field_groups")}),$(document).on("change",".categorychecklist input, .acf-taxonomy-field input, .acf-taxonomy-field select",function(){$(this).closest(".acf-taxonomy-field").exists()&&"0"==$(this).closest(".acf-taxonomy-field").attr("data-save")||$(this).closest(".media-frame").exists()||setTimeout(function(){e()},1)})}(jQuery),function($){var e=acf.fields.color_picker={$el:null,$input:null,set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="text"]'),this},init:function(){var e=this.$input;acf.helpers.is_clone_field(e)||this.$input.wpColorPicker()}};$(document).on("acf/setup_fields",function(t,i){$(i).find(".acf-color_picker").each(function(){e.set({$el:$(this)}).init()})})}(jQuery),function($){acf.fields.date_picker={$el:null,$input:null,$hidden:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="text"]'),this.$hidden=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this},init:function(){if(!acf.helpers.is_clone_field(this.$hidden)){this.$input.val(this.$hidden.val());var e=$.extend({},acf.l10n.date_picker,{dateFormat:this.o.save_format,altField:this.$hidden,altFormat:this.o.save_format,changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day});this.$input.addClass("active").datepicker(e),this.$input.datepicker("option","dateFormat",this.o.display_format),$("body > #ui-datepicker-div").length>0&&$("#ui-datepicker-div").wrap('<div class="ui-acf" />')}},blur:function(){this.$input.val()||this.$hidden.val("")}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf-date_picker").each(function(){acf.fields.date_picker.set({$el:$(this)}).init()})}),$(document).on("blur",'.acf-date_picker input[type="text"]',function(e){acf.fields.date_picker.set({$el:$(this).parent()}).blur()})}(jQuery),function($){var e=acf.media;acf.fields.file={$el:null,$input:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this.o.multiple=!!this.$el.closest(".repeater").exists(),this.o.query={},"uploadedTo"==this.o.library&&(this.o.query.uploadedTo=acf.o.post_id),this},init:function(){acf.helpers.is_clone_field(this.$input)},add:function(t){var i=e.div;i.find(".acf-file-icon").attr("src",t.icon),i.find(".acf-file-title").text(t.title),i.find(".acf-file-name").text(t.name).attr("href",t.url),i.find(".acf-file-size").text(t.size),i.find(".acf-file-value").val(t.id).trigger("change"),i.addClass("active"),i.closest(".field").removeClass("error")},new_frame:function(t){return e.div=this.$el,e.clear_frame(),t.states=[],t.states.push(new wp.media.controller.Library({library:wp.media.query(this.o.query),multiple:t.multiple,title:t.title,priority:20,filterable:"all"})),acf.helpers.isset(wp,"media","controller","EditImage")&&t.states.push(new wp.media.controller.EditImage),e.frame=wp.media(t),e.frame.on("content:render:edit-image",function(){var e=this.state().get("image"),t=new wp.media.view.EditImage({model:e,controller:this}).render();this.content.set(t),t.loadEditor()},e.frame),e.frame.on("toolbar:create:select",function(e){e.view=new wp.media.view.Toolbar.Select({text:t.button.text,controller:this})},e.frame),e.frame},edit:function(){var t=this.$input.val();this.new_frame({title:acf.l10n.file.edit,multiple:!1,button:{text:acf.l10n.file.update}}),e.frame.on("open",function(){"browse"!=e.frame.content._mode&&e.frame.content.mode("browse"),e.frame.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var i=e.frame.state().get("selection"),a=wp.media.attachment(t);$.isEmptyObject(a.changed)&&a.fetch(),i.add(a)}),e.frame.on("close",function(){e.frame.$el.closest(".media-modal").removeClass("acf-media-modal")}),acf.media.frame.open()},remove:function(){this.$el.find(".acf-file-icon").attr("src",""),this.$el.find(".acf-file-title").text(""),this.$el.find(".acf-file-name").text("").attr("href",""),this.$el.find(".acf-file-size").text(""),this.$el.find(".acf-file-value").val("").trigger("change"),this.$el.removeClass("active")},popup:function(){var t=this;return this.new_frame({title:acf.l10n.file.select,multiple:t.o.multiple,button:{text:acf.l10n.file.select}}),acf.media.frame.on("content:activate",function(){var e=null,i=null;try{e=acf.media.frame.content.get().toolbar,i=e.get("filters")}catch(a){}return i?void("uploadedTo"==t.o.library&&(i.$el.find('option[value="uploaded"]').remove(),i.$el.after("<span>"+acf.l10n.file.uploadedTo+"</span>"),$.each(i.filters,function(e,t){t.props.uploadedTo=acf.o.post_id}))):!1}),acf.media.frame.on("select",function(){if(selection=e.frame.state().get("selection"),selection){var t=0;selection.each(function(i){if(t++,t>1){var a=e.div.closest("td"),n=a.closest(".row"),s=n.closest(".repeater"),o=a.attr("data-field_key"),l="td .acf-file-uploader:first";o&&(l='td[data-field_key="'+o+'"] .acf-file-uploader'),n.next(".row").exists()||s.find(".add-row-end").trigger("click"),e.div=n.next(".row").find(l)}var r={id:i.id,title:i.attributes.title,name:i.attributes.filename,url:i.attributes.url,icon:i.attributes.icon,size:i.attributes.filesize};acf.fields.file.add(r)})}}),acf.media.frame.open(),!1}},$(document).on("click",".acf-file-uploader .acf-button-edit",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).edit()}),$(document).on("click",".acf-file-uploader .acf-button-delete",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).remove()}),$(document).on("click",".acf-file-uploader .add-file",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).popup()})}(jQuery),function($){acf.fields.google_map={$el:null,$input:null,o:{},api:{sensor:!1,libraries:"places"},ready:!1,geocoder:!1,map:!1,maps:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find(".input-address"),this.o=acf.helpers.get_atts(this.$el),this.maps[this.o.id]&&(this.map=this.maps[this.o.id]),this},init:function(){this.geocoder||(this.geocoder=new google.maps.Geocoder),this.ready=!0,acf.helpers.is_clone_field(this.$input)||this.render()},render:function(){var e=this,t=this.$el,i={zoom:parseInt(this.o.zoom),center:new google.maps.LatLng(this.o.lat,this.o.lng),mapTypeId:google.maps.MapTypeId.ROADMAP};this.map=new google.maps.Map(this.$el.find(".canvas")[0],i);var a=new google.maps.places.Autocomplete(this.$el.find(".search")[0]);a.map=this.map,a.bindTo("bounds",this.map),this.map.marker=new google.maps.Marker({draggable:!0,raiseOnDrag:!0,map:this.map}),this.map.$el=this.$el;var n=this.$el.find(".input-lat").val(),s=this.$el.find(".input-lng").val();n&&s&&this.update(n,s).center(),google.maps.event.addListener(a,"place_changed",function(t){var i=this.map.$el,a=i.find(".search").val();i.find(".input-address").val(a),i.find(".title h4").text(a);var n=this.getPlace();if(n.geometry){var s=n.geometry.location.lat(),o=n.geometry.location.lng();e.set({$el:i}).update(s,o).center()}else e.geocoder.geocode({address:a},function(t,a){if(a!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+a);if(!t[0])return void console.log("No results found");n=t[0];var s=n.geometry.location.lat(),o=n.geometry.location.lng();e.set({$el:i}).update(s,o).center()})}),google.maps.event.addListener(this.map.marker,"dragend",function(){var t=this.map.$el,i=this.map.marker.getPosition(),a=i.lat(),n=i.lng();e.set({$el:t}).update(a,n).sync()}),google.maps.event.addListener(this.map,"click",function(t){var i=this.$el,a=t.latLng.lat(),n=t.latLng.lng();e.set({$el:i}).update(a,n).sync()}),this.maps[this.o.id]=this.map},update:function(e,t){var i=new google.maps.LatLng(e,t);return this.$el.find(".input-lat").val(e),this.$el.find(".input-lng").val(t).trigger("change"),this.map.marker.setPosition(i),this.map.marker.setVisible(!0),this.$el.addClass("active"),this.$el.closest(".field").removeClass("error"),this},center:function(){var e=this.map.marker.getPosition(),t=this.o.lat,i=this.o.lng;e&&(t=e.lat(),i=e.lng());var a=new google.maps.LatLng(t,i);this.map.setCenter(a)},sync:function(){var e=this.$el,t=this.map.marker.getPosition(),i=new google.maps.LatLng(t.lat(),t.lng());return this.geocoder.geocode({latLng:i},function(t,i){if(i!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+i);if(!t[0])return void console.log("No results found");var a=t[0];e.find(".title h4").text(a.formatted_address),e.find(".input-address").val(a.formatted_address).trigger("change")}),this},locate:function(){var e=this,t=this.$el;return navigator.geolocation?(t.find(".title h4").text(acf.l10n.google_map.locating+"..."),t.addClass("active"),void navigator.geolocation.getCurrentPosition(function(i){var a=i.coords.latitude,n=i.coords.longitude;e.set({$el:t}).update(a,n).sync().center()})):(alert(acf.l10n.google_map.browser_support),this)},clear:function(){this.$el.removeClass("active"),this.$el.find(".search").val(""),this.$el.find(".input-address").val(""),this.$el.find(".input-lat").val(""),this.$el.find(".input-lng").val(""),this.map.marker.setVisible(!1)},edit:function(){this.$el.removeClass("active");var e=this.$el.find(".title h4").text();this.$el.find(".search").val(e).focus()},refresh:function(){google.maps.event.trigger(this.map,"resize"),this.center()}},$(document).on("acf/setup_fields",function(e,t){var i=acf.fields.google_map,a=$(t).find(".acf-google-map");return a.exists()?acf.helpers.isset(window,"google","load")?acf.helpers.isset(window,"google","maps","places")?(a.each(function(){acf.fields.google_map.set({$el:$(this)}).init()}),!0):(google.load("maps","3",{other_params:$.param(i.api),callback:function(){a.each(function(){acf.fields.google_map.set({$el:$(this)}).init()})}}),!1):($.getScript("https://www.google.com/jsapi",function(){google.load("maps","3",{other_params:$.param(i.api),callback:function(){a.each(function(){acf.fields.google_map.set({$el:$(this)}).init()})}})}),!1):!1}),$(document).on("click",".acf-google-map .acf-sprite-remove",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).clear(),$(this).blur()}),$(document).on("click",".acf-google-map .acf-sprite-locate",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).locate(),$(this).blur()}),$(document).on("click",".acf-google-map .title h4",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).edit()}),$(document).on("keydown",".acf-google-map .search",function(e){return 13==e.which?!1:void 0}),$(document).on("blur",".acf-google-map .search",function(e){var t=$(this).closest(".acf-google-map");t.find(".input-lat").val()&&t.addClass("active")}),$(document).on("acf/fields/tab/show acf/conditional_logic/show",function(e,t){acf.fields.google_map.ready&&"google_map"==t.attr("data-field_type")&&acf.fields.google_map.set({$el:t.find(".acf-google-map")}).refresh()})}(jQuery),function($){var e=acf.media;acf.fields.image={$el:null,$input:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this.o.multiple=!!this.$el.closest(".repeater").exists(),this.o.query={type:"image"},"uploadedTo"==this.o.library&&(this.o.query.uploadedTo=acf.o.post_id),this},init:function(){acf.helpers.is_clone_field(this.$input)},add:function(t){var i=e.div;i.find(".acf-image-image").attr("src",t.url),i.find(".acf-image-value").val(t.id).trigger("change"),i.addClass("active"),i.closest(".field").removeClass("error")},new_frame:function(t){return e.div=this.$el,e.clear_frame(),t.states=[],t.states.push(new wp.media.controller.Library({library:wp.media.query(this.o.query),multiple:t.multiple,title:t.title,priority:20,filterable:"all"})),acf.helpers.isset(wp,"media","controller","EditImage")&&t.states.push(new wp.media.controller.EditImage),e.frame=wp.media(t),e.frame.on("content:render:edit-image",function(){var e=this.state().get("image"),t=new wp.media.view.EditImage({model:e,controller:this}).render();this.content.set(t),t.loadEditor()},e.frame),e.frame.on("toolbar:create:select",function(e){e.view=new wp.media.view.Toolbar.Select({text:t.button.text,controller:this})},e.frame),e.frame},edit:function(){var t=this.$input.val();this.new_frame({title:acf.l10n.image.edit,multiple:!1,button:{text:acf.l10n.image.update}}),e.frame.on("open",function(){"browse"!=e.frame.content._mode&&e.frame.content.mode("browse"),e.frame.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var i=e.frame.state().get("selection"),a=wp.media.attachment(t);$.isEmptyObject(a.changed)&&a.fetch(),i.add(a)}),e.frame.on("close",function(){e.frame.$el.closest(".media-modal").removeClass("acf-media-modal")}),e.frame.open()},remove:function(){this.$el.find(".acf-image-image").attr("src",""),this.$el.find(".acf-image-value").val("").trigger("change"),this.$el.removeClass("active")},popup:function(){var t=this;return this.new_frame({title:acf.l10n.image.select,multiple:t.o.multiple,button:{text:acf.l10n.image.select}}),e.frame.on("content:activate",function(){var e=null,i=null;try{e=acf.media.frame.content.get().toolbar,i=e.get("filters")}catch(a){}return i?($.each(i.filters,function(e,t){t.props.type="image"}),"uploadedTo"==t.o.library&&(i.$el.find('option[value="uploaded"]').remove(),i.$el.after("<span>"+acf.l10n.image.uploadedTo+"</span>"),$.each(i.filters,function(e,t){t.props.uploadedTo=acf.o.post_id})),i.$el.find("option").each(function(){var e=$(this).attr("value");"uploaded"==e&&"all"==t.o.library||-1===e.indexOf("image")&&$(this).remove()}),void i.$el.val("image").trigger("change")):!1}),acf.media.frame.on("select",function(){if(selection=e.frame.state().get("selection"),selection){var i=0;selection.each(function(a){if(i++,i>1){var n=e.div.closest("td"),s=n.closest(".row"),o=s.closest(".repeater"),l=n.attr("data-field_key"),r="td .acf-image-uploader:first";l&&(r='td[data-field_key="'+l+'"] .acf-image-uploader'),s.next(".row").exists()||o.find(".add-row-end").trigger("click"),e.div=s.next(".row").find(r)}var c={id:a.id,url:a.attributes.url};a.attributes.sizes&&a.attributes.sizes[t.o.preview_size]&&(c.url=a.attributes.sizes[t.o.preview_size].url),acf.fields.image.add(c)})}}),acf.media.frame.open(),!1},text:{title_add:"Select Image",title_edit:"Edit Image"}},$(document).on("click",".acf-image-uploader .acf-button-edit",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).edit()}),$(document).on("click",".acf-image-uploader .acf-button-delete",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).remove()}),$(document).on("click",".acf-image-uploader .add-image",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).popup()})}(jQuery),function($){acf.fields.radio={$el:null,$input:null,$other:null,farbtastic:null,set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="radio"]:checked'),this.$other=this.$el.find('input[type="text"]'),this},change:function(){"other"==this.$input.val()?(this.$other.attr("name",this.$input.attr("name")),this.$other.show()):(this.$other.attr("name",""),this.$other.hide())}},$(document).on("change",'.acf-radio-list input[type="radio"]',function(e){acf.fields.radio.set({$el:$(this).closest(".acf-radio-list")}).change()})}(jQuery),function($){acf.fields.relationship={$el:null,$input:null,$left:null,$right:null,o:{},timeout:null,set:function(e){return $.extend(this,e),this.$input=this.$el.children('input[type="hidden"]'),this.$left=this.$el.find(".relationship_left"),this.$right=this.$el.find(".relationship_right"),this.o=acf.helpers.get_atts(this.$el),this},init:function(){var e=this;if(!acf.helpers.is_clone_field(this.$input)){this.$right.find(".relationship_list").height(this.$left.height()-2),this.$right.find(".relationship_list").sortable({axis:"y",items:"> li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:function(){e.$input.trigger("change")}});var t=this.$el;this.$left.find(".relationship_list").scrollTop(0).on("scroll",function(i){if(!t.hasClass("loading")&&!t.hasClass("no-results")&&$(this).scrollTop()+$(this).innerHeight()>=$(this).get(0).scrollHeight){var a=parseInt(t.attr("data-paged"));t.attr("data-paged",a+1),e.set({$el:t}).fetch()}}),this.fetch()}},fetch:function(){var e=this,t=this.$el;t.addClass("loading"),$.ajax({url:acf.o.ajaxurl,type:"post",dataType:"json",data:$.extend({action:"acf/fields/relationship/query_posts",post_id:acf.o.post_id,nonce:acf.o.nonce},this.o),success:function(i){e.set({$el:t}).render(i)}})},render:function(e){var t=this;return this.$el.removeClass("no-results").removeClass("loading"),1==this.o.paged&&this.$el.find(".relationship_left li:not(.load-more)").remove(),e&&e.html?(this.$el.find(".relationship_left .load-more").before(e.html),e.next_page_exists||this.$el.addClass("no-results"),void this.$left.find("a").each(function(){var e=$(this).attr("data-post_id");t.$right.find('a[data-post_id="'+e+'"]').exists()&&$(this).parent().addClass("hide")})):void this.$el.addClass("no-results")},add:function(e){var t=e.attr("data-post_id"),i=e.html();if(this.$right.find("a").length>=this.o.max)return alert(acf.l10n.relationship.max.replace("{max}",this.o.max)),!1;if(e.parent().hasClass("hide"))return!1;e.parent().addClass("hide");var a=["<li>",'<a href="#" data-post_id="'+e.attr("data-post_id")+'">',e.html()+'<span class="acf-button-remove"></span>',"</a>",'<input type="hidden" name="'+this.$input.attr("name")+'[]" value="'+e.attr("data-post_id")+'" />',"</li>"].join("");this.$right.find(".relationship_list").append(a),this.$input.trigger("change"),this.$el.closest(".field").removeClass("error")},remove:function(e){e.parent().remove(),this.$left.find('a[data-post_id="'+e.attr("data-post_id")+'"]').parent("li").removeClass("hide"),this.$input.trigger("change")}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf_relationship").each(function(){acf.fields.relationship.set({$el:$(this)}).init()})}),$(document).on("change",".acf_relationship .select-post_type",function(e){var t=$(this).val(),i=$(this).closest(".acf_relationship");i.attr("data-post_type",t),i.attr("data-paged",1),acf.fields.relationship.set({$el:i}).fetch()}),$(document).on("click",".acf_relationship .relationship_left .relationship_list a",function(e){e.preventDefault(),acf.fields.relationship.set({$el:$(this).closest(".acf_relationship")}).add($(this)),$(this).blur()}),$(document).on("click",".acf_relationship .relationship_right .relationship_list a",function(e){e.preventDefault(),acf.fields.relationship.set({$el:$(this).closest(".acf_relationship")}).remove($(this)),$(this).blur()}),$(document).on("keyup",".acf_relationship input.relationship_search",function(e){var t=$(this).val(),i=$(this).closest(".acf_relationship");i.attr("data-s",t),i.attr("data-paged",1),clearTimeout(acf.fields.relationship.timeout),acf.fields.relationship.timeout=setTimeout(function(){acf.fields.relationship.set({$el:i}).fetch()},500)}),$(document).on("keypress",".acf_relationship input.relationship_search",function(e){13==e.which&&e.preventDefault()})}(jQuery),function($){acf.fields.tab={add_group:function(e){var t="";t=e.is("tbody")?'<tr class="acf-tab-wrap"><td colspan="2"><ul class="hl clearfix acf-tab-group"></ul></td></tr>':'<div class="acf-tab-wrap"><ul class="hl clearfix acf-tab-group"></ul></div>',e.children(".field_type-tab:first").before(t)},add_tab:function(e){var t=e.closest(".field"),i=t.parent(),a=t.attr("data-field_key"),n=e.text();i.children(".acf-tab-wrap").exists()||this.add_group(i),i.children(".acf-tab-wrap").find(".acf-tab-group").append('<li><a class="acf-tab-button" href="#" data-key="'+a+'">'+n+"</a></li>")},toggle:function(e){var t=this,i=e.closest(".acf-tab-wrap").parent(),a=e.attr("data-key");e.parent("li").addClass("active").siblings("li").removeClass("active"),i.children(".field_type-tab").each(function(){var e=$(this);e.attr("data-field_key")==a?t.show_tab_fields($(this)):t.hide_tab_fields($(this))})},show_tab_fields:function(e){e.nextUntil(".field_type-tab").each(function(){$(this).removeClass("acf-tab_group-hide").addClass("acf-tab_group-show"),$(document).trigger("acf/fields/tab/show",[$(this)])})},hide_tab_fields:function(e){e.nextUntil(".field_type-tab").each(function(){$(this).removeClass("acf-tab_group-show").addClass("acf-tab_group-hide"),$(document).trigger("acf/fields/tab/hide",[$(this)])})},refresh:function(e){var t=this;e.find(".acf-tab-group").each(function(){$(this).find(".acf-tab-button:first").each(function(){t.toggle($(this))})})}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf-tab").each(function(){acf.fields.tab.add_tab($(this))}),acf.fields.tab.refresh($(t))}),$(document).on("click",".acf-tab-button",function(e){e.preventDefault(),acf.fields.tab.toggle($(this)),$(this).trigger("blur")}),$(document).on("acf/conditional_logic/hide",function(e,t,i){if("tab"==t.attr("data-field_type")){var a=t.siblings(".acf-tab-wrap").find('a[data-key="'+t.attr("data-field_key")+'"]');a.is(":hidden")||(a.parent().hide(),a.parent().siblings(":visible").exists()?a.parent().siblings(":visible").first().children("a").trigger("click"):acf.fields.tab.hide_tab_fields(t))}}),$(document).on("acf/conditional_logic/show",function(e,t,i){if("tab"==t.attr("data-field_type")){var a=t.siblings(".acf-tab-wrap").find('a[data-key="'+t.attr("data-field_key")+'"]');if(!a.is(":visible"))return a.parent().show(),a.parent().hasClass("active")?void a.trigger("click"):a.parent().siblings(".active").is(":hidden")?void a.trigger("click"):void 0}})}(jQuery),function($){acf.validation={status:!0,disabled:!1,run:function(){var e=this;e.status=!0,$(".field.required, .form-field.required").each(function(){e.validate($(this))})},show_spinner:function(e){if(e.exists()){var t=acf.o.wp_version;parseFloat(t)>=4.2?e.addClass("is-active"):e.css("display","inline-block")}},hide_spinner:function(e){if(e.exists()){var t=acf.o.wp_version;parseFloat(t)>=4.2?e.removeClass("is-active"):e.css("display","none")}},validate:function(e){var t=!1,i=null;if(e.data("validation",!0),e.is(":hidden")&&(t=!0,e.hasClass("acf-tab_group-hide"))){t=!1;var a=e.prevAll(".field_type-tab:first"),n=e.prevAll(".acf-tab-wrap:first");a.hasClass("acf-conditional_logic-hide")?t=!0:i=n.find('.acf-tab-button[data-key="'+a.attr("data-field_key")+'"]')}if(e.hasClass("acf-conditional_logic-hide")&&(t=!0),e.closest(".postbox.acf-hidden").exists()&&(t=!0),!t){if(""==e.find('input[type="text"], input[type="email"], input[type="number"], input[type="hidden"], textarea').val()&&e.data("validation",!1),e.find(".acf_wysiwyg").exists()&&"object"==typeof tinyMCE){e.data("validation",!0);var s=e.find(".wp-editor-area").attr("id"),o=tinyMCE.get(s);o&&!o.getContent()&&e.data("validation",!1)}if(e.find("select").exists()&&(e.data("validation",!0),"null"!=e.find("select").val()&&e.find("select").val()||e.data("validation",!1)),e.find('input[type="radio"]').exists()&&(e.data("validation",!1),
|
2 |
+
e.find('input[type="radio"]:checked').exists()&&e.data("validation",!0)),e.find('input[type="checkbox"]').exists()&&(e.data("validation",!1),e.find('input[type="checkbox"]:checked').exists()&&e.data("validation",!0)),e.find(".acf_relationship").exists()&&(e.data("validation",!1),e.find(".acf_relationship .relationship_right input").exists()&&e.data("validation",!0)),e.find(".repeater").exists()&&(e.data("validation",!1),e.find(".repeater tr.row").exists()&&e.data("validation",!0)),e.find(".acf-gallery").exists()&&(e.data("validation",!1),e.find(".acf-gallery .thumbnail").exists()&&e.data("validation",!0)),$(document).trigger("acf/validate_field",[e]),!e.data("validation")){if(this.status=!1,e.closest(".field").addClass("error"),e.data("validation_message")){var l=e.find("p.label:first"),r=null;l.children(".acf-error-message").remove(),l.append('<span class="acf-error-message"><i class="bit"></i>'+e.data("validation_message")+"</span>")}i&&i.trigger("click")}}}},$(document).on("focus click",".field.required input, .field.required textarea, .field.required select",function(e){$(this).closest(".field").removeClass("error")}),$(document).on("click","#save-post",function(){acf.validation.disabled=!0}),$(document).on("submit","#post",function(){if(acf.validation.disabled)return!0;if(acf.validation.run(),!acf.validation.status){var e=$(this);return e.siblings("#message").remove(),e.before('<div id="message" class="error"><p>'+acf.l10n.validation.error+"</p></div>"),$("#submitdiv").exists()&&($("#submitdiv").find(".disabled").removeClass("disabled"),$("#submitdiv").find(".button-disabled").removeClass("button-disabled"),$("#submitdiv").find(".button-primary-disabled").removeClass("button-primary-disabled"),acf.validation.hide_spinner($("#submitdiv .spinner"))),!1}return $(".acf_postbox.acf-hidden").remove(),!0})}(jQuery),function($){var e=acf.fields.wysiwyg={$el:null,$textarea:null,o:{},set:function(e){return $.extend(this,e),this.$textarea=this.$el.find("textarea"),this.o=acf.helpers.get_atts(this.$el),this.o.id=this.$textarea.attr("id"),this},has_tinymce:function(){var e=!1;return"object"==typeof tinyMCE&&(e=!0),e},get_toolbar:function(){return acf.helpers.isset(this,"toolbars",this.o.toolbar)?this.toolbars[this.o.toolbar]:!1},init:function(){if(!acf.helpers.is_clone_field(this.$textarea)){var t=this.o.id,i=this.get_toolbar(),a="mceAddControl",n="theme_advanced_buttons{i}",s=$.extend({},tinyMCE.settings);if(4==tinymce.majorVersion&&(a="mceAddEditor",n="toolbar{i}"),i)for(var o=1;5>o;o++){var l="";acf.helpers.isset(i,"theme_advanced_buttons"+o)&&(l=i["theme_advanced_buttons"+o]),tinyMCE.settings[n.replace("{i}",o)]=l}tinyMCE.execCommand(a,!1,t),$(document).trigger("acf/wysiwyg/load",t),setTimeout(function(){e.add_events(t)},100),tinyMCE.settings=s,wpActiveEditor=null}},add_events:function(e){var t=tinyMCE.get(e);if(t){var i=$("#wp-"+e+"-wrap"),a=$(t.getBody());i.on("click",function(){$(document).trigger("acf/wysiwyg/click",e)}),a.on("focus",function(){$(document).trigger("acf/wysiwyg/focus",e)}),a.on("blur",function(){$(document).trigger("acf/wysiwyg/blur",e)})}},destroy:function(){var e=this.o.id,t="mceRemoveControl";try{var i=tinyMCE.get(e);if(!i)return;4==tinymce.majorVersion&&(t="mceRemoveEditor");var a=i.getContent();tinyMCE.execCommand(t,!1,e),this.$textarea.val(a)}catch(n){}wpActiveEditor=null}};$(document).on("acf/setup_fields",function(t,i){e.has_tinymce()&&($(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).destroy()}),setTimeout(function(){$(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).init()})},0))}),$(document).on("acf/remove_fields",function(t,i){e.has_tinymce()&&i.find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).destroy()})}),$(document).on("acf/wysiwyg/click",function(e,t){wpActiveEditor=t,container=$("#wp-"+t+"-wrap").closest(".field").removeClass("error")}),$(document).on("acf/wysiwyg/focus",function(e,t){wpActiveEditor=t,container=$("#wp-"+t+"-wrap").closest(".field").removeClass("error")}),$(document).on("acf/wysiwyg/blur",function(e,t){wpActiveEditor=null;var i=tinyMCE.get(t);if(i){var a=i.getElement();i.save(),$(a).trigger("change")}}),$(document).on("acf/sortable_start",function(t,i){e.has_tinymce()&&$(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).destroy()})}),$(document).on("acf/sortable_stop",function(t,i){e.has_tinymce()&&$(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).init()})}),$(window).on("load",function(){if(e.has_tinymce()){var t=$("#wp-content-wrap").exists(),i=$("#wp-acf_settings-wrap").exists();mode="tmce",i&&$("#wp-acf_settings-wrap").hasClass("html-active")&&(mode="html"),setTimeout(function(){i&&"html"==mode&&$("#acf_settings-tmce").trigger("click")},1),setTimeout(function(){i&&"html"==mode&&$("#acf_settings-html").trigger("click"),t&&e.add_events("content")},11)}}),$(document).on("click",".acf_wysiwyg a.mce_fullscreen",function(){var e=$(this).closest(".acf_wysiwyg"),t=e.attr("data-upload");"no"==t&&$("#mce_fullscreen_container td.mceToolbar .mce_add_media").remove()})}(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/_listener.js
ADDED
File without changes
|
shared/assets/plugins/advanced-custom-fields/js/input/_listener.min.js
ADDED
File without changes
|
shared/assets/plugins/advanced-custom-fields/js/input/acf.js
ADDED
@@ -0,0 +1,942 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* input.js
|
3 |
+
*
|
4 |
+
* All javascript needed for ACF to work
|
5 |
+
*
|
6 |
+
* @type awesome
|
7 |
+
* @date 1/08/13
|
8 |
+
*
|
9 |
+
* @param N/A
|
10 |
+
* @return N/A
|
11 |
+
*/
|
12 |
+
|
13 |
+
var acf = {
|
14 |
+
|
15 |
+
// vars
|
16 |
+
ajaxurl : '',
|
17 |
+
admin_url : '',
|
18 |
+
wp_version : '',
|
19 |
+
post_id : 0,
|
20 |
+
nonce : '',
|
21 |
+
l10n : null,
|
22 |
+
o : null,
|
23 |
+
|
24 |
+
// helper functions
|
25 |
+
helpers : {
|
26 |
+
get_atts : null,
|
27 |
+
version_compare : null,
|
28 |
+
uniqid : null,
|
29 |
+
sortable : null,
|
30 |
+
add_message : null,
|
31 |
+
is_clone_field : null,
|
32 |
+
url_to_object : null
|
33 |
+
},
|
34 |
+
|
35 |
+
|
36 |
+
// modules
|
37 |
+
validation : null,
|
38 |
+
conditional_logic : null,
|
39 |
+
media : null,
|
40 |
+
|
41 |
+
|
42 |
+
// fields
|
43 |
+
fields : {
|
44 |
+
date_picker : null,
|
45 |
+
color_picker : null,
|
46 |
+
Image : null,
|
47 |
+
file : null,
|
48 |
+
wysiwyg : null,
|
49 |
+
gallery : null,
|
50 |
+
relationship : null
|
51 |
+
}
|
52 |
+
};
|
53 |
+
|
54 |
+
(function($){
|
55 |
+
|
56 |
+
|
57 |
+
/*
|
58 |
+
* acf.helpers.isset
|
59 |
+
*
|
60 |
+
* description
|
61 |
+
*
|
62 |
+
* @type function
|
63 |
+
* @date 20/07/13
|
64 |
+
*
|
65 |
+
* @param {mixed} arguments
|
66 |
+
* @return {boolean}
|
67 |
+
*/
|
68 |
+
|
69 |
+
acf.helpers.isset = function(){
|
70 |
+
|
71 |
+
var a = arguments,
|
72 |
+
l = a.length,
|
73 |
+
c = null,
|
74 |
+
undef;
|
75 |
+
|
76 |
+
if (l === 0) {
|
77 |
+
throw new Error('Empty isset');
|
78 |
+
}
|
79 |
+
|
80 |
+
c = a[0];
|
81 |
+
|
82 |
+
for (i = 1; i < l; i++) {
|
83 |
+
|
84 |
+
if (a[i] === undef || c[ a[i] ] === undef) {
|
85 |
+
return false;
|
86 |
+
}
|
87 |
+
|
88 |
+
c = c[ a[i] ];
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
return true;
|
93 |
+
|
94 |
+
};
|
95 |
+
|
96 |
+
|
97 |
+
/*
|
98 |
+
* acf.helpers.get_atts
|
99 |
+
*
|
100 |
+
* description
|
101 |
+
*
|
102 |
+
* @type function
|
103 |
+
* @date 1/06/13
|
104 |
+
*
|
105 |
+
* @param {el} $el
|
106 |
+
* @return {object} atts
|
107 |
+
*/
|
108 |
+
|
109 |
+
acf.helpers.get_atts = function( $el ){
|
110 |
+
|
111 |
+
var atts = {};
|
112 |
+
|
113 |
+
$.each( $el[0].attributes, function( index, attr ) {
|
114 |
+
|
115 |
+
if( attr.name.substr(0, 5) == 'data-' )
|
116 |
+
{
|
117 |
+
atts[ attr.name.replace('data-', '') ] = attr.value;
|
118 |
+
}
|
119 |
+
});
|
120 |
+
|
121 |
+
return atts;
|
122 |
+
|
123 |
+
};
|
124 |
+
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Simply compares two string version values.
|
128 |
+
*
|
129 |
+
* Example:
|
130 |
+
* versionCompare('1.1', '1.2') => -1
|
131 |
+
* versionCompare('1.1', '1.1') => 0
|
132 |
+
* versionCompare('1.2', '1.1') => 1
|
133 |
+
* versionCompare('2.23.3', '2.22.3') => 1
|
134 |
+
*
|
135 |
+
* Returns:
|
136 |
+
* -1 = left is LOWER than right
|
137 |
+
* 0 = they are equal
|
138 |
+
* 1 = left is GREATER = right is LOWER
|
139 |
+
* And FALSE if one of input versions are not valid
|
140 |
+
*
|
141 |
+
* @function
|
142 |
+
* @param {String} left Version #1
|
143 |
+
* @param {String} right Version #2
|
144 |
+
* @return {Integer|Boolean}
|
145 |
+
* @author Alexey Bass (albass)
|
146 |
+
* @since 2011-07-14
|
147 |
+
*/
|
148 |
+
|
149 |
+
acf.helpers.version_compare = function(left, right)
|
150 |
+
{
|
151 |
+
if (typeof left + typeof right != 'stringstring')
|
152 |
+
return false;
|
153 |
+
|
154 |
+
var a = left.split('.')
|
155 |
+
, b = right.split('.')
|
156 |
+
, i = 0, len = Math.max(a.length, b.length);
|
157 |
+
|
158 |
+
for (; i < len; i++) {
|
159 |
+
if ((a[i] && !b[i] && parseInt(a[i]) > 0) || (parseInt(a[i]) > parseInt(b[i]))) {
|
160 |
+
return 1;
|
161 |
+
} else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || (parseInt(a[i]) < parseInt(b[i]))) {
|
162 |
+
return -1;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
return 0;
|
167 |
+
};
|
168 |
+
|
169 |
+
|
170 |
+
/*
|
171 |
+
* Helper: uniqid
|
172 |
+
*
|
173 |
+
* @description:
|
174 |
+
* @since: 3.5.8
|
175 |
+
* @created: 17/01/13
|
176 |
+
*/
|
177 |
+
|
178 |
+
acf.helpers.uniqid = function()
|
179 |
+
{
|
180 |
+
var newDate = new Date;
|
181 |
+
return newDate.getTime();
|
182 |
+
};
|
183 |
+
|
184 |
+
|
185 |
+
/*
|
186 |
+
* Helper: url_to_object
|
187 |
+
*
|
188 |
+
* @description:
|
189 |
+
* @since: 4.0.0
|
190 |
+
* @created: 17/01/13
|
191 |
+
*/
|
192 |
+
|
193 |
+
acf.helpers.url_to_object = function( url ){
|
194 |
+
|
195 |
+
// vars
|
196 |
+
var obj = {},
|
197 |
+
pairs = url.split('&');
|
198 |
+
|
199 |
+
|
200 |
+
for( i in pairs )
|
201 |
+
{
|
202 |
+
var split = pairs[i].split('=');
|
203 |
+
obj[decodeURIComponent(split[0])] = decodeURIComponent(split[1]);
|
204 |
+
}
|
205 |
+
|
206 |
+
return obj;
|
207 |
+
|
208 |
+
};
|
209 |
+
|
210 |
+
|
211 |
+
/*
|
212 |
+
* Sortable Helper
|
213 |
+
*
|
214 |
+
* @description: keeps widths of td's inside a tr
|
215 |
+
* @since 3.5.1
|
216 |
+
* @created: 10/11/12
|
217 |
+
*/
|
218 |
+
|
219 |
+
acf.helpers.sortable = function(e, ui)
|
220 |
+
{
|
221 |
+
ui.children().each(function(){
|
222 |
+
$(this).width($(this).width());
|
223 |
+
});
|
224 |
+
return ui;
|
225 |
+
};
|
226 |
+
|
227 |
+
|
228 |
+
/*
|
229 |
+
* is_clone_field
|
230 |
+
*
|
231 |
+
* @description:
|
232 |
+
* @since: 3.5.8
|
233 |
+
* @created: 17/01/13
|
234 |
+
*/
|
235 |
+
|
236 |
+
acf.helpers.is_clone_field = function( input )
|
237 |
+
{
|
238 |
+
if( input.attr('name') && input.attr('name').indexOf('[acfcloneindex]') != -1 )
|
239 |
+
{
|
240 |
+
return true;
|
241 |
+
}
|
242 |
+
|
243 |
+
return false;
|
244 |
+
};
|
245 |
+
|
246 |
+
|
247 |
+
/*
|
248 |
+
* acf.helpers.add_message
|
249 |
+
*
|
250 |
+
* @description:
|
251 |
+
* @since: 3.2.7
|
252 |
+
* @created: 10/07/2012
|
253 |
+
*/
|
254 |
+
|
255 |
+
acf.helpers.add_message = function( message, div ){
|
256 |
+
|
257 |
+
var message = $('<div class="acf-message-wrapper"><div class="message updated"><p>' + message + '</p></div></div>');
|
258 |
+
|
259 |
+
div.prepend( message );
|
260 |
+
|
261 |
+
setTimeout(function(){
|
262 |
+
|
263 |
+
message.animate({
|
264 |
+
opacity : 0
|
265 |
+
}, 250, function(){
|
266 |
+
message.remove();
|
267 |
+
});
|
268 |
+
|
269 |
+
}, 1500);
|
270 |
+
|
271 |
+
};
|
272 |
+
|
273 |
+
|
274 |
+
/*
|
275 |
+
* Exists
|
276 |
+
*
|
277 |
+
* @description: returns true / false
|
278 |
+
* @created: 1/03/2011
|
279 |
+
*/
|
280 |
+
|
281 |
+
$.fn.exists = function()
|
282 |
+
{
|
283 |
+
return $(this).length>0;
|
284 |
+
};
|
285 |
+
|
286 |
+
|
287 |
+
/*
|
288 |
+
* 3.5 Media
|
289 |
+
*
|
290 |
+
* @description:
|
291 |
+
* @since: 3.5.7
|
292 |
+
* @created: 16/01/13
|
293 |
+
*/
|
294 |
+
|
295 |
+
acf.media = {
|
296 |
+
|
297 |
+
div : null,
|
298 |
+
frame : null,
|
299 |
+
render_timout : null,
|
300 |
+
|
301 |
+
clear_frame : function(){
|
302 |
+
|
303 |
+
// validate
|
304 |
+
if( !this.frame )
|
305 |
+
{
|
306 |
+
return;
|
307 |
+
}
|
308 |
+
|
309 |
+
|
310 |
+
// detach
|
311 |
+
this.frame.detach();
|
312 |
+
this.frame.dispose();
|
313 |
+
|
314 |
+
|
315 |
+
// reset var
|
316 |
+
this.frame = null;
|
317 |
+
|
318 |
+
},
|
319 |
+
type : function(){
|
320 |
+
|
321 |
+
// default
|
322 |
+
var type = 'thickbox';
|
323 |
+
|
324 |
+
|
325 |
+
// if wp exists
|
326 |
+
if( typeof wp !== 'undefined' )
|
327 |
+
{
|
328 |
+
type = 'backbone';
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
// return
|
333 |
+
return type;
|
334 |
+
|
335 |
+
},
|
336 |
+
init : function(){
|
337 |
+
|
338 |
+
// validate
|
339 |
+
if( this.type() !== 'backbone' )
|
340 |
+
{
|
341 |
+
return false;
|
342 |
+
}
|
343 |
+
|
344 |
+
|
345 |
+
// validate prototype
|
346 |
+
if( ! acf.helpers.isset(wp, 'media', 'view', 'AttachmentCompat', 'prototype') )
|
347 |
+
{
|
348 |
+
return false;
|
349 |
+
}
|
350 |
+
|
351 |
+
|
352 |
+
// vars
|
353 |
+
var _prototype = wp.media.view.AttachmentCompat.prototype;
|
354 |
+
|
355 |
+
|
356 |
+
// orig
|
357 |
+
_prototype.orig_render = _prototype.render;
|
358 |
+
_prototype.orig_dispose = _prototype.dispose;
|
359 |
+
|
360 |
+
|
361 |
+
// update class
|
362 |
+
_prototype.className = 'compat-item acf_postbox no_box';
|
363 |
+
|
364 |
+
|
365 |
+
// modify render
|
366 |
+
_prototype.render = function() {
|
367 |
+
|
368 |
+
// reference
|
369 |
+
var _this = this;
|
370 |
+
|
371 |
+
|
372 |
+
// validate
|
373 |
+
if( _this.ignore_render )
|
374 |
+
{
|
375 |
+
return this;
|
376 |
+
}
|
377 |
+
|
378 |
+
|
379 |
+
// run the old render function
|
380 |
+
this.orig_render();
|
381 |
+
|
382 |
+
|
383 |
+
// add button
|
384 |
+
setTimeout(function(){
|
385 |
+
|
386 |
+
// vars
|
387 |
+
var $media_model = _this.$el.closest('.media-modal');
|
388 |
+
|
389 |
+
|
390 |
+
// is this an edit only modal?
|
391 |
+
if( $media_model.hasClass('acf-media-modal') )
|
392 |
+
{
|
393 |
+
return;
|
394 |
+
}
|
395 |
+
|
396 |
+
|
397 |
+
// does button already exist?
|
398 |
+
if( $media_model.find('.media-frame-router .acf-expand-details').exists() )
|
399 |
+
{
|
400 |
+
return;
|
401 |
+
}
|
402 |
+
|
403 |
+
|
404 |
+
// create button
|
405 |
+
var button = $([
|
406 |
+
'<a href="#" class="acf-expand-details">',
|
407 |
+
'<span class="icon"></span>',
|
408 |
+
'<span class="is-closed">' + acf.l10n.core.expand_details + '</span>',
|
409 |
+
'<span class="is-open">' + acf.l10n.core.collapse_details + '</span>',
|
410 |
+
'</a>'
|
411 |
+
].join(''));
|
412 |
+
|
413 |
+
|
414 |
+
// add events
|
415 |
+
button.on('click', function( e ){
|
416 |
+
|
417 |
+
e.preventDefault();
|
418 |
+
|
419 |
+
if( $media_model.hasClass('acf-expanded') )
|
420 |
+
{
|
421 |
+
$media_model.removeClass('acf-expanded');
|
422 |
+
}
|
423 |
+
else
|
424 |
+
{
|
425 |
+
$media_model.addClass('acf-expanded');
|
426 |
+
}
|
427 |
+
|
428 |
+
});
|
429 |
+
|
430 |
+
|
431 |
+
// append
|
432 |
+
$media_model.find('.media-frame-router').append( button );
|
433 |
+
|
434 |
+
|
435 |
+
}, 0);
|
436 |
+
|
437 |
+
|
438 |
+
// setup fields
|
439 |
+
// The clearTimout is needed to prevent many setup functions from running at the same time
|
440 |
+
clearTimeout( acf.media.render_timout );
|
441 |
+
acf.media.render_timout = setTimeout(function(){
|
442 |
+
|
443 |
+
$(document).trigger( 'acf/setup_fields', [ _this.$el ] );
|
444 |
+
|
445 |
+
}, 50);
|
446 |
+
|
447 |
+
|
448 |
+
// return based on the origional render function
|
449 |
+
return this;
|
450 |
+
};
|
451 |
+
|
452 |
+
|
453 |
+
// modify dispose
|
454 |
+
_prototype.dispose = function() {
|
455 |
+
|
456 |
+
// remove
|
457 |
+
$(document).trigger('acf/remove_fields', [ this.$el ]);
|
458 |
+
|
459 |
+
|
460 |
+
// run the old render function
|
461 |
+
this.orig_dispose();
|
462 |
+
|
463 |
+
};
|
464 |
+
|
465 |
+
|
466 |
+
// override save
|
467 |
+
_prototype.save = function( event ) {
|
468 |
+
|
469 |
+
var data = {},
|
470 |
+
names = {};
|
471 |
+
|
472 |
+
if ( event )
|
473 |
+
event.preventDefault();
|
474 |
+
|
475 |
+
|
476 |
+
_.each( this.$el.serializeArray(), function( pair ) {
|
477 |
+
|
478 |
+
// initiate name
|
479 |
+
if( pair.name.slice(-2) === '[]' )
|
480 |
+
{
|
481 |
+
// remove []
|
482 |
+
pair.name = pair.name.replace('[]', '');
|
483 |
+
|
484 |
+
|
485 |
+
// initiate counter
|
486 |
+
if( typeof names[ pair.name ] === 'undefined'){
|
487 |
+
|
488 |
+
names[ pair.name ] = -1;
|
489 |
+
//console.log( names[ pair.name ] );
|
490 |
+
|
491 |
+
}
|
492 |
+
|
493 |
+
|
494 |
+
names[ pair.name ]++
|
495 |
+
|
496 |
+
pair.name += '[' + names[ pair.name ] +']';
|
497 |
+
|
498 |
+
|
499 |
+
}
|
500 |
+
|
501 |
+
data[ pair.name ] = pair.value;
|
502 |
+
});
|
503 |
+
|
504 |
+
this.ignore_render = true;
|
505 |
+
this.model.saveCompat( data );
|
506 |
+
|
507 |
+
};
|
508 |
+
}
|
509 |
+
};
|
510 |
+
|
511 |
+
|
512 |
+
/*
|
513 |
+
* Conditional Logic Calculate
|
514 |
+
*
|
515 |
+
* @description:
|
516 |
+
* @since 3.5.1
|
517 |
+
* @created: 15/10/12
|
518 |
+
*/
|
519 |
+
|
520 |
+
acf.conditional_logic = {
|
521 |
+
|
522 |
+
items : [],
|
523 |
+
|
524 |
+
init : function(){
|
525 |
+
|
526 |
+
// reference
|
527 |
+
var _this = this;
|
528 |
+
|
529 |
+
|
530 |
+
// events
|
531 |
+
$(document).on('change', '.field input, .field textarea, .field select', function(){
|
532 |
+
|
533 |
+
// preview hack
|
534 |
+
if( $('#acf-has-changed').exists() )
|
535 |
+
{
|
536 |
+
$('#acf-has-changed').val(1);
|
537 |
+
}
|
538 |
+
|
539 |
+
_this.change( $(this) );
|
540 |
+
|
541 |
+
});
|
542 |
+
|
543 |
+
|
544 |
+
$(document).on('acf/setup_fields', function(e, el){
|
545 |
+
|
546 |
+
//console.log('acf/setup_fields calling acf.conditional_logic.refresh()');
|
547 |
+
_this.refresh( $(el) );
|
548 |
+
|
549 |
+
});
|
550 |
+
|
551 |
+
//console.log('acf.conditional_logic.init() calling acf.conditional_logic.refresh()');
|
552 |
+
_this.refresh();
|
553 |
+
|
554 |
+
},
|
555 |
+
change : function( $el ){
|
556 |
+
|
557 |
+
//console.log('change %o', $el);
|
558 |
+
// reference
|
559 |
+
var _this = this;
|
560 |
+
|
561 |
+
|
562 |
+
// vars
|
563 |
+
var $field = $el.closest('.field'),
|
564 |
+
key = $field.attr('data-field_key');
|
565 |
+
|
566 |
+
|
567 |
+
// loop through items and find rules where this field key is a trigger
|
568 |
+
$.each(this.items, function( k, item ){
|
569 |
+
|
570 |
+
$.each(item.rules, function( k2, rule ){
|
571 |
+
|
572 |
+
// compare rule against the changed $field
|
573 |
+
if( rule.field == key )
|
574 |
+
{
|
575 |
+
_this.refresh_field( item );
|
576 |
+
}
|
577 |
+
|
578 |
+
});
|
579 |
+
|
580 |
+
});
|
581 |
+
|
582 |
+
},
|
583 |
+
|
584 |
+
refresh_field : function( item ){
|
585 |
+
|
586 |
+
//console.log( 'refresh_field: %o ', item );
|
587 |
+
// reference
|
588 |
+
var _this = this;
|
589 |
+
|
590 |
+
|
591 |
+
// vars
|
592 |
+
var $targets = $('.field_key-' + item.field);
|
593 |
+
|
594 |
+
|
595 |
+
// may be multiple targets (sub fields)
|
596 |
+
$targets.each(function(){
|
597 |
+
|
598 |
+
//console.log('target %o', $(this));
|
599 |
+
|
600 |
+
// vars
|
601 |
+
var show = true;
|
602 |
+
|
603 |
+
|
604 |
+
// if 'any' was selected, start of as false and any match will result in show = true
|
605 |
+
if( item.allorany == 'any' )
|
606 |
+
{
|
607 |
+
show = false;
|
608 |
+
}
|
609 |
+
|
610 |
+
|
611 |
+
// vars
|
612 |
+
var $target = $(this),
|
613 |
+
hide_all = true;
|
614 |
+
|
615 |
+
|
616 |
+
// loop through rules
|
617 |
+
$.each(item.rules, function( k2, rule ){
|
618 |
+
|
619 |
+
// vars
|
620 |
+
var $toggle = $('.field_key-' + rule.field);
|
621 |
+
|
622 |
+
|
623 |
+
// are any of $toggle a sub field?
|
624 |
+
if( $toggle.hasClass('sub_field') )
|
625 |
+
{
|
626 |
+
// toggle may be a sibling sub field.
|
627 |
+
// if so ,show an empty td but keep the column
|
628 |
+
$toggle = $target.siblings('.field_key-' + rule.field);
|
629 |
+
hide_all = false;
|
630 |
+
|
631 |
+
|
632 |
+
// if no toggle was found, we need to look at parent sub fields.
|
633 |
+
// if so, hide the entire column
|
634 |
+
if( ! $toggle.exists() )
|
635 |
+
{
|
636 |
+
// loop through all the parents that could contain sub fields
|
637 |
+
$target.parents('tr').each(function(){
|
638 |
+
|
639 |
+
// attempt to update $toggle to this parent sub field
|
640 |
+
$toggle = $(this).find('.field_key-' + rule.field)
|
641 |
+
|
642 |
+
// if the parent sub field actuallly exists, great! Stop the loop
|
643 |
+
if( $toggle.exists() )
|
644 |
+
{
|
645 |
+
return false;
|
646 |
+
}
|
647 |
+
|
648 |
+
});
|
649 |
+
|
650 |
+
hide_all = true;
|
651 |
+
}
|
652 |
+
|
653 |
+
}
|
654 |
+
|
655 |
+
|
656 |
+
// if this sub field is within a flexible content layout, hide the entire column because
|
657 |
+
// there will never be another row added to this table
|
658 |
+
var parent = $target.parent('tr').parent().parent('table').parent('.layout');
|
659 |
+
if( parent.exists() )
|
660 |
+
{
|
661 |
+
hide_all = true;
|
662 |
+
|
663 |
+
if( $target.is('th') && $toggle.is('th') )
|
664 |
+
{
|
665 |
+
$toggle = $target.closest('.layout').find('td.field_key-' + rule.field);
|
666 |
+
}
|
667 |
+
|
668 |
+
}
|
669 |
+
|
670 |
+
// if this sub field is within a repeater field which has a max row of 1, hide the entire column because
|
671 |
+
// there will never be another row added to this table
|
672 |
+
var parent = $target.parent('tr').parent().parent('table').parent('.repeater');
|
673 |
+
if( parent.exists() && parent.attr('data-max_rows') == '1' )
|
674 |
+
{
|
675 |
+
hide_all = true;
|
676 |
+
|
677 |
+
if( $target.is('th') && $toggle.is('th') )
|
678 |
+
{
|
679 |
+
$toggle = $target.closest('table').find('td.field_key-' + rule.field);
|
680 |
+
}
|
681 |
+
|
682 |
+
}
|
683 |
+
|
684 |
+
|
685 |
+
var calculate = _this.calculate( rule, $toggle, $target );
|
686 |
+
|
687 |
+
if( item.allorany == 'all' )
|
688 |
+
{
|
689 |
+
if( calculate == false )
|
690 |
+
{
|
691 |
+
show = false;
|
692 |
+
|
693 |
+
// end loop
|
694 |
+
return false;
|
695 |
+
}
|
696 |
+
}
|
697 |
+
else
|
698 |
+
{
|
699 |
+
if( calculate == true )
|
700 |
+
{
|
701 |
+
show = true;
|
702 |
+
|
703 |
+
// end loop
|
704 |
+
return false;
|
705 |
+
}
|
706 |
+
}
|
707 |
+
|
708 |
+
});
|
709 |
+
// $.each(item.rules, function( k2, rule ){
|
710 |
+
|
711 |
+
|
712 |
+
// clear classes
|
713 |
+
$target.removeClass('acf-conditional_logic-hide acf-conditional_logic-show acf-show-blank');
|
714 |
+
|
715 |
+
|
716 |
+
// hide / show field
|
717 |
+
if( show )
|
718 |
+
{
|
719 |
+
// remove "disabled"
|
720 |
+
$target.find('input, textarea, select').removeAttr('disabled');
|
721 |
+
|
722 |
+
$target.addClass('acf-conditional_logic-show');
|
723 |
+
|
724 |
+
// hook
|
725 |
+
$(document).trigger('acf/conditional_logic/show', [ $target, item ]);
|
726 |
+
|
727 |
+
}
|
728 |
+
else
|
729 |
+
{
|
730 |
+
// add "disabled"
|
731 |
+
$target.find('input, textarea, select').attr('disabled', 'disabled');
|
732 |
+
|
733 |
+
$target.addClass('acf-conditional_logic-hide');
|
734 |
+
|
735 |
+
if( !hide_all )
|
736 |
+
{
|
737 |
+
$target.addClass('acf-show-blank');
|
738 |
+
}
|
739 |
+
|
740 |
+
// hook
|
741 |
+
$(document).trigger('acf/conditional_logic/hide', [ $target, item ]);
|
742 |
+
}
|
743 |
+
|
744 |
+
|
745 |
+
});
|
746 |
+
|
747 |
+
},
|
748 |
+
|
749 |
+
refresh : function( $el ){
|
750 |
+
|
751 |
+
// defaults
|
752 |
+
$el = $el || $('body');
|
753 |
+
|
754 |
+
|
755 |
+
// reference
|
756 |
+
var _this = this;
|
757 |
+
|
758 |
+
|
759 |
+
// loop through items and find rules where this field key is a trigger
|
760 |
+
$.each(this.items, function( k, item ){
|
761 |
+
|
762 |
+
$.each(item.rules, function( k2, rule ){
|
763 |
+
|
764 |
+
// is this field within the $el
|
765 |
+
// this will increase performance by ignoring conditional logic outside of this newly appended element ($el)
|
766 |
+
if( ! $el.find('.field[data-field_key="' + item.field + '"]').exists() )
|
767 |
+
{
|
768 |
+
return;
|
769 |
+
}
|
770 |
+
|
771 |
+
_this.refresh_field( item );
|
772 |
+
|
773 |
+
});
|
774 |
+
|
775 |
+
});
|
776 |
+
|
777 |
+
},
|
778 |
+
|
779 |
+
calculate : function( rule, $toggle, $target ){
|
780 |
+
|
781 |
+
// vars
|
782 |
+
var r = false;
|
783 |
+
|
784 |
+
|
785 |
+
// compare values
|
786 |
+
if( $toggle.hasClass('field_type-true_false') || $toggle.hasClass('field_type-checkbox') || $toggle.hasClass('field_type-radio') )
|
787 |
+
{
|
788 |
+
var exists = $toggle.find('input[value="' + rule.value + '"]:checked').exists();
|
789 |
+
|
790 |
+
|
791 |
+
if( rule.operator == "==" )
|
792 |
+
{
|
793 |
+
if( exists )
|
794 |
+
{
|
795 |
+
r = true;
|
796 |
+
}
|
797 |
+
}
|
798 |
+
else
|
799 |
+
{
|
800 |
+
if( ! exists )
|
801 |
+
{
|
802 |
+
r = true;
|
803 |
+
}
|
804 |
+
}
|
805 |
+
|
806 |
+
}
|
807 |
+
else
|
808 |
+
{
|
809 |
+
// get val and make sure it is an array
|
810 |
+
var val = $toggle.find('input, textarea, select').last().val();
|
811 |
+
|
812 |
+
if( ! $.isArray(val) )
|
813 |
+
{
|
814 |
+
val = [ val ];
|
815 |
+
}
|
816 |
+
|
817 |
+
|
818 |
+
if( rule.operator == "==" )
|
819 |
+
{
|
820 |
+
if( $.inArray(rule.value, val) > -1 )
|
821 |
+
{
|
822 |
+
r = true;
|
823 |
+
}
|
824 |
+
}
|
825 |
+
else
|
826 |
+
{
|
827 |
+
if( $.inArray(rule.value, val) < 0 )
|
828 |
+
{
|
829 |
+
r = true;
|
830 |
+
}
|
831 |
+
}
|
832 |
+
|
833 |
+
}
|
834 |
+
|
835 |
+
|
836 |
+
// return
|
837 |
+
return r;
|
838 |
+
|
839 |
+
}
|
840 |
+
|
841 |
+
};
|
842 |
+
|
843 |
+
|
844 |
+
|
845 |
+
|
846 |
+
|
847 |
+
/*
|
848 |
+
* Document Ready
|
849 |
+
*
|
850 |
+
* @description:
|
851 |
+
* @since: 3.5.8
|
852 |
+
* @created: 17/01/13
|
853 |
+
*/
|
854 |
+
|
855 |
+
$(document).ready(function(){
|
856 |
+
|
857 |
+
|
858 |
+
// conditional logic
|
859 |
+
acf.conditional_logic.init();
|
860 |
+
|
861 |
+
|
862 |
+
// fix for older options page add-on
|
863 |
+
$('.acf_postbox > .inside > .options').each(function(){
|
864 |
+
|
865 |
+
$(this).closest('.acf_postbox').addClass( $(this).attr('data-layout') );
|
866 |
+
|
867 |
+
});
|
868 |
+
|
869 |
+
|
870 |
+
// Remove 'field_123' from native custom field metabox
|
871 |
+
$('#metakeyselect option[value^="field_"]').remove();
|
872 |
+
|
873 |
+
|
874 |
+
});
|
875 |
+
|
876 |
+
|
877 |
+
/*
|
878 |
+
* window load
|
879 |
+
*
|
880 |
+
* @description:
|
881 |
+
* @since: 3.5.5
|
882 |
+
* @created: 22/12/12
|
883 |
+
*/
|
884 |
+
|
885 |
+
$(window).on('load', function(){
|
886 |
+
|
887 |
+
// init
|
888 |
+
acf.media.init();
|
889 |
+
|
890 |
+
|
891 |
+
setTimeout(function(){
|
892 |
+
|
893 |
+
// Hack for CPT without a content editor
|
894 |
+
try
|
895 |
+
{
|
896 |
+
// post_id may be string (user_1) and therefore, the uploaded image cannot be attached to the post
|
897 |
+
if( $.isNumeric(acf.o.post_id) )
|
898 |
+
{
|
899 |
+
wp.media.view.settings.post.id = acf.o.post_id;
|
900 |
+
}
|
901 |
+
|
902 |
+
}
|
903 |
+
catch(e)
|
904 |
+
{
|
905 |
+
// one of the objects was 'undefined'...
|
906 |
+
}
|
907 |
+
|
908 |
+
|
909 |
+
// setup fields
|
910 |
+
$(document).trigger('acf/setup_fields', [ $('#poststuff') ]);
|
911 |
+
|
912 |
+
}, 10);
|
913 |
+
|
914 |
+
});
|
915 |
+
|
916 |
+
|
917 |
+
/*
|
918 |
+
* Gallery field Add-on Fix
|
919 |
+
*
|
920 |
+
* Gallery field v1.0.0 required some data in the acf object.
|
921 |
+
* Now not required, but older versions of gallery field need this.
|
922 |
+
*
|
923 |
+
* @type object
|
924 |
+
* @date 1/08/13
|
925 |
+
*
|
926 |
+
* @param N/A
|
927 |
+
* @return N/A
|
928 |
+
*/
|
929 |
+
|
930 |
+
acf.fields.gallery = {
|
931 |
+
add : function(){},
|
932 |
+
edit : function(){},
|
933 |
+
update_count : function(){},
|
934 |
+
hide_selected_items : function(){},
|
935 |
+
text : {
|
936 |
+
title_add : "Select Images"
|
937 |
+
}
|
938 |
+
};
|
939 |
+
|
940 |
+
|
941 |
+
|
942 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/ajax.js
ADDED
@@ -0,0 +1,325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
|
4 |
+
/*
|
5 |
+
* acf.screen
|
6 |
+
*
|
7 |
+
* Data used by AJAX to hide / show field groups
|
8 |
+
*
|
9 |
+
* @type object
|
10 |
+
* @date 1/03/2011
|
11 |
+
*
|
12 |
+
* @param N/A
|
13 |
+
* @return N/A
|
14 |
+
*/
|
15 |
+
|
16 |
+
acf.screen = {
|
17 |
+
action : 'acf/location/match_field_groups_ajax',
|
18 |
+
post_id : 0,
|
19 |
+
page_template : 0,
|
20 |
+
page_parent : 0,
|
21 |
+
page_type : 0,
|
22 |
+
post_category : 0,
|
23 |
+
post_format : 0,
|
24 |
+
taxonomy : 0,
|
25 |
+
lang : 0,
|
26 |
+
nonce : 0
|
27 |
+
};
|
28 |
+
|
29 |
+
|
30 |
+
/*
|
31 |
+
* Document Ready
|
32 |
+
*
|
33 |
+
* Updates acf.screen with more data
|
34 |
+
*
|
35 |
+
* @type function
|
36 |
+
* @date 1/03/2011
|
37 |
+
*
|
38 |
+
* @param N/A
|
39 |
+
* @return N/A
|
40 |
+
*/
|
41 |
+
|
42 |
+
$(document).ready(function(){
|
43 |
+
|
44 |
+
|
45 |
+
// update post_id
|
46 |
+
acf.screen.post_id = acf.o.post_id;
|
47 |
+
acf.screen.nonce = acf.o.nonce;
|
48 |
+
|
49 |
+
|
50 |
+
// MPML
|
51 |
+
if( $('#icl-als-first').length > 0 )
|
52 |
+
{
|
53 |
+
var href = $('#icl-als-first').children('a').attr('href'),
|
54 |
+
regex = new RegExp( "lang=([^&#]*)" ),
|
55 |
+
results = regex.exec( href );
|
56 |
+
|
57 |
+
// lang
|
58 |
+
acf.screen.lang = results[1];
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
});
|
63 |
+
|
64 |
+
|
65 |
+
/*
|
66 |
+
* acf/update_field_groups
|
67 |
+
*
|
68 |
+
* finds the new id's for metaboxes and show's hides metaboxes
|
69 |
+
*
|
70 |
+
* @type event
|
71 |
+
* @date 1/03/2011
|
72 |
+
*
|
73 |
+
* @param N/A
|
74 |
+
* @return N/A
|
75 |
+
*/
|
76 |
+
|
77 |
+
$(document).on('acf/update_field_groups', function(){
|
78 |
+
|
79 |
+
// Only for a post.
|
80 |
+
// This is an attempt to stop the action running on the options page add-on.
|
81 |
+
if( ! acf.screen.post_id || ! $.isNumeric(acf.screen.post_id) )
|
82 |
+
{
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
$.ajax({
|
88 |
+
url: ajaxurl,
|
89 |
+
data: acf.screen,
|
90 |
+
type: 'post',
|
91 |
+
dataType: 'json',
|
92 |
+
success: function(result){
|
93 |
+
|
94 |
+
// validate
|
95 |
+
if( !result )
|
96 |
+
{
|
97 |
+
return false;
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
// hide all metaboxes
|
102 |
+
$('.acf_postbox').addClass('acf-hidden');
|
103 |
+
$('.acf_postbox-toggle').addClass('acf-hidden');
|
104 |
+
|
105 |
+
|
106 |
+
// dont bother loading style or html for inputs
|
107 |
+
if( result.length == 0 )
|
108 |
+
{
|
109 |
+
return false;
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
// show the new postboxes
|
114 |
+
$.each(result, function(k, v) {
|
115 |
+
|
116 |
+
|
117 |
+
// vars
|
118 |
+
var $el = $('#acf_' + v),
|
119 |
+
$toggle = $('#adv-settings .acf_postbox-toggle[for="acf_' + v + '-hide"]');
|
120 |
+
|
121 |
+
|
122 |
+
// classes
|
123 |
+
$el.removeClass('acf-hidden hide-if-js');
|
124 |
+
$toggle.removeClass('acf-hidden');
|
125 |
+
$toggle.find('input[type="checkbox"]').attr('checked', 'checked');
|
126 |
+
|
127 |
+
|
128 |
+
// load fields if needed
|
129 |
+
$el.find('.acf-replace-with-fields').each(function(){
|
130 |
+
|
131 |
+
var $replace = $(this);
|
132 |
+
|
133 |
+
$.ajax({
|
134 |
+
url : ajaxurl,
|
135 |
+
data : {
|
136 |
+
action : 'acf/post/render_fields',
|
137 |
+
acf_id : v,
|
138 |
+
post_id : acf.o.post_id,
|
139 |
+
nonce : acf.o.nonce
|
140 |
+
},
|
141 |
+
type : 'post',
|
142 |
+
dataType : 'html',
|
143 |
+
success : function( html ){
|
144 |
+
|
145 |
+
$replace.replaceWith( html );
|
146 |
+
|
147 |
+
$(document).trigger('acf/setup_fields', $el);
|
148 |
+
|
149 |
+
}
|
150 |
+
});
|
151 |
+
|
152 |
+
});
|
153 |
+
});
|
154 |
+
|
155 |
+
|
156 |
+
// load style
|
157 |
+
$.ajax({
|
158 |
+
url : ajaxurl,
|
159 |
+
data : {
|
160 |
+
action : 'acf/post/get_style',
|
161 |
+
acf_id : result[0],
|
162 |
+
nonce : acf.o.nonce
|
163 |
+
},
|
164 |
+
type : 'post',
|
165 |
+
dataType : 'html',
|
166 |
+
success : function( result ){
|
167 |
+
|
168 |
+
$('#acf_style').html( result );
|
169 |
+
|
170 |
+
}
|
171 |
+
});
|
172 |
+
|
173 |
+
|
174 |
+
|
175 |
+
}
|
176 |
+
});
|
177 |
+
});
|
178 |
+
|
179 |
+
|
180 |
+
/*
|
181 |
+
* Events
|
182 |
+
*
|
183 |
+
* Updates acf.screen with more data and triggers the update event
|
184 |
+
*
|
185 |
+
* @type function
|
186 |
+
* @date 1/03/2011
|
187 |
+
*
|
188 |
+
* @param N/A
|
189 |
+
* @return N/A
|
190 |
+
*/
|
191 |
+
|
192 |
+
$(document).on('change', '#page_template', function(){
|
193 |
+
|
194 |
+
acf.screen.page_template = $(this).val();
|
195 |
+
|
196 |
+
$(document).trigger('acf/update_field_groups');
|
197 |
+
|
198 |
+
});
|
199 |
+
|
200 |
+
|
201 |
+
$(document).on('change', '#parent_id', function(){
|
202 |
+
|
203 |
+
var val = $(this).val();
|
204 |
+
|
205 |
+
|
206 |
+
// set page_type / page_parent
|
207 |
+
if( val != "" )
|
208 |
+
{
|
209 |
+
acf.screen.page_type = 'child';
|
210 |
+
acf.screen.page_parent = val;
|
211 |
+
}
|
212 |
+
else
|
213 |
+
{
|
214 |
+
acf.screen.page_type = 'parent';
|
215 |
+
acf.screen.page_parent = 0;
|
216 |
+
}
|
217 |
+
|
218 |
+
|
219 |
+
$(document).trigger('acf/update_field_groups');
|
220 |
+
|
221 |
+
});
|
222 |
+
|
223 |
+
|
224 |
+
$(document).on('change', '#post-formats-select input[type="radio"]', function(){
|
225 |
+
|
226 |
+
var val = $(this).val();
|
227 |
+
|
228 |
+
if( val == '0' )
|
229 |
+
{
|
230 |
+
val = 'standard';
|
231 |
+
}
|
232 |
+
|
233 |
+
acf.screen.post_format = val;
|
234 |
+
|
235 |
+
$(document).trigger('acf/update_field_groups');
|
236 |
+
|
237 |
+
});
|
238 |
+
|
239 |
+
|
240 |
+
function _sync_taxonomy_terms() {
|
241 |
+
|
242 |
+
// vars
|
243 |
+
var values = [];
|
244 |
+
|
245 |
+
|
246 |
+
$('.categorychecklist input:checked, .acf-taxonomy-field input:checked, .acf-taxonomy-field option:selected').each(function(){
|
247 |
+
|
248 |
+
// validate
|
249 |
+
if( $(this).is(':hidden') || $(this).is(':disabled') )
|
250 |
+
{
|
251 |
+
return;
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
// validate media popup
|
256 |
+
if( $(this).closest('.media-frame').exists() )
|
257 |
+
{
|
258 |
+
return;
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
// validate acf
|
263 |
+
if( $(this).closest('.acf-taxonomy-field').exists() )
|
264 |
+
{
|
265 |
+
if( $(this).closest('.acf-taxonomy-field').attr('data-load_save') == '0' )
|
266 |
+
{
|
267 |
+
return;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
// append
|
273 |
+
if( values.indexOf( $(this).val() ) === -1 )
|
274 |
+
{
|
275 |
+
values.push( $(this).val() );
|
276 |
+
}
|
277 |
+
|
278 |
+
});
|
279 |
+
|
280 |
+
|
281 |
+
// update screen
|
282 |
+
acf.screen.post_category = values;
|
283 |
+
acf.screen.taxonomy = values;
|
284 |
+
|
285 |
+
|
286 |
+
// trigger change
|
287 |
+
$(document).trigger('acf/update_field_groups');
|
288 |
+
|
289 |
+
}
|
290 |
+
|
291 |
+
|
292 |
+
$(document).on('change', '.categorychecklist input, .acf-taxonomy-field input, .acf-taxonomy-field select', function(){
|
293 |
+
|
294 |
+
// a taxonomy field may trigger this change event, however, the value selected is not
|
295 |
+
// actually a term relatinoship, it is meta data
|
296 |
+
if( $(this).closest('.acf-taxonomy-field').exists() )
|
297 |
+
{
|
298 |
+
if( $(this).closest('.acf-taxonomy-field').attr('data-save') == '0' )
|
299 |
+
{
|
300 |
+
return;
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
|
305 |
+
// this may be triggered from editing an imgae in a popup. Popup does not support correct metaboxes so ignore this
|
306 |
+
if( $(this).closest('.media-frame').exists() )
|
307 |
+
{
|
308 |
+
return;
|
309 |
+
}
|
310 |
+
|
311 |
+
|
312 |
+
// set timeout to fix issue with chrome which does not register the change has yet happened
|
313 |
+
setTimeout(function(){
|
314 |
+
|
315 |
+
_sync_taxonomy_terms();
|
316 |
+
|
317 |
+
}, 1);
|
318 |
+
|
319 |
+
|
320 |
+
});
|
321 |
+
|
322 |
+
|
323 |
+
|
324 |
+
|
325 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/color-picker.js
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Color Picker
|
5 |
+
*
|
6 |
+
* jQuery functionality for this field type
|
7 |
+
*
|
8 |
+
* @type object
|
9 |
+
* @date 20/07/13
|
10 |
+
*
|
11 |
+
* @param N/A
|
12 |
+
* @return N/A
|
13 |
+
*/
|
14 |
+
|
15 |
+
var _cp = acf.fields.color_picker = {
|
16 |
+
|
17 |
+
$el : null,
|
18 |
+
$input : null,
|
19 |
+
|
20 |
+
set : function( o ){
|
21 |
+
|
22 |
+
// merge in new option
|
23 |
+
$.extend( this, o );
|
24 |
+
|
25 |
+
|
26 |
+
// find input
|
27 |
+
this.$input = this.$el.find('input[type="text"]');
|
28 |
+
|
29 |
+
|
30 |
+
// return this for chaining
|
31 |
+
return this;
|
32 |
+
|
33 |
+
},
|
34 |
+
init : function(){
|
35 |
+
|
36 |
+
// vars (reference)
|
37 |
+
var $input = this.$input;
|
38 |
+
|
39 |
+
|
40 |
+
// is clone field?
|
41 |
+
if( acf.helpers.is_clone_field($input) )
|
42 |
+
{
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
this.$input.wpColorPicker();
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
}
|
52 |
+
};
|
53 |
+
|
54 |
+
|
55 |
+
/*
|
56 |
+
* acf/setup_fields
|
57 |
+
*
|
58 |
+
* run init function on all elements for this field
|
59 |
+
*
|
60 |
+
* @type event
|
61 |
+
* @date 20/07/13
|
62 |
+
*
|
63 |
+
* @param {object} e event object
|
64 |
+
* @param {object} el DOM object which may contain new ACF elements
|
65 |
+
* @return N/A
|
66 |
+
*/
|
67 |
+
|
68 |
+
$(document).on('acf/setup_fields', function(e, el){
|
69 |
+
|
70 |
+
$(el).find('.acf-color_picker').each(function(){
|
71 |
+
|
72 |
+
_cp.set({ $el : $(this) }).init();
|
73 |
+
|
74 |
+
});
|
75 |
+
|
76 |
+
});
|
77 |
+
|
78 |
+
|
79 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/date-picker.js
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Date Picker
|
5 |
+
*
|
6 |
+
* static model for this field
|
7 |
+
*
|
8 |
+
* @type event
|
9 |
+
* @date 1/06/13
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
acf.fields.date_picker = {
|
14 |
+
|
15 |
+
$el : null,
|
16 |
+
$input : null,
|
17 |
+
$hidden : null,
|
18 |
+
|
19 |
+
o : {},
|
20 |
+
|
21 |
+
set : function( o ){
|
22 |
+
|
23 |
+
// merge in new option
|
24 |
+
$.extend( this, o );
|
25 |
+
|
26 |
+
|
27 |
+
// find input
|
28 |
+
this.$input = this.$el.find('input[type="text"]');
|
29 |
+
this.$hidden = this.$el.find('input[type="hidden"]');
|
30 |
+
|
31 |
+
|
32 |
+
// get options
|
33 |
+
this.o = acf.helpers.get_atts( this.$el );
|
34 |
+
|
35 |
+
|
36 |
+
// return this for chaining
|
37 |
+
return this;
|
38 |
+
|
39 |
+
},
|
40 |
+
init : function(){
|
41 |
+
|
42 |
+
// is clone field?
|
43 |
+
if( acf.helpers.is_clone_field(this.$hidden) )
|
44 |
+
{
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
// get and set value from alt field
|
50 |
+
this.$input.val( this.$hidden.val() );
|
51 |
+
|
52 |
+
|
53 |
+
// create options
|
54 |
+
var options = $.extend( {}, acf.l10n.date_picker, {
|
55 |
+
dateFormat : this.o.save_format,
|
56 |
+
altField : this.$hidden,
|
57 |
+
altFormat : this.o.save_format,
|
58 |
+
changeYear : true,
|
59 |
+
yearRange : "-100:+100",
|
60 |
+
changeMonth : true,
|
61 |
+
showButtonPanel : true,
|
62 |
+
firstDay : this.o.first_day
|
63 |
+
});
|
64 |
+
|
65 |
+
|
66 |
+
// add date picker
|
67 |
+
this.$input.addClass('active').datepicker( options );
|
68 |
+
|
69 |
+
|
70 |
+
// now change the format back to how it should be.
|
71 |
+
this.$input.datepicker( "option", "dateFormat", this.o.display_format );
|
72 |
+
|
73 |
+
|
74 |
+
// wrap the datepicker (only if it hasn't already been wrapped)
|
75 |
+
if( $('body > #ui-datepicker-div').length > 0 )
|
76 |
+
{
|
77 |
+
$('#ui-datepicker-div').wrap('<div class="ui-acf" />');
|
78 |
+
}
|
79 |
+
|
80 |
+
},
|
81 |
+
blur : function(){
|
82 |
+
|
83 |
+
if( !this.$input.val() )
|
84 |
+
{
|
85 |
+
this.$hidden.val('');
|
86 |
+
}
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
};
|
91 |
+
|
92 |
+
|
93 |
+
/*
|
94 |
+
* acf/setup_fields
|
95 |
+
*
|
96 |
+
* run init function on all elements for this field
|
97 |
+
*
|
98 |
+
* @type event
|
99 |
+
* @date 20/07/13
|
100 |
+
*
|
101 |
+
* @param {object} e event object
|
102 |
+
* @param {object} el DOM object which may contain new ACF elements
|
103 |
+
* @return N/A
|
104 |
+
*/
|
105 |
+
|
106 |
+
$(document).on('acf/setup_fields', function(e, el){
|
107 |
+
|
108 |
+
$(el).find('.acf-date_picker').each(function(){
|
109 |
+
|
110 |
+
acf.fields.date_picker.set({ $el : $(this) }).init();
|
111 |
+
|
112 |
+
});
|
113 |
+
|
114 |
+
});
|
115 |
+
|
116 |
+
|
117 |
+
/*
|
118 |
+
* Events
|
119 |
+
*
|
120 |
+
* jQuery events for this field
|
121 |
+
*
|
122 |
+
* @type event
|
123 |
+
* @date 1/06/13
|
124 |
+
*
|
125 |
+
*/
|
126 |
+
|
127 |
+
$(document).on('blur', '.acf-date_picker input[type="text"]', function( e ){
|
128 |
+
|
129 |
+
acf.fields.date_picker.set({ $el : $(this).parent() }).blur();
|
130 |
+
|
131 |
+
});
|
132 |
+
|
133 |
+
|
134 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/file.js
ADDED
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
/*
|
4 |
+
* File
|
5 |
+
*
|
6 |
+
* static model for this field
|
7 |
+
*
|
8 |
+
* @type event
|
9 |
+
* @date 1/06/13
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
// reference
|
15 |
+
var _media = acf.media;
|
16 |
+
|
17 |
+
|
18 |
+
acf.fields.file = {
|
19 |
+
|
20 |
+
$el : null,
|
21 |
+
$input : null,
|
22 |
+
|
23 |
+
o : {},
|
24 |
+
|
25 |
+
set : function( o ){
|
26 |
+
|
27 |
+
// merge in new option
|
28 |
+
$.extend( this, o );
|
29 |
+
|
30 |
+
|
31 |
+
// find input
|
32 |
+
this.$input = this.$el.find('input[type="hidden"]');
|
33 |
+
|
34 |
+
|
35 |
+
// get options
|
36 |
+
this.o = acf.helpers.get_atts( this.$el );
|
37 |
+
|
38 |
+
|
39 |
+
// multiple?
|
40 |
+
this.o.multiple = this.$el.closest('.repeater').exists() ? true : false;
|
41 |
+
|
42 |
+
|
43 |
+
// wp library query
|
44 |
+
this.o.query = {};
|
45 |
+
|
46 |
+
|
47 |
+
// library
|
48 |
+
if( this.o.library == 'uploadedTo' )
|
49 |
+
{
|
50 |
+
this.o.query.uploadedTo = acf.o.post_id;
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
// return this for chaining
|
55 |
+
return this;
|
56 |
+
|
57 |
+
},
|
58 |
+
init : function(){
|
59 |
+
|
60 |
+
// is clone field?
|
61 |
+
if( acf.helpers.is_clone_field(this.$input) )
|
62 |
+
{
|
63 |
+
return;
|
64 |
+
}
|
65 |
+
|
66 |
+
},
|
67 |
+
add : function( file ){
|
68 |
+
|
69 |
+
// this function must reference a global div variable due to the pre WP 3.5 uploader
|
70 |
+
// vars
|
71 |
+
var div = _media.div;
|
72 |
+
|
73 |
+
|
74 |
+
// set atts
|
75 |
+
div.find('.acf-file-icon').attr( 'src', file.icon );
|
76 |
+
div.find('.acf-file-title').text( file.title );
|
77 |
+
div.find('.acf-file-name').text( file.name ).attr( 'href', file.url );
|
78 |
+
div.find('.acf-file-size').text( file.size );
|
79 |
+
div.find('.acf-file-value').val( file.id ).trigger('change');
|
80 |
+
|
81 |
+
|
82 |
+
// set div class
|
83 |
+
div.addClass('active');
|
84 |
+
|
85 |
+
|
86 |
+
// validation
|
87 |
+
div.closest('.field').removeClass('error');
|
88 |
+
|
89 |
+
},
|
90 |
+
|
91 |
+
new_frame: function( attributes ){
|
92 |
+
|
93 |
+
// set global var
|
94 |
+
_media.div = this.$el;
|
95 |
+
|
96 |
+
|
97 |
+
// clear the frame
|
98 |
+
_media.clear_frame();
|
99 |
+
|
100 |
+
|
101 |
+
// vars
|
102 |
+
attributes.states = [];
|
103 |
+
|
104 |
+
// append states
|
105 |
+
attributes.states.push(
|
106 |
+
new wp.media.controller.Library({
|
107 |
+
library : wp.media.query( this.o.query ),
|
108 |
+
multiple : attributes.multiple,
|
109 |
+
title : attributes.title,
|
110 |
+
priority : 20,
|
111 |
+
filterable : 'all'
|
112 |
+
})
|
113 |
+
);
|
114 |
+
|
115 |
+
|
116 |
+
// edit image functionality (added in WP 3.9)
|
117 |
+
if( acf.helpers.isset(wp, 'media', 'controller', 'EditImage') ) {
|
118 |
+
|
119 |
+
attributes.states.push( new wp.media.controller.EditImage() );
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
// Create the media frame
|
125 |
+
_media.frame = wp.media( attributes );
|
126 |
+
|
127 |
+
|
128 |
+
// edit image view
|
129 |
+
// source: media-views.js:2410 editImageContent()
|
130 |
+
_media.frame.on('content:render:edit-image', function(){
|
131 |
+
|
132 |
+
var image = this.state().get('image'),
|
133 |
+
view = new wp.media.view.EditImage( { model: image, controller: this } ).render();
|
134 |
+
|
135 |
+
this.content.set( view );
|
136 |
+
|
137 |
+
// after creating the wrapper view, load the actual editor via an ajax call
|
138 |
+
view.loadEditor();
|
139 |
+
|
140 |
+
}, _media.frame);
|
141 |
+
|
142 |
+
|
143 |
+
// update toolbar button
|
144 |
+
_media.frame.on( 'toolbar:create:select', function( toolbar ) {
|
145 |
+
|
146 |
+
toolbar.view = new wp.media.view.Toolbar.Select({
|
147 |
+
text: attributes.button.text,
|
148 |
+
controller: this
|
149 |
+
});
|
150 |
+
|
151 |
+
}, _media.frame );
|
152 |
+
|
153 |
+
|
154 |
+
// return
|
155 |
+
return _media.frame;
|
156 |
+
|
157 |
+
},
|
158 |
+
|
159 |
+
edit : function(){
|
160 |
+
|
161 |
+
// vars
|
162 |
+
var id = this.$input.val();
|
163 |
+
|
164 |
+
|
165 |
+
// create frame
|
166 |
+
this.new_frame({
|
167 |
+
title : acf.l10n.file.edit,
|
168 |
+
multiple : false,
|
169 |
+
button : { text : acf.l10n.file.update }
|
170 |
+
});
|
171 |
+
|
172 |
+
|
173 |
+
// open
|
174 |
+
_media.frame.on('open',function() {
|
175 |
+
|
176 |
+
// set to browse
|
177 |
+
if( _media.frame.content._mode != 'browse' )
|
178 |
+
{
|
179 |
+
_media.frame.content.mode('browse');
|
180 |
+
}
|
181 |
+
|
182 |
+
|
183 |
+
// add class
|
184 |
+
_media.frame.$el.closest('.media-modal').addClass('acf-media-modal acf-expanded');
|
185 |
+
|
186 |
+
|
187 |
+
// set selection
|
188 |
+
var selection = _media.frame.state().get('selection'),
|
189 |
+
attachment = wp.media.attachment( id );
|
190 |
+
|
191 |
+
|
192 |
+
// to fetch or not to fetch
|
193 |
+
if( $.isEmptyObject(attachment.changed) )
|
194 |
+
{
|
195 |
+
attachment.fetch();
|
196 |
+
}
|
197 |
+
|
198 |
+
|
199 |
+
selection.add( attachment );
|
200 |
+
|
201 |
+
});
|
202 |
+
|
203 |
+
|
204 |
+
// close
|
205 |
+
_media.frame.on('close',function(){
|
206 |
+
|
207 |
+
// remove class
|
208 |
+
_media.frame.$el.closest('.media-modal').removeClass('acf-media-modal');
|
209 |
+
|
210 |
+
});
|
211 |
+
|
212 |
+
|
213 |
+
// Finally, open the modal
|
214 |
+
acf.media.frame.open();
|
215 |
+
|
216 |
+
},
|
217 |
+
remove : function()
|
218 |
+
{
|
219 |
+
|
220 |
+
// set atts
|
221 |
+
this.$el.find('.acf-file-icon').attr( 'src', '' );
|
222 |
+
this.$el.find('.acf-file-title').text( '' );
|
223 |
+
this.$el.find('.acf-file-name').text( '' ).attr( 'href', '' );
|
224 |
+
this.$el.find('.acf-file-size').text( '' );
|
225 |
+
this.$el.find('.acf-file-value').val( '' ).trigger('change');
|
226 |
+
|
227 |
+
|
228 |
+
// remove class
|
229 |
+
this.$el.removeClass('active');
|
230 |
+
|
231 |
+
},
|
232 |
+
popup : function()
|
233 |
+
{
|
234 |
+
// reference
|
235 |
+
var t = this;
|
236 |
+
|
237 |
+
|
238 |
+
// create frame
|
239 |
+
this.new_frame({
|
240 |
+
title : acf.l10n.file.select,
|
241 |
+
multiple : t.o.multiple,
|
242 |
+
button : { text : acf.l10n.file.select }
|
243 |
+
});
|
244 |
+
|
245 |
+
|
246 |
+
// customize model / view
|
247 |
+
acf.media.frame.on('content:activate', function(){
|
248 |
+
|
249 |
+
// vars
|
250 |
+
var toolbar = null,
|
251 |
+
filters = null;
|
252 |
+
|
253 |
+
|
254 |
+
// populate above vars making sure to allow for failure
|
255 |
+
try
|
256 |
+
{
|
257 |
+
toolbar = acf.media.frame.content.get().toolbar;
|
258 |
+
filters = toolbar.get('filters');
|
259 |
+
}
|
260 |
+
catch(e)
|
261 |
+
{
|
262 |
+
// one of the objects was 'undefined'... perhaps the frame open is Upload Files
|
263 |
+
//console.log( e );
|
264 |
+
}
|
265 |
+
|
266 |
+
|
267 |
+
// validate
|
268 |
+
if( !filters )
|
269 |
+
{
|
270 |
+
return false;
|
271 |
+
}
|
272 |
+
|
273 |
+
|
274 |
+
// no need for 'uploaded' filter
|
275 |
+
if( t.o.library == 'uploadedTo' )
|
276 |
+
{
|
277 |
+
filters.$el.find('option[value="uploaded"]').remove();
|
278 |
+
filters.$el.after('<span>' + acf.l10n.file.uploadedTo + '</span>')
|
279 |
+
|
280 |
+
$.each( filters.filters, function( k, v ){
|
281 |
+
|
282 |
+
v.props.uploadedTo = acf.o.post_id;
|
283 |
+
|
284 |
+
});
|
285 |
+
}
|
286 |
+
|
287 |
+
});
|
288 |
+
|
289 |
+
|
290 |
+
// When an image is selected, run a callback.
|
291 |
+
acf.media.frame.on( 'select', function() {
|
292 |
+
|
293 |
+
// get selected images
|
294 |
+
selection = _media.frame.state().get('selection');
|
295 |
+
|
296 |
+
if( selection )
|
297 |
+
{
|
298 |
+
var i = 0;
|
299 |
+
|
300 |
+
selection.each(function(attachment){
|
301 |
+
|
302 |
+
// counter
|
303 |
+
i++;
|
304 |
+
|
305 |
+
|
306 |
+
// select / add another file field?
|
307 |
+
if( i > 1 )
|
308 |
+
{
|
309 |
+
// vars
|
310 |
+
var $td = _media.div.closest('td'),
|
311 |
+
$tr = $td.closest('.row'),
|
312 |
+
$repeater = $tr.closest('.repeater'),
|
313 |
+
key = $td.attr('data-field_key'),
|
314 |
+
selector = 'td .acf-file-uploader:first';
|
315 |
+
|
316 |
+
|
317 |
+
// key only exists for repeater v1.0.1 +
|
318 |
+
if( key )
|
319 |
+
{
|
320 |
+
selector = 'td[data-field_key="' + key + '"] .acf-file-uploader';
|
321 |
+
}
|
322 |
+
|
323 |
+
|
324 |
+
// add row?
|
325 |
+
if( ! $tr.next('.row').exists() )
|
326 |
+
{
|
327 |
+
$repeater.find('.add-row-end').trigger('click');
|
328 |
+
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
// update current div
|
333 |
+
_media.div = $tr.next('.row').find( selector );
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
|
338 |
+
// vars
|
339 |
+
var file = {
|
340 |
+
id : attachment.id,
|
341 |
+
title : attachment.attributes.title,
|
342 |
+
name : attachment.attributes.filename,
|
343 |
+
url : attachment.attributes.url,
|
344 |
+
icon : attachment.attributes.icon,
|
345 |
+
size : attachment.attributes.filesize
|
346 |
+
};
|
347 |
+
|
348 |
+
|
349 |
+
// add file to field
|
350 |
+
acf.fields.file.add( file );
|
351 |
+
|
352 |
+
|
353 |
+
});
|
354 |
+
// selection.each(function(attachment){
|
355 |
+
}
|
356 |
+
// if( selection )
|
357 |
+
|
358 |
+
});
|
359 |
+
// acf.media.frame.on( 'select', function() {
|
360 |
+
|
361 |
+
|
362 |
+
// Finally, open the modal
|
363 |
+
acf.media.frame.open();
|
364 |
+
|
365 |
+
|
366 |
+
return false;
|
367 |
+
}
|
368 |
+
|
369 |
+
};
|
370 |
+
|
371 |
+
|
372 |
+
/*
|
373 |
+
* Events
|
374 |
+
*
|
375 |
+
* jQuery events for this field
|
376 |
+
*
|
377 |
+
* @type function
|
378 |
+
* @date 1/03/2011
|
379 |
+
*
|
380 |
+
* @param N/A
|
381 |
+
* @return N/A
|
382 |
+
*/
|
383 |
+
|
384 |
+
$(document).on('click', '.acf-file-uploader .acf-button-edit', function( e ){
|
385 |
+
|
386 |
+
e.preventDefault();
|
387 |
+
|
388 |
+
acf.fields.file.set({ $el : $(this).closest('.acf-file-uploader') }).edit();
|
389 |
+
|
390 |
+
});
|
391 |
+
|
392 |
+
$(document).on('click', '.acf-file-uploader .acf-button-delete', function( e ){
|
393 |
+
|
394 |
+
e.preventDefault();
|
395 |
+
|
396 |
+
acf.fields.file.set({ $el : $(this).closest('.acf-file-uploader') }).remove();
|
397 |
+
|
398 |
+
});
|
399 |
+
|
400 |
+
|
401 |
+
$(document).on('click', '.acf-file-uploader .add-file', function( e ){
|
402 |
+
|
403 |
+
e.preventDefault();
|
404 |
+
|
405 |
+
acf.fields.file.set({ $el : $(this).closest('.acf-file-uploader') }).popup();
|
406 |
+
|
407 |
+
});
|
408 |
+
|
409 |
+
|
410 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/google-map.js
ADDED
@@ -0,0 +1,566 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Location
|
5 |
+
*
|
6 |
+
* static model for this field
|
7 |
+
*
|
8 |
+
* @type event
|
9 |
+
* @date 1/06/13
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
acf.fields.google_map = {
|
14 |
+
|
15 |
+
$el : null,
|
16 |
+
$input : null,
|
17 |
+
|
18 |
+
o : {},
|
19 |
+
api: {
|
20 |
+
sensor: false,
|
21 |
+
libraries: 'places'
|
22 |
+
},
|
23 |
+
|
24 |
+
ready : false,
|
25 |
+
geocoder : false,
|
26 |
+
map : false,
|
27 |
+
maps : {},
|
28 |
+
|
29 |
+
set : function( o ){
|
30 |
+
|
31 |
+
// merge in new option
|
32 |
+
$.extend( this, o );
|
33 |
+
|
34 |
+
|
35 |
+
// find input
|
36 |
+
this.$input = this.$el.find('.input-address');
|
37 |
+
|
38 |
+
|
39 |
+
// get options
|
40 |
+
this.o = acf.helpers.get_atts( this.$el );
|
41 |
+
|
42 |
+
|
43 |
+
// get map
|
44 |
+
if( this.maps[ this.o.id ] )
|
45 |
+
{
|
46 |
+
this.map = this.maps[ this.o.id ];
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
// return this for chaining
|
51 |
+
return this;
|
52 |
+
|
53 |
+
},
|
54 |
+
init : function(){
|
55 |
+
|
56 |
+
// geocode
|
57 |
+
if( !this.geocoder )
|
58 |
+
{
|
59 |
+
this.geocoder = new google.maps.Geocoder();
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
// google maps is loaded and ready
|
64 |
+
this.ready = true;
|
65 |
+
|
66 |
+
|
67 |
+
// is clone field?
|
68 |
+
if( acf.helpers.is_clone_field(this.$input) )
|
69 |
+
{
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
this.render();
|
74 |
+
|
75 |
+
},
|
76 |
+
render : function(){
|
77 |
+
|
78 |
+
// reference
|
79 |
+
var _this = this,
|
80 |
+
_$el = this.$el;
|
81 |
+
|
82 |
+
|
83 |
+
// vars
|
84 |
+
var args = {
|
85 |
+
zoom : parseInt(this.o.zoom),
|
86 |
+
center : new google.maps.LatLng(this.o.lat, this.o.lng),
|
87 |
+
mapTypeId : google.maps.MapTypeId.ROADMAP
|
88 |
+
};
|
89 |
+
|
90 |
+
// create map
|
91 |
+
this.map = new google.maps.Map( this.$el.find('.canvas')[0], args);
|
92 |
+
|
93 |
+
|
94 |
+
// add search
|
95 |
+
var autocomplete = new google.maps.places.Autocomplete( this.$el.find('.search')[0] );
|
96 |
+
autocomplete.map = this.map;
|
97 |
+
autocomplete.bindTo('bounds', this.map);
|
98 |
+
|
99 |
+
|
100 |
+
// add dummy marker
|
101 |
+
this.map.marker = new google.maps.Marker({
|
102 |
+
draggable : true,
|
103 |
+
raiseOnDrag : true,
|
104 |
+
map : this.map,
|
105 |
+
});
|
106 |
+
|
107 |
+
|
108 |
+
// add references
|
109 |
+
this.map.$el = this.$el;
|
110 |
+
|
111 |
+
|
112 |
+
// value exists?
|
113 |
+
var lat = this.$el.find('.input-lat').val(),
|
114 |
+
lng = this.$el.find('.input-lng').val();
|
115 |
+
|
116 |
+
if( lat && lng )
|
117 |
+
{
|
118 |
+
this.update( lat, lng ).center();
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
// events
|
123 |
+
google.maps.event.addListener(autocomplete, 'place_changed', function( e ) {
|
124 |
+
|
125 |
+
// reference
|
126 |
+
var $el = this.map.$el;
|
127 |
+
|
128 |
+
|
129 |
+
// manually update address
|
130 |
+
var address = $el.find('.search').val();
|
131 |
+
$el.find('.input-address').val( address );
|
132 |
+
$el.find('.title h4').text( address );
|
133 |
+
|
134 |
+
|
135 |
+
// vars
|
136 |
+
var place = this.getPlace();
|
137 |
+
|
138 |
+
|
139 |
+
// validate
|
140 |
+
if( place.geometry )
|
141 |
+
{
|
142 |
+
var lat = place.geometry.location.lat(),
|
143 |
+
lng = place.geometry.location.lng();
|
144 |
+
|
145 |
+
|
146 |
+
_this.set({ $el : $el }).update( lat, lng ).center();
|
147 |
+
}
|
148 |
+
else
|
149 |
+
{
|
150 |
+
// client hit enter, manulaly get the place
|
151 |
+
_this.geocoder.geocode({ 'address' : address }, function( results, status ){
|
152 |
+
|
153 |
+
// validate
|
154 |
+
if( status != google.maps.GeocoderStatus.OK )
|
155 |
+
{
|
156 |
+
console.log('Geocoder failed due to: ' + status);
|
157 |
+
return;
|
158 |
+
}
|
159 |
+
|
160 |
+
if( !results[0] )
|
161 |
+
{
|
162 |
+
console.log('No results found');
|
163 |
+
return;
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
// get place
|
168 |
+
place = results[0];
|
169 |
+
|
170 |
+
var lat = place.geometry.location.lat(),
|
171 |
+
lng = place.geometry.location.lng();
|
172 |
+
|
173 |
+
|
174 |
+
_this.set({ $el : $el }).update( lat, lng ).center();
|
175 |
+
|
176 |
+
});
|
177 |
+
}
|
178 |
+
|
179 |
+
});
|
180 |
+
|
181 |
+
|
182 |
+
google.maps.event.addListener( this.map.marker, 'dragend', function(){
|
183 |
+
|
184 |
+
// reference
|
185 |
+
var $el = this.map.$el;
|
186 |
+
|
187 |
+
|
188 |
+
// vars
|
189 |
+
var position = this.map.marker.getPosition(),
|
190 |
+
lat = position.lat(),
|
191 |
+
lng = position.lng();
|
192 |
+
|
193 |
+
_this.set({ $el : $el }).update( lat, lng ).sync();
|
194 |
+
|
195 |
+
});
|
196 |
+
|
197 |
+
|
198 |
+
google.maps.event.addListener( this.map, 'click', function( e ) {
|
199 |
+
|
200 |
+
// reference
|
201 |
+
var $el = this.$el;
|
202 |
+
|
203 |
+
|
204 |
+
// vars
|
205 |
+
var lat = e.latLng.lat(),
|
206 |
+
lng = e.latLng.lng();
|
207 |
+
|
208 |
+
|
209 |
+
_this.set({ $el : $el }).update( lat, lng ).sync();
|
210 |
+
|
211 |
+
});
|
212 |
+
|
213 |
+
|
214 |
+
|
215 |
+
// add to maps
|
216 |
+
this.maps[ this.o.id ] = this.map;
|
217 |
+
|
218 |
+
|
219 |
+
},
|
220 |
+
|
221 |
+
update : function( lat, lng ){
|
222 |
+
|
223 |
+
// vars
|
224 |
+
var latlng = new google.maps.LatLng( lat, lng );
|
225 |
+
|
226 |
+
|
227 |
+
// update inputs
|
228 |
+
this.$el.find('.input-lat').val( lat );
|
229 |
+
this.$el.find('.input-lng').val( lng ).trigger('change');
|
230 |
+
|
231 |
+
|
232 |
+
// update marker
|
233 |
+
this.map.marker.setPosition( latlng );
|
234 |
+
|
235 |
+
|
236 |
+
// show marker
|
237 |
+
this.map.marker.setVisible( true );
|
238 |
+
|
239 |
+
|
240 |
+
// update class
|
241 |
+
this.$el.addClass('active');
|
242 |
+
|
243 |
+
|
244 |
+
// validation
|
245 |
+
this.$el.closest('.field').removeClass('error');
|
246 |
+
|
247 |
+
|
248 |
+
// return for chaining
|
249 |
+
return this;
|
250 |
+
},
|
251 |
+
|
252 |
+
center : function(){
|
253 |
+
|
254 |
+
// vars
|
255 |
+
var position = this.map.marker.getPosition(),
|
256 |
+
lat = this.o.lat,
|
257 |
+
lng = this.o.lng;
|
258 |
+
|
259 |
+
|
260 |
+
// if marker exists, center on the marker
|
261 |
+
if( position )
|
262 |
+
{
|
263 |
+
lat = position.lat();
|
264 |
+
lng = position.lng();
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
+
var latlng = new google.maps.LatLng( lat, lng );
|
269 |
+
|
270 |
+
|
271 |
+
// set center of map
|
272 |
+
this.map.setCenter( latlng );
|
273 |
+
},
|
274 |
+
|
275 |
+
sync : function(){
|
276 |
+
|
277 |
+
// reference
|
278 |
+
var $el = this.$el;
|
279 |
+
|
280 |
+
|
281 |
+
// vars
|
282 |
+
var position = this.map.marker.getPosition(),
|
283 |
+
latlng = new google.maps.LatLng( position.lat(), position.lng() );
|
284 |
+
|
285 |
+
|
286 |
+
this.geocoder.geocode({ 'latLng' : latlng }, function( results, status ){
|
287 |
+
|
288 |
+
// validate
|
289 |
+
if( status != google.maps.GeocoderStatus.OK )
|
290 |
+
{
|
291 |
+
console.log('Geocoder failed due to: ' + status);
|
292 |
+
return;
|
293 |
+
}
|
294 |
+
|
295 |
+
if( !results[0] )
|
296 |
+
{
|
297 |
+
console.log('No results found');
|
298 |
+
return;
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
// get location
|
303 |
+
var location = results[0];
|
304 |
+
|
305 |
+
|
306 |
+
// update h4
|
307 |
+
$el.find('.title h4').text( location.formatted_address );
|
308 |
+
|
309 |
+
|
310 |
+
// update input
|
311 |
+
$el.find('.input-address').val( location.formatted_address ).trigger('change');
|
312 |
+
|
313 |
+
});
|
314 |
+
|
315 |
+
|
316 |
+
// return for chaining
|
317 |
+
return this;
|
318 |
+
},
|
319 |
+
|
320 |
+
locate : function(){
|
321 |
+
|
322 |
+
// reference
|
323 |
+
var _this = this,
|
324 |
+
_$el = this.$el;
|
325 |
+
|
326 |
+
|
327 |
+
// Try HTML5 geolocation
|
328 |
+
if( ! navigator.geolocation )
|
329 |
+
{
|
330 |
+
alert( acf.l10n.google_map.browser_support );
|
331 |
+
return this;
|
332 |
+
}
|
333 |
+
|
334 |
+
|
335 |
+
// show loading text
|
336 |
+
_$el.find('.title h4').text(acf.l10n.google_map.locating + '...');
|
337 |
+
_$el.addClass('active');
|
338 |
+
|
339 |
+
navigator.geolocation.getCurrentPosition(function(position){
|
340 |
+
|
341 |
+
// vars
|
342 |
+
var lat = position.coords.latitude,
|
343 |
+
lng = position.coords.longitude;
|
344 |
+
|
345 |
+
_this.set({ $el : _$el }).update( lat, lng ).sync().center();
|
346 |
+
|
347 |
+
});
|
348 |
+
|
349 |
+
|
350 |
+
},
|
351 |
+
|
352 |
+
clear : function(){
|
353 |
+
|
354 |
+
// update class
|
355 |
+
this.$el.removeClass('active');
|
356 |
+
|
357 |
+
|
358 |
+
// clear search
|
359 |
+
this.$el.find('.search').val('');
|
360 |
+
|
361 |
+
|
362 |
+
// clear inputs
|
363 |
+
this.$el.find('.input-address').val('');
|
364 |
+
this.$el.find('.input-lat').val('');
|
365 |
+
this.$el.find('.input-lng').val('');
|
366 |
+
|
367 |
+
|
368 |
+
// hide marker
|
369 |
+
this.map.marker.setVisible( false );
|
370 |
+
},
|
371 |
+
|
372 |
+
edit : function(){
|
373 |
+
|
374 |
+
// update class
|
375 |
+
this.$el.removeClass('active');
|
376 |
+
|
377 |
+
|
378 |
+
// clear search
|
379 |
+
var val = this.$el.find('.title h4').text();
|
380 |
+
|
381 |
+
|
382 |
+
this.$el.find('.search').val( val ).focus();
|
383 |
+
|
384 |
+
},
|
385 |
+
|
386 |
+
refresh : function(){
|
387 |
+
|
388 |
+
// trigger resize on div
|
389 |
+
google.maps.event.trigger(this.map, 'resize');
|
390 |
+
|
391 |
+
// center map
|
392 |
+
this.center();
|
393 |
+
|
394 |
+
}
|
395 |
+
|
396 |
+
};
|
397 |
+
|
398 |
+
|
399 |
+
/*
|
400 |
+
* acf/setup_fields
|
401 |
+
*
|
402 |
+
* run init function on all elements for this field
|
403 |
+
*
|
404 |
+
* @type event
|
405 |
+
* @date 20/07/13
|
406 |
+
*
|
407 |
+
* @param {object} e event object
|
408 |
+
* @param {object} el DOM object which may contain new ACF elements
|
409 |
+
* @return N/A
|
410 |
+
*/
|
411 |
+
|
412 |
+
$(document).on('acf/setup_fields', function(e, el){
|
413 |
+
|
414 |
+
// reference
|
415 |
+
var self = acf.fields.google_map;
|
416 |
+
|
417 |
+
|
418 |
+
// vars
|
419 |
+
var $fields = $(el).find('.acf-google-map');
|
420 |
+
|
421 |
+
|
422 |
+
// validate
|
423 |
+
if( ! $fields.exists() ) return false;
|
424 |
+
|
425 |
+
|
426 |
+
// no google
|
427 |
+
if( !acf.helpers.isset(window, 'google', 'load') ) {
|
428 |
+
|
429 |
+
// load API
|
430 |
+
$.getScript('https://www.google.com/jsapi', function(){
|
431 |
+
|
432 |
+
// load maps
|
433 |
+
google.load('maps', '3', { other_params: $.param(self.api), callback: function(){
|
434 |
+
|
435 |
+
$fields.each(function(){
|
436 |
+
|
437 |
+
acf.fields.google_map.set({ $el : $(this) }).init();
|
438 |
+
|
439 |
+
});
|
440 |
+
|
441 |
+
}});
|
442 |
+
|
443 |
+
});
|
444 |
+
|
445 |
+
return false;
|
446 |
+
|
447 |
+
}
|
448 |
+
|
449 |
+
|
450 |
+
// no maps or places
|
451 |
+
if( !acf.helpers.isset(window, 'google', 'maps', 'places') ) {
|
452 |
+
|
453 |
+
google.load('maps', '3', { other_params: $.param(self.api), callback: function(){
|
454 |
+
|
455 |
+
$fields.each(function(){
|
456 |
+
|
457 |
+
acf.fields.google_map.set({ $el : $(this) }).init();
|
458 |
+
|
459 |
+
});
|
460 |
+
|
461 |
+
}});
|
462 |
+
|
463 |
+
return false;
|
464 |
+
|
465 |
+
}
|
466 |
+
|
467 |
+
|
468 |
+
// google exists
|
469 |
+
$fields.each(function(){
|
470 |
+
|
471 |
+
acf.fields.google_map.set({ $el : $(this) }).init();
|
472 |
+
|
473 |
+
});
|
474 |
+
|
475 |
+
|
476 |
+
// return
|
477 |
+
return true;
|
478 |
+
|
479 |
+
});
|
480 |
+
|
481 |
+
|
482 |
+
/*
|
483 |
+
* Events
|
484 |
+
*
|
485 |
+
* jQuery events for this field
|
486 |
+
*
|
487 |
+
* @type function
|
488 |
+
* @date 1/03/2011
|
489 |
+
*
|
490 |
+
* @param N/A
|
491 |
+
* @return N/A
|
492 |
+
*/
|
493 |
+
|
494 |
+
$(document).on('click', '.acf-google-map .acf-sprite-remove', function( e ){
|
495 |
+
|
496 |
+
e.preventDefault();
|
497 |
+
|
498 |
+
acf.fields.google_map.set({ $el : $(this).closest('.acf-google-map') }).clear();
|
499 |
+
|
500 |
+
$(this).blur();
|
501 |
+
|
502 |
+
});
|
503 |
+
|
504 |
+
|
505 |
+
$(document).on('click', '.acf-google-map .acf-sprite-locate', function( e ){
|
506 |
+
|
507 |
+
e.preventDefault();
|
508 |
+
|
509 |
+
acf.fields.google_map.set({ $el : $(this).closest('.acf-google-map') }).locate();
|
510 |
+
|
511 |
+
$(this).blur();
|
512 |
+
|
513 |
+
});
|
514 |
+
|
515 |
+
$(document).on('click', '.acf-google-map .title h4', function( e ){
|
516 |
+
|
517 |
+
e.preventDefault();
|
518 |
+
|
519 |
+
acf.fields.google_map.set({ $el : $(this).closest('.acf-google-map') }).edit();
|
520 |
+
|
521 |
+
});
|
522 |
+
|
523 |
+
$(document).on('keydown', '.acf-google-map .search', function( e ){
|
524 |
+
|
525 |
+
// prevent form from submitting
|
526 |
+
if( e.which == 13 )
|
527 |
+
{
|
528 |
+
return false;
|
529 |
+
}
|
530 |
+
|
531 |
+
});
|
532 |
+
|
533 |
+
$(document).on('blur', '.acf-google-map .search', function( e ){
|
534 |
+
|
535 |
+
// vars
|
536 |
+
var $el = $(this).closest('.acf-google-map');
|
537 |
+
|
538 |
+
|
539 |
+
// has a value?
|
540 |
+
if( $el.find('.input-lat').val() )
|
541 |
+
{
|
542 |
+
$el.addClass('active');
|
543 |
+
}
|
544 |
+
|
545 |
+
});
|
546 |
+
|
547 |
+
$(document).on('acf/fields/tab/show acf/conditional_logic/show', function( e, $field ){
|
548 |
+
|
549 |
+
// validate
|
550 |
+
if( ! acf.fields.google_map.ready )
|
551 |
+
{
|
552 |
+
return;
|
553 |
+
}
|
554 |
+
|
555 |
+
|
556 |
+
// validate
|
557 |
+
if( $field.attr('data-field_type') == 'google_map' )
|
558 |
+
{
|
559 |
+
acf.fields.google_map.set({ $el : $field.find('.acf-google-map') }).refresh();
|
560 |
+
}
|
561 |
+
|
562 |
+
});
|
563 |
+
|
564 |
+
|
565 |
+
|
566 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/image.js
ADDED
@@ -0,0 +1,447 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Image
|
5 |
+
*
|
6 |
+
* static model for this field
|
7 |
+
*
|
8 |
+
* @type event
|
9 |
+
* @date 1/06/13
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
// reference
|
15 |
+
var _media = acf.media;
|
16 |
+
|
17 |
+
|
18 |
+
acf.fields.image = {
|
19 |
+
|
20 |
+
$el : null,
|
21 |
+
$input : null,
|
22 |
+
|
23 |
+
o : {},
|
24 |
+
|
25 |
+
set : function( o ){
|
26 |
+
|
27 |
+
// merge in new option
|
28 |
+
$.extend( this, o );
|
29 |
+
|
30 |
+
|
31 |
+
// find input
|
32 |
+
this.$input = this.$el.find('input[type="hidden"]');
|
33 |
+
|
34 |
+
|
35 |
+
// get options
|
36 |
+
this.o = acf.helpers.get_atts( this.$el );
|
37 |
+
|
38 |
+
|
39 |
+
// multiple?
|
40 |
+
this.o.multiple = this.$el.closest('.repeater').exists() ? true : false;
|
41 |
+
|
42 |
+
|
43 |
+
// wp library query
|
44 |
+
this.o.query = {
|
45 |
+
type : 'image'
|
46 |
+
};
|
47 |
+
|
48 |
+
|
49 |
+
// library
|
50 |
+
if( this.o.library == 'uploadedTo' )
|
51 |
+
{
|
52 |
+
this.o.query.uploadedTo = acf.o.post_id;
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
// return this for chaining
|
57 |
+
return this;
|
58 |
+
|
59 |
+
},
|
60 |
+
init : function(){
|
61 |
+
|
62 |
+
// is clone field?
|
63 |
+
if( acf.helpers.is_clone_field(this.$input) )
|
64 |
+
{
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
},
|
69 |
+
add : function( image ){
|
70 |
+
|
71 |
+
// this function must reference a global div variable due to the pre WP 3.5 uploader
|
72 |
+
// vars
|
73 |
+
var div = _media.div;
|
74 |
+
|
75 |
+
|
76 |
+
// set atts
|
77 |
+
div.find('.acf-image-image').attr( 'src', image.url );
|
78 |
+
div.find('.acf-image-value').val( image.id ).trigger('change');
|
79 |
+
|
80 |
+
|
81 |
+
// set div class
|
82 |
+
div.addClass('active');
|
83 |
+
|
84 |
+
|
85 |
+
// validation
|
86 |
+
div.closest('.field').removeClass('error');
|
87 |
+
|
88 |
+
},
|
89 |
+
|
90 |
+
new_frame: function( attributes ){
|
91 |
+
|
92 |
+
// set global var
|
93 |
+
_media.div = this.$el;
|
94 |
+
|
95 |
+
|
96 |
+
// clear the frame
|
97 |
+
_media.clear_frame();
|
98 |
+
|
99 |
+
|
100 |
+
// vars
|
101 |
+
attributes.states = [];
|
102 |
+
|
103 |
+
|
104 |
+
// append states
|
105 |
+
attributes.states.push(
|
106 |
+
new wp.media.controller.Library({
|
107 |
+
library : wp.media.query( this.o.query ),
|
108 |
+
multiple : attributes.multiple,
|
109 |
+
title : attributes.title,
|
110 |
+
priority : 20,
|
111 |
+
filterable : 'all'
|
112 |
+
})
|
113 |
+
);
|
114 |
+
|
115 |
+
|
116 |
+
// edit image functionality (added in WP 3.9)
|
117 |
+
if( acf.helpers.isset(wp, 'media', 'controller', 'EditImage') ) {
|
118 |
+
|
119 |
+
attributes.states.push( new wp.media.controller.EditImage() );
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
// Create the media frame
|
125 |
+
_media.frame = wp.media( attributes );
|
126 |
+
|
127 |
+
|
128 |
+
// edit image view
|
129 |
+
// source: media-views.js:2410 editImageContent()
|
130 |
+
_media.frame.on('content:render:edit-image', function(){
|
131 |
+
|
132 |
+
var image = this.state().get('image'),
|
133 |
+
view = new wp.media.view.EditImage( { model: image, controller: this } ).render();
|
134 |
+
|
135 |
+
this.content.set( view );
|
136 |
+
|
137 |
+
// after creating the wrapper view, load the actual editor via an ajax call
|
138 |
+
view.loadEditor();
|
139 |
+
|
140 |
+
}, _media.frame);
|
141 |
+
|
142 |
+
|
143 |
+
// update toolbar button
|
144 |
+
_media.frame.on( 'toolbar:create:select', function( toolbar ) {
|
145 |
+
|
146 |
+
toolbar.view = new wp.media.view.Toolbar.Select({
|
147 |
+
text: attributes.button.text,
|
148 |
+
controller: this
|
149 |
+
});
|
150 |
+
|
151 |
+
}, _media.frame );
|
152 |
+
|
153 |
+
|
154 |
+
// return
|
155 |
+
return _media.frame;
|
156 |
+
|
157 |
+
},
|
158 |
+
|
159 |
+
edit : function(){
|
160 |
+
|
161 |
+
// vars
|
162 |
+
var id = this.$input.val();
|
163 |
+
|
164 |
+
|
165 |
+
// create frame
|
166 |
+
this.new_frame({
|
167 |
+
title : acf.l10n.image.edit,
|
168 |
+
multiple : false,
|
169 |
+
button : { text : acf.l10n.image.update }
|
170 |
+
});
|
171 |
+
|
172 |
+
|
173 |
+
// open
|
174 |
+
_media.frame.on('open',function() {
|
175 |
+
|
176 |
+
// set to browse
|
177 |
+
if( _media.frame.content._mode != 'browse' )
|
178 |
+
{
|
179 |
+
_media.frame.content.mode('browse');
|
180 |
+
}
|
181 |
+
|
182 |
+
|
183 |
+
// add class
|
184 |
+
_media.frame.$el.closest('.media-modal').addClass('acf-media-modal acf-expanded');
|
185 |
+
|
186 |
+
|
187 |
+
// set selection
|
188 |
+
var selection = _media.frame.state().get('selection'),
|
189 |
+
attachment = wp.media.attachment( id );
|
190 |
+
|
191 |
+
|
192 |
+
// to fetch or not to fetch
|
193 |
+
if( $.isEmptyObject(attachment.changed) )
|
194 |
+
{
|
195 |
+
attachment.fetch();
|
196 |
+
}
|
197 |
+
|
198 |
+
|
199 |
+
selection.add( attachment );
|
200 |
+
|
201 |
+
});
|
202 |
+
|
203 |
+
|
204 |
+
// close
|
205 |
+
_media.frame.on('close',function(){
|
206 |
+
|
207 |
+
// remove class
|
208 |
+
_media.frame.$el.closest('.media-modal').removeClass('acf-media-modal');
|
209 |
+
|
210 |
+
});
|
211 |
+
|
212 |
+
|
213 |
+
// Finally, open the modal
|
214 |
+
_media.frame.open();
|
215 |
+
|
216 |
+
},
|
217 |
+
remove : function()
|
218 |
+
{
|
219 |
+
|
220 |
+
// set atts
|
221 |
+
this.$el.find('.acf-image-image').attr( 'src', '' );
|
222 |
+
this.$el.find('.acf-image-value').val( '' ).trigger('change');
|
223 |
+
|
224 |
+
|
225 |
+
// remove class
|
226 |
+
this.$el.removeClass('active');
|
227 |
+
|
228 |
+
},
|
229 |
+
popup : function()
|
230 |
+
{
|
231 |
+
// reference
|
232 |
+
var t = this;
|
233 |
+
|
234 |
+
|
235 |
+
// create frame
|
236 |
+
this.new_frame({
|
237 |
+
title : acf.l10n.image.select,
|
238 |
+
multiple : t.o.multiple,
|
239 |
+
button : { text : acf.l10n.image.select }
|
240 |
+
});
|
241 |
+
|
242 |
+
|
243 |
+
// customize model / view
|
244 |
+
_media.frame.on('content:activate', function(){
|
245 |
+
|
246 |
+
// vars
|
247 |
+
var toolbar = null,
|
248 |
+
filters = null;
|
249 |
+
|
250 |
+
|
251 |
+
// populate above vars making sure to allow for failure
|
252 |
+
try
|
253 |
+
{
|
254 |
+
toolbar = acf.media.frame.content.get().toolbar;
|
255 |
+
filters = toolbar.get('filters');
|
256 |
+
}
|
257 |
+
catch(e)
|
258 |
+
{
|
259 |
+
// one of the objects was 'undefined'... perhaps the frame open is Upload Files
|
260 |
+
//console.log( e );
|
261 |
+
}
|
262 |
+
|
263 |
+
|
264 |
+
// validate
|
265 |
+
if( !filters )
|
266 |
+
{
|
267 |
+
return false;
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
// filter only images
|
272 |
+
$.each( filters.filters, function( k, v ){
|
273 |
+
|
274 |
+
v.props.type = 'image';
|
275 |
+
|
276 |
+
});
|
277 |
+
|
278 |
+
|
279 |
+
// no need for 'uploaded' filter
|
280 |
+
if( t.o.library == 'uploadedTo' )
|
281 |
+
{
|
282 |
+
filters.$el.find('option[value="uploaded"]').remove();
|
283 |
+
filters.$el.after('<span>' + acf.l10n.image.uploadedTo + '</span>')
|
284 |
+
|
285 |
+
$.each( filters.filters, function( k, v ){
|
286 |
+
|
287 |
+
v.props.uploadedTo = acf.o.post_id;
|
288 |
+
|
289 |
+
});
|
290 |
+
}
|
291 |
+
|
292 |
+
|
293 |
+
// remove non image options from filter list
|
294 |
+
filters.$el.find('option').each(function(){
|
295 |
+
|
296 |
+
// vars
|
297 |
+
var v = $(this).attr('value');
|
298 |
+
|
299 |
+
|
300 |
+
// don't remove the 'uploadedTo' if the library option is 'all'
|
301 |
+
if( v == 'uploaded' && t.o.library == 'all' )
|
302 |
+
{
|
303 |
+
return;
|
304 |
+
}
|
305 |
+
|
306 |
+
if( v.indexOf('image') === -1 )
|
307 |
+
{
|
308 |
+
$(this).remove();
|
309 |
+
}
|
310 |
+
|
311 |
+
});
|
312 |
+
|
313 |
+
|
314 |
+
// set default filter
|
315 |
+
filters.$el.val('image').trigger('change');
|
316 |
+
|
317 |
+
});
|
318 |
+
|
319 |
+
|
320 |
+
// When an image is selected, run a callback.
|
321 |
+
acf.media.frame.on( 'select', function() {
|
322 |
+
|
323 |
+
// get selected images
|
324 |
+
selection = _media.frame.state().get('selection');
|
325 |
+
|
326 |
+
if( selection )
|
327 |
+
{
|
328 |
+
var i = 0;
|
329 |
+
|
330 |
+
selection.each(function(attachment){
|
331 |
+
|
332 |
+
// counter
|
333 |
+
i++;
|
334 |
+
|
335 |
+
|
336 |
+
// select / add another image field?
|
337 |
+
if( i > 1 )
|
338 |
+
{
|
339 |
+
// vars
|
340 |
+
var $td = _media.div.closest('td'),
|
341 |
+
$tr = $td.closest('.row'),
|
342 |
+
$repeater = $tr.closest('.repeater'),
|
343 |
+
key = $td.attr('data-field_key'),
|
344 |
+
selector = 'td .acf-image-uploader:first';
|
345 |
+
|
346 |
+
|
347 |
+
// key only exists for repeater v1.0.1 +
|
348 |
+
if( key )
|
349 |
+
{
|
350 |
+
selector = 'td[data-field_key="' + key + '"] .acf-image-uploader';
|
351 |
+
}
|
352 |
+
|
353 |
+
|
354 |
+
// add row?
|
355 |
+
if( ! $tr.next('.row').exists() )
|
356 |
+
{
|
357 |
+
$repeater.find('.add-row-end').trigger('click');
|
358 |
+
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
+
// update current div
|
363 |
+
_media.div = $tr.next('.row').find( selector );
|
364 |
+
|
365 |
+
}
|
366 |
+
|
367 |
+
|
368 |
+
// vars
|
369 |
+
var image = {
|
370 |
+
id : attachment.id,
|
371 |
+
url : attachment.attributes.url
|
372 |
+
};
|
373 |
+
|
374 |
+
// is preview size available?
|
375 |
+
if( attachment.attributes.sizes && attachment.attributes.sizes[ t.o.preview_size ] )
|
376 |
+
{
|
377 |
+
image.url = attachment.attributes.sizes[ t.o.preview_size ].url;
|
378 |
+
}
|
379 |
+
|
380 |
+
// add image to field
|
381 |
+
acf.fields.image.add( image );
|
382 |
+
|
383 |
+
|
384 |
+
});
|
385 |
+
// selection.each(function(attachment){
|
386 |
+
}
|
387 |
+
// if( selection )
|
388 |
+
|
389 |
+
});
|
390 |
+
// acf.media.frame.on( 'select', function() {
|
391 |
+
|
392 |
+
|
393 |
+
// Finally, open the modal
|
394 |
+
acf.media.frame.open();
|
395 |
+
|
396 |
+
|
397 |
+
return false;
|
398 |
+
},
|
399 |
+
|
400 |
+
// temporary gallery fix
|
401 |
+
text : {
|
402 |
+
title_add : "Select Image",
|
403 |
+
title_edit : "Edit Image"
|
404 |
+
}
|
405 |
+
|
406 |
+
};
|
407 |
+
|
408 |
+
|
409 |
+
/*
|
410 |
+
* Events
|
411 |
+
*
|
412 |
+
* jQuery events for this field
|
413 |
+
*
|
414 |
+
* @type function
|
415 |
+
* @date 1/03/2011
|
416 |
+
*
|
417 |
+
* @param N/A
|
418 |
+
* @return N/A
|
419 |
+
*/
|
420 |
+
|
421 |
+
$(document).on('click', '.acf-image-uploader .acf-button-edit', function( e ){
|
422 |
+
|
423 |
+
e.preventDefault();
|
424 |
+
|
425 |
+
acf.fields.image.set({ $el : $(this).closest('.acf-image-uploader') }).edit();
|
426 |
+
|
427 |
+
});
|
428 |
+
|
429 |
+
$(document).on('click', '.acf-image-uploader .acf-button-delete', function( e ){
|
430 |
+
|
431 |
+
e.preventDefault();
|
432 |
+
|
433 |
+
acf.fields.image.set({ $el : $(this).closest('.acf-image-uploader') }).remove();
|
434 |
+
|
435 |
+
});
|
436 |
+
|
437 |
+
|
438 |
+
$(document).on('click', '.acf-image-uploader .add-image', function( e ){
|
439 |
+
|
440 |
+
e.preventDefault();
|
441 |
+
|
442 |
+
acf.fields.image.set({ $el : $(this).closest('.acf-image-uploader') }).popup();
|
443 |
+
|
444 |
+
});
|
445 |
+
|
446 |
+
|
447 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/radio.js
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Radio
|
5 |
+
*
|
6 |
+
* static model and events for this field
|
7 |
+
*
|
8 |
+
* @type event
|
9 |
+
* @date 1/06/13
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
acf.fields.radio = {
|
14 |
+
|
15 |
+
$el : null,
|
16 |
+
$input : null,
|
17 |
+
$other : null,
|
18 |
+
farbtastic : null,
|
19 |
+
|
20 |
+
set : function( o ){
|
21 |
+
|
22 |
+
// merge in new option
|
23 |
+
$.extend( this, o );
|
24 |
+
|
25 |
+
|
26 |
+
// find input
|
27 |
+
this.$input = this.$el.find('input[type="radio"]:checked');
|
28 |
+
this.$other = this.$el.find('input[type="text"]');
|
29 |
+
|
30 |
+
|
31 |
+
// return this for chaining
|
32 |
+
return this;
|
33 |
+
|
34 |
+
},
|
35 |
+
change : function(){
|
36 |
+
|
37 |
+
if( this.$input.val() == 'other' )
|
38 |
+
{
|
39 |
+
this.$other.attr('name', this.$input.attr('name'));
|
40 |
+
this.$other.show();
|
41 |
+
}
|
42 |
+
else
|
43 |
+
{
|
44 |
+
this.$other.attr('name', '');
|
45 |
+
this.$other.hide();
|
46 |
+
}
|
47 |
+
}
|
48 |
+
};
|
49 |
+
|
50 |
+
|
51 |
+
/*
|
52 |
+
* Events
|
53 |
+
*
|
54 |
+
* jQuery events for this field
|
55 |
+
*
|
56 |
+
* @type function
|
57 |
+
* @date 1/03/2011
|
58 |
+
*
|
59 |
+
* @param N/A
|
60 |
+
* @return N/A
|
61 |
+
*/
|
62 |
+
|
63 |
+
$(document).on('change', '.acf-radio-list input[type="radio"]', function( e ){
|
64 |
+
|
65 |
+
acf.fields.radio.set({ $el : $(this).closest('.acf-radio-list') }).change();
|
66 |
+
|
67 |
+
});
|
68 |
+
|
69 |
+
|
70 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/relationship.js
ADDED
@@ -0,0 +1,361 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Relationship
|
5 |
+
*
|
6 |
+
* static model for this field
|
7 |
+
*
|
8 |
+
* @type event
|
9 |
+
* @date 1/06/13
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
acf.fields.relationship = {
|
14 |
+
|
15 |
+
$el : null,
|
16 |
+
$input : null,
|
17 |
+
$left : null,
|
18 |
+
$right : null,
|
19 |
+
|
20 |
+
o : {},
|
21 |
+
|
22 |
+
timeout : null,
|
23 |
+
|
24 |
+
set : function( o ){
|
25 |
+
|
26 |
+
// merge in new option
|
27 |
+
$.extend( this, o );
|
28 |
+
|
29 |
+
|
30 |
+
// find elements
|
31 |
+
this.$input = this.$el.children('input[type="hidden"]');
|
32 |
+
this.$left = this.$el.find('.relationship_left'),
|
33 |
+
this.$right = this.$el.find('.relationship_right');
|
34 |
+
|
35 |
+
|
36 |
+
// get options
|
37 |
+
this.o = acf.helpers.get_atts( this.$el );
|
38 |
+
|
39 |
+
|
40 |
+
// return this for chaining
|
41 |
+
return this;
|
42 |
+
|
43 |
+
},
|
44 |
+
init : function(){
|
45 |
+
|
46 |
+
// reference
|
47 |
+
var _this = this;
|
48 |
+
|
49 |
+
|
50 |
+
// is clone field?
|
51 |
+
if( acf.helpers.is_clone_field(this.$input) )
|
52 |
+
{
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
// set height of right column
|
58 |
+
this.$right.find('.relationship_list').height( this.$left.height() -2 );
|
59 |
+
|
60 |
+
|
61 |
+
// right sortable
|
62 |
+
this.$right.find('.relationship_list').sortable({
|
63 |
+
axis : 'y',
|
64 |
+
items : '> li',
|
65 |
+
forceHelperSize : true,
|
66 |
+
forcePlaceholderSize : true,
|
67 |
+
scroll : true,
|
68 |
+
update : function(){
|
69 |
+
|
70 |
+
_this.$input.trigger('change');
|
71 |
+
|
72 |
+
}
|
73 |
+
});
|
74 |
+
|
75 |
+
|
76 |
+
// load more
|
77 |
+
var $el = this.$el;
|
78 |
+
|
79 |
+
this.$left.find('.relationship_list').scrollTop( 0 ).on('scroll', function(e){
|
80 |
+
|
81 |
+
// validate
|
82 |
+
if( $el.hasClass('loading') || $el.hasClass('no-results') )
|
83 |
+
{
|
84 |
+
return;
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
// Scrolled to bottom
|
89 |
+
if( $(this).scrollTop() + $(this).innerHeight() >= $(this).get(0).scrollHeight )
|
90 |
+
{
|
91 |
+
var paged = parseInt( $el.attr('data-paged') );
|
92 |
+
|
93 |
+
// update paged
|
94 |
+
$el.attr('data-paged', (paged + 1) );
|
95 |
+
|
96 |
+
// fetch
|
97 |
+
_this.set({ $el : $el }).fetch();
|
98 |
+
}
|
99 |
+
|
100 |
+
});
|
101 |
+
|
102 |
+
|
103 |
+
// ajax fetch values for left side
|
104 |
+
this.fetch();
|
105 |
+
|
106 |
+
},
|
107 |
+
fetch : function(){
|
108 |
+
|
109 |
+
// reference
|
110 |
+
var _this = this,
|
111 |
+
$el = this.$el;
|
112 |
+
|
113 |
+
|
114 |
+
// add loading class, stops scroll loading
|
115 |
+
$el.addClass('loading');
|
116 |
+
|
117 |
+
|
118 |
+
// get results
|
119 |
+
$.ajax({
|
120 |
+
url : acf.o.ajaxurl,
|
121 |
+
type : 'post',
|
122 |
+
dataType : 'json',
|
123 |
+
data : $.extend({
|
124 |
+
action : 'acf/fields/relationship/query_posts',
|
125 |
+
post_id : acf.o.post_id,
|
126 |
+
nonce : acf.o.nonce
|
127 |
+
}, this.o ),
|
128 |
+
success : function( json ){
|
129 |
+
|
130 |
+
|
131 |
+
// render
|
132 |
+
_this.set({ $el : $el }).render( json );
|
133 |
+
|
134 |
+
}
|
135 |
+
});
|
136 |
+
|
137 |
+
},
|
138 |
+
render : function( json ){
|
139 |
+
|
140 |
+
// reference
|
141 |
+
var _this = this;
|
142 |
+
|
143 |
+
|
144 |
+
// update classes
|
145 |
+
this.$el.removeClass('no-results').removeClass('loading');
|
146 |
+
|
147 |
+
|
148 |
+
// new search?
|
149 |
+
if( this.o.paged == 1 )
|
150 |
+
{
|
151 |
+
this.$el.find('.relationship_left li:not(.load-more)').remove();
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
// no results?
|
156 |
+
if( ! json || ! json.html )
|
157 |
+
{
|
158 |
+
this.$el.addClass('no-results');
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
// append new results
|
164 |
+
this.$el.find('.relationship_left .load-more').before( json.html );
|
165 |
+
|
166 |
+
|
167 |
+
// next page?
|
168 |
+
if( ! json.next_page_exists )
|
169 |
+
{
|
170 |
+
this.$el.addClass('no-results');
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
+
// apply .hide to left li's
|
175 |
+
this.$left.find('a').each(function(){
|
176 |
+
|
177 |
+
var id = $(this).attr('data-post_id');
|
178 |
+
|
179 |
+
if( _this.$right.find('a[data-post_id="' + id + '"]').exists() )
|
180 |
+
{
|
181 |
+
$(this).parent().addClass('hide');
|
182 |
+
}
|
183 |
+
|
184 |
+
});
|
185 |
+
|
186 |
+
},
|
187 |
+
add : function( $a ){
|
188 |
+
|
189 |
+
// vars
|
190 |
+
var id = $a.attr('data-post_id'),
|
191 |
+
title = $a.html();
|
192 |
+
|
193 |
+
|
194 |
+
// max posts
|
195 |
+
if( this.$right.find('a').length >= this.o.max )
|
196 |
+
{
|
197 |
+
alert( acf.l10n.relationship.max.replace('{max}', this.o.max) );
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
// can be added?
|
203 |
+
if( $a.parent().hasClass('hide') )
|
204 |
+
{
|
205 |
+
return false;
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
// hide
|
210 |
+
$a.parent().addClass('hide');
|
211 |
+
|
212 |
+
|
213 |
+
// template
|
214 |
+
var html = [
|
215 |
+
'<li>',
|
216 |
+
'<a href="#" data-post_id="' + $a.attr('data-post_id') + '">',
|
217 |
+
$a.html() + '<span class="acf-button-remove"></span>',
|
218 |
+
'</a>',
|
219 |
+
'<input type="hidden" name="' + this.$input.attr('name') + '[]" value="' + $a.attr('data-post_id') + '" />',
|
220 |
+
'</li>'].join('');
|
221 |
+
|
222 |
+
|
223 |
+
// add new li
|
224 |
+
this.$right.find('.relationship_list').append( html )
|
225 |
+
|
226 |
+
|
227 |
+
// trigger change on new_li
|
228 |
+
this.$input.trigger('change');
|
229 |
+
|
230 |
+
|
231 |
+
// validation
|
232 |
+
this.$el.closest('.field').removeClass('error');
|
233 |
+
|
234 |
+
|
235 |
+
},
|
236 |
+
remove : function( $a ){
|
237 |
+
|
238 |
+
// remove
|
239 |
+
$a.parent().remove();
|
240 |
+
|
241 |
+
|
242 |
+
// show
|
243 |
+
this.$left.find('a[data-post_id="' + $a.attr('data-post_id') + '"]').parent('li').removeClass('hide');
|
244 |
+
|
245 |
+
|
246 |
+
// trigger change on new_li
|
247 |
+
this.$input.trigger('change');
|
248 |
+
|
249 |
+
}
|
250 |
+
|
251 |
+
};
|
252 |
+
|
253 |
+
|
254 |
+
/*
|
255 |
+
* acf/setup_fields
|
256 |
+
*
|
257 |
+
* run init function on all elements for this field
|
258 |
+
*
|
259 |
+
* @type event
|
260 |
+
* @date 20/07/13
|
261 |
+
*
|
262 |
+
* @param {object} e event object
|
263 |
+
* @param {object} el DOM object which may contain new ACF elements
|
264 |
+
* @return N/A
|
265 |
+
*/
|
266 |
+
|
267 |
+
$(document).on('acf/setup_fields', function(e, el){
|
268 |
+
|
269 |
+
$(el).find('.acf_relationship').each(function(){
|
270 |
+
|
271 |
+
acf.fields.relationship.set({ $el : $(this) }).init();
|
272 |
+
|
273 |
+
});
|
274 |
+
|
275 |
+
});
|
276 |
+
|
277 |
+
|
278 |
+
/*
|
279 |
+
* Events
|
280 |
+
*
|
281 |
+
* jQuery events for this field
|
282 |
+
*
|
283 |
+
* @type function
|
284 |
+
* @date 1/03/2011
|
285 |
+
*
|
286 |
+
* @param N/A
|
287 |
+
* @return N/A
|
288 |
+
*/
|
289 |
+
|
290 |
+
$(document).on('change', '.acf_relationship .select-post_type', function(e){
|
291 |
+
|
292 |
+
// vars
|
293 |
+
var val = $(this).val(),
|
294 |
+
$el = $(this).closest('.acf_relationship');
|
295 |
+
|
296 |
+
|
297 |
+
// update attr
|
298 |
+
$el.attr('data-post_type', val);
|
299 |
+
$el.attr('data-paged', 1);
|
300 |
+
|
301 |
+
|
302 |
+
// fetch
|
303 |
+
acf.fields.relationship.set({ $el : $el }).fetch();
|
304 |
+
|
305 |
+
});
|
306 |
+
|
307 |
+
|
308 |
+
$(document).on('click', '.acf_relationship .relationship_left .relationship_list a', function( e ){
|
309 |
+
|
310 |
+
e.preventDefault();
|
311 |
+
|
312 |
+
acf.fields.relationship.set({ $el : $(this).closest('.acf_relationship') }).add( $(this) );
|
313 |
+
|
314 |
+
$(this).blur();
|
315 |
+
|
316 |
+
});
|
317 |
+
|
318 |
+
$(document).on('click', '.acf_relationship .relationship_right .relationship_list a', function( e ){
|
319 |
+
|
320 |
+
e.preventDefault();
|
321 |
+
|
322 |
+
acf.fields.relationship.set({ $el : $(this).closest('.acf_relationship') }).remove( $(this) );
|
323 |
+
|
324 |
+
$(this).blur();
|
325 |
+
|
326 |
+
});
|
327 |
+
|
328 |
+
$(document).on('keyup', '.acf_relationship input.relationship_search', function( e ){
|
329 |
+
|
330 |
+
// vars
|
331 |
+
var val = $(this).val(),
|
332 |
+
$el = $(this).closest('.acf_relationship');
|
333 |
+
|
334 |
+
|
335 |
+
// update attr
|
336 |
+
$el.attr('data-s', val);
|
337 |
+
$el.attr('data-paged', 1);
|
338 |
+
|
339 |
+
|
340 |
+
// fetch
|
341 |
+
clearTimeout( acf.fields.relationship.timeout );
|
342 |
+
acf.fields.relationship.timeout = setTimeout(function(){
|
343 |
+
|
344 |
+
acf.fields.relationship.set({ $el : $el }).fetch();
|
345 |
+
|
346 |
+
}, 500);
|
347 |
+
|
348 |
+
});
|
349 |
+
|
350 |
+
$(document).on('keypress', '.acf_relationship input.relationship_search', function( e ){
|
351 |
+
|
352 |
+
// don't submit form
|
353 |
+
if( e.which == 13 )
|
354 |
+
{
|
355 |
+
e.preventDefault();
|
356 |
+
}
|
357 |
+
|
358 |
+
});
|
359 |
+
|
360 |
+
|
361 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/tab.js
ADDED
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
acf.fields.tab = {
|
4 |
+
|
5 |
+
add_group : function( $wrap ){
|
6 |
+
|
7 |
+
// vars
|
8 |
+
var html = '';
|
9 |
+
|
10 |
+
|
11 |
+
// generate html
|
12 |
+
if( $wrap.is('tbody') )
|
13 |
+
{
|
14 |
+
html = '<tr class="acf-tab-wrap"><td colspan="2"><ul class="hl clearfix acf-tab-group"></ul></td></tr>';
|
15 |
+
}
|
16 |
+
else
|
17 |
+
{
|
18 |
+
html = '<div class="acf-tab-wrap"><ul class="hl clearfix acf-tab-group"></ul></div>';
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
// append html
|
23 |
+
$wrap.children('.field_type-tab:first').before( html );
|
24 |
+
|
25 |
+
},
|
26 |
+
|
27 |
+
add_tab : function( $tab ){
|
28 |
+
|
29 |
+
// vars
|
30 |
+
var $field = $tab.closest('.field'),
|
31 |
+
$wrap = $field.parent(),
|
32 |
+
|
33 |
+
key = $field.attr('data-field_key'),
|
34 |
+
label = $tab.text();
|
35 |
+
|
36 |
+
|
37 |
+
// create tab group if it doesnt exist
|
38 |
+
if( ! $wrap.children('.acf-tab-wrap').exists() )
|
39 |
+
{
|
40 |
+
this.add_group( $wrap );
|
41 |
+
}
|
42 |
+
|
43 |
+
// add tab
|
44 |
+
$wrap.children('.acf-tab-wrap').find('.acf-tab-group').append('<li><a class="acf-tab-button" href="#" data-key="' + key + '">' + label + '</a></li>');
|
45 |
+
|
46 |
+
},
|
47 |
+
|
48 |
+
toggle : function( $a ){
|
49 |
+
|
50 |
+
// reference
|
51 |
+
var _this = this;
|
52 |
+
|
53 |
+
|
54 |
+
//console.log( 'toggle %o ', $a);
|
55 |
+
// vars
|
56 |
+
var $wrap = $a.closest('.acf-tab-wrap').parent(),
|
57 |
+
key = $a.attr('data-key');
|
58 |
+
|
59 |
+
|
60 |
+
// classes
|
61 |
+
$a.parent('li').addClass('active').siblings('li').removeClass('active');
|
62 |
+
|
63 |
+
|
64 |
+
// hide / show
|
65 |
+
$wrap.children('.field_type-tab').each(function(){
|
66 |
+
|
67 |
+
|
68 |
+
// vars
|
69 |
+
var $tab = $(this);
|
70 |
+
|
71 |
+
|
72 |
+
if( $tab.attr('data-field_key') == key )
|
73 |
+
{
|
74 |
+
_this.show_tab_fields( $(this) );
|
75 |
+
}
|
76 |
+
else
|
77 |
+
{
|
78 |
+
_this.hide_tab_fields( $(this) );
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
});
|
83 |
+
|
84 |
+
},
|
85 |
+
|
86 |
+
show_tab_fields : function( $field ) {
|
87 |
+
|
88 |
+
//console.log('show tab fields %o', $field);
|
89 |
+
$field.nextUntil('.field_type-tab').each(function(){
|
90 |
+
|
91 |
+
$(this).removeClass('acf-tab_group-hide').addClass('acf-tab_group-show');
|
92 |
+
$(document).trigger('acf/fields/tab/show', [ $(this) ]);
|
93 |
+
|
94 |
+
});
|
95 |
+
},
|
96 |
+
|
97 |
+
hide_tab_fields : function( $field ) {
|
98 |
+
|
99 |
+
$field.nextUntil('.field_type-tab').each(function(){
|
100 |
+
|
101 |
+
$(this).removeClass('acf-tab_group-show').addClass('acf-tab_group-hide');
|
102 |
+
$(document).trigger('acf/fields/tab/hide', [ $(this) ]);
|
103 |
+
|
104 |
+
});
|
105 |
+
},
|
106 |
+
|
107 |
+
refresh : function( $el ){
|
108 |
+
|
109 |
+
// reference
|
110 |
+
var _this = this;
|
111 |
+
|
112 |
+
|
113 |
+
// trigger
|
114 |
+
$el.find('.acf-tab-group').each(function(){
|
115 |
+
|
116 |
+
$(this).find('.acf-tab-button:first').each(function(){
|
117 |
+
|
118 |
+
_this.toggle( $(this) );
|
119 |
+
|
120 |
+
});
|
121 |
+
|
122 |
+
});
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
};
|
127 |
+
|
128 |
+
|
129 |
+
/*
|
130 |
+
* acf/setup_fields
|
131 |
+
*
|
132 |
+
* run init function on all elements for this field
|
133 |
+
*
|
134 |
+
* @type event
|
135 |
+
* @date 20/07/13
|
136 |
+
*
|
137 |
+
* @param {object} e event object
|
138 |
+
* @param {object} el DOM object which may contain new ACF elements
|
139 |
+
* @return N/A
|
140 |
+
*/
|
141 |
+
|
142 |
+
$(document).on('acf/setup_fields', function(e, el){
|
143 |
+
|
144 |
+
// add tabs
|
145 |
+
$(el).find('.acf-tab').each(function(){
|
146 |
+
|
147 |
+
acf.fields.tab.add_tab( $(this) );
|
148 |
+
|
149 |
+
});
|
150 |
+
|
151 |
+
|
152 |
+
// activate first tab
|
153 |
+
acf.fields.tab.refresh( $(el) );
|
154 |
+
|
155 |
+
|
156 |
+
// NOTE: this code is defined BEFORE the acf.conditional_logic action. This is becuase the 'acf/setup_fields' listener is defined INSIDE the conditional_logic.init() function which is run on doc.ready
|
157 |
+
|
158 |
+
// trigger conditional logic
|
159 |
+
// this code ( acf/setup_fields ) is run after the main acf.conditional_logic.init();
|
160 |
+
//console.log('acf/setup_fields (after tab refresh) calling acf.conditional_logic.refresh()');
|
161 |
+
//acf.conditional_logic.refresh();
|
162 |
+
|
163 |
+
});
|
164 |
+
|
165 |
+
|
166 |
+
|
167 |
+
|
168 |
+
/*
|
169 |
+
* Events
|
170 |
+
*
|
171 |
+
* jQuery events for this field
|
172 |
+
*
|
173 |
+
* @type function
|
174 |
+
* @date 1/03/2011
|
175 |
+
*
|
176 |
+
* @param N/A
|
177 |
+
* @return N/A
|
178 |
+
*/
|
179 |
+
|
180 |
+
$(document).on('click', '.acf-tab-button', function( e ){
|
181 |
+
|
182 |
+
e.preventDefault();
|
183 |
+
|
184 |
+
acf.fields.tab.toggle( $(this) );
|
185 |
+
|
186 |
+
$(this).trigger('blur');
|
187 |
+
|
188 |
+
});
|
189 |
+
|
190 |
+
|
191 |
+
$(document).on('acf/conditional_logic/hide', function( e, $target, item ){
|
192 |
+
|
193 |
+
// validate
|
194 |
+
if( $target.attr('data-field_type') != 'tab' )
|
195 |
+
{
|
196 |
+
return;
|
197 |
+
}
|
198 |
+
|
199 |
+
//console.log('conditional_logic/hide tab %o', $target);
|
200 |
+
|
201 |
+
|
202 |
+
// vars
|
203 |
+
var $tab = $target.siblings('.acf-tab-wrap').find('a[data-key="' + $target.attr('data-field_key') + '"]');
|
204 |
+
|
205 |
+
|
206 |
+
// if tab is already hidden, then ignore the following functiolnality
|
207 |
+
if( $tab.is(':hidden') )
|
208 |
+
{
|
209 |
+
return;
|
210 |
+
}
|
211 |
+
|
212 |
+
|
213 |
+
// visibility
|
214 |
+
$tab.parent().hide();
|
215 |
+
|
216 |
+
|
217 |
+
// if
|
218 |
+
if( $tab.parent().siblings(':visible').exists() )
|
219 |
+
{
|
220 |
+
// if the $target to be hidden is a tab button, lets toggle a sibling tab button
|
221 |
+
$tab.parent().siblings(':visible').first().children('a').trigger('click');
|
222 |
+
}
|
223 |
+
else
|
224 |
+
{
|
225 |
+
// no onther tabs
|
226 |
+
acf.fields.tab.hide_tab_fields( $target );
|
227 |
+
}
|
228 |
+
|
229 |
+
});
|
230 |
+
|
231 |
+
|
232 |
+
$(document).on('acf/conditional_logic/show', function( e, $target, item ){
|
233 |
+
|
234 |
+
// validate
|
235 |
+
if( $target.attr('data-field_type') != 'tab' )
|
236 |
+
{
|
237 |
+
return;
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
//console.log('conditional_logic/show tab %o', $target);
|
242 |
+
|
243 |
+
|
244 |
+
// vars
|
245 |
+
var $tab = $target.siblings('.acf-tab-wrap').find('a[data-key="' + $target.attr('data-field_key') + '"]');
|
246 |
+
|
247 |
+
|
248 |
+
// if tab is already visible, then ignore the following functiolnality
|
249 |
+
if( $tab.is(':visible') )
|
250 |
+
{
|
251 |
+
return;
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
// visibility
|
256 |
+
$tab.parent().show();
|
257 |
+
|
258 |
+
|
259 |
+
// if this is the active tab
|
260 |
+
if( $tab.parent().hasClass('active') )
|
261 |
+
{
|
262 |
+
$tab.trigger('click');
|
263 |
+
return;
|
264 |
+
}
|
265 |
+
|
266 |
+
|
267 |
+
// if the sibling active tab is actually hidden by conditional logic, take ownership of tabs
|
268 |
+
if( $tab.parent().siblings('.active').is(':hidden') )
|
269 |
+
{
|
270 |
+
// show this tab group
|
271 |
+
$tab.trigger('click');
|
272 |
+
return;
|
273 |
+
}
|
274 |
+
|
275 |
+
|
276 |
+
});
|
277 |
+
|
278 |
+
|
279 |
+
|
280 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/validation.js
ADDED
@@ -0,0 +1,432 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
|
4 |
+
/*
|
5 |
+
* Validation
|
6 |
+
*
|
7 |
+
* JS model
|
8 |
+
*
|
9 |
+
* @type object
|
10 |
+
* @date 1/06/13
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
|
14 |
+
acf.validation = {
|
15 |
+
|
16 |
+
status : true,
|
17 |
+
disabled : false,
|
18 |
+
|
19 |
+
run : function(){
|
20 |
+
|
21 |
+
// reference
|
22 |
+
var _this = this;
|
23 |
+
|
24 |
+
|
25 |
+
// reset
|
26 |
+
_this.status = true;
|
27 |
+
|
28 |
+
|
29 |
+
// loop through all fields
|
30 |
+
$('.field.required, .form-field.required').each(function(){
|
31 |
+
|
32 |
+
// run validation
|
33 |
+
_this.validate( $(this) );
|
34 |
+
|
35 |
+
|
36 |
+
});
|
37 |
+
// end loop through all fields
|
38 |
+
},
|
39 |
+
|
40 |
+
/*
|
41 |
+
* show_spinner
|
42 |
+
*
|
43 |
+
* This function will show a spinner element. Logic changed in WP 4.2
|
44 |
+
*
|
45 |
+
* @type function
|
46 |
+
* @date 3/05/2015
|
47 |
+
* @since 5.2.3
|
48 |
+
*
|
49 |
+
* @param $spinner (jQuery)
|
50 |
+
* @return n/a
|
51 |
+
*/
|
52 |
+
|
53 |
+
show_spinner: function( $spinner ){
|
54 |
+
|
55 |
+
// bail early if no spinner
|
56 |
+
if( !$spinner.exists() ) {
|
57 |
+
|
58 |
+
return;
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
// vars
|
64 |
+
var wp_version = acf.o.wp_version;
|
65 |
+
|
66 |
+
|
67 |
+
// show
|
68 |
+
if( parseFloat(wp_version) >= 4.2 ) {
|
69 |
+
|
70 |
+
$spinner.addClass('is-active');
|
71 |
+
|
72 |
+
} else {
|
73 |
+
|
74 |
+
$spinner.css('display', 'inline-block');
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
},
|
79 |
+
|
80 |
+
|
81 |
+
/*
|
82 |
+
* hide_spinner
|
83 |
+
*
|
84 |
+
* This function will hide a spinner element. Logic changed in WP 4.2
|
85 |
+
*
|
86 |
+
* @type function
|
87 |
+
* @date 3/05/2015
|
88 |
+
* @since 5.2.3
|
89 |
+
*
|
90 |
+
* @param $spinner (jQuery)
|
91 |
+
* @return n/a
|
92 |
+
*/
|
93 |
+
|
94 |
+
hide_spinner: function( $spinner ){
|
95 |
+
|
96 |
+
// bail early if no spinner
|
97 |
+
if( !$spinner.exists() ) {
|
98 |
+
|
99 |
+
return;
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
// vars
|
105 |
+
var wp_version = acf.o.wp_version;
|
106 |
+
|
107 |
+
|
108 |
+
// hide
|
109 |
+
if( parseFloat(wp_version) >= 4.2 ) {
|
110 |
+
|
111 |
+
$spinner.removeClass('is-active');
|
112 |
+
|
113 |
+
} else {
|
114 |
+
|
115 |
+
$spinner.css('display', 'none');
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
},
|
120 |
+
|
121 |
+
validate : function( div ){
|
122 |
+
|
123 |
+
// var
|
124 |
+
var ignore = false,
|
125 |
+
$tab = null;
|
126 |
+
|
127 |
+
|
128 |
+
// set validation data
|
129 |
+
div.data('validation', true);
|
130 |
+
|
131 |
+
|
132 |
+
// not visible
|
133 |
+
if( div.is(':hidden') )
|
134 |
+
{
|
135 |
+
// ignore validation
|
136 |
+
ignore = true;
|
137 |
+
|
138 |
+
|
139 |
+
// if this field is hidden by a tab group, allow validation
|
140 |
+
if( div.hasClass('acf-tab_group-hide') )
|
141 |
+
{
|
142 |
+
ignore = false;
|
143 |
+
|
144 |
+
|
145 |
+
// vars
|
146 |
+
var $tab_field = div.prevAll('.field_type-tab:first'),
|
147 |
+
$tab_group = div.prevAll('.acf-tab-wrap:first');
|
148 |
+
|
149 |
+
|
150 |
+
// if the tab itself is hidden, bypass validation
|
151 |
+
if( $tab_field.hasClass('acf-conditional_logic-hide') )
|
152 |
+
{
|
153 |
+
ignore = true;
|
154 |
+
}
|
155 |
+
else
|
156 |
+
{
|
157 |
+
// activate this tab as it holds hidden required field!
|
158 |
+
$tab = $tab_group.find('.acf-tab-button[data-key="' + $tab_field.attr('data-field_key') + '"]');
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
// if is hidden by conditional logic, ignore
|
165 |
+
if( div.hasClass('acf-conditional_logic-hide') )
|
166 |
+
{
|
167 |
+
ignore = true;
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
// if field group is hidden, igrnoe
|
172 |
+
if( div.closest('.postbox.acf-hidden').exists() ) {
|
173 |
+
|
174 |
+
ignore = true;
|
175 |
+
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
if( ignore )
|
180 |
+
{
|
181 |
+
return;
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
|
186 |
+
// text / textarea
|
187 |
+
if( div.find('input[type="text"], input[type="email"], input[type="number"], input[type="hidden"], textarea').val() == "" )
|
188 |
+
{
|
189 |
+
div.data('validation', false);
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
// wysiwyg
|
194 |
+
if( div.find('.acf_wysiwyg').exists() && typeof(tinyMCE) == "object")
|
195 |
+
{
|
196 |
+
div.data('validation', true);
|
197 |
+
|
198 |
+
var id = div.find('.wp-editor-area').attr('id'),
|
199 |
+
editor = tinyMCE.get( id );
|
200 |
+
|
201 |
+
|
202 |
+
if( editor && !editor.getContent() )
|
203 |
+
{
|
204 |
+
div.data('validation', false);
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
// select
|
210 |
+
if( div.find('select').exists() )
|
211 |
+
{
|
212 |
+
div.data('validation', true);
|
213 |
+
|
214 |
+
if( div.find('select').val() == "null" || ! div.find('select').val() )
|
215 |
+
{
|
216 |
+
div.data('validation', false);
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
// radio
|
222 |
+
if( div.find('input[type="radio"]').exists() )
|
223 |
+
{
|
224 |
+
div.data('validation', false);
|
225 |
+
|
226 |
+
if( div.find('input[type="radio"]:checked').exists() )
|
227 |
+
{
|
228 |
+
div.data('validation', true);
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
// checkbox
|
234 |
+
if( div.find('input[type="checkbox"]').exists() )
|
235 |
+
{
|
236 |
+
div.data('validation', false);
|
237 |
+
|
238 |
+
if( div.find('input[type="checkbox"]:checked').exists() )
|
239 |
+
{
|
240 |
+
div.data('validation', true);
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
+
// relationship
|
246 |
+
if( div.find('.acf_relationship').exists() )
|
247 |
+
{
|
248 |
+
div.data('validation', false);
|
249 |
+
|
250 |
+
if( div.find('.acf_relationship .relationship_right input').exists() )
|
251 |
+
{
|
252 |
+
div.data('validation', true);
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
|
257 |
+
// repeater
|
258 |
+
if( div.find('.repeater').exists() )
|
259 |
+
{
|
260 |
+
div.data('validation', false);
|
261 |
+
|
262 |
+
if( div.find('.repeater tr.row').exists() )
|
263 |
+
{
|
264 |
+
div.data('validation', true);
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
|
269 |
+
// gallery
|
270 |
+
if( div.find('.acf-gallery').exists() )
|
271 |
+
{
|
272 |
+
div.data('validation', false);
|
273 |
+
|
274 |
+
if( div.find('.acf-gallery .thumbnail').exists())
|
275 |
+
{
|
276 |
+
div.data('validation', true);
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
|
281 |
+
// hook for custom validation
|
282 |
+
$(document).trigger('acf/validate_field', [ div ] );
|
283 |
+
|
284 |
+
|
285 |
+
// set validation
|
286 |
+
if( ! div.data('validation') )
|
287 |
+
{
|
288 |
+
// show error
|
289 |
+
this.status = false;
|
290 |
+
div.closest('.field').addClass('error');
|
291 |
+
|
292 |
+
|
293 |
+
// custom validation message
|
294 |
+
if( div.data('validation_message') )
|
295 |
+
{
|
296 |
+
var $label = div.find('p.label:first'),
|
297 |
+
$message = null;
|
298 |
+
|
299 |
+
|
300 |
+
// remove old message
|
301 |
+
$label.children('.acf-error-message').remove();
|
302 |
+
|
303 |
+
|
304 |
+
$label.append( '<span class="acf-error-message"><i class="bit"></i>' + div.data('validation_message') + '</span>' );
|
305 |
+
}
|
306 |
+
|
307 |
+
|
308 |
+
// display field (curently hidden due to another tab being active)
|
309 |
+
if( $tab )
|
310 |
+
{
|
311 |
+
$tab.trigger('click');
|
312 |
+
}
|
313 |
+
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
};
|
318 |
+
|
319 |
+
|
320 |
+
/*
|
321 |
+
* Events
|
322 |
+
*
|
323 |
+
* Remove error class on focus
|
324 |
+
*
|
325 |
+
* @type function
|
326 |
+
* @date 1/03/2011
|
327 |
+
*
|
328 |
+
* @param N/A
|
329 |
+
* @return N/A
|
330 |
+
*/
|
331 |
+
|
332 |
+
$(document).on('focus click', '.field.required input, .field.required textarea, .field.required select', function( e ){
|
333 |
+
|
334 |
+
$(this).closest('.field').removeClass('error');
|
335 |
+
|
336 |
+
});
|
337 |
+
|
338 |
+
|
339 |
+
/*
|
340 |
+
$(document).on('blur change', '.field.required input, .field.required textarea, .field.required select', function( e ){
|
341 |
+
|
342 |
+
acf.validation.validate( $(this).closest('.field') );
|
343 |
+
|
344 |
+
});
|
345 |
+
*/
|
346 |
+
|
347 |
+
|
348 |
+
/*
|
349 |
+
* Save Post
|
350 |
+
*
|
351 |
+
* If user is saving a draft, allow them to bypass the validation
|
352 |
+
*
|
353 |
+
* @type function
|
354 |
+
* @date 1/03/2011
|
355 |
+
*
|
356 |
+
* @param N/A
|
357 |
+
* @return N/A
|
358 |
+
*/
|
359 |
+
|
360 |
+
$(document).on('click', '#save-post', function(){
|
361 |
+
|
362 |
+
acf.validation.disabled = true;
|
363 |
+
|
364 |
+
});
|
365 |
+
|
366 |
+
|
367 |
+
/*
|
368 |
+
* Submit Post
|
369 |
+
*
|
370 |
+
* Run validation and return true|false accordingly
|
371 |
+
*
|
372 |
+
* @type function
|
373 |
+
* @date 1/03/2011
|
374 |
+
*
|
375 |
+
* @param N/A
|
376 |
+
* @return N/A
|
377 |
+
*/
|
378 |
+
|
379 |
+
$(document).on('submit', '#post', function(){
|
380 |
+
|
381 |
+
// If disabled, bail early on the validation check
|
382 |
+
if( acf.validation.disabled )
|
383 |
+
{
|
384 |
+
return true;
|
385 |
+
}
|
386 |
+
|
387 |
+
|
388 |
+
// do validation
|
389 |
+
acf.validation.run();
|
390 |
+
|
391 |
+
|
392 |
+
if( ! acf.validation.status ) {
|
393 |
+
|
394 |
+
// vars
|
395 |
+
var $form = $(this);
|
396 |
+
|
397 |
+
|
398 |
+
// show message
|
399 |
+
$form.siblings('#message').remove();
|
400 |
+
$form.before('<div id="message" class="error"><p>' + acf.l10n.validation.error + '</p></div>');
|
401 |
+
|
402 |
+
|
403 |
+
// hide ajax stuff on submit button
|
404 |
+
if( $('#submitdiv').exists() ) {
|
405 |
+
|
406 |
+
// remove disabled classes
|
407 |
+
$('#submitdiv').find('.disabled').removeClass('disabled');
|
408 |
+
$('#submitdiv').find('.button-disabled').removeClass('button-disabled');
|
409 |
+
$('#submitdiv').find('.button-primary-disabled').removeClass('button-primary-disabled');
|
410 |
+
|
411 |
+
|
412 |
+
// remove spinner
|
413 |
+
acf.validation.hide_spinner( $('#submitdiv .spinner') );
|
414 |
+
|
415 |
+
}
|
416 |
+
|
417 |
+
return false;
|
418 |
+
}
|
419 |
+
|
420 |
+
|
421 |
+
// remove hidden postboxes
|
422 |
+
// + this will stop them from being posted to save
|
423 |
+
$('.acf_postbox.acf-hidden').remove();
|
424 |
+
|
425 |
+
|
426 |
+
// submit the form
|
427 |
+
return true;
|
428 |
+
|
429 |
+
});
|
430 |
+
|
431 |
+
|
432 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/js/input/wysiwyg.js
ADDED
@@ -0,0 +1,556 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
/*
|
4 |
+
* WYSIWYG
|
5 |
+
*
|
6 |
+
* jQuery functionality for this field type
|
7 |
+
*
|
8 |
+
* @type object
|
9 |
+
* @date 20/07/13
|
10 |
+
*
|
11 |
+
* @param N/A
|
12 |
+
* @return N/A
|
13 |
+
*/
|
14 |
+
|
15 |
+
var _wysiwyg = acf.fields.wysiwyg = {
|
16 |
+
|
17 |
+
$el: null,
|
18 |
+
$textarea: null,
|
19 |
+
|
20 |
+
o: {},
|
21 |
+
|
22 |
+
set: function( o ){
|
23 |
+
|
24 |
+
// merge in new option
|
25 |
+
$.extend( this, o );
|
26 |
+
|
27 |
+
|
28 |
+
// find textarea
|
29 |
+
this.$textarea = this.$el.find('textarea');
|
30 |
+
|
31 |
+
|
32 |
+
// get options
|
33 |
+
this.o = acf.helpers.get_atts( this.$el );
|
34 |
+
this.o.id = this.$textarea.attr('id');
|
35 |
+
|
36 |
+
|
37 |
+
// return this for chaining
|
38 |
+
return this;
|
39 |
+
|
40 |
+
},
|
41 |
+
|
42 |
+
has_tinymce : function(){
|
43 |
+
|
44 |
+
var r = false;
|
45 |
+
|
46 |
+
if( typeof(tinyMCE) == "object" )
|
47 |
+
{
|
48 |
+
r = true;
|
49 |
+
}
|
50 |
+
|
51 |
+
return r;
|
52 |
+
|
53 |
+
},
|
54 |
+
|
55 |
+
get_toolbar : function(){
|
56 |
+
|
57 |
+
// safely get toolbar
|
58 |
+
if( acf.helpers.isset( this, 'toolbars', this.o.toolbar ) ) {
|
59 |
+
|
60 |
+
return this.toolbars[ this.o.toolbar ];
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
// return
|
66 |
+
return false;
|
67 |
+
|
68 |
+
},
|
69 |
+
|
70 |
+
init : function(){
|
71 |
+
|
72 |
+
// is clone field?
|
73 |
+
if( acf.helpers.is_clone_field( this.$textarea ) )
|
74 |
+
{
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
// vars
|
80 |
+
var id = this.o.id,
|
81 |
+
toolbar = this.get_toolbar(),
|
82 |
+
command = 'mceAddControl',
|
83 |
+
setting = 'theme_advanced_buttons{i}';
|
84 |
+
|
85 |
+
|
86 |
+
// backup
|
87 |
+
var _settings = $.extend( {}, tinyMCE.settings );
|
88 |
+
|
89 |
+
|
90 |
+
// v4 settings
|
91 |
+
if( tinymce.majorVersion == 4 ) {
|
92 |
+
|
93 |
+
command = 'mceAddEditor';
|
94 |
+
setting = 'toolbar{i}';
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
// add toolbars
|
100 |
+
if( toolbar ) {
|
101 |
+
|
102 |
+
for( var i = 1; i < 5; i++ ) {
|
103 |
+
|
104 |
+
// vars
|
105 |
+
var v = '';
|
106 |
+
|
107 |
+
|
108 |
+
// load toolbar
|
109 |
+
if( acf.helpers.isset( toolbar, 'theme_advanced_buttons' + i ) ) {
|
110 |
+
|
111 |
+
v = toolbar['theme_advanced_buttons' + i];
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
// update setting
|
117 |
+
tinyMCE.settings[ setting.replace('{i}', i) ] = v;
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
// add editor
|
125 |
+
tinyMCE.execCommand( command, false, id);
|
126 |
+
|
127 |
+
|
128 |
+
// events - load
|
129 |
+
$(document).trigger('acf/wysiwyg/load', id);
|
130 |
+
|
131 |
+
|
132 |
+
// add events (click, focus, blur) for inserting image into correct editor
|
133 |
+
setTimeout(function(){
|
134 |
+
|
135 |
+
_wysiwyg.add_events( id );
|
136 |
+
|
137 |
+
}, 100);
|
138 |
+
|
139 |
+
|
140 |
+
// restore tinyMCE.settings
|
141 |
+
tinyMCE.settings = _settings;
|
142 |
+
|
143 |
+
|
144 |
+
// set active editor to null
|
145 |
+
wpActiveEditor = null;
|
146 |
+
|
147 |
+
},
|
148 |
+
|
149 |
+
add_events: function( id ){
|
150 |
+
|
151 |
+
// vars
|
152 |
+
var editor = tinyMCE.get( id );
|
153 |
+
|
154 |
+
|
155 |
+
// validate
|
156 |
+
if( !editor ) return;
|
157 |
+
|
158 |
+
|
159 |
+
// vars
|
160 |
+
var $container = $('#wp-' + id + '-wrap'),
|
161 |
+
$body = $( editor.getBody() );
|
162 |
+
|
163 |
+
|
164 |
+
// events
|
165 |
+
$container.on('click', function(){
|
166 |
+
|
167 |
+
$(document).trigger('acf/wysiwyg/click', id);
|
168 |
+
|
169 |
+
});
|
170 |
+
|
171 |
+
$body.on('focus', function(){
|
172 |
+
|
173 |
+
$(document).trigger('acf/wysiwyg/focus', id);
|
174 |
+
|
175 |
+
});
|
176 |
+
|
177 |
+
$body.on('blur', function(){
|
178 |
+
|
179 |
+
$(document).trigger('acf/wysiwyg/blur', id);
|
180 |
+
|
181 |
+
});
|
182 |
+
|
183 |
+
|
184 |
+
},
|
185 |
+
destroy : function(){
|
186 |
+
|
187 |
+
// vars
|
188 |
+
var id = this.o.id,
|
189 |
+
command = 'mceRemoveControl';
|
190 |
+
|
191 |
+
|
192 |
+
// Remove tinymcy functionality.
|
193 |
+
// Due to the media popup destroying and creating the field within such a short amount of time,
|
194 |
+
// a JS error will be thrown when launching the edit window twice in a row.
|
195 |
+
try {
|
196 |
+
|
197 |
+
// vars
|
198 |
+
var editor = tinyMCE.get( id );
|
199 |
+
|
200 |
+
|
201 |
+
// validate
|
202 |
+
if( !editor ) {
|
203 |
+
|
204 |
+
return;
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
// v4 settings
|
210 |
+
if( tinymce.majorVersion == 4 ) {
|
211 |
+
|
212 |
+
command = 'mceRemoveEditor';
|
213 |
+
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
// store value
|
218 |
+
var val = editor.getContent();
|
219 |
+
|
220 |
+
|
221 |
+
// remove editor
|
222 |
+
tinyMCE.execCommand(command, false, id);
|
223 |
+
|
224 |
+
|
225 |
+
// set value
|
226 |
+
this.$textarea.val( val );
|
227 |
+
|
228 |
+
|
229 |
+
} catch(e) {
|
230 |
+
|
231 |
+
//console.log( e );
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
|
236 |
+
// set active editor to null
|
237 |
+
wpActiveEditor = null;
|
238 |
+
|
239 |
+
}
|
240 |
+
|
241 |
+
};
|
242 |
+
|
243 |
+
|
244 |
+
/*
|
245 |
+
* acf/setup_fields
|
246 |
+
*
|
247 |
+
* run init function on all elements for this field
|
248 |
+
*
|
249 |
+
* @type event
|
250 |
+
* @date 20/07/13
|
251 |
+
*
|
252 |
+
* @param {object} e event object
|
253 |
+
* @param {object} el DOM object which may contain new ACF elements
|
254 |
+
* @return N/A
|
255 |
+
*/
|
256 |
+
|
257 |
+
$(document).on('acf/setup_fields', function(e, el){
|
258 |
+
|
259 |
+
// validate
|
260 |
+
if( ! _wysiwyg.has_tinymce() )
|
261 |
+
{
|
262 |
+
return;
|
263 |
+
}
|
264 |
+
|
265 |
+
|
266 |
+
// Destory all WYSIWYG fields
|
267 |
+
// This hack will fix a problem when the WP popup is created and hidden, then the ACF popup (image/file field) is opened
|
268 |
+
$(el).find('.acf_wysiwyg').each(function(){
|
269 |
+
|
270 |
+
_wysiwyg.set({ $el : $(this) }).destroy();
|
271 |
+
|
272 |
+
});
|
273 |
+
|
274 |
+
|
275 |
+
// Add WYSIWYG fields
|
276 |
+
setTimeout(function(){
|
277 |
+
|
278 |
+
$(el).find('.acf_wysiwyg').each(function(){
|
279 |
+
|
280 |
+
_wysiwyg.set({ $el : $(this) }).init();
|
281 |
+
|
282 |
+
});
|
283 |
+
|
284 |
+
}, 0);
|
285 |
+
|
286 |
+
});
|
287 |
+
|
288 |
+
|
289 |
+
/*
|
290 |
+
* acf/remove_fields
|
291 |
+
*
|
292 |
+
* This action is called when the $el is being removed from the DOM
|
293 |
+
*
|
294 |
+
* @type event
|
295 |
+
* @date 20/07/13
|
296 |
+
*
|
297 |
+
* @param {object} e event object
|
298 |
+
* @param {object} $el jQuery element being removed
|
299 |
+
* @return N/A
|
300 |
+
*/
|
301 |
+
|
302 |
+
$(document).on('acf/remove_fields', function(e, $el){
|
303 |
+
|
304 |
+
// validate
|
305 |
+
if( ! _wysiwyg.has_tinymce() )
|
306 |
+
{
|
307 |
+
return;
|
308 |
+
}
|
309 |
+
|
310 |
+
|
311 |
+
$el.find('.acf_wysiwyg').each(function(){
|
312 |
+
|
313 |
+
_wysiwyg.set({ $el : $(this) }).destroy();
|
314 |
+
|
315 |
+
});
|
316 |
+
|
317 |
+
});
|
318 |
+
|
319 |
+
|
320 |
+
/*
|
321 |
+
* acf/wysiwyg/click
|
322 |
+
*
|
323 |
+
* this event is run when a user clicks on a WYSIWYG field
|
324 |
+
*
|
325 |
+
* @type event
|
326 |
+
* @date 17/01/13
|
327 |
+
*
|
328 |
+
* @param {object} e event object
|
329 |
+
* @param {int} id WYSIWYG ID
|
330 |
+
* @return N/A
|
331 |
+
*/
|
332 |
+
|
333 |
+
$(document).on('acf/wysiwyg/click', function(e, id){
|
334 |
+
|
335 |
+
wpActiveEditor = id;
|
336 |
+
|
337 |
+
container = $('#wp-' + id + '-wrap').closest('.field').removeClass('error');
|
338 |
+
|
339 |
+
});
|
340 |
+
|
341 |
+
|
342 |
+
/*
|
343 |
+
* acf/wysiwyg/focus
|
344 |
+
*
|
345 |
+
* this event is run when a user focuses on a WYSIWYG field body
|
346 |
+
*
|
347 |
+
* @type event
|
348 |
+
* @date 17/01/13
|
349 |
+
*
|
350 |
+
* @param {object} e event object
|
351 |
+
* @param {int} id WYSIWYG ID
|
352 |
+
* @return N/A
|
353 |
+
*/
|
354 |
+
|
355 |
+
$(document).on('acf/wysiwyg/focus', function(e, id){
|
356 |
+
|
357 |
+
wpActiveEditor = id;
|
358 |
+
|
359 |
+
container = $('#wp-' + id + '-wrap').closest('.field').removeClass('error');
|
360 |
+
|
361 |
+
});
|
362 |
+
|
363 |
+
|
364 |
+
/*
|
365 |
+
* acf/wysiwyg/blur
|
366 |
+
*
|
367 |
+
* this event is run when a user loses focus on a WYSIWYG field body
|
368 |
+
*
|
369 |
+
* @type event
|
370 |
+
* @date 17/01/13
|
371 |
+
*
|
372 |
+
* @param {object} e event object
|
373 |
+
* @param {int} id WYSIWYG ID
|
374 |
+
* @return N/A
|
375 |
+
*/
|
376 |
+
|
377 |
+
$(document).on('acf/wysiwyg/blur', function(e, id){
|
378 |
+
|
379 |
+
wpActiveEditor = null;
|
380 |
+
|
381 |
+
// update the hidden textarea
|
382 |
+
// - This fixes a but when adding a taxonomy term as the form is not posted and the hidden tetarea is never populated!
|
383 |
+
var editor = tinyMCE.get( id );
|
384 |
+
|
385 |
+
|
386 |
+
// validate
|
387 |
+
if( !editor )
|
388 |
+
{
|
389 |
+
return;
|
390 |
+
}
|
391 |
+
|
392 |
+
|
393 |
+
var el = editor.getElement();
|
394 |
+
|
395 |
+
|
396 |
+
// save to textarea
|
397 |
+
editor.save();
|
398 |
+
|
399 |
+
|
400 |
+
// trigger change on textarea
|
401 |
+
$( el ).trigger('change');
|
402 |
+
|
403 |
+
});
|
404 |
+
|
405 |
+
|
406 |
+
/*
|
407 |
+
* acf/sortable_start
|
408 |
+
*
|
409 |
+
* this event is run when a element is being drag / dropped
|
410 |
+
*
|
411 |
+
* @type event
|
412 |
+
* @date 10/11/12
|
413 |
+
*
|
414 |
+
* @param {object} e event object
|
415 |
+
* @param {object} el DOM object which may contain new ACF elements
|
416 |
+
* @return N/A
|
417 |
+
*/
|
418 |
+
|
419 |
+
$(document).on('acf/sortable_start', function(e, el) {
|
420 |
+
|
421 |
+
// validate
|
422 |
+
if( ! _wysiwyg.has_tinymce() )
|
423 |
+
{
|
424 |
+
return;
|
425 |
+
}
|
426 |
+
|
427 |
+
|
428 |
+
$(el).find('.acf_wysiwyg').each(function(){
|
429 |
+
|
430 |
+
_wysiwyg.set({ $el : $(this) }).destroy();
|
431 |
+
|
432 |
+
});
|
433 |
+
|
434 |
+
});
|
435 |
+
|
436 |
+
|
437 |
+
/*
|
438 |
+
* acf/sortable_stop
|
439 |
+
*
|
440 |
+
* this event is run when a element has finnished being drag / dropped
|
441 |
+
*
|
442 |
+
* @type event
|
443 |
+
* @date 10/11/12
|
444 |
+
*
|
445 |
+
* @param {object} e event object
|
446 |
+
* @param {object} el DOM object which may contain new ACF elements
|
447 |
+
* @return N/A
|
448 |
+
*/
|
449 |
+
|
450 |
+
$(document).on('acf/sortable_stop', function(e, el) {
|
451 |
+
|
452 |
+
// validate
|
453 |
+
if( ! _wysiwyg.has_tinymce() )
|
454 |
+
{
|
455 |
+
return;
|
456 |
+
}
|
457 |
+
|
458 |
+
|
459 |
+
$(el).find('.acf_wysiwyg').each(function(){
|
460 |
+
|
461 |
+
_wysiwyg.set({ $el : $(this) }).init();
|
462 |
+
|
463 |
+
});
|
464 |
+
|
465 |
+
});
|
466 |
+
|
467 |
+
|
468 |
+
/*
|
469 |
+
* window load
|
470 |
+
*
|
471 |
+
* @description:
|
472 |
+
* @since: 3.5.5
|
473 |
+
* @created: 22/12/12
|
474 |
+
*/
|
475 |
+
|
476 |
+
$(window).on('load', function(){
|
477 |
+
|
478 |
+
// validate
|
479 |
+
if( ! _wysiwyg.has_tinymce() )
|
480 |
+
{
|
481 |
+
return;
|
482 |
+
}
|
483 |
+
|
484 |
+
|
485 |
+
// vars
|
486 |
+
var wp_content = $('#wp-content-wrap').exists(),
|
487 |
+
wp_acf_settings = $('#wp-acf_settings-wrap').exists()
|
488 |
+
mode = 'tmce';
|
489 |
+
|
490 |
+
|
491 |
+
// has_editor
|
492 |
+
if( wp_acf_settings )
|
493 |
+
{
|
494 |
+
// html_mode
|
495 |
+
if( $('#wp-acf_settings-wrap').hasClass('html-active') )
|
496 |
+
{
|
497 |
+
mode = 'html';
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
|
502 |
+
setTimeout(function(){
|
503 |
+
|
504 |
+
// trigger click on hidden wysiwyg (to get in HTML mode)
|
505 |
+
if( wp_acf_settings && mode == 'html' )
|
506 |
+
{
|
507 |
+
$('#acf_settings-tmce').trigger('click');
|
508 |
+
}
|
509 |
+
|
510 |
+
}, 1);
|
511 |
+
|
512 |
+
|
513 |
+
setTimeout(function(){
|
514 |
+
|
515 |
+
// trigger html mode for people who want to stay in HTML mode
|
516 |
+
if( wp_acf_settings && mode == 'html' )
|
517 |
+
{
|
518 |
+
$('#acf_settings-html').trigger('click');
|
519 |
+
}
|
520 |
+
|
521 |
+
// Add events to content editor
|
522 |
+
if( wp_content )
|
523 |
+
{
|
524 |
+
_wysiwyg.add_events('content');
|
525 |
+
}
|
526 |
+
|
527 |
+
|
528 |
+
}, 11);
|
529 |
+
|
530 |
+
|
531 |
+
});
|
532 |
+
|
533 |
+
|
534 |
+
/*
|
535 |
+
* Full screen
|
536 |
+
*
|
537 |
+
* @description: this hack will hide the 'image upload' button in the wysiwyg full screen mode if the field has disabled image uploads!
|
538 |
+
* @since: 3.6
|
539 |
+
* @created: 26/02/13
|
540 |
+
*/
|
541 |
+
|
542 |
+
$(document).on('click', '.acf_wysiwyg a.mce_fullscreen', function(){
|
543 |
+
|
544 |
+
// vars
|
545 |
+
var wysiwyg = $(this).closest('.acf_wysiwyg'),
|
546 |
+
upload = wysiwyg.attr('data-upload');
|
547 |
+
|
548 |
+
if( upload == 'no' )
|
549 |
+
{
|
550 |
+
$('#mce_fullscreen_container td.mceToolbar .mce_add_media').remove();
|
551 |
+
}
|
552 |
+
|
553 |
+
});
|
554 |
+
|
555 |
+
|
556 |
+
})(jQuery);
|
templates/simple-solid-lite/config.php
CHANGED
@@ -80,24 +80,6 @@ if( function_exists('register_field_group') ):
|
|
80 |
'toolbar' => 'full',
|
81 |
'media_upload' => 1,
|
82 |
),
|
83 |
-
array (
|
84 |
-
'key' => 'field_55df73e03fb9b',
|
85 |
-
'label' => __('Mailn Headline'),
|
86 |
-
'name' => 'simple-solid-lite-conversion-area-content',
|
87 |
-
'type' => 'wysiwyg',
|
88 |
-
'instructions' => 'Insert a call to action or Inbound form here. ',
|
89 |
-
'required' => 0,
|
90 |
-
'conditional_logic' => 0,
|
91 |
-
'wrapper' => array (
|
92 |
-
'width' => '',
|
93 |
-
'class' => '',
|
94 |
-
'id' => '',
|
95 |
-
),
|
96 |
-
'default_value' => '',
|
97 |
-
'tabs' => 'all',
|
98 |
-
'toolbar' => 'full',
|
99 |
-
'media_upload' => 1,
|
100 |
-
),
|
101 |
array (
|
102 |
'key' => 'field_55df73e03fb9b',
|
103 |
'label' => 'Conversion Area',
|
80 |
'toolbar' => 'full',
|
81 |
'media_upload' => 1,
|
82 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
array (
|
84 |
'key' => 'field_55df73e03fb9b',
|
85 |
'label' => 'Conversion Area',
|