Version Description
- New Addon: Options Page (available on the plugins store: http://plugins.elliotcondon.com/shop/)
- API: all functions now accept 'options' as a second parameter to target the options page
- API: the_field() now implodes array's and returns as a string separated by comma's
- Fixed Bug: Image upload should now work on post types without editor
- Fixed Bug: Location rule now returns true if page_template is set to 'Default' and a new page is created
- General Housekeeping
Download this release
Release Info
Developer | elliotcondon |
Plugin | Advanced Custom Fields |
Version | 2.0.4 |
Comparing to | |
See all releases |
Code changes from version 2.0.3 to 2.0.4
- acf.php +94 -5
- core/admin_head.php +41 -5
- core/api.php +22 -2
- core/fields/file.php +0 -18
- core/fields/image.php +1 -20
- core/fields/page_link.php +1 -1
- core/input_meta_box.php +2 -1
- core/input_save.php +2 -2
- core/location_meta_box.php +22 -1
- core/options_page.php +416 -0
- core/screen_extra.php +39 -0
- css/style.screen_extra.css +16 -6
- js/functions.input.js +11 -3
- js/functions.location.js +10 -0
- js/functions.screen_extra.js +10 -5
- readme.txt +8 -0
acf.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://plugins.elliotcondon.com/advanced-custom-fields/
|
5 |
-
Description:
|
6 |
-
Version: 2.0.
|
7 |
Author: Elliot Condon
|
8 |
Author URI: http://www.elliotcondon.com/
|
9 |
License: GPL
|
@@ -13,9 +13,16 @@ Copyright: Elliot Condon
|
|
13 |
//ini_set('display_errors',1);
|
14 |
//error_reporting(E_ALL|E_STRICT);
|
15 |
|
|
|
|
|
|
|
|
|
16 |
$acf = new Acf();
|
|
|
|
|
17 |
include('core/api.php');
|
18 |
|
|
|
19 |
class Acf
|
20 |
{
|
21 |
var $name;
|
@@ -26,6 +33,7 @@ class Acf
|
|
26 |
var $version;
|
27 |
var $fields;
|
28 |
var $activated_fields;
|
|
|
29 |
|
30 |
function Acf()
|
31 |
{
|
@@ -36,8 +44,9 @@ class Acf
|
|
36 |
$this->dir = plugins_url('',__FILE__);
|
37 |
$this->siteurl = get_bloginfo('url');
|
38 |
$this->wpadminurl = admin_url();
|
39 |
-
$this->version = '2.0.
|
40 |
$this->activated_fields = $this->get_activated_fields();
|
|
|
41 |
|
42 |
|
43 |
// set text domain
|
@@ -83,6 +92,7 @@ class Acf
|
|
83 |
{
|
84 |
include('core/update.php');
|
85 |
}
|
|
|
86 |
|
87 |
/*---------------------------------------------------------------------------------------------
|
88 |
* Init
|
@@ -103,9 +113,23 @@ class Acf
|
|
103 |
$parts = Explode('/', $currentFile);
|
104 |
$currentFile = $parts[count($parts) - 1];
|
105 |
|
106 |
-
|
|
|
107 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
wp_enqueue_script('thickbox');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
}
|
111 |
|
@@ -115,7 +139,7 @@ class Acf
|
|
115 |
$parts = Explode('/', $currentFile);
|
116 |
$currentFile = $parts[count($parts) - 1];
|
117 |
|
118 |
-
if($currentFile == '
|
119 |
{
|
120 |
wp_enqueue_style('thickbox');
|
121 |
}
|
@@ -608,6 +632,28 @@ class Acf
|
|
608 |
// return value
|
609 |
return $value;
|
610 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
611 |
|
612 |
|
613 |
|
@@ -680,6 +726,17 @@ class Acf
|
|
680 |
}
|
681 |
}
|
682 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
683 |
return $activated;
|
684 |
}
|
685 |
|
@@ -813,6 +870,12 @@ class Acf
|
|
813 |
return true;
|
814 |
}
|
815 |
|
|
|
|
|
|
|
|
|
|
|
|
|
816 |
return false;
|
817 |
}
|
818 |
elseif($rule->operator == "!=")
|
@@ -939,6 +1002,32 @@ class Acf
|
|
939 |
}
|
940 |
|
941 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
942 |
|
943 |
}
|
944 |
}
|
2 |
/*
|
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, Repeater, text, textarea, image, file, select, checkbox post type, page link and more! Hide unwanted metaboxes and assign to any edit page!
|
6 |
+
Version: 2.0.4
|
7 |
Author: Elliot Condon
|
8 |
Author URI: http://www.elliotcondon.com/
|
9 |
License: GPL
|
13 |
//ini_set('display_errors',1);
|
14 |
//error_reporting(E_ALL|E_STRICT);
|
15 |
|
16 |
+
|
17 |
+
include('core/options_page.php');
|
18 |
+
|
19 |
+
|
20 |
$acf = new Acf();
|
21 |
+
|
22 |
+
|
23 |
include('core/api.php');
|
24 |
|
25 |
+
|
26 |
class Acf
|
27 |
{
|
28 |
var $name;
|
33 |
var $version;
|
34 |
var $fields;
|
35 |
var $activated_fields;
|
36 |
+
var $options_page;
|
37 |
|
38 |
function Acf()
|
39 |
{
|
44 |
$this->dir = plugins_url('',__FILE__);
|
45 |
$this->siteurl = get_bloginfo('url');
|
46 |
$this->wpadminurl = admin_url();
|
47 |
+
$this->version = '2.0.4';
|
48 |
$this->activated_fields = $this->get_activated_fields();
|
49 |
+
$this->options_page = new Acf_options_page($this);
|
50 |
|
51 |
|
52 |
// set text domain
|
92 |
{
|
93 |
include('core/update.php');
|
94 |
}
|
95 |
+
|
96 |
|
97 |
/*---------------------------------------------------------------------------------------------
|
98 |
* Init
|
113 |
$parts = Explode('/', $currentFile);
|
114 |
$currentFile = $parts[count($parts) - 1];
|
115 |
|
116 |
+
|
117 |
+
if($currentFile == 'post.php' || $currentFile == 'post-new.php' || $currentFile == 'edit.php')
|
118 |
{
|
119 |
+
wp_enqueue_script('jquery');
|
120 |
+
wp_enqueue_script('jquery-ui-core');
|
121 |
+
|
122 |
+
|
123 |
+
// wysiwyg
|
124 |
+
wp_enqueue_script('media-upload');
|
125 |
wp_enqueue_script('thickbox');
|
126 |
+
wp_enqueue_script('word-count');
|
127 |
+
wp_enqueue_script('post');
|
128 |
+
wp_enqueue_script('editor');
|
129 |
+
|
130 |
+
|
131 |
+
// repeater
|
132 |
+
wp_enqueue_script('jquery-ui-sortable');
|
133 |
}
|
134 |
}
|
135 |
|
139 |
$parts = Explode('/', $currentFile);
|
140 |
$currentFile = $parts[count($parts) - 1];
|
141 |
|
142 |
+
if($currentFile == 'post.php' || $currentFile == 'post-new.php' || $currentFile == 'edit.php')
|
143 |
{
|
144 |
wp_enqueue_style('thickbox');
|
145 |
}
|
632 |
// return value
|
633 |
return $value;
|
634 |
}
|
635 |
+
|
636 |
+
|
637 |
+
/*---------------------------------------------------------------------------------------------
|
638 |
+
* load_value_id_input
|
639 |
+
*
|
640 |
+
* @author Elliot Condon
|
641 |
+
* @since 2.0.4
|
642 |
+
*
|
643 |
+
---------------------------------------------------------------------------------------------*/
|
644 |
+
|
645 |
+
function load_value_id_input($post_id, $field)
|
646 |
+
{
|
647 |
+
// set table name
|
648 |
+
global $wpdb;
|
649 |
+
$table_name = $wpdb->prefix.'acf_values';
|
650 |
+
|
651 |
+
|
652 |
+
// get row
|
653 |
+
$value = $wpdb->get_var("SELECT id FROM $table_name WHERE field_id = '$field->id' AND post_id = '$post_id'");
|
654 |
+
|
655 |
+
return $value;
|
656 |
+
}
|
657 |
|
658 |
|
659 |
|
726 |
}
|
727 |
}
|
728 |
|
729 |
+
|
730 |
+
// options
|
731 |
+
if(get_option("acf_options_page_ac"))
|
732 |
+
{
|
733 |
+
$md5 = md5(get_option("acf_options_page_ac"));
|
734 |
+
if($md5 == "1fc8b993548891dc2b9a63ac057935d8")
|
735 |
+
{
|
736 |
+
$activated['options_page'] = get_option("acf_options_page_ac");
|
737 |
+
}
|
738 |
+
}
|
739 |
+
|
740 |
return $activated;
|
741 |
}
|
742 |
|
870 |
return true;
|
871 |
}
|
872 |
|
873 |
+
if($rule->value == "default" && !get_post_meta($post->ID,'_wp_page_template',true))
|
874 |
+
{
|
875 |
+
return true;
|
876 |
+
}
|
877 |
+
|
878 |
+
|
879 |
return false;
|
880 |
}
|
881 |
elseif($rule->operator == "!=")
|
1002 |
}
|
1003 |
|
1004 |
break;
|
1005 |
+
|
1006 |
+
// Options Page
|
1007 |
+
case "options_page":
|
1008 |
+
|
1009 |
+
|
1010 |
+
if($rule->operator == "==")
|
1011 |
+
{
|
1012 |
+
if(get_admin_page_title() == $rule->value)
|
1013 |
+
{
|
1014 |
+
return true;
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
return false;
|
1018 |
+
}
|
1019 |
+
elseif($rule->operator == "!=")
|
1020 |
+
{
|
1021 |
+
if(get_admin_page_title() != $rule->value)
|
1022 |
+
{
|
1023 |
+
return true;
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
return false;
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
break;
|
1030 |
+
|
1031 |
|
1032 |
}
|
1033 |
}
|
core/admin_head.php
CHANGED
@@ -16,11 +16,20 @@ if(isset($_POST['acf_field_deactivate']))
|
|
16 |
$this->fields = $this->_get_field_types();
|
17 |
|
18 |
global $acf_message_field;
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
function my_admin_notice(){
|
22 |
global $acf_message_field;
|
23 |
-
echo '<div class="updated below-h2" id="message"><p>'.$acf_message_field.'
|
24 |
}
|
25 |
add_action('admin_notices', 'my_admin_notice');
|
26 |
|
@@ -44,7 +53,15 @@ if(isset($_POST['acf_field_activate']))
|
|
44 |
$new_count = count($this->activated_fields);
|
45 |
|
46 |
global $acf_message_field;
|
47 |
-
$acf_message_field =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
if($new_count == $old_count)
|
50 |
{
|
@@ -58,10 +75,16 @@ if(isset($_POST['acf_field_activate']))
|
|
58 |
{
|
59 |
function my_admin_notice(){
|
60 |
global $acf_message_field;
|
61 |
-
echo '<div class="updated below-h2" id="message"><p>'.$acf_message_field.'
|
62 |
}
|
63 |
add_action('admin_notices', 'my_admin_notice',$m);
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
|
@@ -69,7 +92,16 @@ if(isset($_POST['acf_field_activate']))
|
|
69 |
}
|
70 |
|
71 |
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
|
75 |
|
@@ -82,6 +114,10 @@ $currentFile = $parts[count($parts) - 1];
|
|
82 |
// only add html to post.php and post-new.php pages
|
83 |
if($currentFile == 'post.php' || $currentFile == 'post-new.php')
|
84 |
{
|
|
|
|
|
|
|
|
|
85 |
|
86 |
if(get_post_type($post) == 'acf')
|
87 |
{
|
16 |
$this->fields = $this->_get_field_types();
|
17 |
|
18 |
global $acf_message_field;
|
19 |
+
|
20 |
+
$acf_message_field = "";
|
21 |
+
if($field == "repeater")
|
22 |
+
{
|
23 |
+
$acf_message_field = "Repeater Field";
|
24 |
+
}
|
25 |
+
elseif($field == "options_page")
|
26 |
+
{
|
27 |
+
$acf_message_field = "Options Page";
|
28 |
+
}
|
29 |
|
30 |
function my_admin_notice(){
|
31 |
global $acf_message_field;
|
32 |
+
echo '<div class="updated below-h2" id="message"><p>'.$acf_message_field.' deactivated</p></div>';
|
33 |
}
|
34 |
add_action('admin_notices', 'my_admin_notice');
|
35 |
|
53 |
$new_count = count($this->activated_fields);
|
54 |
|
55 |
global $acf_message_field;
|
56 |
+
$acf_message_field = "";
|
57 |
+
if($field == "repeater")
|
58 |
+
{
|
59 |
+
$acf_message_field = "Repeater Field";
|
60 |
+
}
|
61 |
+
elseif($field == "options_page")
|
62 |
+
{
|
63 |
+
$acf_message_field = "Options Page";
|
64 |
+
}
|
65 |
|
66 |
if($new_count == $old_count)
|
67 |
{
|
75 |
{
|
76 |
function my_admin_notice(){
|
77 |
global $acf_message_field;
|
78 |
+
echo '<div class="updated below-h2" id="message"><p>'.$acf_message_field.' activated</p></div>';
|
79 |
}
|
80 |
add_action('admin_notices', 'my_admin_notice',$m);
|
81 |
|
82 |
+
|
83 |
+
// re make the optiosn page object
|
84 |
+
if($field == "options_page")
|
85 |
+
{
|
86 |
+
|
87 |
+
}
|
88 |
}
|
89 |
|
90 |
|
92 |
}
|
93 |
|
94 |
|
95 |
+
if(!array_key_exists('options_page', $this->activated_fields))
|
96 |
+
{
|
97 |
+
?>
|
98 |
+
<style type="text/css">
|
99 |
+
#adminmenu li.menu-top#toplevel_page_acf-options {
|
100 |
+
display: none;
|
101 |
+
}
|
102 |
+
</style>
|
103 |
+
<?php
|
104 |
+
}
|
105 |
|
106 |
|
107 |
|
114 |
// only add html to post.php and post-new.php pages
|
115 |
if($currentFile == 'post.php' || $currentFile == 'post-new.php')
|
116 |
{
|
117 |
+
|
118 |
+
// create tyn mce instance for wysiwyg
|
119 |
+
wp_tiny_mce();
|
120 |
+
|
121 |
|
122 |
if(get_post_type($post) == 'acf')
|
123 |
{
|
core/api.php
CHANGED
@@ -61,6 +61,10 @@ function get_acf($post_id = false)
|
|
61 |
{
|
62 |
$post_id = $post->ID;
|
63 |
}
|
|
|
|
|
|
|
|
|
64 |
|
65 |
|
66 |
global $wpdb;
|
@@ -181,7 +185,16 @@ function get_field($field_name, $post_id = false)
|
|
181 |
function the_field($field_name, $post_id = false)
|
182 |
{
|
183 |
//echo 'field name: '.$field_name.', post id: '.$post_id;
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
}
|
186 |
|
187 |
|
@@ -242,7 +255,14 @@ function get_sub_field($field_name, $field = false)
|
|
242 |
// get sub field
|
243 |
function the_sub_field($field_name, $field = false)
|
244 |
{
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
}
|
247 |
|
248 |
|
61 |
{
|
62 |
$post_id = $post->ID;
|
63 |
}
|
64 |
+
elseif($post_id == "options")
|
65 |
+
{
|
66 |
+
$post_id = 0;
|
67 |
+
}
|
68 |
|
69 |
|
70 |
global $wpdb;
|
185 |
function the_field($field_name, $post_id = false)
|
186 |
{
|
187 |
//echo 'field name: '.$field_name.', post id: '.$post_id;
|
188 |
+
$value = get_field($field_name, $post_id);
|
189 |
+
|
190 |
+
if(is_array($value))
|
191 |
+
{
|
192 |
+
$value = @implode(', ',$value);
|
193 |
+
}
|
194 |
+
|
195 |
+
echo $value;
|
196 |
+
|
197 |
+
|
198 |
}
|
199 |
|
200 |
|
255 |
// get sub field
|
256 |
function the_sub_field($field_name, $field = false)
|
257 |
{
|
258 |
+
$value = get_sub_field($field_name, $field);
|
259 |
+
|
260 |
+
if(is_array($value))
|
261 |
+
{
|
262 |
+
$value = implode(', ',$value);
|
263 |
+
}
|
264 |
+
|
265 |
+
echo $value;
|
266 |
}
|
267 |
|
268 |
|
core/fields/file.php
CHANGED
@@ -16,8 +16,6 @@ class acf_File
|
|
16 |
add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
|
17 |
//add_action('admin_init', array($this, 'admin_init'));
|
18 |
|
19 |
-
add_action('admin_print_scripts', array($this, 'my_admin_scripts'));
|
20 |
-
add_action('admin_print_styles', array($this, 'my_admin_styles'));
|
21 |
}
|
22 |
|
23 |
|
@@ -57,22 +55,6 @@ class acf_File
|
|
57 |
}
|
58 |
|
59 |
|
60 |
-
/*---------------------------------------------------------------------------------------------
|
61 |
-
* admin_print_scripts / admin_print_styles
|
62 |
-
*
|
63 |
-
* @author Elliot Condon
|
64 |
-
* @since 2.0.1
|
65 |
-
*
|
66 |
-
---------------------------------------------------------------------------------------------*/
|
67 |
-
function my_admin_scripts() {
|
68 |
-
wp_enqueue_script('media-upload');
|
69 |
-
wp_enqueue_script('thickbox');
|
70 |
-
}
|
71 |
-
|
72 |
-
function my_admin_styles() {
|
73 |
-
wp_enqueue_style('thickbox');
|
74 |
-
}
|
75 |
-
|
76 |
|
77 |
/*---------------------------------------------------------------------------------------------
|
78 |
* popup_head - STYLES MEDIA THICKBOX
|
16 |
add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
|
17 |
//add_action('admin_init', array($this, 'admin_init'));
|
18 |
|
|
|
|
|
19 |
}
|
20 |
|
21 |
|
55 |
}
|
56 |
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
/*---------------------------------------------------------------------------------------------
|
60 |
* popup_head - STYLES MEDIA THICKBOX
|
core/fields/image.php
CHANGED
@@ -15,9 +15,6 @@ class acf_Image
|
|
15 |
add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
|
16 |
add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
|
17 |
//add_action('admin_init', array($this, 'admin_init'));
|
18 |
-
|
19 |
-
add_action('admin_print_scripts', array($this, 'my_admin_scripts'));
|
20 |
-
add_action('admin_print_styles', array($this, 'my_admin_styles'));
|
21 |
|
22 |
}
|
23 |
|
@@ -57,23 +54,7 @@ class acf_Image
|
|
57 |
<?php
|
58 |
}
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
/*---------------------------------------------------------------------------------------------
|
63 |
-
* admin_print_scripts / admin_print_styles
|
64 |
-
*
|
65 |
-
* @author Elliot Condon
|
66 |
-
* @since 2.0.1
|
67 |
-
*
|
68 |
-
---------------------------------------------------------------------------------------------*/
|
69 |
-
function my_admin_scripts() {
|
70 |
-
wp_enqueue_script('media-upload');
|
71 |
-
wp_enqueue_script('thickbox');
|
72 |
-
}
|
73 |
-
|
74 |
-
function my_admin_styles() {
|
75 |
-
wp_enqueue_style('thickbox');
|
76 |
-
}
|
77 |
|
78 |
/*---------------------------------------------------------------------------------------------
|
79 |
* popup_head - STYLES MEDIA THICKBOX
|
15 |
add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
|
16 |
add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
|
17 |
//add_action('admin_init', array($this, 'admin_init'));
|
|
|
|
|
|
|
18 |
|
19 |
}
|
20 |
|
54 |
<?php
|
55 |
}
|
56 |
|
57 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
/*---------------------------------------------------------------------------------------------
|
60 |
* popup_head - STYLES MEDIA THICKBOX
|
core/fields/page_link.php
CHANGED
@@ -54,7 +54,7 @@ class acf_Page_link
|
|
54 |
{
|
55 |
echo '<select id="'.$field->input_name.'" class="'.$field->input_class.'" name="'.$field->input_name.'" >';
|
56 |
// add top option
|
57 |
-
echo '<option value="null">- '.__("Select Option",'acf').' -</option>';
|
58 |
}
|
59 |
|
60 |
|
54 |
{
|
55 |
echo '<select id="'.$field->input_name.'" class="'.$field->input_class.'" name="'.$field->input_name.'" >';
|
56 |
// add top option
|
57 |
+
//echo '<option value="null">- '.__("Select Option",'acf').' -</option>';
|
58 |
}
|
59 |
|
60 |
|
core/input_meta_box.php
CHANGED
@@ -99,6 +99,7 @@
|
|
99 |
|
100 |
|
101 |
// set value, id and name for field
|
|
|
102 |
$field->value = $this->load_value_for_input($post->ID, $field);
|
103 |
$field->input_name = 'acf['.$i.'][value]';
|
104 |
$field->input_class = '';
|
@@ -108,7 +109,7 @@
|
|
108 |
|
109 |
echo '<input type="hidden" name="acf['.$i.'][field_id]" value="'.$field->id.'" />';
|
110 |
echo '<input type="hidden" name="acf['.$i.'][field_type]" value="'.$field->type.'" />';
|
111 |
-
|
112 |
|
113 |
if($field->save_as_cf == 1)
|
114 |
{
|
99 |
|
100 |
|
101 |
// set value, id and name for field
|
102 |
+
$field->value_id = $this->load_value_id_input($post->ID, $field);
|
103 |
$field->value = $this->load_value_for_input($post->ID, $field);
|
104 |
$field->input_name = 'acf['.$i.'][value]';
|
105 |
$field->input_class = '';
|
109 |
|
110 |
echo '<input type="hidden" name="acf['.$i.'][field_id]" value="'.$field->id.'" />';
|
111 |
echo '<input type="hidden" name="acf['.$i.'][field_type]" value="'.$field->type.'" />';
|
112 |
+
echo '<input type="hidden" name="acf['.$i.'][value_id]" value="'.$field->value_id.'" />';
|
113 |
|
114 |
if($field->save_as_cf == 1)
|
115 |
{
|
core/input_save.php
CHANGED
@@ -46,9 +46,9 @@ if(isset($_POST['input_meta_box']) && $_POST['input_meta_box'] == 'true')
|
|
46 |
);
|
47 |
|
48 |
// if there is an id, this value already exists, so save it in the same ID spot
|
49 |
-
if($field['
|
50 |
{
|
51 |
-
$data['id'] = $field['
|
52 |
}
|
53 |
|
54 |
|
46 |
);
|
47 |
|
48 |
// if there is an id, this value already exists, so save it in the same ID spot
|
49 |
+
if($field['value_id'])
|
50 |
{
|
51 |
+
$data['id'] = $field['value_id'];
|
52 |
}
|
53 |
|
54 |
|
core/location_meta_box.php
CHANGED
@@ -51,9 +51,14 @@
|
|
51 |
'page_template' => 'Page Template',
|
52 |
'post' => 'Post',
|
53 |
'post_category' => 'Post Category',
|
54 |
-
'user_type' => 'User Type'
|
55 |
));
|
56 |
|
|
|
|
|
|
|
|
|
|
|
57 |
$this->create_field($temp_field);
|
58 |
|
59 |
?>
|
@@ -223,6 +228,22 @@
|
|
223 |
|
224 |
$this->create_field($temp_field);
|
225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
?>
|
227 |
</div>
|
228 |
</td>
|
51 |
'page_template' => 'Page Template',
|
52 |
'post' => 'Post',
|
53 |
'post_category' => 'Post Category',
|
54 |
+
'user_type' => 'User Type',
|
55 |
));
|
56 |
|
57 |
+
if(array_key_exists('options_page', $this->activated_fields))
|
58 |
+
{
|
59 |
+
$temp_field->options['choices']['options_page'] = "Options Page";
|
60 |
+
}
|
61 |
+
|
62 |
$this->create_field($temp_field);
|
63 |
|
64 |
?>
|
228 |
|
229 |
$this->create_field($temp_field);
|
230 |
|
231 |
+
?>
|
232 |
+
</div>
|
233 |
+
<div rel="options_page">
|
234 |
+
|
235 |
+
<?php
|
236 |
+
|
237 |
+
$choices = array(
|
238 |
+
'acf_options' => 'Options',
|
239 |
+
);
|
240 |
+
|
241 |
+
$temp_field->options = array(
|
242 |
+
'choices' => $choices,
|
243 |
+
);
|
244 |
+
|
245 |
+
$this->create_field($temp_field);
|
246 |
+
|
247 |
?>
|
248 |
</div>
|
249 |
</td>
|
core/options_page.php
ADDED
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*--------------------------------------------------------------------------
|
4 |
+
*
|
5 |
+
* Acf_options_page
|
6 |
+
*
|
7 |
+
* @author Elliot Condon
|
8 |
+
* @since 2.0.4
|
9 |
+
*
|
10 |
+
*-------------------------------------------------------------------------*/
|
11 |
+
|
12 |
+
|
13 |
+
class Acf_options_page
|
14 |
+
{
|
15 |
+
|
16 |
+
var $parent;
|
17 |
+
var $dir;
|
18 |
+
|
19 |
+
var $menu_name;
|
20 |
+
var $menu_heading;
|
21 |
+
|
22 |
+
|
23 |
+
/*--------------------------------------------------------------------------------------
|
24 |
+
*
|
25 |
+
* Acf_options_page
|
26 |
+
*
|
27 |
+
* @author Elliot Condon
|
28 |
+
* @since 2.0.4
|
29 |
+
*
|
30 |
+
*-------------------------------------------------------------------------------------*/
|
31 |
+
function Acf_options_page($parent)
|
32 |
+
{
|
33 |
+
// vars
|
34 |
+
$this->parent = $parent;
|
35 |
+
$this->dir = $parent->dir;
|
36 |
+
|
37 |
+
|
38 |
+
// Customize the Labels here
|
39 |
+
$this->menu_name = __('Options','acf');
|
40 |
+
$this->menu_heading = __('Options','acf');
|
41 |
+
|
42 |
+
|
43 |
+
// actions
|
44 |
+
add_action('admin_menu', array($this,'admin_menu'));
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/*--------------------------------------------------------------------------------------
|
50 |
+
*
|
51 |
+
* create_menu
|
52 |
+
*
|
53 |
+
* @author Elliot Condon
|
54 |
+
* @since 2.0.4
|
55 |
+
*
|
56 |
+
*-------------------------------------------------------------------------------------*/
|
57 |
+
function admin_menu()
|
58 |
+
{
|
59 |
+
|
60 |
+
// add page
|
61 |
+
$options_page = add_menu_page('acf_options', $this->menu_name, 'edit_posts', 'acf-options',array($this, 'options_page'));
|
62 |
+
|
63 |
+
|
64 |
+
// some fields require js + css
|
65 |
+
add_action('admin_print_scripts-'.$options_page, array($this, 'admin_print_scripts'));
|
66 |
+
add_action('admin_print_styles-'.$options_page, array($this, 'admin_print_styles'));
|
67 |
+
|
68 |
+
|
69 |
+
// Add admin head
|
70 |
+
add_action('admin_head-'.$options_page, array($this,'admin_head'));
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/*--------------------------------------------------------------------------------------
|
76 |
+
*
|
77 |
+
* admin_head
|
78 |
+
*
|
79 |
+
* @author Elliot Condon
|
80 |
+
* @since 2.0.4
|
81 |
+
*
|
82 |
+
*-------------------------------------------------------------------------------------*/
|
83 |
+
function admin_head()
|
84 |
+
{
|
85 |
+
if(!array_key_exists('options_page', $this->parent->activated_fields)){exit;}
|
86 |
+
|
87 |
+
|
88 |
+
// save
|
89 |
+
if(isset($_POST['update_options']))
|
90 |
+
{
|
91 |
+
$this->update_options();
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
// create tyn mce instance for wysiwyg
|
96 |
+
wp_tiny_mce();
|
97 |
+
|
98 |
+
|
99 |
+
// add these acf's to the page
|
100 |
+
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.global.css" />';
|
101 |
+
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.input.css" />';
|
102 |
+
echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.input.js" ></script>';
|
103 |
+
|
104 |
+
|
105 |
+
// date picker!
|
106 |
+
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/core/fields/date_picker/style.date_picker.css" />';
|
107 |
+
echo '<script type="text/javascript" src="'.$this->dir.'/core/fields/date_picker/jquery.ui.datepicker.js" ></script>';
|
108 |
+
}
|
109 |
+
|
110 |
+
|
111 |
+
/*---------------------------------------------------------------------------------------------
|
112 |
+
* admin_print_scripts / admin_print_styles
|
113 |
+
*
|
114 |
+
* @author Elliot Condon
|
115 |
+
* @since 2.0.4
|
116 |
+
*
|
117 |
+
---------------------------------------------------------------------------------------------*/
|
118 |
+
function admin_print_scripts() {
|
119 |
+
|
120 |
+
wp_enqueue_script('jquery');
|
121 |
+
wp_enqueue_script('jquery-ui-core');
|
122 |
+
|
123 |
+
|
124 |
+
// wysiwyg
|
125 |
+
wp_enqueue_script('media-upload');
|
126 |
+
wp_enqueue_script('thickbox');
|
127 |
+
wp_enqueue_script('word-count');
|
128 |
+
wp_enqueue_script('post');
|
129 |
+
wp_enqueue_script('editor');
|
130 |
+
|
131 |
+
|
132 |
+
// repeater
|
133 |
+
wp_enqueue_script('jquery-ui-sortable');
|
134 |
+
|
135 |
+
}
|
136 |
+
|
137 |
+
function admin_print_styles() {
|
138 |
+
wp_enqueue_style('thickbox');
|
139 |
+
}
|
140 |
+
|
141 |
+
|
142 |
+
/*--------------------------------------------------------------------------------------
|
143 |
+
*
|
144 |
+
* options_page
|
145 |
+
*
|
146 |
+
* @author Elliot Condon
|
147 |
+
* @since 2.0.4
|
148 |
+
*
|
149 |
+
*-------------------------------------------------------------------------------------*/
|
150 |
+
function options_page()
|
151 |
+
{
|
152 |
+
if(!array_key_exists('options_page', $this->parent->activated_fields)){exit;}
|
153 |
+
|
154 |
+
|
155 |
+
// load acf's
|
156 |
+
$acfs = get_pages(array(
|
157 |
+
'numberposts' => -1,
|
158 |
+
'post_type' => 'acf',
|
159 |
+
'sort_column' => 'menu_order',
|
160 |
+
));
|
161 |
+
|
162 |
+
// blank array to hold acfs
|
163 |
+
$add_acf = array();
|
164 |
+
|
165 |
+
if($acfs)
|
166 |
+
{
|
167 |
+
foreach($acfs as $acf)
|
168 |
+
{
|
169 |
+
$add_box = false;
|
170 |
+
$location = $this->parent->get_acf_location($acf->ID);
|
171 |
+
|
172 |
+
|
173 |
+
if($location->allorany == 'all')
|
174 |
+
{
|
175 |
+
// ALL
|
176 |
+
|
177 |
+
$add_box = true;
|
178 |
+
|
179 |
+
if($location->rules)
|
180 |
+
{
|
181 |
+
foreach($location->rules as $rule)
|
182 |
+
{
|
183 |
+
// if any rules dont return true, dont add this acf
|
184 |
+
if(!$this->parent->match_location_rule($post, $rule))
|
185 |
+
{
|
186 |
+
$add_box = false;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
}
|
192 |
+
elseif($location->allorany == 'any')
|
193 |
+
{
|
194 |
+
// ANY
|
195 |
+
|
196 |
+
$add_box = false;
|
197 |
+
|
198 |
+
if($location->rules)
|
199 |
+
{
|
200 |
+
foreach($location->rules as $rule)
|
201 |
+
{
|
202 |
+
// if any rules return true, add this acf
|
203 |
+
if($this->parent->match_location_rule($post, $rule))
|
204 |
+
{
|
205 |
+
$add_box = true;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
if($add_box == true)
|
212 |
+
{
|
213 |
+
$add_acf[] = $acf;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
?>
|
219 |
+
|
220 |
+
<div class="wrap">
|
221 |
+
|
222 |
+
<div class="icon32" id="icon-options-general"><br></div>
|
223 |
+
<h2><?php echo $this->menu_heading; ?></h2>
|
224 |
+
|
225 |
+
<?php if(isset($_POST['update_options'])): ?>
|
226 |
+
<div class="updated settings-error" id="setting-error-settings_updated"><p><strong><?php _e("Settings saved",'acf'); ?></strong></p></div>
|
227 |
+
<?php endif; ?>
|
228 |
+
|
229 |
+
<form id="post" method="post" name="post">
|
230 |
+
|
231 |
+
<div class="metabox-holder has-right-sidebar" id="poststuff">
|
232 |
+
|
233 |
+
<div class="inner-sidebar" id="side-info-column">
|
234 |
+
|
235 |
+
<?php if($add_acf): ?>
|
236 |
+
<div class="postbox">
|
237 |
+
<h3 class="hndle"><span><?php _e("Save",'acf'); ?></span></h3>
|
238 |
+
<div class="inside">
|
239 |
+
|
240 |
+
<input type="submit" class="button-primary" value="Save Options" name="update_options">
|
241 |
+
|
242 |
+
</div>
|
243 |
+
</div>
|
244 |
+
<?php endif; ?>
|
245 |
+
|
246 |
+
</div>
|
247 |
+
|
248 |
+
|
249 |
+
|
250 |
+
<div id="post-body">
|
251 |
+
<div id="post-body-content">
|
252 |
+
<div id="acf_input" class="postbox">
|
253 |
+
<div class="acf_fields_input">
|
254 |
+
<?php
|
255 |
+
|
256 |
+
$i = 0;
|
257 |
+
if($add_acf)
|
258 |
+
{
|
259 |
+
foreach($add_acf as $acf)
|
260 |
+
{
|
261 |
+
|
262 |
+
// load acf data
|
263 |
+
$options = $this->parent->get_acf_options($acf->ID);
|
264 |
+
$fields = $this->parent->get_fields($acf->ID);
|
265 |
+
$html = '';
|
266 |
+
|
267 |
+
|
268 |
+
if($options->field_group_layout == "in_box")
|
269 |
+
{
|
270 |
+
echo '<div class="postbox"><div title="Click to toggle" class="handlediv"><br></div><h3 class="hndle"><span>'.$acf->post_title.'</span></h3><div class="inside">';
|
271 |
+
}
|
272 |
+
|
273 |
+
|
274 |
+
foreach($fields as $field)
|
275 |
+
{
|
276 |
+
|
277 |
+
// if they didn't select a type, skip this field
|
278 |
+
if($field->type == 'null')
|
279 |
+
{
|
280 |
+
continue;
|
281 |
+
}
|
282 |
+
|
283 |
+
|
284 |
+
// set value, id and name for field
|
285 |
+
$field->value_id = $this->parent->load_value_id_input($post->ID, $field);
|
286 |
+
$field->value = $this->parent->load_value_for_input($post->ID, $field);
|
287 |
+
$field->input_name = 'acf['.$i.'][value]';
|
288 |
+
$field->input_class = '';
|
289 |
+
|
290 |
+
|
291 |
+
echo '<div class="field">';
|
292 |
+
|
293 |
+
echo '<input type="hidden" name="acf['.$i.'][field_id]" value="'.$field->id.'" />';
|
294 |
+
echo '<input type="hidden" name="acf['.$i.'][field_type]" value="'.$field->type.'" />';
|
295 |
+
echo '<input type="hidden" name="acf['.$i.'][value_id]" value="'.$field->value_id.'" />';
|
296 |
+
|
297 |
+
|
298 |
+
echo '<label for="'.$field->input_name.'">'.$field->label.'</label>';
|
299 |
+
|
300 |
+
|
301 |
+
if($field->instructions)
|
302 |
+
{
|
303 |
+
echo '<p class="instructions">'.$field->instructions.'</p>';
|
304 |
+
}
|
305 |
+
|
306 |
+
|
307 |
+
$this->parent->create_field($field);
|
308 |
+
|
309 |
+
echo '</div>';
|
310 |
+
|
311 |
+
$i++;
|
312 |
+
}
|
313 |
+
|
314 |
+
|
315 |
+
if($options->field_group_layout == "in_box")
|
316 |
+
{
|
317 |
+
echo '</div></div>';
|
318 |
+
}
|
319 |
+
}
|
320 |
+
}
|
321 |
+
else
|
322 |
+
{
|
323 |
+
?>
|
324 |
+
|
325 |
+
<div class="postbox">
|
326 |
+
<div title="Click to toggle" class="handlediv"><br></div>
|
327 |
+
<h3 class="hndle"><span><?php _e("No Options",'acf'); ?></span></h3>
|
328 |
+
|
329 |
+
<div class="inside">
|
330 |
+
<div class="field">
|
331 |
+
<p><?php _e("Sorry, it seems there are no fields for this options page.",'acf'); ?></p>
|
332 |
+
</div>
|
333 |
+
</div>
|
334 |
+
</div>
|
335 |
+
|
336 |
+
<?php
|
337 |
+
}
|
338 |
+
|
339 |
+
|
340 |
+
?>
|
341 |
+
</div>
|
342 |
+
</div>
|
343 |
+
</div>
|
344 |
+
</div>
|
345 |
+
</div>
|
346 |
+
</form>
|
347 |
+
</div>
|
348 |
+
<?php
|
349 |
+
}
|
350 |
+
|
351 |
+
|
352 |
+
/*--------------------------------------------------------------------------------------
|
353 |
+
*
|
354 |
+
* options_page
|
355 |
+
*
|
356 |
+
* @author Elliot Condon
|
357 |
+
* @since 2.0.4
|
358 |
+
*
|
359 |
+
*-------------------------------------------------------------------------------------*/
|
360 |
+
function update_options()
|
361 |
+
{
|
362 |
+
// vars
|
363 |
+
global $wpdb;
|
364 |
+
$table_name = $wpdb->prefix.'acf_values';
|
365 |
+
$post_id = 0;
|
366 |
+
|
367 |
+
|
368 |
+
// remove all old values from the database
|
369 |
+
$wpdb->query("DELETE FROM $table_name WHERE post_id = '$post_id'");
|
370 |
+
|
371 |
+
|
372 |
+
foreach($_POST['acf'] as $field)
|
373 |
+
{
|
374 |
+
if(method_exists($this->parent->fields[$field['field_type']], 'save_input'))
|
375 |
+
{
|
376 |
+
$this->parent->fields[$field['field_type']]->save_input($post_id, $field);
|
377 |
+
}
|
378 |
+
else
|
379 |
+
{
|
380 |
+
//$field = apply_filters('wp_insert_post_data', $field);
|
381 |
+
$field = stripslashes_deep( $field );
|
382 |
+
|
383 |
+
|
384 |
+
// if select is a multiple (multiple select value), you need to save it as an array!
|
385 |
+
if(is_array($field['value']))
|
386 |
+
{
|
387 |
+
$field['value'] = serialize($field['value']);
|
388 |
+
}
|
389 |
+
|
390 |
+
|
391 |
+
// create data object to save
|
392 |
+
$data = array(
|
393 |
+
'post_id' => $post_id,
|
394 |
+
'field_id' => $field['field_id'],
|
395 |
+
'value' => $field['value']
|
396 |
+
);
|
397 |
+
|
398 |
+
// if there is an id, this value already exists, so save it in the same ID spot
|
399 |
+
if($field['value_id'])
|
400 |
+
{
|
401 |
+
$data['id'] = $field['value_id'];
|
402 |
+
}
|
403 |
+
|
404 |
+
|
405 |
+
// insert new data
|
406 |
+
$new_id = $wpdb->insert($table_name, $data);
|
407 |
+
}
|
408 |
+
|
409 |
+
|
410 |
+
}
|
411 |
+
|
412 |
+
}
|
413 |
+
|
414 |
+
}
|
415 |
+
|
416 |
+
?>
|
core/screen_extra.php
CHANGED
@@ -12,6 +12,13 @@
|
|
12 |
</tr>
|
13 |
</thead>
|
14 |
<tbody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
<tr>
|
16 |
<td><?php _e("Repeater",'acf'); ?></td>
|
17 |
<td><?php if(array_key_exists('repeater', $this->activated_fields)){
|
@@ -37,6 +44,38 @@
|
|
37 |
</form>
|
38 |
</td>
|
39 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
</tbody>
|
41 |
</table>
|
42 |
</div>
|
12 |
</tr>
|
13 |
</thead>
|
14 |
<tbody>
|
15 |
+
<?php
|
16 |
+
/*--------------------------------------------------------------------------------------
|
17 |
+
*
|
18 |
+
* Repeater Field
|
19 |
+
*
|
20 |
+
*-------------------------------------------------------------------------------------*/
|
21 |
+
?>
|
22 |
<tr>
|
23 |
<td><?php _e("Repeater",'acf'); ?></td>
|
24 |
<td><?php if(array_key_exists('repeater', $this->activated_fields)){
|
44 |
</form>
|
45 |
</td>
|
46 |
</tr>
|
47 |
+
<?php
|
48 |
+
/*--------------------------------------------------------------------------------------
|
49 |
+
*
|
50 |
+
* Options Page
|
51 |
+
*
|
52 |
+
*-------------------------------------------------------------------------------------*/
|
53 |
+
?>
|
54 |
+
<tr>
|
55 |
+
<td><?php _e("Options Page",'acf'); ?></td>
|
56 |
+
<td><?php if(array_key_exists('options_page', $this->activated_fields)){
|
57 |
+
_e("Active",'acf');
|
58 |
+
}
|
59 |
+
else
|
60 |
+
{
|
61 |
+
_e("Inactive",'acf');
|
62 |
+
} ?></td>
|
63 |
+
<td>
|
64 |
+
<form action="" method="post">
|
65 |
+
<?php if(array_key_exists('options_page', $this->activated_fields)){
|
66 |
+
echo '<span class="activation_code">XXXX-XXXX-XXXX-'.substr($this->activated_fields['options_page'],-4) .'</span>';
|
67 |
+
echo '<input type="hidden" name="acf_field_deactivate" value="options_page" />';
|
68 |
+
echo '<input type="submit" class="button" value="Deactivate" />';
|
69 |
+
}
|
70 |
+
else
|
71 |
+
{
|
72 |
+
echo '<input type="text" name="acf_ac" value="" />';
|
73 |
+
echo '<input type="hidden" name="acf_field_activate" value="options_page" />';
|
74 |
+
echo '<input type="submit" class="button" value="Activate" />';
|
75 |
+
} ?>
|
76 |
+
</form>
|
77 |
+
</td>
|
78 |
+
</tr>
|
79 |
</tbody>
|
80 |
</table>
|
81 |
</div>
|
css/style.screen_extra.css
CHANGED
@@ -47,21 +47,31 @@
|
|
47 |
/*--------------------------------------------------------------------------------------------
|
48 |
Unlock Fields
|
49 |
--------------------------------------------------------------------------------------------*/
|
50 |
-
.screen-meta-toggle.acf {
|
51 |
float: right;
|
52 |
-
background: none repeat scroll 0 0 #
|
53 |
border-radius: 0 0 3px 3px;
|
54 |
float: right;
|
55 |
font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;
|
56 |
height: 22px;
|
57 |
margin: 0 6px 0 0;
|
58 |
-
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
#screen-meta-links .acf a.show-settings {
|
62 |
padding: 0 16px;
|
63 |
-
background: 0 none;
|
64 |
border-top: 0 none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
.screen-meta-wrap h5 {
|
@@ -69,8 +79,8 @@
|
|
69 |
font-size: 13px;
|
70 |
}
|
71 |
.screen-meta-wrap {
|
72 |
-
background: #
|
73 |
-
border: #
|
74 |
border-top: 0 none;
|
75 |
margin: 0 15px;
|
76 |
padding: 8px 12px 12px;
|
47 |
/*--------------------------------------------------------------------------------------------
|
48 |
Unlock Fields
|
49 |
--------------------------------------------------------------------------------------------*/
|
50 |
+
#screen-meta-links .screen-meta-toggle.acf {
|
51 |
float: right;
|
52 |
+
background: none repeat scroll 0 0 #F9F9F9;
|
53 |
border-radius: 0 0 3px 3px;
|
54 |
float: right;
|
55 |
font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;
|
56 |
height: 22px;
|
57 |
margin: 0 6px 0 0;
|
58 |
+
position: relative;
|
59 |
+
border: #DFDFDF solid 1px;
|
60 |
+
border-top: 0 none;
|
61 |
+
padding: 0 3px;
|
62 |
+
|
63 |
}
|
64 |
|
65 |
#screen-meta-links .acf a.show-settings {
|
66 |
padding: 0 16px;
|
|
|
67 |
border-top: 0 none;
|
68 |
+
color: #21759B;
|
69 |
+
padding: 0 20px 0 10px;
|
70 |
+
text-shadow: #fff 0 1px 0;
|
71 |
+
}
|
72 |
+
|
73 |
+
#screen-meta-links .acf.screen-meta-active {
|
74 |
+
margin-top: -1px;
|
75 |
}
|
76 |
|
77 |
.screen-meta-wrap h5 {
|
79 |
font-size: 13px;
|
80 |
}
|
81 |
.screen-meta-wrap {
|
82 |
+
background-color: #F9F9F9;
|
83 |
+
border: #DFDFDF solid 1px;
|
84 |
border-top: 0 none;
|
85 |
margin: 0 15px;
|
86 |
padding: 8px 12px 12px;
|
js/functions.input.js
CHANGED
@@ -398,14 +398,22 @@
|
|
398 |
-------------------------------------------*/
|
399 |
$(document).ready(function(){
|
400 |
|
|
|
401 |
post_id = $('form#post input#post_ID').val();
|
402 |
-
var div = $('
|
403 |
|
404 |
|
405 |
if(typeof(tinyMCE) != "undefined")
|
406 |
{
|
407 |
-
tinyMCE.settings.theme_advanced_buttons1
|
408 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
}
|
410 |
|
411 |
|
398 |
-------------------------------------------*/
|
399 |
$(document).ready(function(){
|
400 |
|
401 |
+
|
402 |
post_id = $('form#post input#post_ID').val();
|
403 |
+
var div = $('#acf_input');
|
404 |
|
405 |
|
406 |
if(typeof(tinyMCE) != "undefined")
|
407 |
{
|
408 |
+
if(tinyMCE.settings.theme_advanced_buttons1)
|
409 |
+
{
|
410 |
+
tinyMCE.settings.theme_advanced_buttons1 += ",|,add_image,add_video,add_audio,add_media";
|
411 |
+
}
|
412 |
+
|
413 |
+
if(tinyMCE.settings.theme_advanced_buttons2)
|
414 |
+
{
|
415 |
+
tinyMCE.settings.theme_advanced_buttons2 += ",code";
|
416 |
+
}
|
417 |
}
|
418 |
|
419 |
|
js/functions.location.js
CHANGED
@@ -16,6 +16,16 @@
|
|
16 |
var tr = $(this).closest('tr');
|
17 |
var val = $(this).val();
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
tr.find('td.value div').hide();
|
20 |
tr.find('td.value div [name]').attr('disabled', 'true');
|
21 |
|
16 |
var tr = $(this).closest('tr');
|
17 |
var val = $(this).val();
|
18 |
|
19 |
+
|
20 |
+
// does it have options?
|
21 |
+
if(!$(this).find('option[value="options_page"]').exists())
|
22 |
+
{
|
23 |
+
//console.log('select: '+type+'. parent length: '+$(this).closest('.repeater').length);
|
24 |
+
$(this).append('<option value="options_page" disabled="true">Options Page (Unlock field with activation code)</option>');
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
tr.find('td.value div').hide();
|
30 |
tr.find('td.value div [name]').attr('disabled', 'true');
|
31 |
|
js/functions.screen_extra.js
CHANGED
@@ -20,15 +20,20 @@
|
|
20 |
});
|
21 |
|
22 |
$('#screen-meta-links a#screen-meta-activate-acf-link').unbind('click').click(function() {
|
|
|
23 |
var a = $(this);
|
|
|
|
|
24 |
$(a.attr('href')+'-wrap').slideToggle('fast', function() {
|
25 |
-
if (
|
26 |
-
|
27 |
-
|
|
|
28 |
}
|
29 |
else {
|
30 |
-
|
31 |
-
|
|
|
32 |
}
|
33 |
});
|
34 |
return false;
|
20 |
});
|
21 |
|
22 |
$('#screen-meta-links a#screen-meta-activate-acf-link').unbind('click').click(function() {
|
23 |
+
|
24 |
var a = $(this);
|
25 |
+
var div = a.parent();
|
26 |
+
|
27 |
$(a.attr('href')+'-wrap').slideToggle('fast', function() {
|
28 |
+
if (div.hasClass('screen-meta-active')) {
|
29 |
+
div.removeClass('screen-meta-active');
|
30 |
+
//a.css({'background-position':'right top'}).removeClass('screen-meta-shown');
|
31 |
+
div.siblings().css('visibility', 'visible');
|
32 |
}
|
33 |
else {
|
34 |
+
div.addClass('screen-meta-active');
|
35 |
+
div.siblings().css('visibility', 'hidden');
|
36 |
+
//a.css({'background-position':'right bottom'}).addClass('screen-meta-shown').parent().css('visibility', 'visible');
|
37 |
}
|
38 |
});
|
39 |
return false;
|
readme.txt
CHANGED
@@ -81,6 +81,14 @@ http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
|
|
81 |
|
82 |
== Changelog ==
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
= 2.0.3 =
|
85 |
* Added Option: Repeater Layout (Row / Table)
|
86 |
* Fixed bug: Now you can search for media in the image / file fields
|
81 |
|
82 |
== Changelog ==
|
83 |
|
84 |
+
= 2.0.4 =
|
85 |
+
* New Addon: Options Page (available on the plugins store: http://plugins.elliotcondon.com/shop/)
|
86 |
+
* API: all functions now accept 'options' as a second parameter to target the options page
|
87 |
+
* API: the_field() now implodes array's and returns as a string separated by comma's
|
88 |
+
* Fixed Bug: Image upload should now work on post types without editor
|
89 |
+
* Fixed Bug: Location rule now returns true if page_template is set to 'Default' and a new page is created
|
90 |
+
* General Housekeeping
|
91 |
+
|
92 |
= 2.0.3 =
|
93 |
* Added Option: Repeater Layout (Row / Table)
|
94 |
* Fixed bug: Now you can search for media in the image / file fields
|