field-groups-export.php
3 years ago
field-groups-local.php
3 months ago
module-export.php
3 months ago
module-import.php
3 months ago
field-groups-export.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if(!class_exists('acfe_field_groups_export')): |
| 8 | |
| 9 | class acfe_field_groups_export extends ACF_Admin_Tool{ |
| 10 | |
| 11 | function initialize(){ |
| 12 | |
| 13 | $this->name = 'acfe-export'; |
| 14 | |
| 15 | } |
| 16 | |
| 17 | function load(){ |
| 18 | |
| 19 | $action = $this->get_action(); |
| 20 | |
| 21 | if($action === 'json'){ |
| 22 | |
| 23 | acf()->admin_tools->get_tool('export')->submit_download(); |
| 24 | |
| 25 | } |
| 26 | |
| 27 | // active |
| 28 | if($this->is_active()){ |
| 29 | |
| 30 | // get selected keys |
| 31 | $selected = acf()->admin_tools->get_tool('export')->get_selected_keys(); |
| 32 | |
| 33 | // add notice |
| 34 | if($selected){ |
| 35 | |
| 36 | $count = count($selected); |
| 37 | $text = sprintf( _n('Exported 1 field group.', 'Exported %s field groups.', $count, 'acf' ), $count); |
| 38 | |
| 39 | acf_add_admin_notice( $text, 'success' ); |
| 40 | |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | } |
| 45 | |
| 46 | function get_action(){ |
| 47 | |
| 48 | // vars |
| 49 | $action = acfe_maybe_get_REQUEST('action'); |
| 50 | |
| 51 | // check allowed |
| 52 | if(!in_array($action, array('json', 'php'))) |
| 53 | $action = false; |
| 54 | |
| 55 | // return |
| 56 | return $action; |
| 57 | |
| 58 | } |
| 59 | |
| 60 | } |
| 61 | |
| 62 | acf_register_admin_tool('acfe_field_groups_export'); |
| 63 | |
| 64 | endif; |