Version Description
- Added new database table "acf_rules"
- Removed database table "ac_options"
- Updated location meta box to now allow for custom location queries
- Hid Activation Code from logged in users
- Fixed JS bugs with wp v3.2 beta 2
- Added new option "Field group layout" - you can now wrap your fields in a metabox!
- General housekeeping
=2.0.1= * Added Field Option: Field Instructions * Added Field Option: Is field searchable? (saves field value as a normal custom field so you can use the field against wp queries) * Added Media Search / Pagination to Image / File thickbox * Added Media Upload support to post types which do not have a Content Editor. * Fixed "Select Image" / "Select File" text on thickbox buttons after upload * Repeater field now returns null if no data was added
=2.0.0= * Completely re-designed the ACF edit page * Added repeater field (unlocked through external purchase) * Fixed minor js bugs * Fixed PHP error handling * Fixed problem with update script not running * General js + css improvements
Download this release
Release Info
Developer | elliotcondon |
Plugin | Advanced Custom Fields |
Version | 2.0.2 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.0.2
- acf.php +241 -69
- core/acf_post_type.php +1 -1
- core/admin_head.php +45 -17
- core/api.php +1 -4
- core/fields/file.php +1 -1
- core/fields/repeater.php +26 -24
- core/fields/select.php +1 -1
- core/fields_save.php +9 -0
- core/input_meta_box.php +107 -43
- core/input_save.php +1 -1
- core/location_meta_box.php +238 -191
- core/location_save.php +23 -40
- core/options_meta_box.php +16 -17
- core/options_save.php +5 -30
- core/screen_extra.php +1 -1
- core/update.php +178 -2
- css/style.fields.css +1 -0
- css/style.input.css +34 -14
- css/style.location.css +67 -22
- js/functions.fields.js +10 -18
- js/functions.input.js +1 -55
- js/functions.location.js +102 -0
- lang/advanced-custom-fields.pot +58 -19
- readme.txt +10 -1
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
|
@@ -36,7 +36,7 @@ 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 |
|
@@ -493,45 +493,15 @@ class Acf
|
|
493 |
|
494 |
// set table name
|
495 |
global $wpdb;
|
496 |
-
$table_name = $wpdb->prefix.'
|
497 |
-
|
498 |
-
|
499 |
-
// get fields and add them to $options
|
500 |
$location = new stdClass();
|
501 |
-
$db_locations = $wpdb->get_results("SELECT name, value FROM $table_name WHERE acf_id = '$acf_id' AND type = 'location'");
|
502 |
-
|
503 |
-
foreach($db_locations as $db_location)
|
504 |
-
{
|
505 |
-
$key = $db_location->name;
|
506 |
-
$value = $db_location->value;
|
507 |
-
$location->$key = $value;
|
508 |
-
}
|
509 |
-
|
510 |
-
|
511 |
-
// if empty
|
512 |
-
if(empty($location->post_types)){$location->post_types = serialize(array());}
|
513 |
-
if(empty($location->page_titles)){$location->page_titles = serialize(array());}
|
514 |
-
if(empty($location->page_slugs)){$location->page_slugs = serialize(array());}
|
515 |
-
if(empty($location->post_ids)){$location->post_ids = serialize(array());}
|
516 |
-
if(empty($location->page_templates)){$location->page_templates = serialize(array());}
|
517 |
-
if(empty($location->page_parents)){$location->page_parents = serialize(array());}
|
518 |
-
if(empty($location->category_names)){$location->category_names = serialize(array());}
|
519 |
-
if(empty($location->ignore_other_acfs)){$location->ignore_other_acfs = '0';}
|
520 |
-
|
521 |
-
|
522 |
-
// unserialize values
|
523 |
-
$location->post_types = unserialize($location->post_types);
|
524 |
-
$location->page_titles = unserialize($location->page_titles);
|
525 |
-
$location->page_slugs = unserialize($location->page_slugs);
|
526 |
-
$location->post_ids = unserialize($location->post_ids);
|
527 |
-
$location->page_templates = unserialize($location->page_templates);
|
528 |
-
$location->page_parents = unserialize($location->page_parents);
|
529 |
-
$location->category_names = unserialize($location->category_names);
|
530 |
-
|
531 |
-
|
532 |
|
533 |
|
|
|
|
|
|
|
534 |
|
|
|
535 |
// return location
|
536 |
return $location;
|
537 |
|
@@ -554,39 +524,29 @@ class Acf
|
|
554 |
if(!get_post_custom_keys($acf_id))
|
555 |
{
|
556 |
$options->show_on_page = array('the_content', 'discussion', 'custom_fields', 'comments', 'slug', 'author');
|
557 |
-
$options->user_roles = array();
|
558 |
-
|
559 |
-
return $options;
|
560 |
}
|
561 |
-
|
562 |
-
|
563 |
-
// set table name
|
564 |
-
global $wpdb;
|
565 |
-
$table_name = $wpdb->prefix.'acf_options';
|
566 |
-
|
567 |
-
|
568 |
-
// get fields and add them to $options
|
569 |
-
$db_options = $wpdb->get_results("SELECT name, value FROM $table_name WHERE acf_id = '$acf_id' AND type = 'option'");
|
570 |
-
|
571 |
-
foreach($db_options as $db_option)
|
572 |
{
|
573 |
-
$
|
574 |
-
|
575 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
}
|
577 |
|
578 |
-
|
579 |
-
// if empty
|
580 |
-
if(empty($options->show_on_page)){$options->show_on_page = serialize(array());}
|
581 |
-
if(empty($options->user_roles)){$options->user_roles = serialize(array());}
|
582 |
-
|
583 |
-
|
584 |
-
// unserialize options
|
585 |
-
$options->show_on_page = unserialize($options->show_on_page);
|
586 |
-
$options->user_roles = unserialize($options->user_roles);
|
587 |
-
|
588 |
-
|
589 |
-
// return fields
|
590 |
return $options;
|
591 |
|
592 |
}
|
@@ -652,7 +612,7 @@ class Acf
|
|
652 |
|
653 |
|
654 |
/*---------------------------------------------------------------------------------------------
|
655 |
-
*
|
656 |
*
|
657 |
* @author Elliot Condon
|
658 |
* @since 1.0.6
|
@@ -684,7 +644,10 @@ class Acf
|
|
684 |
}
|
685 |
|
686 |
|
687 |
-
|
|
|
|
|
|
|
688 |
|
689 |
|
690 |
// return value
|
@@ -719,6 +682,215 @@ class Acf
|
|
719 |
|
720 |
return $activated;
|
721 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
722 |
|
723 |
|
724 |
}
|
2 |
/*
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://plugins.elliotcondon.com/advanced-custom-fields/
|
5 |
+
Description: Comfpletely 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.2
|
7 |
Author: Elliot Condon
|
8 |
Author URI: http://www.elliotcondon.com/
|
9 |
License: GPL
|
36 |
$this->dir = plugins_url('',__FILE__);
|
37 |
$this->siteurl = get_bloginfo('url');
|
38 |
$this->wpadminurl = admin_url();
|
39 |
+
$this->version = '2.0.2';
|
40 |
$this->activated_fields = $this->get_activated_fields();
|
41 |
|
42 |
|
493 |
|
494 |
// set table name
|
495 |
global $wpdb;
|
496 |
+
$table_name = $wpdb->prefix.'acf_rules';
|
|
|
|
|
|
|
497 |
$location = new stdClass();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
|
499 |
|
500 |
+
// get fields and add them to $options
|
501 |
+
$location->rules = $wpdb->get_results("SELECT * FROM $table_name WHERE acf_id = '$acf_id' ORDER BY order_no ASC");
|
502 |
+
$location->allorany = get_post_meta($acf_id, 'allorany', true) ? get_post_meta($acf_id, 'allorany', true) : 'all';
|
503 |
|
504 |
+
|
505 |
// return location
|
506 |
return $location;
|
507 |
|
524 |
if(!get_post_custom_keys($acf_id))
|
525 |
{
|
526 |
$options->show_on_page = array('the_content', 'discussion', 'custom_fields', 'comments', 'slug', 'author');
|
|
|
|
|
|
|
527 |
}
|
528 |
+
else
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
{
|
530 |
+
if(@unserialize(get_post_meta($acf_id, 'show_on_page', true)))
|
531 |
+
{
|
532 |
+
$options->show_on_page = unserialize(get_post_meta($acf_id, 'show_on_page', true));
|
533 |
+
}
|
534 |
+
else
|
535 |
+
{
|
536 |
+
$options->show_on_page = array();
|
537 |
+
}
|
538 |
+
|
539 |
+
if(get_post_meta($acf_id, 'field_group_layout', true))
|
540 |
+
{
|
541 |
+
$options->field_group_layout = get_post_meta($acf_id, 'field_group_layout', true);
|
542 |
+
}
|
543 |
+
else
|
544 |
+
{
|
545 |
+
$options->field_group_layout = "no_box";
|
546 |
+
}
|
547 |
+
|
548 |
}
|
549 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
550 |
return $options;
|
551 |
|
552 |
}
|
612 |
|
613 |
|
614 |
/*---------------------------------------------------------------------------------------------
|
615 |
+
* load_value_for_api
|
616 |
*
|
617 |
* @author Elliot Condon
|
618 |
* @since 1.0.6
|
644 |
}
|
645 |
|
646 |
|
647 |
+
if(empty($value) || $value == null || $value == "")
|
648 |
+
{
|
649 |
+
$value = false;
|
650 |
+
}
|
651 |
|
652 |
|
653 |
// return value
|
682 |
|
683 |
return $activated;
|
684 |
}
|
685 |
+
|
686 |
+
|
687 |
+
|
688 |
+
/*---------------------------------------------------------------------------------------------
|
689 |
+
* match_location_rule
|
690 |
+
*
|
691 |
+
* @author Elliot Condon
|
692 |
+
* @since 2.0.s
|
693 |
+
*
|
694 |
+
---------------------------------------------------------------------------------------------*/
|
695 |
+
function match_location_rule($post, $rule)
|
696 |
+
{
|
697 |
+
switch ($rule->param) {
|
698 |
+
|
699 |
+
// POST TYPE
|
700 |
+
case "post_type":
|
701 |
+
|
702 |
+
if($rule->operator == "==")
|
703 |
+
{
|
704 |
+
if(get_post_type($post) == $rule->value)
|
705 |
+
{
|
706 |
+
return true;
|
707 |
+
}
|
708 |
+
|
709 |
+
return false;
|
710 |
+
}
|
711 |
+
elseif($rule->operator == "!=")
|
712 |
+
{
|
713 |
+
if(get_post_type($post) != $rule->value)
|
714 |
+
{
|
715 |
+
return true;
|
716 |
+
}
|
717 |
+
|
718 |
+
return false;
|
719 |
+
}
|
720 |
+
|
721 |
+
break;
|
722 |
+
|
723 |
+
// PAGE
|
724 |
+
case "page":
|
725 |
+
|
726 |
+
if($rule->operator == "==")
|
727 |
+
{
|
728 |
+
if($post->ID == $rule->value)
|
729 |
+
{
|
730 |
+
return true;
|
731 |
+
}
|
732 |
+
|
733 |
+
return false;
|
734 |
+
}
|
735 |
+
elseif($rule->operator == "!=")
|
736 |
+
{
|
737 |
+
if($post->ID != $rule->value)
|
738 |
+
{
|
739 |
+
return true;
|
740 |
+
}
|
741 |
+
|
742 |
+
return false;
|
743 |
+
}
|
744 |
+
|
745 |
+
break;
|
746 |
+
|
747 |
+
// PAGE
|
748 |
+
case "page_type":
|
749 |
+
|
750 |
+
if($rule->operator == "==")
|
751 |
+
{
|
752 |
+
if($rule->value == "parent" && $post->post_parent == "0")
|
753 |
+
{
|
754 |
+
return true;
|
755 |
+
}
|
756 |
+
|
757 |
+
if($rule->value == "child" && $post->post_parent != "0")
|
758 |
+
{
|
759 |
+
return true;
|
760 |
+
}
|
761 |
+
|
762 |
+
return false;
|
763 |
+
}
|
764 |
+
elseif($rule->operator == "!=")
|
765 |
+
{
|
766 |
+
if($rule->value == "parent" && $post->post_parent != "0")
|
767 |
+
{
|
768 |
+
return true;
|
769 |
+
}
|
770 |
+
|
771 |
+
if($rule->value == "child" && $post->post_parent == "0")
|
772 |
+
{
|
773 |
+
return true;
|
774 |
+
}
|
775 |
+
|
776 |
+
return false;
|
777 |
+
}
|
778 |
+
|
779 |
+
break;
|
780 |
+
|
781 |
+
// PAGE
|
782 |
+
case "page_template":
|
783 |
+
|
784 |
+
if($rule->operator == "==")
|
785 |
+
{
|
786 |
+
if(get_post_meta($post->ID,'_wp_page_template',true) == $rule->value)
|
787 |
+
{
|
788 |
+
return true;
|
789 |
+
}
|
790 |
+
|
791 |
+
return false;
|
792 |
+
}
|
793 |
+
elseif($rule->operator == "!=")
|
794 |
+
{
|
795 |
+
if(get_post_meta($post->ID,'_wp_page_template',true) != $rule->value)
|
796 |
+
{
|
797 |
+
return true;
|
798 |
+
}
|
799 |
+
|
800 |
+
return false;
|
801 |
+
}
|
802 |
+
|
803 |
+
break;
|
804 |
+
|
805 |
+
// POST
|
806 |
+
case "post":
|
807 |
+
|
808 |
+
if($rule->operator == "==")
|
809 |
+
{
|
810 |
+
if($post->ID == $rule->value)
|
811 |
+
{
|
812 |
+
return true;
|
813 |
+
}
|
814 |
+
|
815 |
+
return false;
|
816 |
+
}
|
817 |
+
elseif($rule->operator == "!=")
|
818 |
+
{
|
819 |
+
if($post->ID != $rule->value)
|
820 |
+
{
|
821 |
+
return true;
|
822 |
+
}
|
823 |
+
|
824 |
+
return false;
|
825 |
+
}
|
826 |
+
|
827 |
+
break;
|
828 |
+
|
829 |
+
// POST CATEGORY
|
830 |
+
case "post_category":
|
831 |
+
|
832 |
+
// category names
|
833 |
+
$cats = get_the_category();
|
834 |
+
|
835 |
+
if($rule->operator == "==")
|
836 |
+
{
|
837 |
+
if($cats)
|
838 |
+
{
|
839 |
+
foreach($cats as $cat)
|
840 |
+
{
|
841 |
+
if($cat->name == $rule->value)
|
842 |
+
{
|
843 |
+
return true;
|
844 |
+
}
|
845 |
+
}
|
846 |
+
}
|
847 |
+
|
848 |
+
return false;
|
849 |
+
}
|
850 |
+
elseif($rule->operator == "!=")
|
851 |
+
{
|
852 |
+
if($cats)
|
853 |
+
{
|
854 |
+
foreach($cats as $cat)
|
855 |
+
{
|
856 |
+
if($cat->name != $rule->value)
|
857 |
+
{
|
858 |
+
return true;
|
859 |
+
}
|
860 |
+
}
|
861 |
+
}
|
862 |
+
|
863 |
+
return false;
|
864 |
+
}
|
865 |
+
|
866 |
+
break;
|
867 |
+
|
868 |
+
// USER TYPE
|
869 |
+
case "user_type":
|
870 |
+
|
871 |
+
if($rule->operator == "==")
|
872 |
+
{
|
873 |
+
if(current_user_can($rule->value))
|
874 |
+
{
|
875 |
+
return true;
|
876 |
+
}
|
877 |
+
|
878 |
+
return false;
|
879 |
+
}
|
880 |
+
elseif($rule->operator == "!=")
|
881 |
+
{
|
882 |
+
if(!current_user_can($rule->value))
|
883 |
+
{
|
884 |
+
return true;
|
885 |
+
}
|
886 |
+
|
887 |
+
return false;
|
888 |
+
}
|
889 |
+
|
890 |
+
break;
|
891 |
+
|
892 |
+
}
|
893 |
+
}
|
894 |
|
895 |
|
896 |
}
|
core/acf_post_type.php
CHANGED
@@ -16,7 +16,7 @@ $labels = array(
|
|
16 |
|
17 |
$supports = array(
|
18 |
'title',
|
19 |
-
'revisions',
|
20 |
//'custom-fields',
|
21 |
'page-attributes'
|
22 |
);
|
16 |
|
17 |
$supports = array(
|
18 |
'title',
|
19 |
+
//'revisions',
|
20 |
//'custom-fields',
|
21 |
'page-attributes'
|
22 |
);
|
core/admin_head.php
CHANGED
@@ -88,6 +88,7 @@ if($currentFile == 'post.php' || $currentFile == 'post-new.php')
|
|
88 |
|
89 |
// ACF
|
90 |
echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.fields.js" ></script>';
|
|
|
91 |
|
92 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.global.css" />';
|
93 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.fields.css" />';
|
@@ -95,7 +96,7 @@ if($currentFile == 'post.php' || $currentFile == 'post-new.php')
|
|
95 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.options.css" />';
|
96 |
|
97 |
add_meta_box('acf_fields', 'Fields', array($this, '_fields_meta_box'), 'acf', 'normal', 'high');
|
98 |
-
add_meta_box('acf_location', '
|
99 |
add_meta_box('acf_options', 'Advanced Options</span><span class="description">- Customise the edit page', array($this, '_options_meta_box'), 'acf', 'normal', 'high');
|
100 |
|
101 |
}
|
@@ -116,12 +117,50 @@ if($currentFile == 'post.php' || $currentFile == 'post-new.php')
|
|
116 |
foreach($acfs as $acf)
|
117 |
{
|
118 |
$add_box = false;
|
119 |
-
|
120 |
-
// get options of matrix
|
121 |
$location = $this->get_acf_location($acf->ID);
|
122 |
-
$options = $this->get_acf_options($acf->ID);
|
123 |
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
// post type
|
126 |
if(in_array(get_post_type($post), $location->post_types)) {$add_box = true; }
|
127 |
|
@@ -165,22 +204,11 @@ if($currentFile == 'post.php' || $currentFile == 'post-new.php')
|
|
165 |
if(!in_array($current_user->user_level, $options->user_roles)) {$add_box = false; }
|
166 |
}
|
167 |
|
168 |
-
|
169 |
|
170 |
if($add_box == true)
|
171 |
{
|
172 |
-
|
173 |
-
if($location->ignore_other_acfs == '1')
|
174 |
-
{
|
175 |
-
// if ignore other acf's was ticked, override the $add_acf array and break the loop
|
176 |
-
$add_acf = array($acf);
|
177 |
-
break;
|
178 |
-
}
|
179 |
-
else
|
180 |
-
{
|
181 |
-
// add acf to array
|
182 |
-
$add_acf[] = $acf;
|
183 |
-
}
|
184 |
}
|
185 |
|
186 |
}// end foreach
|
88 |
|
89 |
// ACF
|
90 |
echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.fields.js" ></script>';
|
91 |
+
echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.location.js" ></script>';
|
92 |
|
93 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.global.css" />';
|
94 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.fields.css" />';
|
96 |
echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.options.css" />';
|
97 |
|
98 |
add_meta_box('acf_fields', 'Fields', array($this, '_fields_meta_box'), 'acf', 'normal', 'high');
|
99 |
+
add_meta_box('acf_location', 'Location </span><span class="description">- Add Fields to Edit Screens', array($this, '_location_meta_box'), 'acf', 'normal', 'high');
|
100 |
add_meta_box('acf_options', 'Advanced Options</span><span class="description">- Customise the edit page', array($this, '_options_meta_box'), 'acf', 'normal', 'high');
|
101 |
|
102 |
}
|
117 |
foreach($acfs as $acf)
|
118 |
{
|
119 |
$add_box = false;
|
|
|
|
|
120 |
$location = $this->get_acf_location($acf->ID);
|
|
|
121 |
|
122 |
|
123 |
+
if($location->allorany == 'all')
|
124 |
+
{
|
125 |
+
// ALL
|
126 |
+
|
127 |
+
$add_box = true;
|
128 |
+
|
129 |
+
if($location->rules)
|
130 |
+
{
|
131 |
+
foreach($location->rules as $rule)
|
132 |
+
{
|
133 |
+
// if any rules dont return true, dont add this acf
|
134 |
+
if(!$this->match_location_rule($post, $rule))
|
135 |
+
{
|
136 |
+
$add_box = false;
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
142 |
+
elseif($location->allorany == 'any')
|
143 |
+
{
|
144 |
+
// ANY
|
145 |
+
|
146 |
+
$add_box = false;
|
147 |
+
|
148 |
+
if($location->rules)
|
149 |
+
{
|
150 |
+
foreach($location->rules as $rule)
|
151 |
+
{
|
152 |
+
// if any rules return true, add this acf
|
153 |
+
if($this->match_location_rule($post, $rule))
|
154 |
+
{
|
155 |
+
$add_box = true;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
//$options = $this->get_acf_options($acf->ID);
|
162 |
+
/*
|
163 |
+
|
164 |
// post type
|
165 |
if(in_array(get_post_type($post), $location->post_types)) {$add_box = true; }
|
166 |
|
204 |
if(!in_array($current_user->user_level, $options->user_roles)) {$add_box = false; }
|
205 |
}
|
206 |
|
207 |
+
*/
|
208 |
|
209 |
if($add_box == true)
|
210 |
{
|
211 |
+
$add_acf[] = $acf;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
|
214 |
}// end foreach
|
core/api.php
CHANGED
@@ -98,10 +98,7 @@ function get_acf($post_id = false)
|
|
98 |
unset($fields[$i]);
|
99 |
}
|
100 |
}
|
101 |
-
|
102 |
-
//print_r($fields);
|
103 |
-
//echo '</pre>';
|
104 |
-
//die;
|
105 |
foreach($fields as $field)
|
106 |
{
|
107 |
|
98 |
unset($fields[$i]);
|
99 |
}
|
100 |
}
|
101 |
+
|
|
|
|
|
|
|
102 |
foreach($fields as $field)
|
103 |
{
|
104 |
|
core/fields/file.php
CHANGED
@@ -45,7 +45,7 @@ class acf_File
|
|
45 |
---------------------------------------------------------------------------------------------*/
|
46 |
function popup_head()
|
47 |
{
|
48 |
-
if($_GET['acf_type'] == 'file')
|
49 |
{
|
50 |
?>
|
51 |
<style type="text/css">
|
45 |
---------------------------------------------------------------------------------------------*/
|
46 |
function popup_head()
|
47 |
{
|
48 |
+
if(isset($_GET["acf_type"]) && $_GET['acf_type'] == 'file')
|
49 |
{
|
50 |
?>
|
51 |
<style type="text/css">
|
core/fields/repeater.php
CHANGED
@@ -504,39 +504,41 @@ class acf_Repeater
|
|
504 |
global $wpdb;
|
505 |
$table_name = $wpdb->prefix.'acf_values';
|
506 |
|
507 |
-
|
508 |
-
foreach($sub_fields as $sub_field)
|
509 |
{
|
510 |
-
|
511 |
-
$db_values = $wpdb->get_results("SELECT value, order_no FROM $table_name WHERE field_id = '$sub_field->id' AND post_id = '$post_id' ORDER BY order_no ASC");
|
512 |
-
|
513 |
-
if($db_values)
|
514 |
{
|
515 |
-
|
|
|
|
|
|
|
516 |
{
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
|
|
|
|
|
|
|
|
527 |
}
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
}
|
534 |
-
|
535 |
}
|
536 |
|
537 |
if(empty($values))
|
538 |
{
|
539 |
-
$values =
|
540 |
}
|
541 |
|
542 |
return $values;
|
504 |
global $wpdb;
|
505 |
$table_name = $wpdb->prefix.'acf_values';
|
506 |
|
507 |
+
if($sub_fields)
|
|
|
508 |
{
|
509 |
+
foreach($sub_fields as $sub_field)
|
|
|
|
|
|
|
510 |
{
|
511 |
+
// get var
|
512 |
+
$db_values = $wpdb->get_results("SELECT value, order_no FROM $table_name WHERE field_id = '$sub_field->id' AND post_id = '$post_id' ORDER BY order_no ASC");
|
513 |
+
|
514 |
+
if($db_values)
|
515 |
{
|
516 |
+
foreach($db_values as $db_value)
|
517 |
+
{
|
518 |
+
|
519 |
+
$value = $db_value->value;
|
520 |
+
// format if needed
|
521 |
+
if(method_exists($this->parent->fields[$sub_field->type], 'format_value_for_api'))
|
522 |
+
{
|
523 |
+
$value = $this->parent->fields[$sub_field->type]->format_value_for_api($value);
|
524 |
+
}
|
525 |
+
|
526 |
+
//echo 'db order no = '.$db_value->order_no;
|
527 |
+
$values[$db_value->order_no][$sub_field->name] = $value;
|
528 |
+
}
|
529 |
+
|
530 |
}
|
531 |
+
else
|
532 |
+
{
|
533 |
+
$values[0][$sub_field->name] = false;
|
534 |
+
}
|
535 |
+
|
536 |
}
|
|
|
537 |
}
|
538 |
|
539 |
if(empty($values))
|
540 |
{
|
541 |
+
$values = false;
|
542 |
}
|
543 |
|
544 |
return $values;
|
core/fields/select.php
CHANGED
@@ -28,7 +28,7 @@ class acf_Select
|
|
28 |
{
|
29 |
echo '<select id="'.$field->input_id.'" class="'.$field->input_class.'" name="'.$field->input_name.'" >';
|
30 |
// add top option
|
31 |
-
echo '<option value="null">- Select Option -</option>';
|
32 |
}
|
33 |
|
34 |
|
28 |
{
|
29 |
echo '<select id="'.$field->input_id.'" class="'.$field->input_class.'" name="'.$field->input_name.'" >';
|
30 |
// add top option
|
31 |
+
//echo '<option value="null">- Select Option -</option>';
|
32 |
}
|
33 |
|
34 |
|
core/fields_save.php
CHANGED
@@ -31,6 +31,15 @@ if(isset($_POST['fields_meta_box']) && $_POST['fields_meta_box'] == 'true')
|
|
31 |
}
|
32 |
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
// clean field
|
35 |
$field = stripslashes_deep($field);
|
36 |
|
31 |
}
|
32 |
|
33 |
|
34 |
+
// defaults
|
35 |
+
if(!isset($field['label'])) { $field['label'] = ""; }
|
36 |
+
if(!isset($field['name'])) { $field['label'] = ""; }
|
37 |
+
if(!isset($field['type'])) { $field['label'] = "text"; }
|
38 |
+
if(!isset($field['options'])) { $field['options'] = array(); }
|
39 |
+
if(!isset($field['instructions'])) { $field['instructions'] = ""; }
|
40 |
+
if(!isset($field['save_as_cf'])) { $field['save_as_cf'] = ""; }
|
41 |
+
|
42 |
+
|
43 |
// clean field
|
44 |
$field = stripslashes_deep($field);
|
45 |
|
core/input_meta_box.php
CHANGED
@@ -1,9 +1,18 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
global $post;
|
4 |
|
|
|
|
|
5 |
$acfs = $args['args']['acfs'];
|
6 |
-
$
|
|
|
|
|
|
|
|
|
7 |
|
8 |
$fields = array();
|
9 |
|
@@ -15,67 +24,122 @@
|
|
15 |
{
|
16 |
$fields[] = $this_field;
|
17 |
}
|
18 |
-
|
19 |
-
}
|
20 |
|
21 |
-
|
22 |
-
$adv_options = $this->get_acf_options($acfs[0]->ID);
|
23 |
|
24 |
-
|
25 |
?>
|
26 |
|
27 |
|
28 |
<input type="hidden" name="ei_noncename" id="ei_noncename" value="<?php echo wp_create_nonce('ei-n'); ?>" />
|
29 |
<input type="hidden" name="input_meta_box" value="true" />
|
30 |
-
<?php
|
31 |
|
32 |
|
33 |
-
|
34 |
-
if(!in_array('the_content',$adv_options->show_on_page)): ?>
|
35 |
-
<style type="text/css">
|
36 |
#postdivrich {display: none;}
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
<?php foreach($adv_options->show_on_page as $option): ?>
|
42 |
-
<input type="hidden" name="show_<?php echo $option; ?>" value="true" />
|
43 |
-
<?php endforeach; ?>
|
44 |
|
45 |
<div class="acf_fields_input">
|
46 |
-
|
47 |
-
<?php foreach($fields as $field): $i++ ?>
|
48 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
|
51 |
-
if($field->type == 'null')
|
52 |
{
|
53 |
-
|
54 |
}
|
55 |
-
|
56 |
-
|
57 |
-
// set value, id and name for field
|
58 |
-
$value = $this->load_value_for_input($post->ID, $field);
|
59 |
|
60 |
-
|
61 |
-
$
|
62 |
-
|
63 |
-
$field->input_class = '';
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
74 |
|
75 |
-
<label for="<?php echo $field->input_id ?>"><?php echo $field->label ?></label>
|
76 |
-
<?php if($field->instructions): ?><p class="instructions"><?php echo $field->instructions; ?></p><?php endif; ?>
|
77 |
-
<?php $this->create_field($field); ?>
|
78 |
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
</div>
|
1 |
<?php
|
2 |
+
|
3 |
+
/*---------------------------------------------------------------------------------------------
|
4 |
+
Input Meta Box
|
5 |
+
---------------------------------------------------------------------------------------------*/
|
6 |
|
|
|
7 |
|
8 |
+
// vars
|
9 |
+
global $post;
|
10 |
$acfs = $args['args']['acfs'];
|
11 |
+
$adv_options = $this->get_acf_options($acfs[0]->ID);
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
|
17 |
$fields = array();
|
18 |
|
24 |
{
|
25 |
$fields[] = $this_field;
|
26 |
}
|
|
|
|
|
27 |
|
28 |
+
}
|
|
|
29 |
|
|
|
30 |
?>
|
31 |
|
32 |
|
33 |
<input type="hidden" name="ei_noncename" id="ei_noncename" value="<?php echo wp_create_nonce('ei-n'); ?>" />
|
34 |
<input type="hidden" name="input_meta_box" value="true" />
|
|
|
35 |
|
36 |
|
37 |
+
<style type="text/css">
|
38 |
+
<?php if(!in_array('the_content',$adv_options->show_on_page)): ?>
|
|
|
39 |
#postdivrich {display: none;}
|
40 |
+
<?php endif; ?>
|
41 |
+
|
42 |
+
<?php if(!in_array('custom_fields',$adv_options->show_on_page)): ?>
|
43 |
+
#postcustom,
|
44 |
+
#screen-meta label[for=postcustom-hide] {display: none;}
|
45 |
+
<?php endif; ?>
|
46 |
+
|
47 |
+
<?php if(!in_array('discussion',$adv_options->show_on_page)): ?>
|
48 |
+
#commentstatusdiv,
|
49 |
+
#screen-meta label[for=commentstatusdiv-hide] {display: none;}
|
50 |
+
<?php endif; ?>
|
51 |
+
|
52 |
+
<?php if(!in_array('comments',$adv_options->show_on_page)): ?>
|
53 |
+
#commentsdiv,
|
54 |
+
#screen-meta label[for=commentsdiv-hide] {display: none;}
|
55 |
+
<?php endif; ?>
|
56 |
+
|
57 |
+
<?php if(!in_array('slug',$adv_options->show_on_page)): ?>
|
58 |
+
#slugdiv,
|
59 |
+
#screen-meta label[for=slugdiv-hide] {display: none;}
|
60 |
+
<?php endif; ?>
|
61 |
+
|
62 |
+
<?php if(!in_array('author',$adv_options->show_on_page)): ?>
|
63 |
+
#authordiv,
|
64 |
+
#screen-meta label[for=authordiv-hide] {display: none;}
|
65 |
+
<?php endif; ?>
|
66 |
+
|
67 |
+
#screen-meta label[for=acf_input-hide] {display: none;}
|
68 |
+
</style>
|
69 |
|
|
|
|
|
|
|
70 |
|
71 |
<div class="acf_fields_input">
|
72 |
+
|
|
|
73 |
<?php
|
74 |
+
|
75 |
+
$i = 0;
|
76 |
+
foreach($acfs as $acf)
|
77 |
+
{
|
78 |
+
|
79 |
+
// load acf data
|
80 |
+
$options = $this->get_acf_options($acf->ID);
|
81 |
+
$fields = $this->get_fields($acf->ID);
|
82 |
+
$html = '';
|
83 |
+
|
84 |
|
85 |
+
if($options->field_group_layout == "in_box")
|
|
|
86 |
{
|
87 |
+
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">';
|
88 |
}
|
|
|
|
|
|
|
|
|
89 |
|
90 |
+
|
91 |
+
foreach($fields as $field)
|
92 |
+
{
|
|
|
93 |
|
94 |
+
// if they didn't select a type, skip this field
|
95 |
+
if($field->type == 'null')
|
96 |
+
{
|
97 |
+
continue;
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
// set value, id and name for field
|
102 |
+
$field->value = $this->load_value_for_input($post->ID, $field);
|
103 |
+
$field->input_id = 'acf['.$i.'][value]';
|
104 |
+
$field->input_name = 'acf['.$i.'][value]';
|
105 |
+
$field->input_class = '';
|
106 |
+
|
107 |
+
|
108 |
+
echo '<div class="field">';
|
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 |
+
|
113 |
+
|
114 |
+
if($field->save_as_cf == 1)
|
115 |
+
{
|
116 |
+
echo '<input type="hidden" name="acf['.$i.'][save_as_cf]" value="'.$field->name.'" />';
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
echo '<label for="'.$field->input_id.'">'.$field->label.'</label>';
|
121 |
+
|
122 |
+
|
123 |
+
if($field->instructions)
|
124 |
+
{
|
125 |
+
echo '<p class="instructions">'.$field->instructions.'</p>';
|
126 |
+
}
|
127 |
+
|
128 |
+
|
129 |
+
$this->create_field($field);
|
130 |
|
131 |
+
echo '</div>';
|
132 |
+
|
133 |
+
$i++;
|
134 |
+
}
|
135 |
|
|
|
|
|
|
|
136 |
|
137 |
+
if($options->field_group_layout == "in_box")
|
138 |
+
{
|
139 |
+
echo '</div></div>';
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
?>
|
144 |
+
|
145 |
</div>
|
core/input_save.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*---------------------------------------------------------------------------------------------
|
3 |
Fields Meta Box
|
4 |
---------------------------------------------------------------------------------------------*/
|
5 |
-
if($_POST['input_meta_box'] == 'true')
|
6 |
{
|
7 |
|
8 |
// If acf was not posted, don't go any further
|
2 |
/*---------------------------------------------------------------------------------------------
|
3 |
Fields Meta Box
|
4 |
---------------------------------------------------------------------------------------------*/
|
5 |
+
if(isset($_POST['input_meta_box']) && $_POST['input_meta_box'] == 'true')
|
6 |
{
|
7 |
|
8 |
// If acf was not posted, don't go any further
|
core/location_meta_box.php
CHANGED
@@ -4,211 +4,258 @@
|
|
4 |
|
5 |
// get options
|
6 |
$location = $this->get_acf_location($post->ID);
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
// create temp field from creating inputs
|
9 |
$temp_field = new stdClass();
|
10 |
?>
|
11 |
|
12 |
-
<a class="help" href="javascript:;"></a>
|
13 |
-
|
14 |
-
<div class="help_box_mask">
|
15 |
-
<div class="help_box">
|
16 |
-
<h4><?php _e("Enter values in the fields below to add this ACF to an edit screen",'acf'); ?></h4>
|
17 |
-
<ul>
|
18 |
-
<li><?php _e("The values you enter bellow will be used to match against edit screens",'acf'); ?></li>
|
19 |
-
<li><?php _e("If <strong>any</strong> of the values match the edit screen, this ACF will be used",'acf'); ?></li>
|
20 |
-
<li><?php _e("Blank fields will be ignored",'acf'); ?></li>
|
21 |
-
<li><?php _e("Use the override to remove all previous ACF's form an edit screen. This is useful for creating an ACF for all normal pages, and then creating a custom ACF for a home page (page title = 'Home'). Please note that the home page ACF needs a higher page order to remove ACF's before it",'acf'); ?></li>
|
22 |
-
</ul>
|
23 |
-
</div>
|
24 |
-
</div>
|
25 |
-
|
26 |
<input type="hidden" name="location_meta_box" value="true" />
|
27 |
<input type="hidden" name="ei_noncename" id="ei_noncename" value="<?php echo wp_create_nonce('ei-n'); ?>" />
|
28 |
|
29 |
<table class="acf_input" id="acf_location">
|
|
|
30 |
<tr>
|
31 |
<td class="label">
|
32 |
-
<label for="post_type"
|
33 |
-
<p class="description"
|
34 |
</td>
|
35 |
<td>
|
36 |
-
<?php
|
37 |
-
|
38 |
-
$post_types = array();
|
39 |
-
|
40 |
-
foreach (get_post_types() as $post_type ) {
|
41 |
-
$post_types[$post_type] = $post_type;
|
42 |
-
}
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
|
50 |
-
$temp_field->type = 'checkbox';
|
51 |
-
$temp_field->input_name = 'acf[location][post_types]';
|
52 |
-
$temp_field->input_class = '';
|
53 |
-
$temp_field->input_id = 'post_types';
|
54 |
-
$temp_field->value = $location->post_types;
|
55 |
-
$temp_field->options = array(
|
56 |
-
'choices' => $post_types,
|
57 |
-
);
|
58 |
-
|
59 |
-
$this->create_field($temp_field);
|
60 |
-
|
61 |
-
?>
|
62 |
-
|
63 |
-
</td>
|
64 |
-
</tr>
|
65 |
-
<tr>
|
66 |
-
<td class="label">
|
67 |
-
<label for="page_title"><?php _e("Page Title's",'acf'); ?></label>
|
68 |
-
<p class="description"><?php _e("eg. Home, About Us",'acf'); ?></p>
|
69 |
-
</td>
|
70 |
-
<td>
|
71 |
-
<?php
|
72 |
-
|
73 |
-
$temp_field->type = 'text';
|
74 |
-
$temp_field->input_name = 'acf[location][page_titles]';
|
75 |
-
$temp_field->input_class = '';
|
76 |
-
$temp_field->input_id = 'page_titles';
|
77 |
-
$temp_field->value = implode(', ',$location->page_titles);
|
78 |
-
$temp_field->options = array();
|
79 |
-
|
80 |
-
$this->create_field($temp_field);
|
81 |
-
|
82 |
-
?>
|
83 |
-
|
84 |
-
</td>
|
85 |
-
</tr>
|
86 |
-
<tr>
|
87 |
-
<td class="label">
|
88 |
-
<label for="page_slug"><?php _e("Page Slug's",'acf'); ?></label>
|
89 |
-
<p class="description"><?php _e("eg. home, about-us",'acf'); ?></p>
|
90 |
-
</td>
|
91 |
-
<td>
|
92 |
-
<?php
|
93 |
-
|
94 |
-
$temp_field->type = 'text';
|
95 |
-
$temp_field->input_name = 'acf[location][page_slugs]';
|
96 |
-
$temp_field->input_class = '';
|
97 |
-
$temp_field->input_id = 'page_slugs';
|
98 |
-
$temp_field->value = implode(', ',$location->page_slugs);
|
99 |
-
$temp_field->options = array();
|
100 |
-
|
101 |
-
$this->create_field($temp_field);
|
102 |
-
|
103 |
-
?>
|
104 |
-
|
105 |
-
</td>
|
106 |
-
</tr>
|
107 |
-
<tr>
|
108 |
-
<td class="label">
|
109 |
-
<label for="post_id"><?php _e("Post ID's",'acf'); ?></label>
|
110 |
-
<p class="description"><?php _e("eg. 1, 2, 3",'acf'); ?></p>
|
111 |
-
</td>
|
112 |
-
<td>
|
113 |
-
<?php
|
114 |
-
|
115 |
-
$temp_field->type = 'text';
|
116 |
-
$temp_field->input_name = 'acf[location][post_ids]';
|
117 |
-
$temp_field->input_class = '';
|
118 |
-
$temp_field->input_id = 'post_ids';
|
119 |
-
$temp_field->value = implode(', ',$location->post_ids);
|
120 |
-
$temp_field->options = array();
|
121 |
-
|
122 |
-
$this->create_field($temp_field);
|
123 |
-
|
124 |
-
?>
|
125 |
-
|
126 |
-
</td>
|
127 |
-
</tr>
|
128 |
-
<tr>
|
129 |
-
<td class="label">
|
130 |
-
<label for="template_name"><?php _e("Page Template's",'acf'); ?></label>
|
131 |
-
<p class="description"><?php _e("eg. home_page.php",'acf'); ?></p>
|
132 |
-
</td>
|
133 |
-
<td>
|
134 |
-
<?php
|
135 |
-
|
136 |
-
$temp_field->type = 'text';
|
137 |
-
$temp_field->input_name = 'acf[location][page_templates]';
|
138 |
-
$temp_field->input_class = '';
|
139 |
-
$temp_field->input_id = 'page_templates';
|
140 |
-
$temp_field->value = implode(', ',$location->page_templates);
|
141 |
-
$temp_field->options = array();
|
142 |
-
|
143 |
-
$this->create_field($temp_field);
|
144 |
-
|
145 |
-
?>
|
146 |
-
|
147 |
-
</td>
|
148 |
-
</tr>
|
149 |
-
<tr>
|
150 |
-
<td class="label">
|
151 |
-
<label for="page_parent"><?php _e("Page Parent ID's",'acf'); ?></label>
|
152 |
-
<p class="description"><?php _e("eg. 1, 2, 3",'acf'); ?></p>
|
153 |
-
</td>
|
154 |
-
<td>
|
155 |
-
<?php
|
156 |
-
|
157 |
-
$temp_field->type = 'text';
|
158 |
-
$temp_field->input_name = 'acf[location][page_parents]';
|
159 |
-
$temp_field->input_class = '';
|
160 |
-
$temp_field->input_id = 'page_parents';
|
161 |
-
$temp_field->value = implode(', ',$location->page_parents);
|
162 |
-
$temp_field->options = array();
|
163 |
-
|
164 |
-
$this->create_field($temp_field);
|
165 |
-
|
166 |
-
?>
|
167 |
-
|
168 |
-
</td>
|
169 |
-
</tr>
|
170 |
-
<tr>
|
171 |
-
<td class="label">
|
172 |
-
<label for="category_names"><?php _e("Category Names's",'acf'); ?></label>
|
173 |
-
<p class="description"><?php _e("eg. News, Media, Uncategoriazed",'acf'); ?></p>
|
174 |
-
</td>
|
175 |
-
<td>
|
176 |
-
<?php
|
177 |
-
|
178 |
-
$temp_field->type = 'text';
|
179 |
-
$temp_field->input_name = 'acf[location][category_names]';
|
180 |
-
$temp_field->input_class = '';
|
181 |
-
$temp_field->input_id = 'category_names';
|
182 |
-
$temp_field->value = implode(', ',$location->category_names);
|
183 |
-
$temp_field->options = array();
|
184 |
-
|
185 |
-
$this->create_field($temp_field);
|
186 |
-
|
187 |
-
?>
|
188 |
-
|
189 |
-
</td>
|
190 |
-
</tr>
|
191 |
-
<tr>
|
192 |
-
<td class="label">
|
193 |
-
<label for="page_parent"><?php _e("Overrides",'acf'); ?></label>
|
194 |
-
<p class="description"><?php _e("Tick this box to remove all other ACF's (from the edit screen where this ACF appears)",'acf'); ?></p>
|
195 |
-
</td>
|
196 |
-
<td>
|
197 |
-
<?php
|
198 |
-
|
199 |
-
$temp_field->type = 'true_false';
|
200 |
-
$temp_field->input_name = 'acf[location][ignore_other_acfs]';
|
201 |
-
$temp_field->input_class = '';
|
202 |
-
$temp_field->input_id = 'ignore_other_acfs';
|
203 |
-
$temp_field->value = $location->ignore_other_acfs;
|
204 |
-
$temp_field->options = array(
|
205 |
-
'message' => 'Ignore all other Advanced Custom Field\'s'
|
206 |
-
);
|
207 |
-
|
208 |
-
$this->create_field($temp_field);
|
209 |
-
|
210 |
-
?>
|
211 |
-
|
212 |
</td>
|
|
|
213 |
</tr>
|
214 |
-
|
|
|
|
4 |
|
5 |
// get options
|
6 |
$location = $this->get_acf_location($post->ID);
|
7 |
+
if(!isset($location->rules) || empty($location->rules))
|
8 |
+
{
|
9 |
+
$rule = new stdClass();
|
10 |
+
$rule->param = '';
|
11 |
+
$rule->operator = '';
|
12 |
+
$rule->value = '';
|
13 |
+
|
14 |
+
$location->rules = array();
|
15 |
+
$location->rules[] = $rule;
|
16 |
+
}
|
17 |
// create temp field from creating inputs
|
18 |
$temp_field = new stdClass();
|
19 |
?>
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
<input type="hidden" name="location_meta_box" value="true" />
|
22 |
<input type="hidden" name="ei_noncename" id="ei_noncename" value="<?php echo wp_create_nonce('ei-n'); ?>" />
|
23 |
|
24 |
<table class="acf_input" id="acf_location">
|
25 |
+
<tbody>
|
26 |
<tr>
|
27 |
<td class="label">
|
28 |
+
<label for="post_type">Rules</label>
|
29 |
+
<p class="description">Create a set of rules to determine which edit screens will use these advanced custom fields</p>
|
30 |
</td>
|
31 |
<td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
<div class="location_rules">
|
34 |
+
<?php if($location->rules): ?>
|
35 |
+
<table class="acf_input" id="location_rules">
|
36 |
+
<tbody>
|
37 |
+
<?php foreach($location->rules as $k => $rule): ?>
|
38 |
+
<tr>
|
39 |
+
<td class="param">
|
40 |
+
<?php
|
41 |
+
|
42 |
+
$temp_field->type = 'select';
|
43 |
+
$temp_field->input_name = 'acf[location][rules]['.$k.'][param]';
|
44 |
+
$temp_field->input_class = '';
|
45 |
+
$temp_field->input_id = '';
|
46 |
+
$temp_field->value = $rule->param;
|
47 |
+
$temp_field->options = array('choices' => array(
|
48 |
+
'post_type' => 'Post Type',
|
49 |
+
'page' => 'Page',
|
50 |
+
'page_type' => 'Page Type',
|
51 |
+
//'page_parent' => 'Page Parent',
|
52 |
+
'page_template' => 'Page Template',
|
53 |
+
'post' => 'Post',
|
54 |
+
'post_category' => 'Post Category',
|
55 |
+
'user_type' => 'User Type'
|
56 |
+
));
|
57 |
+
|
58 |
+
$this->create_field($temp_field);
|
59 |
+
|
60 |
+
?>
|
61 |
+
|
62 |
+
</td>
|
63 |
+
<td class="operator">
|
64 |
+
<?php
|
65 |
+
|
66 |
+
$temp_field->type = 'select';
|
67 |
+
$temp_field->input_name = 'acf[location][rules]['.$k.'][operator]';
|
68 |
+
$temp_field->input_class = '';
|
69 |
+
$temp_field->input_id = '';
|
70 |
+
$temp_field->value = $rule->operator;
|
71 |
+
$temp_field->options = array('choices' => array(
|
72 |
+
'==' => 'is equal to',
|
73 |
+
'!=' => 'is not equal to',
|
74 |
+
));
|
75 |
+
|
76 |
+
$this->create_field($temp_field);
|
77 |
+
|
78 |
+
?>
|
79 |
+
</td>
|
80 |
+
<td class="value">
|
81 |
+
<div rel="post_type">
|
82 |
+
<?php
|
83 |
+
$choices = get_post_types();
|
84 |
+
|
85 |
+
unset($choices['attachment']);
|
86 |
+
unset($choices['nav_menu_item']);
|
87 |
+
unset($choices['revision']);
|
88 |
+
unset($choices['acf']);
|
89 |
+
|
90 |
+
$temp_field->type = 'select';
|
91 |
+
$temp_field->input_name = 'acf[location][rules]['.$k.'][value]';
|
92 |
+
$temp_field->input_class = '';
|
93 |
+
$temp_field->input_id = '';
|
94 |
+
$temp_field->value = $rule->value;
|
95 |
+
$temp_field->options = array(
|
96 |
+
'choices' => $choices,
|
97 |
+
);
|
98 |
+
|
99 |
+
$this->create_field($temp_field);
|
100 |
+
|
101 |
+
?>
|
102 |
+
</div>
|
103 |
+
<div rel="page">
|
104 |
+
<?php
|
105 |
+
$choices = array();
|
106 |
+
|
107 |
+
foreach(get_pages('sort_column=menu_order&sort_order=desc') as $page)
|
108 |
+
{
|
109 |
+
if($page->post_parent != 0)
|
110 |
+
{
|
111 |
+
$choices[$page->ID] = '- '.$page->post_title;
|
112 |
+
}
|
113 |
+
else
|
114 |
+
{
|
115 |
+
$choices[$page->ID] = $page->post_title;
|
116 |
+
}
|
117 |
+
|
118 |
+
}
|
119 |
+
$temp_field->options = array(
|
120 |
+
'choices' => $choices,
|
121 |
+
);
|
122 |
+
|
123 |
+
$this->create_field($temp_field);
|
124 |
+
|
125 |
+
?>
|
126 |
+
</div>
|
127 |
+
<div rel="page_type">
|
128 |
+
<?php
|
129 |
+
$choices = array(
|
130 |
+
'parent' => 'Parent Page',
|
131 |
+
'child' => 'Child Page'
|
132 |
+
);
|
133 |
+
|
134 |
+
$temp_field->options = array(
|
135 |
+
'choices' => $choices,
|
136 |
+
);
|
137 |
+
|
138 |
+
$this->create_field($temp_field);
|
139 |
+
|
140 |
+
?>
|
141 |
+
</div>
|
142 |
+
<?php /*<div rel="page_parent">
|
143 |
+
<?php
|
144 |
+
$choices = array();
|
145 |
+
foreach(get_pages('parent=0&sort_column=menu_order&sort_order=desc') as $page)
|
146 |
+
{
|
147 |
+
$choices[$page->ID] = $page->post_title;
|
148 |
+
}
|
149 |
+
$temp_field->options = array(
|
150 |
+
'choices' => $choices,
|
151 |
+
);
|
152 |
+
|
153 |
+
$this->create_field($temp_field);
|
154 |
+
|
155 |
+
?>
|
156 |
+
</div> */ ?>
|
157 |
+
<div rel="page_template">
|
158 |
+
|
159 |
+
<?php
|
160 |
+
|
161 |
+
$choices = array();
|
162 |
+
$choices['default'] = 'Default Template';
|
163 |
+
foreach(get_page_templates() as $k => $v)
|
164 |
+
{
|
165 |
+
$choices[$v] = $k;
|
166 |
+
}
|
167 |
+
$temp_field->options = array(
|
168 |
+
'choices' => $choices,
|
169 |
+
);
|
170 |
+
|
171 |
+
$this->create_field($temp_field);
|
172 |
+
|
173 |
+
?>
|
174 |
+
</div>
|
175 |
+
<div rel="post">
|
176 |
+
|
177 |
+
<?php
|
178 |
+
$choices = array();
|
179 |
+
foreach(get_posts(array('numberposts'=>'-1')) as $v)
|
180 |
+
{
|
181 |
+
$choices[$v->ID] = $v->post_title;
|
182 |
+
}
|
183 |
+
$temp_field->options = array(
|
184 |
+
'choices' => $choices,
|
185 |
+
);
|
186 |
+
|
187 |
+
$this->create_field($temp_field);
|
188 |
+
|
189 |
+
?>
|
190 |
+
</div>
|
191 |
+
<div rel="post_category">
|
192 |
+
|
193 |
+
<?php
|
194 |
+
|
195 |
+
$choices = array();
|
196 |
+
foreach(get_categories() as $v);
|
197 |
+
{
|
198 |
+
$choices[$v->term_id] = $v->name;
|
199 |
+
}
|
200 |
+
$temp_field->options = array(
|
201 |
+
'choices' => $choices,
|
202 |
+
);
|
203 |
+
|
204 |
+
$this->create_field($temp_field);
|
205 |
+
|
206 |
+
?>
|
207 |
+
</div>
|
208 |
+
<div rel="user_type">
|
209 |
+
|
210 |
+
<?php
|
211 |
+
|
212 |
+
$choices = array(
|
213 |
+
'administrator' => 'Administrator',
|
214 |
+
'editor' => 'Editor',
|
215 |
+
'author' => 'Author',
|
216 |
+
'contributor' => 'contributor'
|
217 |
+
);
|
218 |
+
|
219 |
+
$temp_field->options = array(
|
220 |
+
'choices' => $choices,
|
221 |
+
);
|
222 |
+
|
223 |
+
$this->create_field($temp_field);
|
224 |
+
|
225 |
+
?>
|
226 |
+
</div>
|
227 |
+
</td>
|
228 |
+
<td class="buttons">
|
229 |
+
<a href="javascript:;" class="remove"></a>
|
230 |
+
<a href="javascript:;" class="add"></a>
|
231 |
+
</td>
|
232 |
+
</tr>
|
233 |
+
<?php endforeach; ?>
|
234 |
+
</tbody>
|
235 |
+
|
236 |
+
</table>
|
237 |
+
<?php endif; ?>
|
238 |
+
<p>match <?php
|
239 |
+
|
240 |
+
$temp_field->type = 'select';
|
241 |
+
$temp_field->input_name = 'acf[location][allorany]';
|
242 |
+
$temp_field->input_class = '';
|
243 |
+
$temp_field->input_id = '';
|
244 |
+
$temp_field->value = $location->allorany;
|
245 |
+
$temp_field->options = array('choices' => array(
|
246 |
+
'all' => 'all',
|
247 |
+
'any' => 'any',
|
248 |
+
));
|
249 |
+
|
250 |
+
$this->create_field($temp_field);
|
251 |
+
|
252 |
+
?> of the above criteria</p>
|
253 |
+
</div>
|
254 |
|
255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
</td>
|
257 |
+
|
258 |
</tr>
|
259 |
+
|
260 |
+
</tbody>
|
261 |
+
</table>
|
core/location_save.php
CHANGED
@@ -4,59 +4,42 @@
|
|
4 |
---------------------------------------------------------------------------------------------*/
|
5 |
if(isset($_POST['location_meta_box']) && $_POST['location_meta_box'] == 'true')
|
6 |
{
|
7 |
-
|
8 |
global $wpdb;
|
9 |
-
$table_name = $wpdb->prefix.'
|
10 |
|
11 |
|
12 |
// remove all old fields from the database
|
13 |
-
$wpdb->query("DELETE FROM $table_name WHERE acf_id = '$post_id'
|
|
|
14 |
|
15 |
-
|
16 |
// turn inputs into database friendly data
|
17 |
-
$
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
{
|
20 |
-
foreach($
|
21 |
{
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
// already array, serialize the array for database save
|
32 |
-
$value = serialize($value);
|
33 |
-
}
|
34 |
-
elseif($key == 'ignore_other_acfs')
|
35 |
-
{
|
36 |
-
// do nothing
|
37 |
-
}
|
38 |
-
else
|
39 |
{
|
40 |
-
|
41 |
-
$value = str_replace(', ',',',$value);
|
42 |
-
$value = explode(',',$value);
|
43 |
-
|
44 |
-
// serialize the array for database save
|
45 |
-
$value = serialize($value);
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
$new_id = $wpdb->insert($table_name, array(
|
50 |
-
'acf_id' => $post_id,
|
51 |
-
'name' => $key,
|
52 |
-
'value' => $value,
|
53 |
-
'type' => 'location'
|
54 |
-
));
|
55 |
-
|
56 |
-
//echo $post_id.' : '.$key.': '.' : '.$value;
|
57 |
-
|
58 |
}
|
59 |
}
|
|
|
60 |
}
|
61 |
|
62 |
?>
|
4 |
---------------------------------------------------------------------------------------------*/
|
5 |
if(isset($_POST['location_meta_box']) && $_POST['location_meta_box'] == 'true')
|
6 |
{
|
7 |
+
|
8 |
global $wpdb;
|
9 |
+
$table_name = $wpdb->prefix.'acf_rules';
|
10 |
|
11 |
|
12 |
// remove all old fields from the database
|
13 |
+
$wpdb->query("DELETE FROM $table_name WHERE acf_id = '$post_id'");
|
14 |
+
|
15 |
|
|
|
16 |
// turn inputs into database friendly data
|
17 |
+
$rules = $_POST['acf']['location']['rules'];
|
18 |
+
$allorany = $_POST['acf']['location']['allorany'];
|
19 |
+
|
20 |
+
update_post_meta($post_id, 'allorany', $allorany);
|
21 |
+
|
22 |
+
if($rules)
|
23 |
{
|
24 |
+
foreach($rules as $k => $rule)
|
25 |
{
|
26 |
+
$data = array(
|
27 |
+
'acf_id' => $post_id,
|
28 |
+
'order_no' => $k,
|
29 |
+
'param' => $rule['param'],
|
30 |
+
'operator' => $rule['operator'],
|
31 |
+
'value' => $rule['value']
|
32 |
+
);
|
33 |
+
|
34 |
+
if(isset($rule['id']))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
{
|
36 |
+
$data['id'] = $rule['id'];
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
+
$wpdb->insert($table_name, $data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
}
|
42 |
+
|
43 |
}
|
44 |
|
45 |
?>
|
core/options_meta_box.php
CHANGED
@@ -16,6 +16,8 @@
|
|
16 |
<tr>
|
17 |
<td class="label">
|
18 |
<label for="post_type"><?php _e("Show on page",'acf'); ?></label>
|
|
|
|
|
19 |
</td>
|
20 |
<td>
|
21 |
<?php
|
@@ -23,7 +25,7 @@
|
|
23 |
$temp_field->type = 'checkbox';
|
24 |
$temp_field->input_name = 'acf[options][show_on_page]';
|
25 |
$temp_field->input_class = '';
|
26 |
-
$temp_field->input_id = 'show_on_page';
|
27 |
$temp_field->value = $options->show_on_page;
|
28 |
$temp_field->options = array(
|
29 |
'choices' => array(
|
@@ -40,37 +42,34 @@
|
|
40 |
|
41 |
?>
|
42 |
|
43 |
-
|
44 |
-
Tip: This is useful to customise the edit screen",'acf'); ?></p>
|
45 |
</td>
|
46 |
</tr>
|
47 |
<tr>
|
48 |
<td class="label">
|
49 |
-
<label for="post_type"><?php _e("
|
|
|
50 |
</td>
|
51 |
<td>
|
52 |
<?php
|
53 |
|
54 |
-
$temp_field->type = '
|
55 |
-
$temp_field->input_name = 'acf[options][
|
56 |
$temp_field->input_class = '';
|
57 |
-
$temp_field->input_id = '
|
58 |
-
$temp_field->value = $options->
|
59 |
$temp_field->options = array(
|
60 |
'choices' => array(
|
61 |
-
'
|
62 |
-
'
|
63 |
-
|
64 |
-
'1' => 'contributor'
|
65 |
-
)
|
66 |
);
|
67 |
|
68 |
$this->create_field($temp_field);
|
69 |
|
70 |
?>
|
71 |
-
|
72 |
-
|
73 |
</td>
|
74 |
-
</tr>
|
75 |
-
|
76 |
</table>
|
16 |
<tr>
|
17 |
<td class="label">
|
18 |
<label for="post_type"><?php _e("Show on page",'acf'); ?></label>
|
19 |
+
<p class="description"><?php _e("Deselect items to hide them on the edit page",'acf'); ?></p>
|
20 |
+
<p class="description"><?php _e("If multiple ACF groups appear on an edit page, the first ACF group's options will be used. The first ACF group is the one with the lowest order number.",'acf'); ?></p>
|
21 |
</td>
|
22 |
<td>
|
23 |
<?php
|
25 |
$temp_field->type = 'checkbox';
|
26 |
$temp_field->input_name = 'acf[options][show_on_page]';
|
27 |
$temp_field->input_class = '';
|
28 |
+
$temp_field->input_id = 'acf[options][show_on_page]';
|
29 |
$temp_field->value = $options->show_on_page;
|
30 |
$temp_field->options = array(
|
31 |
'choices' => array(
|
42 |
|
43 |
?>
|
44 |
|
45 |
+
|
|
|
46 |
</td>
|
47 |
</tr>
|
48 |
<tr>
|
49 |
<td class="label">
|
50 |
+
<label for="post_type"><?php _e("Field Group Layout",'acf'); ?></label>
|
51 |
+
<p class="description"><?php _e("Display your field group with or without a box",'acf'); ?></p>
|
52 |
</td>
|
53 |
<td>
|
54 |
<?php
|
55 |
|
56 |
+
$temp_field->type = 'select';
|
57 |
+
$temp_field->input_name = 'acf[options][field_group_layout]';
|
58 |
$temp_field->input_class = '';
|
59 |
+
$temp_field->input_id = '';
|
60 |
+
$temp_field->value = $options->field_group_layout;
|
61 |
$temp_field->options = array(
|
62 |
'choices' => array(
|
63 |
+
'in_box' => 'In a postbox',
|
64 |
+
'default' => 'No Box',
|
65 |
+
)
|
|
|
|
|
66 |
);
|
67 |
|
68 |
$this->create_field($temp_field);
|
69 |
|
70 |
?>
|
71 |
+
|
72 |
+
|
73 |
</td>
|
74 |
+
</tr>
|
|
|
75 |
</table>
|
core/options_save.php
CHANGED
@@ -4,39 +4,14 @@
|
|
4 |
---------------------------------------------------------------------------------------------*/
|
5 |
if(isset($_POST['options_meta_box']) && $_POST['options_meta_box'] == 'true')
|
6 |
{
|
7 |
-
|
8 |
-
global $wpdb;
|
9 |
-
$table_name = $wpdb->prefix.'acf_options';
|
10 |
-
|
11 |
-
|
12 |
// turn inputs into database friendly data
|
13 |
$options = $_POST['acf']['options'];
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
// loop through and save
|
21 |
-
if($options)
|
22 |
-
{
|
23 |
-
foreach($options as $key => $value)
|
24 |
-
{
|
25 |
-
// already array, serialize the array for database save
|
26 |
-
$value = serialize($value);
|
27 |
-
|
28 |
-
|
29 |
-
//save todatabase
|
30 |
-
$new_id = $wpdb->insert($table_name, array(
|
31 |
-
'acf_id' => $post_id,
|
32 |
-
'name' => $key,
|
33 |
-
'value' => $value,
|
34 |
-
'type' => 'option'
|
35 |
-
));
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
|
40 |
}
|
41 |
|
42 |
?>
|
4 |
---------------------------------------------------------------------------------------------*/
|
5 |
if(isset($_POST['options_meta_box']) && $_POST['options_meta_box'] == 'true')
|
6 |
{
|
7 |
+
|
|
|
|
|
|
|
|
|
8 |
// turn inputs into database friendly data
|
9 |
$options = $_POST['acf']['options'];
|
10 |
|
11 |
+
|
12 |
+
update_post_meta($post_id, 'show_on_page', serialize($options['show_on_page']));
|
13 |
+
update_post_meta($post_id, 'field_group_layout', $options['field_group_layout']);
|
14 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
?>
|
core/screen_extra.php
CHANGED
@@ -24,7 +24,7 @@
|
|
24 |
<td>
|
25 |
<form action="" method="post">
|
26 |
<?php if(array_key_exists('repeater', $this->activated_fields)){
|
27 |
-
echo '<span class="activation_code">'
|
28 |
echo '<input type="hidden" name="acf_field_deactivate" value="repeater" />';
|
29 |
echo '<input type="submit" class="button" value="Deactivate" />';
|
30 |
}
|
24 |
<td>
|
25 |
<form action="" method="post">
|
26 |
<?php if(array_key_exists('repeater', $this->activated_fields)){
|
27 |
+
echo '<span class="activation_code">XXXX-XXXX-XXXX-'.substr($this->activated_fields['repeater'],-4) .'</span>';
|
28 |
echo '<input type="hidden" name="acf_field_deactivate" value="repeater" />';
|
29 |
echo '<input type="submit" class="button" value="Deactivate" />';
|
30 |
}
|
core/update.php
CHANGED
@@ -408,8 +408,184 @@ if(version_compare($version,'2.0.1') < 0)
|
|
408 |
) ".$char.";";
|
409 |
dbDelta($sql);
|
410 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
}
|
412 |
|
413 |
-
// update to latest acf version
|
414 |
-
update_option('acf_version','2.0.1');
|
415 |
?>
|
408 |
) ".$char.";";
|
409 |
dbDelta($sql);
|
410 |
}
|
411 |
+
|
412 |
+
update_option('acf_version','2.0.1');
|
413 |
+
$version = '2.0.1';
|
414 |
+
}
|
415 |
+
|
416 |
+
|
417 |
+
/*---------------------------------------------------------------------------------------------
|
418 |
+
* Update to 2.0.1 - this version adds field description and save as custom field columns to acf_fields
|
419 |
+
*
|
420 |
+
* @author Elliot Condon
|
421 |
+
* @since 2.0.6
|
422 |
+
*
|
423 |
+
---------------------------------------------------------------------------------------------*/
|
424 |
+
|
425 |
+
if(version_compare($version,'2.0.2') < 0)
|
426 |
+
{
|
427 |
+
global $wpdb;
|
428 |
+
|
429 |
+
|
430 |
+
// 1. CREATE NEW RULES TABLE
|
431 |
+
|
432 |
+
$table_name = $wpdb->prefix.'acf_rules';
|
433 |
+
|
434 |
+
if ($wpdb->has_cap('collation'))
|
435 |
+
{
|
436 |
+
if(!empty($wpdb->charset))
|
437 |
+
{
|
438 |
+
$charset_collate = " DEFAULT CHARACTER SET $wpdb->charset";
|
439 |
+
}
|
440 |
+
if(!empty($wpdb->collate))
|
441 |
+
{
|
442 |
+
$charset_collate .= " COLLATE $wpdb->collate";
|
443 |
+
|
444 |
+
}
|
445 |
+
}
|
446 |
+
|
447 |
+
if(!$wpdb->get_var("SHOW TABLES LIKE '".$table_name."'"))
|
448 |
+
{
|
449 |
+
// rules table does not exist
|
450 |
+
|
451 |
+
$sql = "CREATE TABLE " . $table_name . " (
|
452 |
+
id bigint(20) NOT NULL AUTO_INCREMENT,
|
453 |
+
acf_id bigint(20) NOT NULL DEFAULT '0',
|
454 |
+
order_no int(9) NOT NULL DEFAULT '0',
|
455 |
+
param text NOT NULL,
|
456 |
+
operator text NOT NULL,
|
457 |
+
value text NOT NULL,
|
458 |
+
UNIQUE KEY id (id)
|
459 |
+
) ".$charset_collate.";";
|
460 |
+
dbDelta($sql);
|
461 |
+
|
462 |
+
}
|
463 |
+
|
464 |
+
|
465 |
+
// 2. SAVE LOCATION DATA AS RULES
|
466 |
+
|
467 |
+
$table_name = $wpdb->prefix.'acf_options';
|
468 |
+
$rules = array();
|
469 |
+
|
470 |
+
|
471 |
+
// get fields and add them to $options
|
472 |
+
$locations = $wpdb->get_results("SELECT * FROM $table_name WHERE type = 'location'");
|
473 |
+
|
474 |
+
|
475 |
+
// rewrite into new format
|
476 |
+
if($locations)
|
477 |
+
{
|
478 |
+
foreach($locations as $location)
|
479 |
+
{
|
480 |
+
|
481 |
+
$values = unserialize($location->value);
|
482 |
+
|
483 |
+
foreach($values as $value)
|
484 |
+
{
|
485 |
+
|
486 |
+
$rules[] = array(
|
487 |
+
'acf_id' => $location->acf_id,
|
488 |
+
'order_no' => 0,
|
489 |
+
'param' => substr($location->name, 0, -1),
|
490 |
+
'operator' => '==',
|
491 |
+
'value' => $value,
|
492 |
+
);
|
493 |
+
|
494 |
+
}
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
|
499 |
+
// 3. SAVE USER TYPE OPTION DATA AS RULES
|
500 |
+
|
501 |
+
|
502 |
+
// get fields and add them to $options
|
503 |
+
$locations = $wpdb->get_results("SELECT * FROM $table_name WHERE type = 'option' AND name = 'user_roles'");
|
504 |
+
|
505 |
+
|
506 |
+
// rewrite into new format
|
507 |
+
if($locations)
|
508 |
+
{
|
509 |
+
|
510 |
+
$user_roles = array(
|
511 |
+
'10' => 'administrator',
|
512 |
+
'7' => 'editor',
|
513 |
+
'4' => 'author',
|
514 |
+
'1' => 'contributor',
|
515 |
+
);
|
516 |
+
|
517 |
+
|
518 |
+
foreach($locations as $location)
|
519 |
+
{
|
520 |
+
|
521 |
+
$values = unserialize($location->value);
|
522 |
+
|
523 |
+
foreach($values as $value)
|
524 |
+
{
|
525 |
+
|
526 |
+
$rules[] = array(
|
527 |
+
'acf_id' => $location->acf_id,
|
528 |
+
'order_no' => 0,
|
529 |
+
'param' => 'user_type',
|
530 |
+
'operator' => '==',
|
531 |
+
'value' => $user_roles[$value],
|
532 |
+
);
|
533 |
+
|
534 |
+
}
|
535 |
+
}
|
536 |
+
}
|
537 |
+
|
538 |
+
|
539 |
+
// 4. SAVE RULES INTO DATABASE
|
540 |
+
|
541 |
+
$table_name = $wpdb->prefix.'acf_rules';
|
542 |
+
|
543 |
+
foreach($rules as $rule)
|
544 |
+
{
|
545 |
+
$wpdb->insert($table_name, $rule);
|
546 |
+
}
|
547 |
+
|
548 |
+
|
549 |
+
// 5. SAVE OPTIONS
|
550 |
+
|
551 |
+
$table_name = $wpdb->prefix.'acf_options';
|
552 |
+
$options = array();
|
553 |
+
|
554 |
+
$options = $wpdb->get_results("SELECT * FROM $table_name WHERE type = 'option' AND name = 'show_on_page'");
|
555 |
+
|
556 |
+
if($options)
|
557 |
+
{
|
558 |
+
foreach($options as $option)
|
559 |
+
{
|
560 |
+
update_post_meta($option->acf_id, 'show_on_page', $option->value);
|
561 |
+
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
+
|
566 |
+
// 6. SAVE NEW POST META
|
567 |
+
|
568 |
+
$options = $wpdb->get_results("SELECT DISTINCT acf_id FROM $table_name WHERE type = 'option'");
|
569 |
+
|
570 |
+
|
571 |
+
if($options)
|
572 |
+
{
|
573 |
+
foreach($options as $option)
|
574 |
+
{
|
575 |
+
update_post_meta($option->acf_id, 'allorany', 'any');
|
576 |
+
update_post_meta($option->acf_id, 'field_group_layout', 'default');
|
577 |
+
}
|
578 |
+
}
|
579 |
+
|
580 |
+
|
581 |
+
// drop options table
|
582 |
+
$wpdb->query("DROP TABLE $table_name");
|
583 |
+
|
584 |
+
|
585 |
+
update_option('acf_version','2.0.2');
|
586 |
+
$version = '2.0.2';
|
587 |
+
|
588 |
+
|
589 |
}
|
590 |
|
|
|
|
|
591 |
?>
|
css/style.fields.css
CHANGED
@@ -16,6 +16,7 @@
|
|
16 |
|
17 |
.postbox#acf_fields .inside {
|
18 |
margin: 0;
|
|
|
19 |
}
|
20 |
|
21 |
/*---------------------------------------------------------------------------------------------
|
16 |
|
17 |
.postbox#acf_fields .inside {
|
18 |
margin: 0;
|
19 |
+
padding: 0;
|
20 |
}
|
21 |
|
22 |
/*---------------------------------------------------------------------------------------------
|
css/style.input.css
CHANGED
@@ -7,15 +7,13 @@
|
|
7 |
|
8 |
.acf_fields_input {
|
9 |
position: relative;
|
10 |
-
border-top: 1px solid #eaeaea;
|
11 |
-
border-bottom: 1px solid #FFFFFF;
|
12 |
}
|
13 |
|
14 |
.acf_fields_input .field {
|
15 |
position: relative;
|
16 |
padding: 10px 2px;
|
17 |
-
border-
|
18 |
-
|
19 |
}
|
20 |
|
21 |
.acf_fields_input .field label {
|
@@ -27,23 +25,16 @@
|
|
27 |
text-shadow: 0 1px 0 #FFFFFF;
|
28 |
}
|
29 |
|
30 |
-
/* .acf_fields_input .field:first-child {
|
31 |
-
border-top: 0 none;
|
32 |
-
}
|
33 |
-
|
34 |
-
.acf_fields_input .field:last-child {
|
35 |
-
border-bottom: 0 none;
|
36 |
-
} */
|
37 |
|
38 |
-
.postbox#acf_input
|
39 |
display: none;
|
40 |
}
|
41 |
|
42 |
-
.postbox#acf_input .inside {
|
43 |
margin: 0;
|
44 |
}
|
45 |
|
46 |
-
.postbox#acf_input .handlediv {
|
47 |
display: none;
|
48 |
height: 0;
|
49 |
width: 0;
|
@@ -301,4 +292,33 @@ a.remove_field:hover {
|
|
301 |
|
302 |
ul.checkbox_list {
|
303 |
background: transparent !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
}
|
7 |
|
8 |
.acf_fields_input {
|
9 |
position: relative;
|
|
|
|
|
10 |
}
|
11 |
|
12 |
.acf_fields_input .field {
|
13 |
position: relative;
|
14 |
padding: 10px 2px;
|
15 |
+
border-top: 1px solid #eaeaea;
|
16 |
+
-moz-box-shadow: inset 0px 1px 0px #fff; -webkit-box-shadow: inset 0px 1px 0px #fff; box-shadow: inset 0px 1px 0px #fff;
|
17 |
}
|
18 |
|
19 |
.acf_fields_input .field label {
|
25 |
text-shadow: 0 1px 0 #FFFFFF;
|
26 |
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
.postbox#acf_input > h3.hndle{
|
30 |
display: none;
|
31 |
}
|
32 |
|
33 |
+
.postbox#acf_input > .inside {
|
34 |
margin: 0;
|
35 |
}
|
36 |
|
37 |
+
.postbox#acf_input > .handlediv {
|
38 |
display: none;
|
39 |
height: 0;
|
40 |
width: 0;
|
292 |
|
293 |
ul.checkbox_list {
|
294 |
background: transparent !important;
|
295 |
+
}
|
296 |
+
|
297 |
+
|
298 |
+
/*---------------------------------------------------------------------------------------------
|
299 |
+
In Box
|
300 |
+
---------------------------------------------------------------------------------------------*/
|
301 |
+
|
302 |
+
#acf_input .acf_fields_input {
|
303 |
+
|
304 |
+
}
|
305 |
+
|
306 |
+
#acf_input .acf_fields_input .postbox {
|
307 |
+
background: #fdfdfd;
|
308 |
+
}
|
309 |
+
|
310 |
+
#acf_input .acf_fields_input .postbox .inside {
|
311 |
+
margin: 0;
|
312 |
+
|
313 |
+
}
|
314 |
+
|
315 |
+
#acf_input .acf_fields_input .postbox .inside .field {
|
316 |
+
padding: 10px 10px;
|
317 |
+
border-top: 1px solid #f3f3f3;
|
318 |
+
-moz-box-shadow: inset 0px 1px 0px #fff; -webkit-box-shadow: inset 0px 1px 0px #fff; box-shadow: inset 0px 1px 0px #fff;
|
319 |
+
}
|
320 |
+
|
321 |
+
#acf_input .acf_fields_input .postbox .inside .field:first-child {
|
322 |
+
border-top: none;
|
323 |
+
-moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none;
|
324 |
}
|
css/style.location.css
CHANGED
@@ -23,36 +23,81 @@ table.acf_input > tbody > tr > td > select[multiple="multiple"] {
|
|
23 |
display: none;
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
.help_box {
|
32 |
-
background: #FFFFE0;
|
33 |
-
border: #E6DB55 solid 1px;
|
34 |
-
padding: 8px 16px;
|
35 |
-
margin-bottom: 10px;
|
36 |
}
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
padding: 0;
|
41 |
}
|
42 |
|
43 |
-
|
44 |
|
45 |
}
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
list-style: square;
|
51 |
}
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
display: none;
|
24 |
}
|
25 |
|
26 |
+
|
27 |
+
td.param {
|
28 |
+
width: 40%;
|
29 |
}
|
30 |
+
td.operator {
|
31 |
+
width: 20%;
|
32 |
+
}
|
33 |
+
|
34 |
+
/*---------------------------------------------------------------------------------------------
|
35 |
+
Location Rules
|
36 |
+
---------------------------------------------------------------------------------------------*/
|
37 |
+
.location_rules {
|
38 |
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
+
table#location_rules {
|
42 |
+
|
|
|
43 |
}
|
44 |
|
45 |
+
table#location_rules tr {
|
46 |
|
47 |
}
|
48 |
|
49 |
+
table#location_rules tr td {
|
50 |
+
padding: 4px;
|
51 |
+
border-right: 0 none;
|
|
|
52 |
}
|
53 |
|
54 |
+
table#location_rules tr:nth-child(odd) {
|
55 |
+
background: #F9F9F9
|
56 |
+
}
|
57 |
+
|
58 |
+
table#location_rules tr:nth-child(even) {
|
59 |
+
background: transparent;
|
60 |
+
}
|
61 |
+
|
62 |
+
table#location_rules tr td.buttons {
|
63 |
+
width: 40px;
|
64 |
+
}
|
65 |
+
|
66 |
+
table#location_rules a.remove {
|
67 |
+
display: block;
|
68 |
+
width: 16px;
|
69 |
+
height: 16px;
|
70 |
+
background: url(../images/button_remove.png) 0 0 no-repeat;
|
71 |
+
float: left;
|
72 |
+
margin-right: 4px;
|
73 |
+
}
|
74 |
+
|
75 |
+
table#location_rules a.remove:hover {
|
76 |
+
background-position: 0 100%;
|
77 |
+
}
|
78 |
+
|
79 |
+
table#location_rules a.remove.disabled {
|
80 |
+
opacity: 0.4;
|
81 |
+
background-position: 0 0 !important;
|
82 |
+
cursor: default;
|
83 |
+
}
|
84 |
+
|
85 |
+
table#location_rules a.add {
|
86 |
+
display: block;
|
87 |
+
width: 16px;
|
88 |
+
height: 16px;
|
89 |
+
background: url(../images/button_add.png) 0 0 no-repeat;
|
90 |
+
float: left;
|
91 |
+
}
|
92 |
+
|
93 |
+
table#location_rules a.add:hover {
|
94 |
+
background-position: 0 100%;
|
95 |
+
}
|
96 |
+
|
97 |
+
.location_rules p select {
|
98 |
+
width: 50px;
|
99 |
+
}
|
100 |
+
|
101 |
+
table#location_rules tr td.value div {
|
102 |
+
display: none;
|
103 |
+
}
|
js/functions.fields.js
CHANGED
@@ -20,10 +20,13 @@
|
|
20 |
|
21 |
var name = $(this).attr('name');
|
22 |
var id = $(this).attr('id');
|
23 |
-
|
24 |
-
if(name.indexOf("[fields][999]") != -1)
|
25 |
{
|
26 |
name = name.replace('[fields][999]','[fields]['+new_no+']');
|
|
|
|
|
|
|
27 |
id = id.replace('[fields][999]','[fields]['+new_no+']');
|
28 |
}
|
29 |
|
@@ -33,17 +36,14 @@
|
|
33 |
}
|
34 |
else
|
35 |
{
|
36 |
-
|
37 |
-
|
38 |
-
if(name.indexOf("[sub_fields][999]") != -1)
|
39 |
{
|
40 |
name = name.replace('[sub_fields][999]','[sub_fields]['+new_sub_no+']');
|
|
|
|
|
|
|
41 |
id = id.replace('[sub_fields][999]','[sub_fields]['+new_sub_no+']');
|
42 |
}
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
}
|
48 |
|
49 |
$(this).attr('name', name);
|
@@ -261,15 +261,7 @@
|
|
261 |
$(document).ready(function(){
|
262 |
|
263 |
setup_fields();
|
264 |
-
|
265 |
-
//$('div.postbox#acf_fields .fields').each(function(){
|
266 |
-
//$(this).make_acf();
|
267 |
-
//});
|
268 |
-
|
269 |
-
|
270 |
-
$('div.postbox a.help').click(function(){
|
271 |
-
$('div.postbox .help_box_mask').animate({'height':'toggle'}, 500);
|
272 |
-
});
|
273 |
});
|
274 |
|
275 |
})(jQuery);
|
20 |
|
21 |
var name = $(this).attr('name');
|
22 |
var id = $(this).attr('id');
|
23 |
+
|
24 |
+
if(name && name.indexOf("[fields][999]") != -1)
|
25 |
{
|
26 |
name = name.replace('[fields][999]','[fields]['+new_no+']');
|
27 |
+
}
|
28 |
+
if(id && id.indexOf("[fields][999]") != -1)
|
29 |
+
{
|
30 |
id = id.replace('[fields][999]','[fields]['+new_no+']');
|
31 |
}
|
32 |
|
36 |
}
|
37 |
else
|
38 |
{
|
39 |
+
if(name && name.indexOf("[sub_fields][999]") != -1)
|
|
|
|
|
40 |
{
|
41 |
name = name.replace('[sub_fields][999]','[sub_fields]['+new_sub_no+']');
|
42 |
+
}
|
43 |
+
if(id && id.indexOf("[sub_fields][999]") != -1)
|
44 |
+
{
|
45 |
id = id.replace('[sub_fields][999]','[sub_fields]['+new_sub_no+']');
|
46 |
}
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
$(this).attr('name', name);
|
261 |
$(document).ready(function(){
|
262 |
|
263 |
setup_fields();
|
264 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
});
|
266 |
|
267 |
})(jQuery);
|
js/functions.input.js
CHANGED
@@ -42,57 +42,6 @@
|
|
42 |
});
|
43 |
};
|
44 |
|
45 |
-
/*-------------------------------------------
|
46 |
-
Hide Meta Boxes
|
47 |
-
-------------------------------------------*/
|
48 |
-
$.fn.hide_meta_boxes = function()
|
49 |
-
{
|
50 |
-
var screen_options = $('#screen-meta');
|
51 |
-
var div = $(this);
|
52 |
-
|
53 |
-
// hide content_editor
|
54 |
-
if(!div.find('input[name=show_the_content]').exists())
|
55 |
-
{
|
56 |
-
$('#postdivrich').hide();
|
57 |
-
}
|
58 |
-
|
59 |
-
// hide custom_fields
|
60 |
-
if(!div.find('input[name=show_custom_fields]').exists())
|
61 |
-
{
|
62 |
-
$('#postcustom').hide();
|
63 |
-
screen_options.find('label[for=postcustom-hide]').hide();
|
64 |
-
}
|
65 |
-
|
66 |
-
// hide discussion
|
67 |
-
if(!div.find('input[name=show_discussion]').exists())
|
68 |
-
{
|
69 |
-
$('#commentstatusdiv').hide();
|
70 |
-
screen_options.find('label[for=commentstatusdiv-hide]').hide();
|
71 |
-
}
|
72 |
-
|
73 |
-
// hide comments
|
74 |
-
if(!div.find('input[name=show_comments]').exists())
|
75 |
-
{
|
76 |
-
$('#commentsdiv').hide();
|
77 |
-
screen_options.find('label[for=commentsdiv-hide]').hide();
|
78 |
-
}
|
79 |
-
|
80 |
-
// hide slug
|
81 |
-
if(!div.find('input[name=show_slug]').exists())
|
82 |
-
{
|
83 |
-
$('#slugdiv').hide();
|
84 |
-
screen_options.find('label[for=slugdiv-hide]').hide();
|
85 |
-
}
|
86 |
-
|
87 |
-
// hide author
|
88 |
-
if(!div.find('input[name=show_author]').exists())
|
89 |
-
{
|
90 |
-
$('#authordiv').hide();
|
91 |
-
screen_options.find('label[for=authordiv-hide]').hide();
|
92 |
-
}
|
93 |
-
|
94 |
-
screen_options.find('label[for=acf_input-hide]').hide();
|
95 |
-
};
|
96 |
|
97 |
/*-------------------------------------------
|
98 |
Image Upload
|
@@ -450,10 +399,7 @@
|
|
450 |
tinyMCE.settings.theme_advanced_buttons1 += ",|,add_image,add_video,add_audio,add_media";
|
451 |
tinyMCE.settings.theme_advanced_buttons2 += ",code";
|
452 |
}
|
453 |
-
|
454 |
-
|
455 |
-
// hide meta boxes
|
456 |
-
div.hide_meta_boxes();
|
457 |
|
458 |
div.make_all_fields();
|
459 |
|
42 |
});
|
43 |
};
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
/*-------------------------------------------
|
47 |
Image Upload
|
399 |
tinyMCE.settings.theme_advanced_buttons1 += ",|,add_image,add_video,add_audio,add_media";
|
400 |
tinyMCE.settings.theme_advanced_buttons2 += ",code";
|
401 |
}
|
402 |
+
|
|
|
|
|
|
|
403 |
|
404 |
div.make_all_fields();
|
405 |
|
js/functions.location.js
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
/*--------------------------------------------------------------------------
|
6 |
+
setup_fields
|
7 |
+
--------------------------------------------------------------------------*/
|
8 |
+
function setup_rules()
|
9 |
+
{
|
10 |
+
var tbody = $('table#location_rules tbody');
|
11 |
+
|
12 |
+
|
13 |
+
// show field type options
|
14 |
+
tbody.find('td.param select').live('change', function(){
|
15 |
+
|
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 |
+
|
22 |
+
tr.find('td.value div[rel="'+val+'"]').show();
|
23 |
+
tr.find('td.value div[rel="'+val+'"] [name]').removeAttr('disabled');
|
24 |
+
|
25 |
+
}).trigger('change');
|
26 |
+
|
27 |
+
|
28 |
+
// Add Button
|
29 |
+
tbody.find('td.buttons a.add').live('click',function(){
|
30 |
+
|
31 |
+
var tr_count = $(this).closest('tbody').children('tr').length;
|
32 |
+
var tr = $(this).closest('tr').clone();
|
33 |
+
|
34 |
+
tr.insertAfter($(this).closest('tr'));
|
35 |
+
|
36 |
+
update_names();
|
37 |
+
|
38 |
+
can_remove_more();
|
39 |
+
|
40 |
+
return false;
|
41 |
+
|
42 |
+
});
|
43 |
+
|
44 |
+
|
45 |
+
// Remove Button
|
46 |
+
tbody.find('td.buttons a.remove').live('click',function(){
|
47 |
+
|
48 |
+
var tr = $(this).closest('tr').remove();
|
49 |
+
|
50 |
+
can_remove_more();
|
51 |
+
|
52 |
+
return false;
|
53 |
+
|
54 |
+
});
|
55 |
+
|
56 |
+
function can_remove_more()
|
57 |
+
{
|
58 |
+
if(tbody.children('tr').length == 1)
|
59 |
+
{
|
60 |
+
tbody.children('tr').each(function(){
|
61 |
+
$(this).find('td.buttons a.remove').addClass('disabled');
|
62 |
+
});
|
63 |
+
}
|
64 |
+
else
|
65 |
+
{
|
66 |
+
tbody.children('tr').each(function(){
|
67 |
+
$(this).find('td.buttons a.remove').removeClass('disabled');
|
68 |
+
});
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
can_remove_more();
|
74 |
+
|
75 |
+
function update_names()
|
76 |
+
{
|
77 |
+
tbody.children('tr').each(function(i){
|
78 |
+
|
79 |
+
$(this).find('[name]').each(function(){
|
80 |
+
|
81 |
+
var name = $(this).attr('name').split("][");
|
82 |
+
|
83 |
+
var new_name = name[0] + "][" + name[1] + "][" + i + "][" + name[3];
|
84 |
+
|
85 |
+
$(this).attr('name', new_name);
|
86 |
+
});
|
87 |
+
|
88 |
+
})
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/*--------------------------------------------------------------------------
|
94 |
+
Document Ready
|
95 |
+
--------------------------------------------------------------------------*/
|
96 |
+
$(document).ready(function(){
|
97 |
+
|
98 |
+
setup_rules();
|
99 |
+
|
100 |
+
});
|
101 |
+
|
102 |
+
})(jQuery);
|
lang/advanced-custom-fields.pot
CHANGED
@@ -4,7 +4,7 @@ msgid ""
|
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: \n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/advanced-custom-fields\n"
|
7 |
-
"POT-Creation-Date: 2011-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -28,19 +28,58 @@ msgstr ""
|
|
28 |
msgid "Field Order"
|
29 |
msgstr ""
|
30 |
|
31 |
-
#: core/fields_meta_box.php:37 core/
|
|
|
32 |
msgid "Field Label"
|
33 |
msgstr ""
|
34 |
|
35 |
-
#: core/fields_meta_box.php:38 core/
|
|
|
36 |
msgid "Field Name"
|
37 |
msgstr ""
|
38 |
|
39 |
-
#: core/fields_meta_box.php:39 core/
|
|
|
40 |
msgid "Field Type"
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: core/fields_meta_box.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
msgid "+ Add Field"
|
45 |
msgstr ""
|
46 |
|
@@ -65,35 +104,35 @@ msgid ""
|
|
65 |
"this ACF"
|
66 |
msgstr ""
|
67 |
|
68 |
-
#: core/screen_extra.php:
|
69 |
msgid "Advanced Custom Fields v"
|
70 |
msgstr ""
|
71 |
|
72 |
-
#: core/screen_extra.php:
|
73 |
msgid "see what's new"
|
74 |
msgstr ""
|
75 |
|
76 |
-
#: core/screen_extra.php:
|
77 |
msgid "User Guide + Code Examples"
|
78 |
msgstr ""
|
79 |
|
80 |
-
#: core/screen_extra.php:
|
81 |
msgid "Visit the Plugin Website"
|
82 |
msgstr ""
|
83 |
|
84 |
-
#: core/screen_extra.php:
|
85 |
msgid "Need Help?"
|
86 |
msgstr ""
|
87 |
|
88 |
-
#: core/screen_extra.php:
|
89 |
msgid "Visit the Support Forum"
|
90 |
msgstr ""
|
91 |
|
92 |
-
#: core/screen_extra.php:
|
93 |
msgid "Help fund future development"
|
94 |
msgstr ""
|
95 |
|
96 |
-
#: core/screen_extra.php:
|
97 |
msgid "Created by"
|
98 |
msgstr ""
|
99 |
|
@@ -269,11 +308,11 @@ msgstr ""
|
|
269 |
msgid "Select Image"
|
270 |
msgstr ""
|
271 |
|
272 |
-
#: core/fields/image.php:
|
273 |
msgid "No image selected"
|
274 |
msgstr ""
|
275 |
|
276 |
-
#: core/fields/image.php:
|
277 |
msgid "Add Image"
|
278 |
msgstr ""
|
279 |
|
@@ -346,18 +385,18 @@ msgstr ""
|
|
346 |
msgid "File"
|
347 |
msgstr ""
|
348 |
|
349 |
-
#: core/fields/file.php:
|
350 |
msgid "Select File"
|
351 |
msgstr ""
|
352 |
|
353 |
-
#: core/fields/file.php:
|
354 |
msgid "Remove File"
|
355 |
msgstr ""
|
356 |
|
357 |
-
#: core/fields/file.php:
|
358 |
msgid "No File selected"
|
359 |
msgstr ""
|
360 |
|
361 |
-
#: core/fields/file.php:
|
362 |
msgid "Add File"
|
363 |
msgstr ""
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: \n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/advanced-custom-fields\n"
|
7 |
+
"POT-Creation-Date: 2011-06-04 05:22:03+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
28 |
msgid "Field Order"
|
29 |
msgstr ""
|
30 |
|
31 |
+
#: core/fields_meta_box.php:37 core/fields_meta_box.php:87
|
32 |
+
#: core/fields/repeater.php:141
|
33 |
msgid "Field Label"
|
34 |
msgstr ""
|
35 |
|
36 |
+
#: core/fields_meta_box.php:38 core/fields_meta_box.php:107
|
37 |
+
#: core/fields/repeater.php:142
|
38 |
msgid "Field Name"
|
39 |
msgstr ""
|
40 |
|
41 |
+
#: core/fields_meta_box.php:39 core/fields_meta_box.php:126
|
42 |
+
#: core/fields/repeater.php:143
|
43 |
msgid "Field Type"
|
44 |
msgstr ""
|
45 |
|
46 |
+
#: core/fields_meta_box.php:46
|
47 |
+
msgid "No fields. Click the \"+ Add Field button\" to create your first field."
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: core/fields_meta_box.php:62
|
51 |
+
msgid "Edit"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: core/fields_meta_box.php:63
|
55 |
+
msgid "Delete"
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: core/fields_meta_box.php:88
|
59 |
+
msgid "This is the name which will appear on the EDIT page"
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: core/fields_meta_box.php:108
|
63 |
+
msgid "Single word, no spaces. Underscores and dashes allowed"
|
64 |
+
msgstr ""
|
65 |
+
|
66 |
+
#: core/fields_meta_box.php:143
|
67 |
+
msgid "Field Instructions"
|
68 |
+
msgstr ""
|
69 |
+
|
70 |
+
#: core/fields_meta_box.php:144
|
71 |
+
msgid "Instructions for authors. Shown when submitting data"
|
72 |
+
msgstr ""
|
73 |
+
|
74 |
+
#: core/fields_meta_box.php:161
|
75 |
+
msgid "Is field searchable?"
|
76 |
+
msgstr ""
|
77 |
+
|
78 |
+
#: core/fields_meta_box.php:170
|
79 |
+
msgid "Save this field's value as a standard WordPress Custom Field"
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: core/fields_meta_box.php:205
|
83 |
msgid "+ Add Field"
|
84 |
msgstr ""
|
85 |
|
104 |
"this ACF"
|
105 |
msgstr ""
|
106 |
|
107 |
+
#: core/screen_extra.php:63
|
108 |
msgid "Advanced Custom Fields v"
|
109 |
msgstr ""
|
110 |
|
111 |
+
#: core/screen_extra.php:64
|
112 |
msgid "see what's new"
|
113 |
msgstr ""
|
114 |
|
115 |
+
#: core/screen_extra.php:75
|
116 |
msgid "User Guide + Code Examples"
|
117 |
msgstr ""
|
118 |
|
119 |
+
#: core/screen_extra.php:75
|
120 |
msgid "Visit the Plugin Website"
|
121 |
msgstr ""
|
122 |
|
123 |
+
#: core/screen_extra.php:85
|
124 |
msgid "Need Help?"
|
125 |
msgstr ""
|
126 |
|
127 |
+
#: core/screen_extra.php:85
|
128 |
msgid "Visit the Support Forum"
|
129 |
msgstr ""
|
130 |
|
131 |
+
#: core/screen_extra.php:98
|
132 |
msgid "Help fund future development"
|
133 |
msgstr ""
|
134 |
|
135 |
+
#: core/screen_extra.php:111
|
136 |
msgid "Created by"
|
137 |
msgstr ""
|
138 |
|
308 |
msgid "Select Image"
|
309 |
msgstr ""
|
310 |
|
311 |
+
#: core/fields/image.php:173
|
312 |
msgid "No image selected"
|
313 |
msgstr ""
|
314 |
|
315 |
+
#: core/fields/image.php:173
|
316 |
msgid "Add Image"
|
317 |
msgstr ""
|
318 |
|
385 |
msgid "File"
|
386 |
msgstr ""
|
387 |
|
388 |
+
#: core/fields/file.php:83
|
389 |
msgid "Select File"
|
390 |
msgstr ""
|
391 |
|
392 |
+
#: core/fields/file.php:151
|
393 |
msgid "Remove File"
|
394 |
msgstr ""
|
395 |
|
396 |
+
#: core/fields/file.php:153
|
397 |
msgid "No File selected"
|
398 |
msgstr ""
|
399 |
|
400 |
+
#: core/fields/file.php:153
|
401 |
msgid "Add File"
|
402 |
msgstr ""
|
readme.txt
CHANGED
@@ -81,13 +81,22 @@ http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
|
|
81 |
|
82 |
== Changelog ==
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
=2.0.1=
|
85 |
* Added Field Option: Field Instructions
|
86 |
* Added Field Option: Is field searchable? (saves field value as a normal custom field so you can use the field against wp queries)
|
87 |
* Added Media Search / Pagination to Image / File thickbox
|
88 |
* Added Media Upload support to post types which do not have a Content Editor.
|
89 |
* Fixed "Select Image" / "Select File" text on thickbox buttons after upload
|
90 |
-
* Repeater field now returns null if no data was added
|
91 |
|
92 |
=2.0.0=
|
93 |
* Completely re-designed the ACF edit page
|
81 |
|
82 |
== Changelog ==
|
83 |
|
84 |
+
= 2.0.2 =
|
85 |
+
* Added new database table "acf_rules"
|
86 |
+
* Removed database table "ac_options"
|
87 |
+
* Updated location meta box to now allow for custom location queries
|
88 |
+
* Hid Activation Code from logged in users
|
89 |
+
* Fixed JS bugs with wp v3.2 beta 2
|
90 |
+
* Added new option "Field group layout" - you can now wrap your fields in a metabox!
|
91 |
+
* General housekeeping
|
92 |
+
|
93 |
=2.0.1=
|
94 |
* Added Field Option: Field Instructions
|
95 |
* Added Field Option: Is field searchable? (saves field value as a normal custom field so you can use the field against wp queries)
|
96 |
* Added Media Search / Pagination to Image / File thickbox
|
97 |
* Added Media Upload support to post types which do not have a Content Editor.
|
98 |
* Fixed "Select Image" / "Select File" text on thickbox buttons after upload
|
99 |
+
* Repeater field now returns null if no data was added
|
100 |
|
101 |
=2.0.0=
|
102 |
* Completely re-designed the ACF edit page
|