|
@@ 675-714 (lines=40) @@
|
| 672 |
|
* @return (boolean) |
| 673 |
|
*/ |
| 674 |
|
|
| 675 |
|
function acf_delete_field_group( $selector = 0 ) { |
| 676 |
|
|
| 677 |
|
// disable JSON to avoid conflicts between DB and JSON |
| 678 |
|
acf_disable_local(); |
| 679 |
|
|
| 680 |
|
|
| 681 |
|
// load the origional field gorup |
| 682 |
|
$field_group = acf_get_field_group( $selector ); |
| 683 |
|
|
| 684 |
|
|
| 685 |
|
// bail early if field group did not load correctly |
| 686 |
|
if( empty($field_group) ) return false; |
| 687 |
|
|
| 688 |
|
|
| 689 |
|
// get fields |
| 690 |
|
$fields = acf_get_fields($field_group); |
| 691 |
|
|
| 692 |
|
|
| 693 |
|
if( !empty($fields) ) { |
| 694 |
|
|
| 695 |
|
foreach( $fields as $field ) { |
| 696 |
|
|
| 697 |
|
acf_delete_field( $field['ID'] ); |
| 698 |
|
|
| 699 |
|
} |
| 700 |
|
|
| 701 |
|
} |
| 702 |
|
|
| 703 |
|
|
| 704 |
|
// delete |
| 705 |
|
wp_delete_post( $field_group['ID'] ); |
| 706 |
|
|
| 707 |
|
|
| 708 |
|
// action for 3rd party customization |
| 709 |
|
do_action('acf/delete_field_group', $field_group); |
| 710 |
|
|
| 711 |
|
|
| 712 |
|
// return |
| 713 |
|
return true; |
| 714 |
|
} |
| 715 |
|
|
| 716 |
|
|
| 717 |
|
/* |
|
@@ 730-769 (lines=40) @@
|
| 727 |
|
* @return (boolean) |
| 728 |
|
*/ |
| 729 |
|
|
| 730 |
|
function acf_trash_field_group( $selector = 0 ) { |
| 731 |
|
|
| 732 |
|
// disable JSON to avoid conflicts between DB and JSON |
| 733 |
|
acf_disable_local(); |
| 734 |
|
|
| 735 |
|
|
| 736 |
|
// load the origional field gorup |
| 737 |
|
$field_group = acf_get_field_group( $selector ); |
| 738 |
|
|
| 739 |
|
|
| 740 |
|
// bail early if field group did not load correctly |
| 741 |
|
if( empty($field_group) ) return false; |
| 742 |
|
|
| 743 |
|
|
| 744 |
|
// get fields |
| 745 |
|
$fields = acf_get_fields($field_group); |
| 746 |
|
|
| 747 |
|
|
| 748 |
|
if( !empty($fields) ) { |
| 749 |
|
|
| 750 |
|
foreach( $fields as $field ) { |
| 751 |
|
|
| 752 |
|
acf_trash_field( $field['ID'] ); |
| 753 |
|
|
| 754 |
|
} |
| 755 |
|
|
| 756 |
|
} |
| 757 |
|
|
| 758 |
|
|
| 759 |
|
// delete |
| 760 |
|
wp_trash_post( $field_group['ID'] ); |
| 761 |
|
|
| 762 |
|
|
| 763 |
|
// action for 3rd party customization |
| 764 |
|
do_action('acf/trash_field_group', $field_group); |
| 765 |
|
|
| 766 |
|
|
| 767 |
|
// return |
| 768 |
|
return true; |
| 769 |
|
} |
| 770 |
|
|
| 771 |
|
|
| 772 |
|
/* |
|
@@ 785-824 (lines=40) @@
|
| 782 |
|
* @return (boolean) |
| 783 |
|
*/ |
| 784 |
|
|
| 785 |
|
function acf_untrash_field_group( $selector = 0 ) { |
| 786 |
|
|
| 787 |
|
// disable JSON to avoid conflicts between DB and JSON |
| 788 |
|
acf_disable_local(); |
| 789 |
|
|
| 790 |
|
|
| 791 |
|
// load the origional field gorup |
| 792 |
|
$field_group = acf_get_field_group( $selector ); |
| 793 |
|
|
| 794 |
|
|
| 795 |
|
// bail early if field group did not load correctly |
| 796 |
|
if( empty($field_group) ) return false; |
| 797 |
|
|
| 798 |
|
|
| 799 |
|
// get fields |
| 800 |
|
$fields = acf_get_fields($field_group); |
| 801 |
|
|
| 802 |
|
|
| 803 |
|
if( !empty($fields) ) { |
| 804 |
|
|
| 805 |
|
foreach( $fields as $field ) { |
| 806 |
|
|
| 807 |
|
acf_untrash_field( $field['ID'] ); |
| 808 |
|
|
| 809 |
|
} |
| 810 |
|
|
| 811 |
|
} |
| 812 |
|
|
| 813 |
|
|
| 814 |
|
// delete |
| 815 |
|
wp_untrash_post( $field_group['ID'] ); |
| 816 |
|
|
| 817 |
|
|
| 818 |
|
// action for 3rd party customization |
| 819 |
|
do_action('acf/untrash_field_group', $field_group); |
| 820 |
|
|
| 821 |
|
|
| 822 |
|
// return |
| 823 |
|
return true; |
| 824 |
|
} |
| 825 |
|
|
| 826 |
|
|
| 827 |
|
|