Version Description
- Heaps of js bug fixes
- API will now work with looped posts
- Date Picker returns the correct value
- Added Post type option to Page Link Field
- Fixed Image + File Uploads!
- Lots of tidying up!
Download this release
Release Info
Developer | elliotcondon |
Plugin | Advanced Custom Fields |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- acf.php +52 -25
- core/acf_post_type.php +1 -1
- core/admin_head.php +2 -1
- core/api.php +6 -6
- core/fields/checkbox.php +10 -1
- core/fields/date_picker/date_picker.php +5 -3
- core/fields/file.php +6 -0
- core/fields/image.php +6 -0
- core/fields/page_link.php +53 -7
- core/fields/select.php +15 -1
- core/fields/text.php +6 -0
- core/fields/textarea.php +6 -0
- core/fields/wysiwyg.php +6 -0
- core/fields_save.php +16 -12
- core/input_meta_box.php +12 -4
- core/input_save.php +34 -4
- core/location_meta_box.php +7 -1
- core/upload.php +10 -0
- css/style.fields.css +20 -1
- css/style.global.css +1 -1
- css/style.input.css +121 -10
- js/functions.fields.js +137 -99
- js/functions.input.js +422 -163
- readme.txt +17 -4
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
acf.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://plugins.elliotcondon.com/advanced-custom-fields/
|
5 |
Description: Completely Customise your edit pages with an assortment of field types: Wysiwyg, text, image, select, checkbox and more! Hide unwanted metaboxes and assign to any edit page!
|
6 |
-
Version: 1.0.
|
7 |
Author: Elliot Condon
|
8 |
Author URI: http://www.elliotcondon.com/
|
9 |
License: GPL
|
@@ -14,9 +14,6 @@ Copyright: Elliot Condon
|
|
14 |
$acf = new Acf();
|
15 |
include('core/api.php');
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
class Acf
|
21 |
{
|
22 |
var $name;
|
@@ -36,7 +33,7 @@ class Acf
|
|
36 |
$this->dir = plugins_url('',__FILE__);
|
37 |
$this->siteurl = get_bloginfo('url');
|
38 |
$this->wpadminurl = admin_url();
|
39 |
-
$this->version = '1.0.
|
40 |
|
41 |
// set text domain
|
42 |
load_plugin_textdomain('acf', false, $this->path.'/lang' );
|
@@ -156,23 +153,6 @@ class Acf
|
|
156 |
}
|
157 |
|
158 |
|
159 |
-
/*---------------------------------------------------------------------------------------------
|
160 |
-
* admin_head
|
161 |
-
*
|
162 |
-
* @author Elliot Condon
|
163 |
-
* @since 1.0.0
|
164 |
-
*
|
165 |
-
---------------------------------------------------------------------------------------------*/
|
166 |
-
function admin_footer()
|
167 |
-
{
|
168 |
-
//if($_GET['post_type'] != 'cf_matrix'){return false;}
|
169 |
-
|
170 |
-
//echo '<link rel="stylesheet" href="'.$this->dir.'/css/cf_matrix_admin.css" type="text/css" media="all" />';
|
171 |
-
//echo '<script type="text/javascript" src="'.$this->dir.'/js/admin.js"></script>';
|
172 |
-
//include('core/meta_box_4.php');
|
173 |
-
}
|
174 |
-
|
175 |
-
|
176 |
/*---------------------------------------------------------------------------------------------
|
177 |
* activate
|
178 |
*
|
@@ -214,7 +194,7 @@ class Acf
|
|
214 |
$array['file'] = new File($this->dir);
|
215 |
$array['select'] = new Select();
|
216 |
$array['checkbox'] = new Checkbox();
|
217 |
-
$array['page_link'] = new Page_link();
|
218 |
$array['date_picker'] = new Date_picker($this->dir);
|
219 |
|
220 |
return $array;
|
@@ -230,9 +210,33 @@ class Acf
|
|
230 |
---------------------------------------------------------------------------------------------*/
|
231 |
function create_field($options)
|
232 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
$this->fields[$options['type']]->html($options);
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
/*---------------------------------------------------------------------------------------------
|
238 |
* Add Meta Box to the ACF post type edit page
|
@@ -327,7 +331,7 @@ class Acf
|
|
327 |
{
|
328 |
if(in_array('_acf_field_'.$i.'_label',$keys))
|
329 |
{
|
330 |
-
$
|
331 |
'label' => get_post_meta($acf_id, '_acf_field_'.$i.'_label', true),
|
332 |
'name' => get_post_meta($acf_id, '_acf_field_'.$i.'_name', true),
|
333 |
'type' => get_post_meta($acf_id, '_acf_field_'.$i.'_type', true),
|
@@ -335,6 +339,28 @@ class Acf
|
|
335 |
get_post_meta($acf_id, '_acf_field_'.$i.'_options', true)
|
336 |
),
|
337 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
}
|
339 |
else
|
340 |
{
|
@@ -452,6 +478,7 @@ class Acf
|
|
452 |
}
|
453 |
|
454 |
$array = unserialize($string);
|
|
|
455 |
|
456 |
foreach($array as $key => $value)
|
457 |
{
|
@@ -468,7 +495,7 @@ class Acf
|
|
468 |
{
|
469 |
$array[$key] = stripslashes($value);
|
470 |
}
|
471 |
-
}
|
472 |
return $array;
|
473 |
}
|
474 |
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://plugins.elliotcondon.com/advanced-custom-fields/
|
5 |
Description: Completely Customise your edit pages with an assortment of field types: Wysiwyg, text, image, select, checkbox and more! Hide unwanted metaboxes and assign to any edit page!
|
6 |
+
Version: 1.0.3
|
7 |
Author: Elliot Condon
|
8 |
Author URI: http://www.elliotcondon.com/
|
9 |
License: GPL
|
14 |
$acf = new Acf();
|
15 |
include('core/api.php');
|
16 |
|
|
|
|
|
|
|
17 |
class Acf
|
18 |
{
|
19 |
var $name;
|
33 |
$this->dir = plugins_url('',__FILE__);
|
34 |
$this->siteurl = get_bloginfo('url');
|
35 |
$this->wpadminurl = admin_url();
|
36 |
+
$this->version = '1.0.3';
|
37 |
|
38 |
// set text domain
|
39 |
load_plugin_textdomain('acf', false, $this->path.'/lang' );
|
153 |
}
|
154 |
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
/*---------------------------------------------------------------------------------------------
|
157 |
* activate
|
158 |
*
|
194 |
$array['file'] = new File($this->dir);
|
195 |
$array['select'] = new Select();
|
196 |
$array['checkbox'] = new Checkbox();
|
197 |
+
$array['page_link'] = new Page_link($this);
|
198 |
$array['date_picker'] = new Date_picker($this->dir);
|
199 |
|
200 |
return $array;
|
210 |
---------------------------------------------------------------------------------------------*/
|
211 |
function create_field($options)
|
212 |
{
|
213 |
+
if(!$this->fields[$options['type']])
|
214 |
+
{
|
215 |
+
echo 'error: Field Type does not exist!';
|
216 |
+
return false;
|
217 |
+
}
|
218 |
+
|
219 |
$this->fields[$options['type']]->html($options);
|
220 |
}
|
221 |
|
222 |
+
/*---------------------------------------------------------------------------------------------
|
223 |
+
* save_field
|
224 |
+
*
|
225 |
+
* @author Elliot Condon
|
226 |
+
* @since 1.0.0
|
227 |
+
*
|
228 |
+
---------------------------------------------------------------------------------------------*/
|
229 |
+
function save_field($options)
|
230 |
+
{
|
231 |
+
if(!$this->fields[$options['field_type']])
|
232 |
+
{
|
233 |
+
echo 'error: Field Type does not exist!';
|
234 |
+
return false;
|
235 |
+
}
|
236 |
+
|
237 |
+
$this->fields[$options['field_type']]->save_field($options['post_id'], $options['field_name'], $options['field_value']);
|
238 |
+
}
|
239 |
+
|
240 |
|
241 |
/*---------------------------------------------------------------------------------------------
|
242 |
* Add Meta Box to the ACF post type edit page
|
331 |
{
|
332 |
if(in_array('_acf_field_'.$i.'_label',$keys))
|
333 |
{
|
334 |
+
$field = array(
|
335 |
'label' => get_post_meta($acf_id, '_acf_field_'.$i.'_label', true),
|
336 |
'name' => get_post_meta($acf_id, '_acf_field_'.$i.'_name', true),
|
337 |
'type' => get_post_meta($acf_id, '_acf_field_'.$i.'_type', true),
|
339 |
get_post_meta($acf_id, '_acf_field_'.$i.'_options', true)
|
340 |
),
|
341 |
);
|
342 |
+
|
343 |
+
// if matrix, it will have sub fields
|
344 |
+
for($j = 0; $j < 99; $j++)
|
345 |
+
{
|
346 |
+
if(in_array('_acf_field_'.$i.'_field_'.$j.'_label',$keys))
|
347 |
+
{
|
348 |
+
$field['options']['repeaters'][] = array(
|
349 |
+
'label' => get_post_meta($acf_id, '_acf_field_'.$i.'_field_'.$j.'_label', true),
|
350 |
+
'name' => get_post_meta($acf_id, '_acf_field_'.$i.'_field_'.$j.'_name', true),
|
351 |
+
'type' => get_post_meta($acf_id, '_acf_field_'.$i.'_field_'.$j.'_type', true),
|
352 |
+
);
|
353 |
+
}
|
354 |
+
else
|
355 |
+
{
|
356 |
+
// data doesnt exist, break loop
|
357 |
+
//echo 'not in array, field = '.$field['label'].'<br>';
|
358 |
+
break;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
$fields[] = $field;
|
363 |
+
|
364 |
}
|
365 |
else
|
366 |
{
|
478 |
}
|
479 |
|
480 |
$array = unserialize($string);
|
481 |
+
/*print_r($string);
|
482 |
|
483 |
foreach($array as $key => $value)
|
484 |
{
|
495 |
{
|
496 |
$array[$key] = stripslashes($value);
|
497 |
}
|
498 |
+
}*/
|
499 |
return $array;
|
500 |
}
|
501 |
|
core/acf_post_type.php
CHANGED
@@ -16,7 +16,7 @@ $labels = array(
|
|
16 |
$supports = array(
|
17 |
'title',
|
18 |
'revisions',
|
19 |
-
'custom-fields',
|
20 |
'page-attributes'
|
21 |
);
|
22 |
|
16 |
$supports = array(
|
17 |
'title',
|
18 |
'revisions',
|
19 |
+
//'custom-fields',
|
20 |
'page-attributes'
|
21 |
);
|
22 |
|
core/admin_head.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
global $post;
|
4 |
|
5 |
// shows hidden custom fields
|
6 |
-
|
7 |
|
8 |
// add metabox, style and javascript to acf page
|
9 |
//if($_GET['post_type'] == 'acf')
|
@@ -105,6 +105,7 @@ else
|
|
105 |
// add these acf's to the page
|
106 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.global.css" />';
|
107 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.input.css" />';
|
|
|
108 |
echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.input.js" ></script>';
|
109 |
|
110 |
add_meta_box('acf_input', 'ACF Fields', array($this, '_input_meta_box'), get_post_type($post), 'normal', 'high', array('acfs' => $add_acf));
|
3 |
global $post;
|
4 |
|
5 |
// shows hidden custom fields
|
6 |
+
echo "<style type='text/css'>#postcustom .hidden { display: table-row; }</style>";
|
7 |
|
8 |
// add metabox, style and javascript to acf page
|
9 |
//if($_GET['post_type'] == 'acf')
|
105 |
// add these acf's to the page
|
106 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.global.css" />';
|
107 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.input.css" />';
|
108 |
+
echo '<script type="text/javascript" src="'.$this->dir.'/js/swap.jquery.js" ></script>';
|
109 |
echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.input.js" ></script>';
|
110 |
|
111 |
add_meta_box('acf_input', 'ACF Fields', array($this, '_input_meta_box'), get_post_type($post), 'normal', 'high', array('acfs' => $add_acf));
|
core/api.php
CHANGED
@@ -50,11 +50,12 @@ function get_acf($post_id = false)
|
|
50 |
// checkpoint
|
51 |
|
52 |
if(empty($acf_id)){return null;}
|
53 |
-
|
54 |
foreach($acf_id as $id)
|
55 |
{
|
56 |
$this_fields = $acf->get_fields($id);
|
57 |
if(empty($this_fields)){return null;}
|
|
|
58 |
foreach($this_fields as $this_field)
|
59 |
{
|
60 |
$fields[] = $this_field;
|
@@ -63,7 +64,7 @@ function get_acf($post_id = false)
|
|
63 |
|
64 |
// checkpoint
|
65 |
if(empty($fields)){return null;}
|
66 |
-
|
67 |
$variables = array();
|
68 |
|
69 |
foreach($fields as $field)
|
@@ -102,8 +103,9 @@ function get_field($field_name)
|
|
102 |
if(empty($acf_fields))
|
103 |
{
|
104 |
$acf_fields = array();
|
105 |
-
|
106 |
-
|
|
|
107 |
$acf_fields[$post->ID] = get_acf();
|
108 |
}
|
109 |
|
@@ -116,6 +118,4 @@ function the_field($field_name)
|
|
116 |
echo get_field($field_name);
|
117 |
}
|
118 |
|
119 |
-
|
120 |
-
|
121 |
?>
|
50 |
// checkpoint
|
51 |
|
52 |
if(empty($acf_id)){return null;}
|
53 |
+
|
54 |
foreach($acf_id as $id)
|
55 |
{
|
56 |
$this_fields = $acf->get_fields($id);
|
57 |
if(empty($this_fields)){return null;}
|
58 |
+
|
59 |
foreach($this_fields as $this_field)
|
60 |
{
|
61 |
$fields[] = $this_field;
|
64 |
|
65 |
// checkpoint
|
66 |
if(empty($fields)){return null;}
|
67 |
+
|
68 |
$variables = array();
|
69 |
|
70 |
foreach($fields as $field)
|
103 |
if(empty($acf_fields))
|
104 |
{
|
105 |
$acf_fields = array();
|
106 |
+
}
|
107 |
+
if(empty($acf_fields[$post->ID]))
|
108 |
+
{
|
109 |
$acf_fields[$post->ID] = get_acf();
|
110 |
}
|
111 |
|
118 |
echo get_field($field_name);
|
119 |
}
|
120 |
|
|
|
|
|
121 |
?>
|
core/fields/checkbox.php
CHANGED
@@ -48,7 +48,7 @@ class Checkbox
|
|
48 |
//if($options['choices'] == ''){$options['choices'] = "option 1\noption 2\noption 3";}
|
49 |
?>
|
50 |
|
51 |
-
<table>
|
52 |
<tr>
|
53 |
<td class="label">
|
54 |
<label for="">Choices</label>
|
@@ -84,6 +84,15 @@ class Checkbox
|
|
84 |
return $value;
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
?>
|
48 |
//if($options['choices'] == ''){$options['choices'] = "option 1\noption 2\noption 3";}
|
49 |
?>
|
50 |
|
51 |
+
<table class="acf_input">
|
52 |
<tr>
|
53 |
<td class="label">
|
54 |
<label for="">Choices</label>
|
84 |
return $value;
|
85 |
}
|
86 |
|
87 |
+
function save_field($post_id, $field_name, $field_value)
|
88 |
+
{
|
89 |
+
if(is_array($field_value))
|
90 |
+
{
|
91 |
+
$field_value = implode(',',$field_value);
|
92 |
+
}
|
93 |
+
add_post_meta($post_id, '_acf_'.$field_name, $field_value);
|
94 |
+
}
|
95 |
+
|
96 |
}
|
97 |
|
98 |
?>
|
core/fields/date_picker/date_picker.php
CHANGED
@@ -46,12 +46,14 @@ class Date_picker
|
|
46 |
|
47 |
function has_format_value()
|
48 |
{
|
49 |
-
return
|
50 |
}
|
|
|
51 |
|
52 |
-
function
|
53 |
{
|
54 |
-
|
|
|
55 |
}
|
56 |
|
57 |
}
|
46 |
|
47 |
function has_format_value()
|
48 |
{
|
49 |
+
return false;
|
50 |
}
|
51 |
+
|
52 |
|
53 |
+
function save_field($post_id, $field_name, $field_value)
|
54 |
{
|
55 |
+
// this is a normal text save
|
56 |
+
add_post_meta($post_id, '_acf_'.$field_name, $field_value);
|
57 |
}
|
58 |
|
59 |
}
|
core/fields/file.php
CHANGED
@@ -45,6 +45,12 @@ class File
|
|
45 |
return false;
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
|
50 |
?>
|
45 |
return false;
|
46 |
}
|
47 |
|
48 |
+
function save_field($post_id, $field_name, $field_value)
|
49 |
+
{
|
50 |
+
// this is a normal text save
|
51 |
+
add_post_meta($post_id, '_acf_'.$field_name, $field_value);
|
52 |
+
}
|
53 |
+
|
54 |
}
|
55 |
|
56 |
?>
|
core/fields/image.php
CHANGED
@@ -45,6 +45,12 @@ class Image
|
|
45 |
return false;
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
|
50 |
?>
|
45 |
return false;
|
46 |
}
|
47 |
|
48 |
+
function save_field($post_id, $field_name, $field_value)
|
49 |
+
{
|
50 |
+
// this is a normal text save
|
51 |
+
add_post_meta($post_id, '_acf_'.$field_name, $field_value);
|
52 |
+
}
|
53 |
+
|
54 |
}
|
55 |
|
56 |
?>
|
core/fields/page_link.php
CHANGED
@@ -4,24 +4,36 @@ class Page_link
|
|
4 |
{
|
5 |
var $name;
|
6 |
var $title;
|
|
|
7 |
|
8 |
-
function Page_link()
|
9 |
{
|
10 |
$this->name = 'page_link';
|
11 |
$this->title = 'Page Link';
|
|
|
12 |
}
|
13 |
|
14 |
function html($options)
|
15 |
{
|
16 |
-
|
17 |
-
|
18 |
-
foreach($post_types as $key => $value)
|
19 |
{
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
-
|
|
|
|
|
|
|
23 |
}
|
24 |
}
|
|
|
25 |
|
26 |
$posts = get_posts(array(
|
27 |
'numberposts' => -1,
|
@@ -75,7 +87,35 @@ class Page_link
|
|
75 |
|
76 |
function has_options()
|
77 |
{
|
78 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
|
81 |
function has_format_value()
|
@@ -90,6 +130,12 @@ class Page_link
|
|
90 |
return $value;
|
91 |
}
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
|
95 |
?>
|
4 |
{
|
5 |
var $name;
|
6 |
var $title;
|
7 |
+
var $parent;
|
8 |
|
9 |
+
function Page_link($parent)
|
10 |
{
|
11 |
$this->name = 'page_link';
|
12 |
$this->title = 'Page Link';
|
13 |
+
$this->parent = $parent;
|
14 |
}
|
15 |
|
16 |
function html($options)
|
17 |
{
|
18 |
+
// get post types
|
19 |
+
if(is_array($options['options']['post_type']))
|
|
|
20 |
{
|
21 |
+
// 1. If select has selected post types, just use them
|
22 |
+
$post_types = $options['options']['post_type'];
|
23 |
+
}
|
24 |
+
else
|
25 |
+
{
|
26 |
+
//2. If not post types have been selected, load all the public ones
|
27 |
+
$post_types = get_post_types(array('public' => true));
|
28 |
+
foreach($post_types as $key => $value)
|
29 |
{
|
30 |
+
if($value == 'attachment')
|
31 |
+
{
|
32 |
+
unset($post_types[$key]);
|
33 |
+
}
|
34 |
}
|
35 |
}
|
36 |
+
|
37 |
|
38 |
$posts = get_posts(array(
|
39 |
'numberposts' => -1,
|
87 |
|
88 |
function has_options()
|
89 |
{
|
90 |
+
return true;
|
91 |
+
}
|
92 |
+
|
93 |
+
function options($key, $options)
|
94 |
+
{
|
95 |
+
?>
|
96 |
+
<table class="acf_input">
|
97 |
+
<tr>
|
98 |
+
<td class="label">
|
99 |
+
<label for="">Post Type</label>
|
100 |
+
</td>
|
101 |
+
<td>
|
102 |
+
<?php
|
103 |
+
foreach (get_post_types() as $post_type ) {
|
104 |
+
$post_types[$post_type] = $post_type;
|
105 |
+
}
|
106 |
+
|
107 |
+
unset($post_types['attachment']);
|
108 |
+
unset($post_types['nav_menu_item']);
|
109 |
+
unset($post_types['revision']);
|
110 |
+
unset($post_types['acf']);
|
111 |
+
|
112 |
+
$this->parent->create_field(array('type'=>'select','name'=>'acf[fields]['.$key.'][options][post_type]','value'=>$options['post_type'],'id'=>'acf[fields]['.$key.'][options][post_type]', 'options' => array('choices' => $post_types, 'multiple' => 'true')));
|
113 |
+
?>
|
114 |
+
<p class="description">Filter posts by selecting a post type</p>
|
115 |
+
</td>
|
116 |
+
</tr>
|
117 |
+
</table>
|
118 |
+
<?php
|
119 |
}
|
120 |
|
121 |
function has_format_value()
|
130 |
return $value;
|
131 |
}
|
132 |
|
133 |
+
function save_field($post_id, $field_name, $field_value)
|
134 |
+
{
|
135 |
+
// this is a normal text save
|
136 |
+
add_post_meta($post_id, '_acf_'.$field_name, $field_value);
|
137 |
+
}
|
138 |
+
|
139 |
}
|
140 |
|
141 |
?>
|
core/fields/select.php
CHANGED
@@ -13,6 +13,7 @@ class Select
|
|
13 |
|
14 |
function html($options)
|
15 |
{
|
|
|
16 |
//$options['choices'] = explode("\n",$options['choices']);
|
17 |
if($options['options']['multiple'] == 'true')
|
18 |
{
|
@@ -33,8 +34,14 @@ class Select
|
|
33 |
foreach($options['options']['choices'] as $key => $value)
|
34 |
{
|
35 |
$selected = '';
|
36 |
-
if(
|
|
|
|
|
|
|
|
|
|
|
37 |
{
|
|
|
38 |
if(in_array($key, $options['value']))
|
39 |
{
|
40 |
$selected = 'selected="selected"';
|
@@ -42,6 +49,7 @@ class Select
|
|
42 |
}
|
43 |
else
|
44 |
{
|
|
|
45 |
if($key == $options['value'])
|
46 |
{
|
47 |
$selected = 'selected="selected"';
|
@@ -86,6 +94,12 @@ class Select
|
|
86 |
return false;
|
87 |
}
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
|
91 |
?>
|
13 |
|
14 |
function html($options)
|
15 |
{
|
16 |
+
|
17 |
//$options['choices'] = explode("\n",$options['choices']);
|
18 |
if($options['options']['multiple'] == 'true')
|
19 |
{
|
34 |
foreach($options['options']['choices'] as $key => $value)
|
35 |
{
|
36 |
$selected = '';
|
37 |
+
if($options['options']['multiple'] == 'true' && empty($options['value']))
|
38 |
+
{
|
39 |
+
// 1. If it is multiple select & there are no values selected, make all options selected
|
40 |
+
$selected = 'selected="selected"';
|
41 |
+
}
|
42 |
+
elseif(is_array($options['value']))
|
43 |
{
|
44 |
+
// 2. If the value is an array (multiple select), loop through values and check if it is selected
|
45 |
if(in_array($key, $options['value']))
|
46 |
{
|
47 |
$selected = 'selected="selected"';
|
49 |
}
|
50 |
else
|
51 |
{
|
52 |
+
// 3. this is not a multiple select, just check normaly
|
53 |
if($key == $options['value'])
|
54 |
{
|
55 |
$selected = 'selected="selected"';
|
94 |
return false;
|
95 |
}
|
96 |
|
97 |
+
function save_field($post_id, $field_name, $field_value)
|
98 |
+
{
|
99 |
+
// this is a normal text save
|
100 |
+
add_post_meta($post_id, '_acf_'.$field_name, $field_value);
|
101 |
+
}
|
102 |
+
|
103 |
}
|
104 |
|
105 |
?>
|
core/fields/text.php
CHANGED
@@ -26,6 +26,12 @@ class Text
|
|
26 |
return false;
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
?>
|
26 |
return false;
|
27 |
}
|
28 |
|
29 |
+
function save_field($post_id, $field_name, $field_value)
|
30 |
+
{
|
31 |
+
// this is a normal text save
|
32 |
+
add_post_meta($post_id, '_acf_'.$field_name, $field_value);
|
33 |
+
}
|
34 |
+
|
35 |
}
|
36 |
|
37 |
?>
|
core/fields/textarea.php
CHANGED
@@ -32,6 +32,12 @@ class Textarea
|
|
32 |
|
33 |
return $value;
|
34 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
?>
|
32 |
|
33 |
return $value;
|
34 |
}
|
35 |
+
|
36 |
+
function save_field($post_id, $field_name, $field_value)
|
37 |
+
{
|
38 |
+
// this is a normal text save
|
39 |
+
add_post_meta($post_id, '_acf_'.$field_name, $field_value);
|
40 |
+
}
|
41 |
}
|
42 |
|
43 |
?>
|
core/fields/wysiwyg.php
CHANGED
@@ -34,6 +34,12 @@ class Wysiwyg
|
|
34 |
|
35 |
return $value;
|
36 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
?>
|
34 |
|
35 |
return $value;
|
36 |
}
|
37 |
+
|
38 |
+
function save_field($post_id, $field_name, $field_value)
|
39 |
+
{
|
40 |
+
// this is a normal text save
|
41 |
+
add_post_meta($post_id, '_acf_'.$field_name, $field_value);
|
42 |
+
}
|
43 |
}
|
44 |
|
45 |
?>
|
core/fields_save.php
CHANGED
@@ -13,19 +13,23 @@ if($_POST['fields_meta_box'] == 'true')
|
|
13 |
add_post_meta($post_id, '_acf_field_'.$i.'_name', $field['name']);
|
14 |
add_post_meta($post_id, '_acf_field_'.$i.'_type', $field['type']);
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
|
|
|
|
29 |
// increase counter
|
30 |
$i++;
|
31 |
}
|
13 |
add_post_meta($post_id, '_acf_field_'.$i.'_name', $field['name']);
|
14 |
add_post_meta($post_id, '_acf_field_'.$i.'_type', $field['type']);
|
15 |
|
16 |
+
if(!empty($field['fields']))
|
17 |
+
{
|
18 |
+
$j = 0;
|
19 |
+
|
20 |
+
foreach($field['fields'] as $repeater)
|
21 |
+
{
|
22 |
+
// add post meta
|
23 |
+
add_post_meta($post_id, '_acf_field_'.$i.'_field_'.$j.'_label', $repeater['label']);
|
24 |
+
add_post_meta($post_id, '_acf_field_'.$i.'_field_'.$j.'_name', $repeater['name']);
|
25 |
+
add_post_meta($post_id, '_acf_field_'.$i.'_field_'.$j.'_type', $repeater['type']);
|
26 |
+
|
27 |
+
$j++;
|
28 |
+
}
|
29 |
+
}
|
30 |
|
31 |
+
add_post_meta($post_id, '_acf_field_'.$i.'_options', serialize($field['options']));
|
32 |
+
|
33 |
// increase counter
|
34 |
$i++;
|
35 |
}
|
core/input_meta_box.php
CHANGED
@@ -86,11 +86,19 @@
|
|
86 |
{
|
87 |
continue;
|
88 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
-
$field['value'] = get_post_meta($post->ID, '_acf_'.$field['name'], true);
|
91 |
-
|
92 |
-
$field['id'] = 'acf['.$field['name'].']';
|
93 |
-
$field['name'] = 'acf['.$field['name'].']';
|
94 |
|
95 |
if($field['type'] == 'select' || $field['type'] == 'checkbox')
|
96 |
{
|
86 |
{
|
87 |
continue;
|
88 |
}
|
89 |
+
elseif($field['type'] == 'repeater')
|
90 |
+
{
|
91 |
+
// if repeater, get the repeater class to find and add the values to field
|
92 |
+
$field = $this->fields['repeater']->add_values_to_field($field);
|
93 |
+
|
94 |
+
}
|
95 |
+
else
|
96 |
+
{
|
97 |
+
$field['value'] = get_post_meta($post->ID, '_acf_'.$field['name'], true);
|
98 |
+
$field['id'] = 'acf['.$field['name'].']';
|
99 |
+
$field['name'] = 'acf['.$field['name'].']';
|
100 |
+
}
|
101 |
|
|
|
|
|
|
|
|
|
102 |
|
103 |
if($field['type'] == 'select' || $field['type'] == 'checkbox')
|
104 |
{
|
core/input_save.php
CHANGED
@@ -4,14 +4,44 @@
|
|
4 |
---------------------------------------------------------------------------------------------*/
|
5 |
if($_POST['input_meta_box'] == 'true')
|
6 |
{
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
{
|
9 |
-
|
|
|
|
|
10 |
{
|
11 |
-
$
|
12 |
}
|
13 |
-
add_post_meta($post_id, '_acf_'.$key, $value);
|
14 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
?>
|
4 |
---------------------------------------------------------------------------------------------*/
|
5 |
if($_POST['input_meta_box'] == 'true')
|
6 |
{
|
7 |
+
// save acf id's
|
8 |
+
add_post_meta($post_id, '_acf_id', $_POST['acf']['id']);
|
9 |
+
|
10 |
+
// get field id's
|
11 |
+
$acf_id = explode(',',$_POST['acf']['id']);
|
12 |
+
$fields = array();
|
13 |
+
|
14 |
+
if(empty($acf_id)){return null;}
|
15 |
+
foreach($acf_id as $id)
|
16 |
{
|
17 |
+
$this_fields = $this->get_fields($id);
|
18 |
+
if(empty($this_fields)){return null;}
|
19 |
+
foreach($this_fields as $this_field)
|
20 |
{
|
21 |
+
$fields[] = $this_field;
|
22 |
}
|
|
|
23 |
}
|
24 |
+
|
25 |
+
// now we have this page's fields, loop through them and save
|
26 |
+
foreach($fields as $field)
|
27 |
+
{
|
28 |
+
// if this field has not been submitted, don't save, just continue to next loop
|
29 |
+
/*if(!isset($_POST['acf'][$field['name']]))
|
30 |
+
{
|
31 |
+
echo $field['name'] . ' was not set';
|
32 |
+
continue;
|
33 |
+
}*/
|
34 |
+
|
35 |
+
$options = array(
|
36 |
+
'post_id' => $post_id,
|
37 |
+
'field_name' => $field['name'],
|
38 |
+
'field_value' => $_POST['acf'][$field['name']],
|
39 |
+
'field_type' => $field['type'],
|
40 |
+
);
|
41 |
+
|
42 |
+
$this->save_field($options);
|
43 |
+
}
|
44 |
+
|
45 |
}
|
46 |
|
47 |
?>
|
core/location_meta_box.php
CHANGED
@@ -4,7 +4,12 @@
|
|
4 |
|
5 |
// get options
|
6 |
$location = $this->get_acf_location($post->ID);
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
?>
|
10 |
|
@@ -18,6 +23,7 @@
|
|
18 |
</td>
|
19 |
<td>
|
20 |
<?php
|
|
|
21 |
$post_types = array();
|
22 |
foreach (get_post_types() as $post_type ) {
|
23 |
$post_types[$post_type] = $post_type;
|
4 |
|
5 |
// get options
|
6 |
$location = $this->get_acf_location($post->ID);
|
7 |
+
|
8 |
+
// if post_type exists, it will be an array and neds to be exploded
|
9 |
+
if(is_array($location['post_type']))
|
10 |
+
{
|
11 |
+
$location['post_type'] = explode(',',str_replace(' ','',$location['post_type']));
|
12 |
+
}
|
13 |
|
14 |
?>
|
15 |
|
23 |
</td>
|
24 |
<td>
|
25 |
<?php
|
26 |
+
|
27 |
$post_types = array();
|
28 |
foreach (get_post_types() as $post_type ) {
|
29 |
$post_types[$post_type] = $post_type;
|
core/upload.php
CHANGED
@@ -32,6 +32,15 @@ if(isset($_POST['acf_post']))
|
|
32 |
}
|
33 |
|
34 |
.result {display: none;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
</style>
|
36 |
|
37 |
</head>
|
@@ -53,6 +62,7 @@ if(!empty($file))
|
|
53 |
|
54 |
<input type="hidden" name="acf_post" value="true" />
|
55 |
<input type="file" name="acf_image" id="acf_image" />
|
|
|
56 |
|
57 |
</form>
|
58 |
|
32 |
}
|
33 |
|
34 |
.result {display: none;}
|
35 |
+
|
36 |
+
form {
|
37 |
+
display: block;
|
38 |
+
position: relative;
|
39 |
+
overflow: hidden;
|
40 |
+
padding: 2px;
|
41 |
+
float: left;
|
42 |
+
}
|
43 |
+
|
44 |
</style>
|
45 |
|
46 |
</head>
|
62 |
|
63 |
<input type="hidden" name="acf_post" value="true" />
|
64 |
<input type="file" name="acf_image" id="acf_image" />
|
65 |
+
<input type="submit" class="button" value="Upload" />
|
66 |
|
67 |
</form>
|
68 |
|
css/style.fields.css
CHANGED
@@ -25,6 +25,7 @@
|
|
25 |
.fields {
|
26 |
position: relative;
|
27 |
overflow: hidden;
|
|
|
28 |
}
|
29 |
|
30 |
.fields .field {
|
@@ -33,6 +34,9 @@
|
|
33 |
border-top: #fff solid 1px;
|
34 |
border-bottom: #eaeaea solid 1px;
|
35 |
background: #f6f6f6;
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
.fields .field:hover {
|
@@ -90,7 +94,7 @@
|
|
90 |
text-align: center;
|
91 |
vertical-align: middle;
|
92 |
border-right: 0 none;
|
93 |
-
color: #
|
94 |
text-shadow: #fff 0 1px 0;
|
95 |
padding: 8px 0 8px 8px;
|
96 |
}
|
@@ -285,3 +289,18 @@ a.field_options_button:hover {
|
|
285 |
width: 300px;
|
286 |
|
287 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
.fields {
|
26 |
position: relative;
|
27 |
overflow: hidden;
|
28 |
+
background: #eaeaea;
|
29 |
}
|
30 |
|
31 |
.fields .field {
|
34 |
border-top: #fff solid 1px;
|
35 |
border-bottom: #eaeaea solid 1px;
|
36 |
background: #f6f6f6;
|
37 |
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fafafa', endColorstr='#f6f6f6'); /* for IE */
|
38 |
+
background: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#f6f6f6)); /* for webkit browsers */
|
39 |
+
background: -moz-linear-gradient(top, #fafafa, #f6f6f6); /* for firefox 3.6+ */
|
40 |
}
|
41 |
|
42 |
.fields .field:hover {
|
94 |
text-align: center;
|
95 |
vertical-align: middle;
|
96 |
border-right: 0 none;
|
97 |
+
color: #aaa;
|
98 |
text-shadow: #fff 0 1px 0;
|
99 |
padding: 8px 0 8px 8px;
|
100 |
}
|
289 |
width: 300px;
|
290 |
|
291 |
}
|
292 |
+
|
293 |
+
/*---------------------------------------------------------------------------------------------
|
294 |
+
Repeater
|
295 |
+
---------------------------------------------------------------------------------------------*/
|
296 |
+
.repeater {
|
297 |
+
border: #CCCCCC solid 1px;
|
298 |
+
-moz-border-radius: 5px; -webkit-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px;
|
299 |
+
position: relative;
|
300 |
+
overflow: hidden;
|
301 |
+
}
|
302 |
+
|
303 |
+
.field_options .field_option .repeater table {
|
304 |
+
border: 0 none;
|
305 |
+
-moz-border-radius: 0; -webkit-border-radius: 0; -khtml-border-radius: 0; border-radius: 0;
|
306 |
+
}
|
css/style.global.css
CHANGED
@@ -14,7 +14,7 @@ table.acf_input > tbody > tr > td {
|
|
14 |
padding: 6px;
|
15 |
}
|
16 |
|
17 |
-
table.acf_input > tbody > tr:last-child td {
|
18 |
border-bottom: 0 none;
|
19 |
}
|
20 |
|
14 |
padding: 6px;
|
15 |
}
|
16 |
|
17 |
+
table.acf_input > tbody > tr:last-child > td {
|
18 |
border-bottom: 0 none;
|
19 |
}
|
20 |
|
css/style.input.css
CHANGED
@@ -35,14 +35,13 @@ table.acf_input > tbody > tr > td > textarea {
|
|
35 |
/* image upload */
|
36 |
.acf_image_uploader {
|
37 |
position: relative;
|
38 |
-
float: left;
|
39 |
}
|
40 |
|
41 |
.acf_image_uploader iframe {
|
42 |
display: block;
|
43 |
overflow: hidden;
|
44 |
height: 40px;
|
45 |
-
width:
|
46 |
float: left;
|
47 |
}
|
48 |
|
@@ -83,8 +82,9 @@ table.acf_input > tbody > tr > td > textarea {
|
|
83 |
}
|
84 |
|
85 |
.acf_image_uploader img {
|
86 |
-
height: 100px;
|
87 |
width: auto;
|
|
|
88 |
padding: 3px;
|
89 |
background: #FFF;
|
90 |
border: #d8d8d8 solid 1px;
|
@@ -93,14 +93,13 @@ table.acf_input > tbody > tr > td > textarea {
|
|
93 |
/* File upload */
|
94 |
.acf_file_uploader {
|
95 |
position: relative;
|
96 |
-
float: left;
|
97 |
}
|
98 |
|
99 |
.acf_file_uploader iframe {
|
100 |
display: block;
|
101 |
overflow: hidden;
|
102 |
height: 40px;
|
103 |
-
width:
|
104 |
float: left;
|
105 |
}
|
106 |
|
@@ -143,7 +142,7 @@ table.acf_input > tbody > tr > td > textarea {
|
|
143 |
|
144 |
table.acf_input {
|
145 |
border: 0 none;
|
146 |
-
border-top: 1px solid #
|
147 |
border-bottom: 1px solid #FFFFFF;
|
148 |
}
|
149 |
|
@@ -152,7 +151,7 @@ table.acf_input {
|
|
152 |
}
|
153 |
|
154 |
table.acf_input > tbody > tr > td {
|
155 |
-
border-bottom: 1px solid #
|
156 |
border-top: 1px solid #FFFFFF;
|
157 |
padding: 8px;
|
158 |
}
|
@@ -164,10 +163,122 @@ table.acf_input > tbody > tr > td > label {
|
|
164 |
padding: 0 0 8px;
|
165 |
text-shadow: 0 1px 0 #FFFFFF;
|
166 |
}
|
167 |
-
table.acf_input > tbody > tr:last-child td {
|
168 |
-
border-bottom: 1px solid #
|
169 |
}
|
170 |
|
171 |
table.acf_input > tbody > tr > td > label {
|
172 |
width: auto;
|
173 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
/* image upload */
|
36 |
.acf_image_uploader {
|
37 |
position: relative;
|
|
|
38 |
}
|
39 |
|
40 |
.acf_image_uploader iframe {
|
41 |
display: block;
|
42 |
overflow: hidden;
|
43 |
height: 40px;
|
44 |
+
min-width: 330px;
|
45 |
float: left;
|
46 |
}
|
47 |
|
82 |
}
|
83 |
|
84 |
.acf_image_uploader img {
|
85 |
+
max-height: 100px;
|
86 |
width: auto;
|
87 |
+
height: auto;
|
88 |
padding: 3px;
|
89 |
background: #FFF;
|
90 |
border: #d8d8d8 solid 1px;
|
93 |
/* File upload */
|
94 |
.acf_file_uploader {
|
95 |
position: relative;
|
|
|
96 |
}
|
97 |
|
98 |
.acf_file_uploader iframe {
|
99 |
display: block;
|
100 |
overflow: hidden;
|
101 |
height: 40px;
|
102 |
+
min-width: 330px
|
103 |
float: left;
|
104 |
}
|
105 |
|
142 |
|
143 |
table.acf_input {
|
144 |
border: 0 none;
|
145 |
+
border-top: 1px solid #eaeaea;
|
146 |
border-bottom: 1px solid #FFFFFF;
|
147 |
}
|
148 |
|
151 |
}
|
152 |
|
153 |
table.acf_input > tbody > tr > td {
|
154 |
+
border-bottom: 1px solid #eaeaea;
|
155 |
border-top: 1px solid #FFFFFF;
|
156 |
padding: 8px;
|
157 |
}
|
163 |
padding: 0 0 8px;
|
164 |
text-shadow: 0 1px 0 #FFFFFF;
|
165 |
}
|
166 |
+
table.acf_input > tbody > tr:last-child > td {
|
167 |
+
border-bottom: 1px solid #eaeaea;
|
168 |
}
|
169 |
|
170 |
table.acf_input > tbody > tr > td > label {
|
171 |
width: auto;
|
172 |
+
}
|
173 |
+
|
174 |
+
/*---------------------------------------------------------------------------------------------
|
175 |
+
Repeater
|
176 |
+
---------------------------------------------------------------------------------------------*/
|
177 |
+
.repeater {
|
178 |
+
border: 1px solid #eeeeee;
|
179 |
+
-moz-border-radius: 5px; -webkit-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px;
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
.repeater > table {
|
184 |
+
width: 100%;
|
185 |
+
border-top:#fff solid 1px;
|
186 |
+
border-bottom: 0 none;
|
187 |
+
-moz-border-radius: 5px; -webkit-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px;
|
188 |
+
}
|
189 |
+
|
190 |
+
.repeater > table > thead > tr > th {
|
191 |
+
|
192 |
+
color: #21759B;
|
193 |
+
text-shadow: #fff 0 1px 0;
|
194 |
+
padding: 8px;
|
195 |
+
text-align: left;
|
196 |
+
font-size: 12px;
|
197 |
+
border-bottom: 1px solid #EEEEEE;
|
198 |
+
border-right: 1px solid #EEEEEE;
|
199 |
+
border-left: 1px solid #ffffff;
|
200 |
+
background: #f8f8f8;
|
201 |
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#f8f8f8'); /* for IE */
|
202 |
+
background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#f8f8f8)); /* for webkit browsers */
|
203 |
+
background: -moz-linear-gradient(top, #ffffff, #f8f8f8); /* for firefox 3.6+ */
|
204 |
+
}
|
205 |
+
|
206 |
+
.repeater > table > thead > tr > th:last-child {
|
207 |
+
border-right: 1px solid #ffffff;
|
208 |
+
}
|
209 |
+
|
210 |
+
.repeater > table > tbody > tr:hover a.remove_field {
|
211 |
+
visibility: visible;
|
212 |
+
}
|
213 |
+
|
214 |
+
a.remove_field {
|
215 |
+
display: block;
|
216 |
+
width: 16px;
|
217 |
+
height: 16px;
|
218 |
+
background: url(../images/button_remove.png) 0 0 no-repeat;
|
219 |
+
visibility: hidden;
|
220 |
+
}
|
221 |
+
|
222 |
+
a.remove_field:hover {
|
223 |
+
background-position: 0 100%;
|
224 |
+
}
|
225 |
+
|
226 |
+
.repeater > table td.remove {
|
227 |
+
padding: 8px 4px;
|
228 |
+
}
|
229 |
+
|
230 |
+
.repeater > table td.order {
|
231 |
+
color: #CCC;
|
232 |
+
text-shadow: #fff 0 1px 0;
|
233 |
+
}
|
234 |
+
|
235 |
+
.repeater > table td.order a.order_up {
|
236 |
+
display: block;
|
237 |
+
width: 16px;
|
238 |
+
height: 16px;
|
239 |
+
background: green;
|
240 |
+
margin: 0 auto;
|
241 |
+
}
|
242 |
+
|
243 |
+
.repeater > table td.order a.order_down {
|
244 |
+
display: block;
|
245 |
+
width: 16px;
|
246 |
+
height: 16px;
|
247 |
+
background: red;
|
248 |
+
margin: 0 auto;
|
249 |
+
}
|
250 |
+
|
251 |
+
|
252 |
+
.repeater .table_footer {
|
253 |
+
position: relative;
|
254 |
+
overflow: hidden;
|
255 |
+
padding: 8px;
|
256 |
+
padding-right: 38px;
|
257 |
+
}
|
258 |
+
|
259 |
+
.repeater .table_footer .order_message {
|
260 |
+
background: url(../images/drag_and_drop_to_reorder.png);
|
261 |
+
width: 161px;
|
262 |
+
height: 23px;
|
263 |
+
float: left;
|
264 |
+
margin-left: 5px;
|
265 |
+
}
|
266 |
+
|
267 |
+
.repeater .table_footer a#add_field{
|
268 |
+
display: block;
|
269 |
+
float: right;
|
270 |
+
margin: 0;
|
271 |
+
text-align: center;
|
272 |
+
width: 70px;
|
273 |
+
}
|
274 |
+
|
275 |
+
|
276 |
+
#acf_input .wp_themeSkin tr.mceFirst td.mceToolbar {
|
277 |
+
background: none repeat scroll 0 0 #E6EBF0;
|
278 |
+
border-color: #d7dee4;
|
279 |
+
}
|
280 |
+
|
281 |
+
#poststuff #acf_input .wp_themeSkin .mceStatusbar {
|
282 |
+
background: #f3f6f9;
|
283 |
+
border-color: #d7dee4;
|
284 |
+
}
|
js/functions.fields.js
CHANGED
@@ -1,123 +1,121 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
$.fn.exists = function(){return jQuery(this).length>0;}
|
5 |
-
|
6 |
-
|
7 |
-
// elements
|
8 |
-
var div = $('div.postbox#acf_fields');
|
9 |
-
var fields = div.find('.fields');
|
10 |
|
11 |
-
|
12 |
-
// vars
|
13 |
-
var total_fields = parseInt(div.find('input[name=total_fields]').attr('value')) - 1;
|
14 |
-
var fields_limit = parseInt(div.find('input[name=fields_limit]').attr('value')) -1;
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
// limit fields
|
20 |
-
if(total_fields >= fields_limit)
|
21 |
-
{
|
22 |
-
alert('Field limit reached!');
|
23 |
return false;
|
24 |
-
|
25 |
-
|
26 |
-
// increase total fields
|
27 |
-
total_fields++;
|
28 |
-
|
29 |
-
// clone last tr
|
30 |
-
var new_field = fields.find('.field:last-child').clone(true);
|
31 |
-
|
32 |
-
// update names of input, textarea and all other elements that have name
|
33 |
-
new_field.find('[name]').each(function()
|
34 |
-
{
|
35 |
-
var name = $(this).attr('name').replace('[fields]['+(total_fields-1)+']','[fields]['+(total_fields)+']');
|
36 |
-
$(this).attr('name', name);
|
37 |
-
$(this).val('');
|
38 |
-
$(this).attr('checked','');
|
39 |
-
$(this).attr('selected','');
|
40 |
});
|
41 |
|
42 |
-
// append to table
|
43 |
-
fields.append(new_field);
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
return false;
|
52 |
-
});
|
53 |
-
|
54 |
-
// update order numbers
|
55 |
-
function update_order_numbers(){
|
56 |
-
fields.find('.field').each(function(i){
|
57 |
-
$(this).find('td.order').html(i+1);
|
58 |
});
|
59 |
-
}
|
60 |
-
|
61 |
-
// sortable tr
|
62 |
-
fields.sortable({
|
63 |
-
update: function(event, ui){update_order_numbers();},
|
64 |
-
handle: 'table'
|
65 |
-
});
|
66 |
-
|
67 |
-
|
68 |
-
// add default names
|
69 |
-
fields.find('.field').each(function(){
|
70 |
|
71 |
-
var _this = $(this);
|
72 |
|
73 |
-
|
74 |
-
|
|
|
|
|
75 |
{
|
76 |
-
var
|
77 |
-
|
|
|
|
|
78 |
{
|
79 |
-
var
|
80 |
-
|
81 |
-
$(this).val(label);
|
82 |
}
|
83 |
});
|
84 |
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
87 |
{
|
88 |
-
|
|
|
89 |
{
|
90 |
return false;
|
91 |
}
|
92 |
|
93 |
-
var
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
update_order_numbers();
|
98 |
});
|
99 |
});
|
100 |
|
101 |
return false;
|
102 |
});
|
103 |
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
106 |
{
|
107 |
-
var _this = $(this).parents('.field');
|
108 |
-
|
109 |
-
// store selected value
|
110 |
var selected = $(this).val();
|
111 |
-
var td = $(this).parent();
|
|
|
|
|
|
|
|
|
112 |
|
113 |
// remove preivous field option button
|
114 |
-
td.
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
118 |
|
119 |
// if options...
|
120 |
-
if(
|
121 |
{
|
122 |
var a = $('<a class="field_options_button" href="javascript:;"></a>');
|
123 |
td.append(a);
|
@@ -126,27 +124,67 @@ jQuery(document).ready(function($){
|
|
126 |
selected_option.find('[name]').removeAttr('disabled');
|
127 |
|
128 |
a.click(function(){
|
129 |
-
if(
|
130 |
{
|
131 |
-
|
132 |
-
|
133 |
}
|
134 |
else
|
135 |
{
|
136 |
-
|
137 |
-
|
138 |
});
|
139 |
}
|
140 |
|
141 |
-
|
142 |
});
|
|
|
143 |
}
|
144 |
-
|
145 |
}).trigger('change');
|
146 |
-
|
147 |
|
148 |
-
|
|
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
// exists
|
3 |
+
$.fn.exists = function(){return jQuery(this).length>0;}
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
$.fn.make_acf = function()
|
7 |
+
{
|
8 |
+
// vars
|
9 |
+
var fields = $(this); // .fields
|
10 |
+
var add_field = fields.siblings('.table_footer').children('a#add_field');
|
11 |
+
var fields_limit = parseInt(fields.siblings('input[name=fields_limit]').val()) - 1;
|
12 |
+
|
13 |
+
/*-------------------------------------------
|
14 |
+
Add Field Button
|
15 |
+
-------------------------------------------*/
|
16 |
+
add_field.unbind("click").click(function(){
|
17 |
+
|
18 |
+
var total_fields = fields.children('.field').length-1;
|
19 |
+
|
20 |
+
// limit fields
|
21 |
+
if(total_fields >= fields_limit)
|
22 |
+
{
|
23 |
+
alert('Field limit reached!');
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
|
27 |
+
// clone last tr
|
28 |
+
var new_field = fields.children('.field').last().clone(true);
|
29 |
+
|
30 |
+
// reset new field
|
31 |
+
new_field.reset_values();
|
32 |
+
new_field.update_names(total_fields, (total_fields+1));
|
33 |
+
|
34 |
+
// append to table
|
35 |
+
fields.append(new_field);
|
36 |
+
|
37 |
+
// close options
|
38 |
+
new_field.find('select.type').trigger('change');
|
39 |
+
new_field.find('input.label').focus();
|
40 |
+
|
41 |
+
// update order numbers
|
42 |
+
fields.update_order_numbers();
|
43 |
|
|
|
|
|
|
|
|
|
44 |
return false;
|
45 |
+
|
46 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
});
|
48 |
|
|
|
|
|
49 |
|
50 |
+
/*-------------------------------------------
|
51 |
+
Sortable
|
52 |
+
-------------------------------------------*/
|
53 |
+
fields.sortable({
|
54 |
+
update: function(event, ui){fields.update_order_numbers();},
|
55 |
+
handle: 'table'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
|
|
58 |
|
59 |
+
/*-------------------------------------------
|
60 |
+
Auto Fill Name
|
61 |
+
-------------------------------------------*/
|
62 |
+
fields.children('.field').children('table').find('input.label').unbind('blur').blur(function()
|
63 |
{
|
64 |
+
var label = $(this);
|
65 |
+
var name = $(this).parent().siblings('td.name').children('input');
|
66 |
+
|
67 |
+
if(name.val() == '')
|
68 |
{
|
69 |
+
var val = label.val().toLowerCase().split(' ').join('_').split('\'').join('');
|
70 |
+
name.val(val);
|
|
|
71 |
}
|
72 |
});
|
73 |
|
74 |
+
|
75 |
+
/*-------------------------------------------
|
76 |
+
Remove Field Button
|
77 |
+
-------------------------------------------*/
|
78 |
+
fields.children('.field').children('table').find('a.remove_field').unbind('click').click(function()
|
79 |
{
|
80 |
+
// needs at least one
|
81 |
+
if(fields.children('.field').length <= 1)
|
82 |
{
|
83 |
return false;
|
84 |
}
|
85 |
|
86 |
+
var field = $(this).parents('.field').first();
|
87 |
+
field.fadeTo(300,0,function(){
|
88 |
+
field.animate({'height':0}, 300, function(){
|
89 |
+
field.remove();
|
90 |
+
fields.update_order_numbers();
|
91 |
});
|
92 |
});
|
93 |
|
94 |
return false;
|
95 |
});
|
96 |
|
97 |
+
|
98 |
+
/*-------------------------------------------
|
99 |
+
Field Options
|
100 |
+
-------------------------------------------*/
|
101 |
+
fields.children('.field').children('table').find('select.type').change(function()
|
102 |
{
|
|
|
|
|
|
|
103 |
var selected = $(this).val();
|
104 |
+
var td = $(this).parent('td');
|
105 |
+
|
106 |
+
var field = $(this).parents('.field').first();
|
107 |
+
var field_options = field.children('.field_options');
|
108 |
+
var selected_option = field_options.children('.field_option#'+selected);
|
109 |
|
110 |
// remove preivous field option button
|
111 |
+
td.children('a.field_options_button').remove();
|
112 |
+
field.removeClass('options_open');
|
113 |
+
field_options.children('.field_option').hide();
|
114 |
+
field_options.children('.field_option').find('[name]').attr('disabled', 'true');
|
115 |
+
|
116 |
|
117 |
// if options...
|
118 |
+
if(selected_option.exists())
|
119 |
{
|
120 |
var a = $('<a class="field_options_button" href="javascript:;"></a>');
|
121 |
td.append(a);
|
124 |
selected_option.find('[name]').removeAttr('disabled');
|
125 |
|
126 |
a.click(function(){
|
127 |
+
if(!field.is('.options_open'))
|
128 |
{
|
129 |
+
field.addClass('options_open');
|
130 |
+
selected_option.animate({'height':'toggle', 'padding-top':'toggle', 'padding-bottom':'toggle'}, 500);
|
131 |
}
|
132 |
else
|
133 |
{
|
134 |
+
selected_option.animate({'height':'toggle', 'padding-top':'toggle', 'padding-bottom':'toggle'}, 500, function(){
|
135 |
+
field.removeClass('options_open');
|
136 |
});
|
137 |
}
|
138 |
|
139 |
+
selected_option.find('[name]').removeAttr('disabled');
|
140 |
});
|
141 |
+
|
142 |
}
|
|
|
143 |
}).trigger('change');
|
|
|
144 |
|
145 |
+
|
146 |
+
}
|
147 |
|
148 |
+
/*-------------------------------------------
|
149 |
+
Reset Values
|
150 |
+
-------------------------------------------*/
|
151 |
+
$.fn.reset_values = function(){
|
152 |
+
$(this).find('[name]').each(function()
|
153 |
+
{
|
154 |
+
$(this).val('');
|
155 |
+
$(this).attr('checked','');
|
156 |
+
$(this).attr('selected','');
|
157 |
+
});
|
158 |
+
}
|
159 |
+
|
160 |
+
$.fn.update_names = function(old_no, new_no)
|
161 |
+
{
|
162 |
+
//alert('passed through '+total_fields);
|
163 |
+
$(this).find('[name]').each(function()
|
164 |
+
{
|
165 |
+
var name = $(this).attr('name').replace('['+(old_no)+']','['+new_no+']');
|
166 |
+
$(this).attr('name', name);
|
167 |
+
});
|
168 |
+
}
|
169 |
|
170 |
+
|
171 |
+
/*-------------------------------------------
|
172 |
+
Update Orer Numbers
|
173 |
+
-------------------------------------------*/
|
174 |
+
$.fn.update_order_numbers = function(){
|
175 |
+
$(this).children('.field').each(function(i){
|
176 |
+
$(this).children('table').children('tbody').children('tr').children('td.order').html(i+1);
|
177 |
+
});
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
/*-------------------------------------------
|
182 |
+
Document Ready
|
183 |
+
-------------------------------------------*/
|
184 |
+
$(document).ready(function(){
|
185 |
+
$('div.postbox#acf_fields .fields').each(function(){
|
186 |
+
$(this).make_acf();
|
187 |
+
});
|
188 |
+
});
|
189 |
+
|
190 |
+
})(jQuery);
|
js/functions.input.js
CHANGED
@@ -1,31 +1,30 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
// elements
|
6 |
-
var div = $('.postbox#acf_input');
|
7 |
-
var table = div.find('table#acf_input');
|
8 |
-
|
9 |
|
|
|
|
|
|
|
10 |
// add code to tinymce
|
11 |
-
tinyMCE.settings.theme_advanced_buttons1 += ",|,add_image,add_video,add_audio,add_media";
|
12 |
-
tinyMCE.settings.theme_advanced_buttons2 += ",code";
|
13 |
-
|
14 |
|
15 |
-
// create wysiwyg's
|
16 |
-
table.find('.acf_wysiwyg textarea').each(function(i)
|
17 |
-
{
|
18 |
-
// make i start from 1 to match row number
|
19 |
-
var id = 'acf_wysiwyg_'+(i+1);
|
20 |
-
$(this).attr('id',id);
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
tinyMCE.execCommand('mceAddControl', false, id);
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
table.find('.acf_datepicker').each(function()
|
29 |
{
|
30 |
var format = 'dd/mm/yy';
|
31 |
if($(this).siblings('input[name="date_format"]').val() != '')
|
@@ -36,181 +35,441 @@ jQuery(document).ready(function($){
|
|
36 |
$(this).datepicker({
|
37 |
dateFormat: format
|
38 |
});
|
39 |
-
}
|
40 |
-
|
41 |
-
// hide meta boxes
|
42 |
-
|
43 |
-
var screen_options = $('#screen-meta');
|
44 |
-
|
45 |
-
// hide content_editor
|
46 |
-
if(!div.find('input[name=show_the_content]').exists())
|
47 |
-
{
|
48 |
-
$('#postdivrich').hide();
|
49 |
-
}
|
50 |
-
|
51 |
-
// hide custom_fields
|
52 |
-
if(!div.find('input[name=show_custom_fields]').exists())
|
53 |
-
{
|
54 |
-
$('#postcustom').hide();
|
55 |
-
screen_options.find('label[for=postcustom-hide]').hide();
|
56 |
-
}
|
57 |
-
|
58 |
-
// hide discussion
|
59 |
-
if(!div.find('input[name=show_discussion]').exists())
|
60 |
-
{
|
61 |
-
$('#commentstatusdiv').hide();
|
62 |
-
screen_options.find('label[for=commentstatusdiv-hide]').hide();
|
63 |
-
}
|
64 |
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
{
|
68 |
-
$('#
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
function setup_iframes()
|
92 |
-
{
|
93 |
|
94 |
-
// setup images
|
95 |
-
table.find('.acf_image_uploader').each(function(){
|
96 |
-
|
97 |
var div = $(this);
|
98 |
var iframe = div.find('iframe');
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
if(
|
108 |
-
{
|
109 |
-
//alert('null');
|
110 |
-
}
|
111 |
-
else if(result == '0')
|
112 |
{
|
113 |
-
|
114 |
-
|
115 |
}
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
-
div.
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
div.find('iframe').addClass('hide');
|
128 |
-
}
|
129 |
|
130 |
-
div
|
131 |
-
|
132 |
|
|
|
133 |
});
|
|
|
134 |
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
div.find('input[type=hidden]').val('');
|
145 |
-
div.find('img').remove();
|
146 |
-
div.find('iframe').removeClass('hide');
|
147 |
-
$(this).addClass('hide');
|
148 |
|
149 |
-
|
150 |
-
});
|
151 |
-
});
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
156 |
var div = $(this);
|
157 |
var iframe = div.find('iframe');
|
158 |
-
|
159 |
-
iframe
|
160 |
-
|
161 |
-
|
162 |
-
iframe.unbind(
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
if(result == null)
|
167 |
-
{
|
168 |
-
//alert('null');
|
169 |
-
}
|
170 |
-
else if(result == '0')
|
171 |
{
|
172 |
-
|
173 |
-
|
174 |
}
|
175 |
-
else
|
176 |
-
{
|
177 |
-
//alert(result);
|
178 |
-
div.children('input[type=hidden]').attr('value',result);
|
179 |
-
|
180 |
-
div.append('<span>'+result+'</span>');
|
181 |
-
div.children('a.remove_file').removeClass('hide');
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
|
187 |
-
|
188 |
-
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
-
// send image
|
193 |
-
iframe.contents().find('form').submit();
|
194 |
|
195 |
-
// add loading div
|
196 |
-
div.append('<div class="loading"></div>');
|
197 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
{
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
205 |
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
});
|
208 |
-
|
|
|
|
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
}
|
211 |
|
212 |
-
setup_iframes();
|
213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
-
|
216 |
-
});
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
// exists
|
4 |
+
$.fn.exists = function(){return jQuery(this).length>0;}
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
// vars
|
7 |
+
var wysiwyg_count = 0;
|
8 |
+
|
9 |
// add code to tinymce
|
|
|
|
|
|
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
/*-------------------------------------------
|
13 |
+
Wysiwyg
|
14 |
+
-------------------------------------------*/
|
15 |
+
$.fn.make_acf_wysiwyg = function()
|
16 |
+
{
|
17 |
+
wysiwyg_count++;
|
18 |
+
var id = 'acf_wysiwyg_'+wysiwyg_count;
|
19 |
+
//alert(id);
|
20 |
+
$(this).find('textarea').attr('id',id);
|
21 |
tinyMCE.execCommand('mceAddControl', false, id);
|
22 |
+
}
|
23 |
|
24 |
+
/*-------------------------------------------
|
25 |
+
Datepicker
|
26 |
+
-------------------------------------------*/
|
27 |
+
$.fn.make_acf_datepicker = function()
|
|
|
28 |
{
|
29 |
var format = 'dd/mm/yy';
|
30 |
if($(this).siblings('input[name="date_format"]').val() != '')
|
35 |
$(this).datepicker({
|
36 |
dateFormat: format
|
37 |
});
|
38 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
+
/*-------------------------------------------
|
41 |
+
Hide Meta Boxes
|
42 |
+
-------------------------------------------*/
|
43 |
+
$.fn.hide_meta_boxes = function()
|
44 |
{
|
45 |
+
var screen_options = $('#screen-meta');
|
46 |
+
var div = $(this);
|
47 |
+
|
48 |
+
// hide content_editor
|
49 |
+
if(!div.find('input[name=show_the_content]').exists())
|
50 |
+
{
|
51 |
+
$('#postdivrich').hide();
|
52 |
+
}
|
53 |
+
|
54 |
+
// hide custom_fields
|
55 |
+
if(!div.find('input[name=show_custom_fields]').exists())
|
56 |
+
{
|
57 |
+
$('#postcustom').hide();
|
58 |
+
screen_options.find('label[for=postcustom-hide]').hide();
|
59 |
+
}
|
60 |
+
|
61 |
+
// hide discussion
|
62 |
+
if(!div.find('input[name=show_discussion]').exists())
|
63 |
+
{
|
64 |
+
$('#commentstatusdiv').hide();
|
65 |
+
screen_options.find('label[for=commentstatusdiv-hide]').hide();
|
66 |
+
}
|
67 |
+
|
68 |
+
// hide comments
|
69 |
+
if(!div.find('input[name=show_comments]').exists())
|
70 |
+
{
|
71 |
+
$('#commentsdiv').hide();
|
72 |
+
screen_options.find('label[for=commentsdiv-hide]').hide();
|
73 |
+
}
|
74 |
+
|
75 |
+
// hide slug
|
76 |
+
if(!div.find('input[name=show_slug]').exists())
|
77 |
+
{
|
78 |
+
$('#slugdiv').hide();
|
79 |
+
screen_options.find('label[for=slugdiv-hide]').hide();
|
80 |
+
}
|
81 |
+
|
82 |
+
// hide author
|
83 |
+
if(!div.find('input[name=show_author]').exists())
|
84 |
+
{
|
85 |
+
$('#authordiv').hide();
|
86 |
+
screen_options.find('label[for=authordiv-hide]').hide();
|
87 |
+
}
|
88 |
+
|
89 |
+
screen_options.find('label[for=acf_input-hide]').hide();
|
90 |
}
|
91 |
|
92 |
+
/*-------------------------------------------
|
93 |
+
Image Upload
|
94 |
+
-------------------------------------------*/
|
95 |
+
$.fn.make_acf_image = function(){
|
|
|
|
|
|
|
96 |
|
|
|
|
|
|
|
97 |
var div = $(this);
|
98 |
var iframe = div.find('iframe');
|
99 |
+
|
100 |
+
|
101 |
+
// can only add functions to the iframe if its loaded
|
102 |
+
iframe.load(function(){
|
103 |
+
|
104 |
+
iframe.contents().find('form').unbind('submit').submit(function(){
|
105 |
+
|
106 |
+
// if value is empty, return faslse and stop it from uploading!
|
107 |
+
if(iframe.contents().find('input[type="file"]').val() == '')
|
|
|
|
|
|
|
|
|
108 |
{
|
109 |
+
alert('No Image chosen');
|
110 |
+
return false;
|
111 |
}
|
112 |
+
|
113 |
+
// set up load event
|
114 |
+
iframe.unbind("load").load(function(){
|
115 |
+
|
116 |
+
var result = $(this).contents().find('body .result').html();
|
117 |
+
|
118 |
+
if(result == null)
|
119 |
+
{
|
120 |
+
//alert('null');
|
121 |
+
}
|
122 |
+
else if(result == '0')
|
123 |
+
{
|
124 |
+
//alert('0');
|
125 |
+
//window.history.back();
|
126 |
+
}
|
127 |
+
else
|
128 |
+
{
|
129 |
+
//alert(result);
|
130 |
+
div.children('input[type=hidden]').attr('value',result);
|
131 |
+
|
132 |
+
div.append('<img src="'+result+'" width="100" height="100" />');
|
133 |
+
div.find('img').hide().load(function(){
|
134 |
+
$(this).fadeIn(500);
|
135 |
+
div.children('a.remove_image').removeClass('hide');
|
136 |
+
});
|
137 |
+
//iframe.history.back();
|
138 |
+
div.find('iframe').addClass('hide');
|
139 |
+
}
|
140 |
|
141 |
+
div.find('.loading').remove();
|
142 |
+
|
143 |
+
});
|
144 |
+
|
145 |
+
// send image
|
146 |
+
//iframe.contents().find('form').submit();
|
|
|
|
|
147 |
|
148 |
+
// add loading div
|
149 |
+
div.append('<div class="loading"></div>');
|
150 |
|
151 |
+
return true;
|
152 |
});
|
153 |
+
// end form.submit
|
154 |
|
155 |
+
div.find('a.remove_image').unbind('click').click(function()
|
156 |
+
{
|
157 |
+
div.find('input[type=hidden]').val('');
|
158 |
+
div.find('img').remove();
|
159 |
+
div.find('iframe').removeClass('hide');
|
160 |
+
$(this).addClass('hide');
|
161 |
|
162 |
+
return false;
|
163 |
+
});
|
164 |
+
// end a.remove_image.click
|
165 |
+
|
166 |
+
}).trigger('load');
|
167 |
+
// end iframe.load
|
|
|
|
|
|
|
|
|
168 |
|
169 |
+
}
|
|
|
|
|
170 |
|
171 |
+
/*-------------------------------------------
|
172 |
+
File Upload
|
173 |
+
-------------------------------------------*/
|
174 |
+
$.fn.make_acf_file = function(){
|
175 |
var div = $(this);
|
176 |
var iframe = div.find('iframe');
|
177 |
+
|
178 |
+
// can only add functions to the iframe if its loaded
|
179 |
+
iframe.load(function(){
|
180 |
+
|
181 |
+
iframe.contents().find('form').unbind('submit').submit(function(){
|
182 |
+
|
183 |
+
// if value is empty, return faslse and stop it from uploading!
|
184 |
+
if(iframe.contents().find('input[type="file"]').val() == '')
|
|
|
|
|
|
|
|
|
|
|
185 |
{
|
186 |
+
alert('No File chosen');
|
187 |
+
return false;
|
188 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
|
190 |
+
// set up load event
|
191 |
+
iframe.unbind("load").load(function(){
|
192 |
+
|
193 |
+
var result = $(this).contents().find('body .result').html();
|
194 |
+
|
195 |
+
if(result == null)
|
196 |
+
{
|
197 |
+
//alert('null');
|
198 |
+
}
|
199 |
+
else if(result == '0')
|
200 |
+
{
|
201 |
+
//alert('0');
|
202 |
+
//window.history.back();
|
203 |
+
}
|
204 |
+
else
|
205 |
+
{
|
206 |
+
//alert(result);
|
207 |
+
div.children('input[type=hidden]').attr('value',result);
|
208 |
+
|
209 |
+
div.append('<span>'+result+'</span>');
|
210 |
+
div.children('a.remove_file').removeClass('hide');
|
211 |
+
|
212 |
+
//iframe.history.back();
|
213 |
+
div.find('iframe').addClass('hide');
|
214 |
+
}
|
215 |
+
|
216 |
+
div.find('.loading').remove();
|
217 |
+
|
218 |
+
});
|
219 |
|
220 |
+
// send image
|
221 |
+
//iframe.contents().find('form').submit();
|
222 |
|
223 |
+
// add loading div
|
224 |
+
div.append('<div class="loading"></div>');
|
225 |
+
|
226 |
+
return true;
|
227 |
+
});
|
228 |
+
|
229 |
+
div.find('a.remove_file').unbind('click').click(function()
|
230 |
+
{
|
231 |
+
div.find('input[type=hidden]').val('');
|
232 |
+
div.find('span').remove();
|
233 |
+
div.find('iframe').removeClass('hide');
|
234 |
+
$(this).addClass('hide');
|
235 |
+
|
236 |
+
return false;
|
237 |
});
|
238 |
+
// end a.remove_file.click
|
239 |
+
|
240 |
+
}).trigger('load');
|
241 |
+
// end iframe.load
|
242 |
+
}
|
243 |
+
|
244 |
+
/*-------------------------------------------
|
245 |
+
Repeaters
|
246 |
+
-------------------------------------------*/
|
247 |
+
$.fn.make_acf_repeater = function(){
|
248 |
+
|
249 |
+
// vars
|
250 |
+
var div = $(this);
|
251 |
+
var add_field = div.find('a#add_field');
|
252 |
+
var fields_limit = 99;
|
253 |
+
|
254 |
+
|
255 |
+
/*-------------------------------------------
|
256 |
+
Add Field Button
|
257 |
+
-------------------------------------------*/
|
258 |
+
add_field.unbind("click").click(function(){
|
259 |
+
|
260 |
+
// limit fields
|
261 |
+
if(div.children('table').children('tbody').children('tr').length >= fields_limit)
|
262 |
+
{
|
263 |
+
alert('Field limit reached!');
|
264 |
+
return false;
|
265 |
+
}
|
266 |
+
|
267 |
+
// clone last tr
|
268 |
+
var new_field = div.children('table').children('tbody').children('tr').last().clone();
|
269 |
+
|
270 |
+
// append to table
|
271 |
+
div.children('table').children('tbody').append(new_field);
|
272 |
+
|
273 |
+
// set new field
|
274 |
+
new_field.reset_values();
|
275 |
+
|
276 |
+
// re make special fields
|
277 |
+
new_field.make_all_fields();
|
278 |
+
|
279 |
+
// update order numbers
|
280 |
+
update_order_numbers();
|
281 |
+
|
282 |
+
|
283 |
+
return false;
|
284 |
|
|
|
|
|
285 |
|
|
|
|
|
286 |
});
|
287 |
+
}
|
288 |
+
|
289 |
+
|
290 |
+
/*-------------------------------------------
|
291 |
+
Update Order Numbers
|
292 |
+
-------------------------------------------*/
|
293 |
+
function update_order_numbers(){
|
294 |
+
$('.postbox#acf_input .repeater').each(function(){
|
295 |
+
$(this).children('table').children('tbody').children('tr').each(function(i){
|
296 |
+
$(this).children('td.order').html(i+1);
|
297 |
+
});
|
298 |
+
|
299 |
+
});
|
300 |
+
}
|
301 |
+
|
302 |
+
/*-------------------------------------------
|
303 |
+
Sortable
|
304 |
+
-------------------------------------------*/
|
305 |
+
$.fn.make_sortable = function(){
|
306 |
+
|
307 |
+
//alert('make sortable');
|
308 |
+
var div = $(this).find('.repeater');
|
309 |
|
310 |
+
var fixHelper = function(e, ui) {
|
311 |
+
ui.children().each(function() {
|
312 |
+
$(this).width($(this).width());
|
313 |
+
});
|
314 |
+
return ui;
|
315 |
+
};
|
316 |
+
|
317 |
+
div.find('table.acf_input').children('tbody').unbind('sortable').sortable({
|
318 |
+
update: function(event, ui){
|
319 |
+
update_order_numbers();
|
320 |
+
$(this).make_all_fields();
|
321 |
+
//alert('update');
|
322 |
+
},
|
323 |
+
handle: 'td.order',
|
324 |
+
helper: fixHelper,
|
325 |
+
//pre process stuff as soon as the element has been lifted
|
326 |
+
start: function(event, ui)
|
327 |
+
{
|
328 |
+
console.log(ui.item);
|
329 |
+
if(ui.item.find('.acf_wysiwyg').exists())
|
330 |
+
{
|
331 |
+
//console.log('aaaah, i found a wysiwyg')
|
332 |
+
var id = ui.item.find('.acf_wysiwyg textarea').attr('id');
|
333 |
+
//alert(tinyMCE.get(id).getContent());
|
334 |
+
//tinyMCE.execCommand("mceRemoveControl", false, id);
|
335 |
+
}
|
336 |
+
},
|
337 |
+
|
338 |
+
//post process stuff as soon as the element has been dropped
|
339 |
+
stop: function(event, ui)
|
340 |
+
{
|
341 |
+
if(ui.item.find('.acf_wysiwyg').exists())
|
342 |
+
{
|
343 |
+
//var id = ui.item.find('.acf_wysiwyg textarea').attr('id');
|
344 |
+
//tinyMCE.execCommand("mceAddControl", false, id);
|
345 |
+
//div.make_sortable();
|
346 |
+
}
|
347 |
+
}
|
348 |
+
});
|
349 |
+
}
|
350 |
+
|
351 |
+
|
352 |
+
|
353 |
+
/*-------------------------------------------
|
354 |
+
Reset Values
|
355 |
+
-------------------------------------------*/
|
356 |
+
$.fn.reset_values = function(){
|
357 |
+
|
358 |
+
if($(this).find('.acf_wysiwyg').exists())
|
359 |
{
|
360 |
+
var wysiwyg = $(this).find('.acf_wysiwyg');
|
361 |
+
|
362 |
+
var name = wysiwyg.find('textarea').first().attr('name');
|
363 |
+
|
364 |
+
wysiwyg.html('<textarea name="'+name+'"></textarea>');
|
365 |
+
}
|
366 |
|
367 |
+
|
368 |
+
// image upload
|
369 |
+
$(this).find('img').remove();
|
370 |
+
$(this).find('a.remove_image').addClass('hide');
|
371 |
+
$(this).find('iframe').removeClass('hide');
|
372 |
+
|
373 |
+
|
374 |
+
// total fields
|
375 |
+
var total_fields = $(this).siblings('tr').length;
|
376 |
+
|
377 |
+
|
378 |
+
// reset all values
|
379 |
+
$(this).find('[name]').each(function()
|
380 |
+
{
|
381 |
+
var name = $(this).attr('name').replace('['+(total_fields-1)+']','['+(total_fields)+']');
|
382 |
+
$(this).attr('name', name);
|
383 |
+
$(this).val('');
|
384 |
+
$(this).attr('checked','');
|
385 |
+
$(this).attr('selected','');
|
386 |
});
|
387 |
+
|
388 |
+
|
389 |
+
}
|
390 |
|
391 |
+
$.fn.make_all_fields = function()
|
392 |
+
{
|
393 |
+
var div = $(this);
|
394 |
+
|
395 |
+
// wysiwyg
|
396 |
+
div.find('.acf_wysiwyg').each(function(){
|
397 |
+
$(this).make_acf_wysiwyg();
|
398 |
+
});
|
399 |
+
|
400 |
+
// datepicker
|
401 |
+
div.find('.acf_datepicker').each(function(){
|
402 |
+
$(this).make_acf_datepicker();
|
403 |
+
});
|
404 |
+
|
405 |
+
// image
|
406 |
+
div.find('.acf_image_uploader').each(function(){
|
407 |
+
$(this).make_acf_image();
|
408 |
+
});
|
409 |
+
|
410 |
+
// file
|
411 |
+
div.find('.acf_file_uploader').each(function(){
|
412 |
+
$(this).make_acf_file();
|
413 |
+
});
|
414 |
}
|
415 |
|
|
|
416 |
|
417 |
+
/*-------------------------------------------
|
418 |
+
Remove Field Button
|
419 |
+
-------------------------------------------*/
|
420 |
+
$.fn.add_remove_buttons = function(){
|
421 |
+
$(this).find('a.remove_field').unbind('click').live('click', function(){
|
422 |
+
|
423 |
+
var total_fields = $(this).parents('.repeater').children('table').children('tbody').children('tr').length;
|
424 |
+
|
425 |
+
// needs at least one
|
426 |
+
if(total_fields <= 1)
|
427 |
+
{
|
428 |
+
return false;
|
429 |
+
}
|
430 |
+
|
431 |
+
var tr = $(this).parents('tr').first();
|
432 |
+
console.log('s');
|
433 |
+
tr.fadeTo(300,0,function(){
|
434 |
+
tr.animate({'height':0}, 300, function(){
|
435 |
+
tr.remove();
|
436 |
+
update_order_numbers();
|
437 |
+
});
|
438 |
+
});
|
439 |
+
|
440 |
+
return false;
|
441 |
+
|
442 |
+
});
|
443 |
+
}
|
444 |
+
|
445 |
+
|
446 |
+
|
447 |
+
|
448 |
+
/*-------------------------------------------
|
449 |
+
Document Ready
|
450 |
+
-------------------------------------------*/
|
451 |
+
$(document).ready(function(){
|
452 |
+
|
453 |
+
var div = $('.postbox#acf_input');
|
454 |
+
|
455 |
+
tinyMCE.settings.theme_advanced_buttons1 += ",|,add_image,add_video,add_audio,add_media";
|
456 |
+
tinyMCE.settings.theme_advanced_buttons2 += ",code";
|
457 |
+
|
458 |
+
// hide meta boxes
|
459 |
+
div.hide_meta_boxes();
|
460 |
+
|
461 |
+
div.make_all_fields();
|
462 |
+
|
463 |
+
div.make_sortable();
|
464 |
+
|
465 |
+
div.add_remove_buttons();
|
466 |
+
|
467 |
+
// repeater
|
468 |
+
div.find('.repeater').each(function(){
|
469 |
+
$(this).make_acf_repeater();
|
470 |
+
});
|
471 |
+
|
472 |
+
|
473 |
+
});
|
474 |
|
475 |
+
})(jQuery);
|
|
readme.txt
CHANGED
@@ -13,7 +13,7 @@ Completely Customise your edit pages with an assortment of field types: Wysiwyg,
|
|
13 |
Advanced Custom Fields is the perfect solution for any wordpress website which needs more flexible data like other Content Management Systems.
|
14 |
|
15 |
* Visually create your Fields
|
16 |
-
* Select from multiple input types (text, textarea, wysiwyg, image,
|
17 |
* Assign your fields to multiple edit pages (specific ID's, post types, post slugs, parent ID's, template names)
|
18 |
* Add, Edit and reorder infinite rows to your fields
|
19 |
* Easily load data through a simple and friendly API
|
@@ -43,7 +43,7 @@ http://plugins.elliotcondon.com/advanced-custom-fields/user-guide/
|
|
43 |
= Website =
|
44 |
http://plugins.elliotcondon.com/advanced-custom-fields/
|
45 |
|
46 |
-
= Forum Support =
|
47 |
http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
|
48 |
|
49 |
= Please Vote and Enjoy =
|
@@ -61,12 +61,25 @@ http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
|
|
61 |
|
62 |
|
63 |
== Screenshots ==
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
|
68 |
== Changelog ==
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
= 1.0.2 =
|
71 |
* Bug Fix: Stopped Field Options from loosing data
|
72 |
* Bug Fix: API will now work with looped posts
|
13 |
Advanced Custom Fields is the perfect solution for any wordpress website which needs more flexible data like other Content Management Systems.
|
14 |
|
15 |
* Visually create your Fields
|
16 |
+
* Select from multiple input types (text, textarea, wysiwyg, image upload, page link, select, checkbox, more to come)
|
17 |
* Assign your fields to multiple edit pages (specific ID's, post types, post slugs, parent ID's, template names)
|
18 |
* Add, Edit and reorder infinite rows to your fields
|
19 |
* Easily load data through a simple and friendly API
|
43 |
= Website =
|
44 |
http://plugins.elliotcondon.com/advanced-custom-fields/
|
45 |
|
46 |
+
= Bug Submission and Forum Support =
|
47 |
http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
|
48 |
|
49 |
= Please Vote and Enjoy =
|
61 |
|
62 |
|
63 |
== Screenshots ==
|
64 |
+
1. Creating the Advanced Custom Fields
|
65 |
+
|
66 |
+
2. Adding the Custom Fields to a page and hiding the default meta boxes
|
67 |
+
|
68 |
+
3. The Page edit screen after creating the Advanced Custom Fields
|
69 |
+
|
70 |
+
4. Simple and intuitive API. Read the documentation at: http://plugins.elliotcondon.com/advanced-custom-fields/code-examples/
|
71 |
|
72 |
|
73 |
== Changelog ==
|
74 |
|
75 |
+
= 1.0.3 =
|
76 |
+
* Heaps of js bug fixes
|
77 |
+
* API will now work with looped posts
|
78 |
+
* Date Picker returns the correct value
|
79 |
+
* Added Post type option to Page Link Field
|
80 |
+
* Fixed Image + File Uploads!
|
81 |
+
* Lots of tidying up!
|
82 |
+
|
83 |
= 1.0.2 =
|
84 |
* Bug Fix: Stopped Field Options from loosing data
|
85 |
* Bug Fix: API will now work with looped posts
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
screenshot-3.png
ADDED
Binary file
|
screenshot-4.png
ADDED
Binary file
|