'', // Unused. Messages start at index 1. 1 => __('Field group updated.', 'acf'), 2 => __('Field group updated.', 'acf'), 3 => __('Field group deleted.', 'acf'), 4 => __('Field group updated.', 'acf'), 5 => false, // field group does not support revisions 6 => __('Field group published.', 'acf'), 7 => __('Field group saved.', 'acf'), 8 => __('Field group submitted.', 'acf'), 9 => __('Field group scheduled for.', 'acf'), 10 => __('Field group draft updated.', 'acf') ); // return return $messages; } /* * current_screen * * This function is fired when loading the admin page before HTML has been rendered. * * @type action (current_screen) * @date 21/07/2014 * @since 5.0.0 * * @param n/a * @return n/a */ function current_screen() { // validate screen if( !acf_is_screen('acf-field-group') ) return; // disable filters to ensure ACF loads raw data from DB acf_disable_filters(); // enqueue scripts acf_enqueue_scripts(); // actions add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_action('acf/input/admin_head', array($this, 'admin_head')); add_action('acf/input/form_data', array($this, 'form_data')); add_action('acf/input/admin_footer', array($this, 'admin_footer')); add_action('acf/input/admin_footer_js', array($this, 'admin_footer_js')); // filters add_filter('acf/input/admin_l10n', array($this, 'admin_l10n')); } /* * admin_enqueue_scripts * * This action is run after post query but before any admin script / head actions. * It is a good place to register all actions. * * @type action (admin_enqueue_scripts) * @date 30/06/2014 * @since 5.0.0 * * @param n/a * @return n/a */ function admin_enqueue_scripts() { // no autosave wp_dequeue_script('autosave'); // custom scripts wp_enqueue_style('acf-field-group'); wp_enqueue_script('acf-field-group'); // localize text acf_localize_text(array( 'The string "field_" may not be used at the start of a field name' => __('The string "field_" may not be used at the start of a field name', 'acf'), 'This field cannot be moved until its changes have been saved' => __('This field cannot be moved until its changes have been saved', 'acf'), 'Field group title is required' => __('Field group title is required', 'acf'), 'Move to trash. Are you sure?' => __('Move to trash. Are you sure?', 'acf'), 'No toggle fields available' => __('No toggle fields available', 'acf'), 'Move Custom Field' => __('Move Custom Field', 'acf'), 'Checked' => __('Checked', 'acf'), '(no label)' => __('(no label)', 'acf'), '(this field)' => __('(this field)', 'acf'), 'copy' => __('copy', 'acf'), 'or' => __('or', 'acf'), 'Null' => __('Null', 'acf'), )); // localize data acf_localize_data(array( 'fieldTypes' => acf_get_field_types_info() )); // 3rd party hook do_action('acf/field_group/admin_enqueue_scripts'); } /* * admin_head * * This function will setup all functionality for the field group edit page to work * * @type action (admin_head) * @date 23/06/12 * @since 3.1.8 * * @param $post_id (int) * @return $post_id (int) */ function admin_head() { // global global $post, $field_group; // set global var $field_group = acf_get_field_group( $post ); // metaboxes add_meta_box('acf-field-group-fields', __("Fields",'acf'), array($this, 'mb_fields'), 'acf-field-group', 'normal', 'high'); add_meta_box('acf-field-group-locations', __("Location",'acf'), array($this, 'mb_locations'), 'acf-field-group', 'normal', 'high'); add_meta_box('acf-field-group-options', __("Settings",'acf'), array($this, 'mb_options'), 'acf-field-group', 'normal', 'high'); // actions add_action('post_submitbox_misc_actions', array($this, 'post_submitbox_misc_actions'), 10, 0); add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10, 0); // filters add_filter('screen_settings', array($this, 'screen_settings'), 10, 1); // 3rd party hook do_action('acf/field_group/admin_head'); } /* * edit_form_after_title * * This action will allow ACF to render metaboxes after the title * * @type action * @date 17/08/13 * * @param n/a * @return n/a */ function edit_form_after_title() { // globals global $post; // render post data acf_form_data(array( 'screen' => 'field_group', 'post_id' => $post->ID, 'delete_fields' => 0, 'validation' => 0 )); } /* * form_data * * This function will add extra HTML to the acf form data element * * @type function * @date 31/05/2016 * @since 5.3.8 * * @param n/a * @return n/a */ function form_data( $args ) { // do action do_action('acf/field_group/form_data', $args); } /* * admin_l10n * * This function will append extra l10n strings to the acf JS object * * @type function * @date 31/05/2016 * @since 5.3.8 * * @param $l10n (array) * @return $l10n */ function admin_l10n( $l10n ) { return apply_filters('acf/field_group/admin_l10n', $l10n); } /* * admin_footer * * description * * @type function * @date 11/01/2016 * @since 5.3.2 * * @param $post_id (int) * @return $post_id (int) */ function admin_footer() { // 3rd party hook do_action('acf/field_group/admin_footer'); } /* * admin_footer_js * * description * * @type function * @date 31/05/2016 * @since 5.3.8 * * @param $post_id (int) * @return $post_id (int) */ function admin_footer_js() { // 3rd party hook do_action('acf/field_group/admin_footer_js'); } /* * screen_settings * * description * * @type function * @date 26/01/13 * @since 3.6.0 * * @param $current (string) * @return $current */ function screen_settings( $html ) { // vars $checked = acf_get_user_setting('show_field_keys') ? 'checked="checked"' : ''; // append $html .= '
' . __('Move Complete.', 'acf') . '
'; echo '' . sprintf( __('The %s field can now be found in the %s field group', 'acf'), $field['label'], $a ). '
'; echo '' . __("Close Window",'acf') . ''; die(); } // get all field groups $field_groups = acf_get_field_groups(); $choices = array(); // check if( !empty($field_groups) ) { // loop foreach( $field_groups as $field_group ) { // bail early if no ID if( !$field_group['ID'] ) continue; // bail ealry if is current if( $field_group['ID'] == $args['post_id'] ) continue; // append $choices[ $field_group['ID'] ] = $field_group['title']; } } // render options $field = acf_get_valid_field(array( 'type' => 'select', 'name' => 'acf_field_group', 'choices' => $choices )); echo '' . __('Please select the destination for this field', 'acf') . '
'; echo ''; // die die(); } } // initialize new acf_admin_field_group(); endif; ?>