first commit
This commit is contained in:
@@ -0,0 +1,834 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ACF Admin Field Group Class
|
||||
*
|
||||
* All the logic for editing a field group
|
||||
*
|
||||
* @class acf_admin_field_group
|
||||
* @package ACF
|
||||
* @subpackage Admin
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_admin_field_group') ) :
|
||||
|
||||
class acf_admin_field_group {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the class functionality
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action('current_screen', array($this, 'current_screen'));
|
||||
add_action('save_post', array($this, 'save_post'), 10, 2);
|
||||
|
||||
|
||||
// ajax
|
||||
add_action('wp_ajax_acf/field_group/render_field_settings', array($this, 'ajax_render_field_settings'));
|
||||
add_action('wp_ajax_acf/field_group/render_location_rule', array($this, 'ajax_render_location_rule'));
|
||||
add_action('wp_ajax_acf/field_group/move_field', array($this, 'ajax_move_field'));
|
||||
|
||||
|
||||
// filters
|
||||
add_filter('post_updated_messages', array($this, 'post_updated_messages'));
|
||||
add_filter('use_block_editor_for_post_type', array($this, 'use_block_editor_for_post_type'), 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* use_block_editor_for_post_type
|
||||
*
|
||||
* Prevents the block editor from loading when editing an ACF field group.
|
||||
*
|
||||
* @date 7/12/18
|
||||
* @since 5.8.0
|
||||
*
|
||||
* @param bool $use_block_editor Whether the post type can be edited or not. Default true.
|
||||
* @param string $post_type The post type being checked.
|
||||
* @return bool
|
||||
*/
|
||||
function use_block_editor_for_post_type( $use_block_editor, $post_type ) {
|
||||
if( $post_type === 'acf-field-group' ) {
|
||||
return false;
|
||||
}
|
||||
return $use_block_editor;
|
||||
}
|
||||
|
||||
/*
|
||||
* post_updated_messages
|
||||
*
|
||||
* This function will customize the message shown when editing a field group
|
||||
*
|
||||
* @type action (post_updated_messages)
|
||||
* @date 30/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $messages (array)
|
||||
* @return $messages
|
||||
*/
|
||||
|
||||
function post_updated_messages( $messages ) {
|
||||
|
||||
// append to messages
|
||||
$messages['acf-field-group'] = array(
|
||||
0 => '', // 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->ID );
|
||||
|
||||
|
||||
// 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 .= '<div id="acf-append-show-on-screen" class="acf-hidden">';
|
||||
$html .= '<label for="acf-field-key-hide"><input id="acf-field-key-hide" type="checkbox" value="1" name="show_field_keys" ' . $checked . ' /> ' . __('Field Keys','acf') . '</label>';
|
||||
$html .= '</div>';
|
||||
|
||||
|
||||
// return
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* post_submitbox_misc_actions
|
||||
*
|
||||
* This function will customize the publish metabox
|
||||
*
|
||||
* @type function
|
||||
* @date 17/07/2015
|
||||
* @since 5.2.9
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function post_submitbox_misc_actions() {
|
||||
|
||||
// global
|
||||
global $field_group;
|
||||
|
||||
|
||||
// vars
|
||||
$status = $field_group['active'] ? __("Active",'acf') : __("Inactive",'acf');
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
// modify status
|
||||
$('#post-status-display').html('<?php echo $status; ?>');
|
||||
|
||||
|
||||
// remove edit links
|
||||
$('#misc-publishing-actions a').remove();
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* save_post
|
||||
*
|
||||
* This function will save all the field group data
|
||||
*
|
||||
* @type function
|
||||
* @date 23/06/12
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function save_post( $post_id, $post ) {
|
||||
|
||||
// do not save if this is an auto save routine
|
||||
if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
// bail early if not acf-field-group
|
||||
if( $post->post_type !== 'acf-field-group' ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
// only save once! WordPress save's a revision as well.
|
||||
if( wp_is_post_revision($post_id) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
// verify nonce
|
||||
if( !acf_verify_nonce('field_group') ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
// Bail early if request came from an unauthorised user.
|
||||
if( !current_user_can(acf_get_setting('capability')) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
|
||||
// disable filters to ensure ACF loads raw data from DB
|
||||
acf_disable_filters();
|
||||
|
||||
|
||||
// save fields
|
||||
if( !empty($_POST['acf_fields']) ) {
|
||||
|
||||
// loop
|
||||
foreach( $_POST['acf_fields'] as $field ) {
|
||||
|
||||
// vars
|
||||
$specific = false;
|
||||
$save = acf_extract_var( $field, 'save' );
|
||||
|
||||
|
||||
// only saved field if has changed
|
||||
if( $save == 'meta' ) {
|
||||
$specific = array(
|
||||
'menu_order',
|
||||
'post_parent',
|
||||
);
|
||||
}
|
||||
|
||||
// set parent
|
||||
if( !$field['parent'] ) {
|
||||
$field['parent'] = $post_id;
|
||||
}
|
||||
|
||||
// save field
|
||||
acf_update_field( $field, $specific );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// delete fields
|
||||
if( $_POST['_acf_delete_fields'] ) {
|
||||
|
||||
// clean
|
||||
$ids = explode('|', $_POST['_acf_delete_fields']);
|
||||
$ids = array_map( 'intval', $ids );
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $ids as $id ) {
|
||||
|
||||
// bai early if no id
|
||||
if( !$id ) continue;
|
||||
|
||||
|
||||
// delete
|
||||
acf_delete_field( $id );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add args
|
||||
$_POST['acf_field_group']['ID'] = $post_id;
|
||||
$_POST['acf_field_group']['title'] = $_POST['post_title'];
|
||||
|
||||
|
||||
// save field group
|
||||
acf_update_field_group( $_POST['acf_field_group'] );
|
||||
|
||||
|
||||
// return
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* mb_fields
|
||||
*
|
||||
* This function will render the HTML for the medtabox 'acf-field-group-fields'
|
||||
*
|
||||
* @type function
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function mb_fields() {
|
||||
|
||||
// global
|
||||
global $field_group;
|
||||
|
||||
|
||||
// get fields
|
||||
$view = array(
|
||||
'fields' => acf_get_fields( $field_group ),
|
||||
'parent' => 0
|
||||
);
|
||||
|
||||
|
||||
// load view
|
||||
acf_get_view('field-group-fields', $view);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* mb_options
|
||||
*
|
||||
* This function will render the HTML for the medtabox 'acf-field-group-options'
|
||||
*
|
||||
* @type function
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function mb_options() {
|
||||
|
||||
// global
|
||||
global $field_group;
|
||||
|
||||
|
||||
// field key (leave in for compatibility)
|
||||
if( !acf_is_field_group_key( $field_group['key']) ) {
|
||||
|
||||
$field_group['key'] = uniqid('group_');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// view
|
||||
acf_get_view('field-group-options');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* mb_locations
|
||||
*
|
||||
* This function will render the HTML for the medtabox 'acf-field-group-locations'
|
||||
*
|
||||
* @type function
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function mb_locations() {
|
||||
|
||||
// global
|
||||
global $field_group;
|
||||
|
||||
|
||||
// UI needs at lease 1 location rule
|
||||
if( empty($field_group['location']) ) {
|
||||
|
||||
$field_group['location'] = array(
|
||||
|
||||
// group 0
|
||||
array(
|
||||
|
||||
// rule 0
|
||||
array(
|
||||
'param' => 'post_type',
|
||||
'operator' => '==',
|
||||
'value' => 'post',
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// view
|
||||
acf_get_view('field-group-locations');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ajax_render_location_rule
|
||||
*
|
||||
* This function can be accessed via an AJAX action and will return the result from the render_location_value function
|
||||
*
|
||||
* @type function (ajax)
|
||||
* @date 30/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function ajax_render_location_rule() {
|
||||
|
||||
// validate
|
||||
if( !acf_verify_ajax() ) die();
|
||||
|
||||
// validate rule
|
||||
$rule = acf_validate_location_rule($_POST['rule']);
|
||||
|
||||
// view
|
||||
acf_get_view( 'html-location-rule', array(
|
||||
'rule' => $rule
|
||||
));
|
||||
|
||||
// die
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ajax_render_field_settings
|
||||
*
|
||||
* This function will return HTML containing the field's settings based on it's new type
|
||||
*
|
||||
* @type function (ajax)
|
||||
* @date 30/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function ajax_render_field_settings() {
|
||||
|
||||
// validate
|
||||
if( !acf_verify_ajax() ) die();
|
||||
|
||||
// vars
|
||||
$field = acf_maybe_get_POST('field');
|
||||
|
||||
// check
|
||||
if( !$field ) die();
|
||||
|
||||
// set prefix
|
||||
$field['prefix'] = acf_maybe_get_POST('prefix');
|
||||
|
||||
// validate
|
||||
$field = acf_get_valid_field( $field );
|
||||
|
||||
// render
|
||||
do_action("acf/render_field_settings/type={$field['type']}", $field);
|
||||
|
||||
// return
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* ajax_move_field
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 20/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function ajax_move_field() {
|
||||
|
||||
// disable filters to ensure ACF loads raw data from DB
|
||||
acf_disable_filters();
|
||||
|
||||
|
||||
$args = acf_parse_args($_POST, array(
|
||||
'nonce' => '',
|
||||
'post_id' => 0,
|
||||
'field_id' => 0,
|
||||
'field_group_id' => 0
|
||||
));
|
||||
|
||||
|
||||
// verify nonce
|
||||
if( !wp_verify_nonce($args['nonce'], 'acf_nonce') ) die();
|
||||
|
||||
|
||||
// confirm?
|
||||
if( $args['field_id'] && $args['field_group_id'] ) {
|
||||
|
||||
// vars
|
||||
$field = acf_get_field($args['field_id']);
|
||||
$field_group = acf_get_field_group($args['field_group_id']);
|
||||
|
||||
|
||||
// update parent
|
||||
$field['parent'] = $field_group['ID'];
|
||||
|
||||
|
||||
// remove conditional logic
|
||||
$field['conditional_logic'] = 0;
|
||||
|
||||
|
||||
// update field
|
||||
acf_update_field($field);
|
||||
|
||||
|
||||
// message
|
||||
$a = '<a href="' . admin_url("post.php?post={$field_group['ID']}&action=edit") . '" target="_blank">' . $field_group['title'] . '</a>';
|
||||
echo '<p><strong>' . __('Move Complete.', 'acf') . '</strong></p>';
|
||||
echo '<p>' . sprintf( __('The %s field can now be found in the %s field group', 'acf'), $field['label'], $a ). '</p>';
|
||||
echo '<a href="#" class="button button-primary acf-close-popup">' . __("Close Window",'acf') . '</a>';
|
||||
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 '<p>' . __('Please select the destination for this field', 'acf') . '</p>';
|
||||
|
||||
echo '<form id="acf-move-field-form">';
|
||||
|
||||
// render
|
||||
acf_render_field_wrap( $field );
|
||||
|
||||
echo '<button type="submit" class="button button-primary">' . __("Move Field",'acf') . '</button>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
|
||||
// die
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize
|
||||
new acf_admin_field_group();
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,830 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ACF Admin Field Groups Class
|
||||
*
|
||||
* All the logic for editing a list of field groups
|
||||
*
|
||||
* @class acf_admin_field_groups
|
||||
* @package ACF
|
||||
* @subpackage Admin
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_admin_field_groups') ) :
|
||||
|
||||
class acf_admin_field_groups {
|
||||
|
||||
// vars
|
||||
var $url = 'edit.php?post_type=acf-field-group',
|
||||
$sync = array();
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the class functionality
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action('current_screen', array($this, 'current_screen'));
|
||||
add_action('trashed_post', array($this, 'trashed_post'));
|
||||
add_action('untrashed_post', array($this, 'untrashed_post'));
|
||||
add_action('deleted_post', array($this, 'deleted_post'));
|
||||
add_action('load-edit.php', array($this, 'maybe_redirect_edit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* maybe_redirect_edit
|
||||
*
|
||||
* Redirects the user from the old ACF4 edit page to the new ACF5 edit page
|
||||
*
|
||||
* @date 17/9/18
|
||||
* @since 5.7.6
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function maybe_redirect_edit() {
|
||||
if( acf_maybe_get_GET('post_type') == 'acf' ) {
|
||||
wp_redirect( admin_url($this->url) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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('edit-acf-field-group') ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// customize post_status
|
||||
global $wp_post_statuses;
|
||||
|
||||
|
||||
// modify publish post status
|
||||
$wp_post_statuses['publish']->label_count = _n_noop( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', 'acf' );
|
||||
|
||||
|
||||
// reorder trash to end
|
||||
$wp_post_statuses['trash'] = acf_extract_var( $wp_post_statuses, 'trash' );
|
||||
|
||||
|
||||
// check stuff
|
||||
$this->check_duplicate();
|
||||
$this->check_sync();
|
||||
|
||||
|
||||
// actions
|
||||
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
||||
add_action('admin_footer', array($this, 'admin_footer'));
|
||||
|
||||
|
||||
// columns
|
||||
add_filter('manage_edit-acf-field-group_columns', array($this, 'field_group_columns'), 10, 1);
|
||||
add_action('manage_acf-field-group_posts_custom_column', array($this, 'field_group_columns_html'), 10, 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_enqueue_scripts
|
||||
*
|
||||
* This function will add the already registered css
|
||||
*
|
||||
* @type function
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
wp_enqueue_script('acf-input');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check_duplicate
|
||||
*
|
||||
* This function will check for any $_GET data to duplicate
|
||||
*
|
||||
* @type function
|
||||
* @date 17/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function check_duplicate() {
|
||||
|
||||
// Display notice
|
||||
if( $ids = acf_maybe_get_GET('acfduplicatecomplete') ) {
|
||||
|
||||
// explode
|
||||
$ids = explode(',', $ids);
|
||||
$total = count($ids);
|
||||
|
||||
// Generate text.
|
||||
$text = sprintf( _n( 'Field group duplicated.', '%s field groups duplicated.', $total, 'acf' ), $total );
|
||||
|
||||
// Add links to text.
|
||||
$links = array();
|
||||
foreach( $ids as $id ) {
|
||||
$links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>';
|
||||
}
|
||||
$text .= ' ' . implode( ', ', $links );
|
||||
|
||||
// Add notice
|
||||
acf_add_admin_notice( $text, 'success' );
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$ids = array();
|
||||
|
||||
|
||||
// check single
|
||||
if( $id = acf_maybe_get_GET('acfduplicate') ) {
|
||||
|
||||
$ids[] = $id;
|
||||
|
||||
// check multiple
|
||||
} elseif( acf_maybe_get_GET('action2') === 'acfduplicate' ) {
|
||||
|
||||
$ids = acf_maybe_get_GET('post');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// sync
|
||||
if( !empty($ids) ) {
|
||||
|
||||
// validate
|
||||
check_admin_referer('bulk-posts');
|
||||
|
||||
|
||||
// vars
|
||||
$new_ids = array();
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $ids as $id ) {
|
||||
|
||||
// duplicate
|
||||
$field_group = acf_duplicate_field_group( $id );
|
||||
|
||||
|
||||
// increase counter
|
||||
$new_ids[] = $field_group['ID'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// redirect
|
||||
wp_redirect( admin_url( $this->url . '&acfduplicatecomplete=' . implode(',', $new_ids)) );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check_sync
|
||||
*
|
||||
* This function will check for any $_GET data to sync
|
||||
*
|
||||
* @type function
|
||||
* @date 9/12/2014
|
||||
* @since 5.1.5
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function check_sync() {
|
||||
|
||||
// Display notice
|
||||
if( $ids = acf_maybe_get_GET('acfsynccomplete') ) {
|
||||
|
||||
// explode
|
||||
$ids = explode(',', $ids);
|
||||
$total = count($ids);
|
||||
|
||||
// Generate text.
|
||||
$text = sprintf( _n( 'Field group synchronised.', '%s field groups synchronised.', $total, 'acf' ), $total );
|
||||
|
||||
// Add links to text.
|
||||
$links = array();
|
||||
foreach( $ids as $id ) {
|
||||
$links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>';
|
||||
}
|
||||
$text .= ' ' . implode( ', ', $links );
|
||||
|
||||
// Add notice
|
||||
acf_add_admin_notice( $text, 'success' );
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$groups = acf_get_field_groups();
|
||||
|
||||
|
||||
// bail early if no field groups
|
||||
if( empty($groups) ) return;
|
||||
|
||||
|
||||
// find JSON field groups which have not yet been imported
|
||||
foreach( $groups as $group ) {
|
||||
|
||||
// vars
|
||||
$local = acf_maybe_get($group, 'local', false);
|
||||
$modified = acf_maybe_get($group, 'modified', 0);
|
||||
$private = acf_maybe_get($group, 'private', false);
|
||||
|
||||
// Ignore if is private.
|
||||
if( $private ) {
|
||||
continue;
|
||||
|
||||
// Ignore not local "json".
|
||||
} elseif( $local !== 'json' ) {
|
||||
continue;
|
||||
|
||||
// Append to sync if not yet in database.
|
||||
} elseif( !$group['ID'] ) {
|
||||
$this->sync[ $group['key'] ] = $group;
|
||||
|
||||
// Append to sync if "json" modified time is newer than database.
|
||||
} elseif( $modified && $modified > get_post_modified_time('U', true, $group['ID'], true) ) {
|
||||
$this->sync[ $group['key'] ] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// bail if no sync needed
|
||||
if( empty($this->sync) ) return;
|
||||
|
||||
|
||||
// maybe sync
|
||||
$sync_keys = array();
|
||||
|
||||
|
||||
// check single
|
||||
if( $key = acf_maybe_get_GET('acfsync') ) {
|
||||
|
||||
$sync_keys[] = $key;
|
||||
|
||||
// check multiple
|
||||
} elseif( acf_maybe_get_GET('action2') === 'acfsync' ) {
|
||||
|
||||
$sync_keys = acf_maybe_get_GET('post');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// sync
|
||||
if( !empty($sync_keys) ) {
|
||||
|
||||
// validate
|
||||
check_admin_referer('bulk-posts');
|
||||
|
||||
|
||||
// disable filters to ensure ACF loads raw data from DB
|
||||
acf_disable_filters();
|
||||
acf_enable_filter('local');
|
||||
|
||||
|
||||
// disable JSON
|
||||
// - this prevents a new JSON file being created and causing a 'change' to theme files - solves git anoyance
|
||||
acf_update_setting('json', false);
|
||||
|
||||
|
||||
// vars
|
||||
$new_ids = array();
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $sync_keys as $key ) {
|
||||
|
||||
// Bail early if not found.
|
||||
if( !isset($this->sync[ $key ]) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get field group.
|
||||
$field_group = $this->sync[ $key ];
|
||||
|
||||
// Append fields.
|
||||
$field_group['fields'] = acf_get_fields( $field_group );
|
||||
|
||||
// Import field group.
|
||||
$field_group = acf_import_field_group( $field_group );
|
||||
|
||||
// Append imported ID.
|
||||
$new_ids[] = $field_group['ID'];
|
||||
}
|
||||
|
||||
|
||||
// redirect
|
||||
wp_redirect( admin_url( $this->url . '&acfsynccomplete=' . implode(',', $new_ids)) );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// filters
|
||||
add_filter('views_edit-acf-field-group', array($this, 'list_table_views'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* list_table_views
|
||||
*
|
||||
* This function will add an extra link for JSON in the field group list table
|
||||
*
|
||||
* @type function
|
||||
* @date 3/12/2014
|
||||
* @since 5.1.5
|
||||
*
|
||||
* @param $views (array)
|
||||
* @return $views
|
||||
*/
|
||||
|
||||
function list_table_views( $views ) {
|
||||
|
||||
// vars
|
||||
$class = '';
|
||||
$total = count($this->sync);
|
||||
|
||||
// active
|
||||
if( acf_maybe_get_GET('post_status') === 'sync' ) {
|
||||
|
||||
// actions
|
||||
add_action('admin_footer', array($this, 'sync_admin_footer'), 5);
|
||||
|
||||
|
||||
// set active class
|
||||
$class = ' class="current"';
|
||||
|
||||
|
||||
// global
|
||||
global $wp_list_table;
|
||||
|
||||
|
||||
// update pagination
|
||||
$wp_list_table->set_pagination_args( array(
|
||||
'total_items' => $total,
|
||||
'total_pages' => 1,
|
||||
'per_page' => $total
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add view
|
||||
$views['json'] = '<a' . $class . ' href="' . admin_url($this->url . '&post_status=sync') . '">' . __('Sync available', 'acf') . ' <span class="count">(' . $total . ')</span></a>';
|
||||
|
||||
|
||||
// return
|
||||
return $views;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* trashed_post
|
||||
*
|
||||
* This function is run when a post object is sent to the trash
|
||||
*
|
||||
* @type action (trashed_post)
|
||||
* @date 8/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function trashed_post( $post_id ) {
|
||||
|
||||
// validate post type
|
||||
if( get_post_type($post_id) != 'acf-field-group' ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// trash field group
|
||||
acf_trash_field_group( $post_id );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* untrashed_post
|
||||
*
|
||||
* This function is run when a post object is restored from the trash
|
||||
*
|
||||
* @type action (untrashed_post)
|
||||
* @date 8/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function untrashed_post( $post_id ) {
|
||||
|
||||
// validate post type
|
||||
if( get_post_type($post_id) != 'acf-field-group' ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// trash field group
|
||||
acf_untrash_field_group( $post_id );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* deleted_post
|
||||
*
|
||||
* This function is run when a post object is deleted from the trash
|
||||
*
|
||||
* @type action (deleted_post)
|
||||
* @date 8/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function deleted_post( $post_id ) {
|
||||
|
||||
// validate post type
|
||||
if( get_post_type($post_id) != 'acf-field-group' ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// trash field group
|
||||
acf_delete_field_group( $post_id );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* field_group_columns
|
||||
*
|
||||
* This function will customize the columns for the field group table
|
||||
*
|
||||
* @type filter (manage_edit-acf-field-group_columns)
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $columns (array)
|
||||
* @return $columns (array)
|
||||
*/
|
||||
|
||||
function field_group_columns( $columns ) {
|
||||
|
||||
return array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __('Title', 'acf'),
|
||||
'acf-fg-description' => __('Description', 'acf'),
|
||||
'acf-fg-status' => '<i class="acf-icon -dot-3 small acf-js-tooltip" title="' . esc_attr__('Status', 'acf') . '"></i>',
|
||||
'acf-fg-count' => __('Fields', 'acf'),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* field_group_columns_html
|
||||
*
|
||||
* This function will render the HTML for each table cell
|
||||
*
|
||||
* @type action (manage_acf-field-group_posts_custom_column)
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $column (string)
|
||||
* @param $post_id (int)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function field_group_columns_html( $column, $post_id ) {
|
||||
|
||||
// vars
|
||||
$field_group = acf_get_field_group( $post_id );
|
||||
|
||||
|
||||
// render
|
||||
$this->render_column( $column, $field_group );
|
||||
|
||||
}
|
||||
|
||||
function render_column( $column, $field_group ) {
|
||||
|
||||
// description
|
||||
if( $column == 'acf-fg-description' ) {
|
||||
|
||||
if( $field_group['description'] ) {
|
||||
|
||||
echo '<span class="acf-description">' . acf_esc_html($field_group['description']) . '</span>';
|
||||
|
||||
}
|
||||
|
||||
// status
|
||||
} elseif( $column == 'acf-fg-status' ) {
|
||||
|
||||
if( isset($this->sync[ $field_group['key'] ]) ) {
|
||||
|
||||
echo '<i class="acf-icon -sync grey small acf-js-tooltip" title="' . esc_attr__('Sync available', 'acf') .'"></i> ';
|
||||
|
||||
}
|
||||
|
||||
if( $field_group['active'] ) {
|
||||
|
||||
//echo '<i class="acf-icon -check small acf-js-tooltip" title="' . esc_attr__('Active', 'acf') .'"></i> ';
|
||||
|
||||
} else {
|
||||
|
||||
echo '<i class="acf-icon -minus yellow small acf-js-tooltip" title="' . esc_attr__('Inactive', 'acf') . '"></i> ';
|
||||
|
||||
}
|
||||
|
||||
// fields
|
||||
} elseif( $column == 'acf-fg-count' ) {
|
||||
|
||||
echo esc_html( acf_get_field_count( $field_group ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_footer
|
||||
*
|
||||
* This function will render extra HTML onto the page
|
||||
*
|
||||
* @type action (admin_footer)
|
||||
* @date 23/06/12
|
||||
* @since 3.1.8
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
// vars
|
||||
$url_home = 'https://www.advancedcustomfields.com';
|
||||
$icon = '<i aria-hidden="true" class="dashicons dashicons-external"></i>';
|
||||
|
||||
?>
|
||||
<script type="text/html" id="tmpl-acf-column-2">
|
||||
<div class="acf-column-2">
|
||||
<div class="acf-box">
|
||||
<div class="inner">
|
||||
<h2><?php echo acf_get_setting('name'); ?></h2>
|
||||
<p><?php _e('Customize WordPress with powerful, professional and intuitive fields.','acf'); ?></p>
|
||||
|
||||
<h3><?php _e("Changelog",'acf'); ?></h3>
|
||||
<p><?php
|
||||
|
||||
$acf_changelog = admin_url('edit.php?post_type=acf-field-group&page=acf-settings-info&tab=changelog');
|
||||
$acf_version = acf_get_setting('version');
|
||||
printf( __('See what\'s new in <a href="%s">version %s</a>.','acf'), esc_url($acf_changelog), $acf_version );
|
||||
|
||||
?></p>
|
||||
<h3><?php _e("Resources",'acf'); ?></h3>
|
||||
<ul>
|
||||
<li><a href="<?php echo esc_url( $url_home ); ?>" target="_blank"><?php echo $icon; ?> <?php _e("Website",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo esc_url( $url_home . '/resources/' ); ?>" target="_blank"><?php echo $icon; ?> <?php _e("Documentation",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo esc_url( $url_home . '/support/' ); ?>" target="_blank"><?php echo $icon; ?> <?php _e("Support",'acf'); ?></a></li>
|
||||
<?php if( !acf_get_setting('pro') ): ?>
|
||||
<li><a href="<?php echo esc_url( $url_home . '/pro/' ); ?>" target="_blank"><?php echo $icon; ?> <?php _e("Pro",'acf'); ?></a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p><?php printf( __('Thank you for creating with <a href="%s">ACF</a>.','acf'), esc_url($url_home) ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
(function($){
|
||||
|
||||
// wrap
|
||||
$('#wpbody .wrap').attr('id', 'acf-field-group-wrap');
|
||||
|
||||
|
||||
// wrap form
|
||||
$('#posts-filter').wrap('<div class="acf-columns-2" />');
|
||||
|
||||
|
||||
// add column main
|
||||
$('#posts-filter').addClass('acf-column-1');
|
||||
|
||||
|
||||
// add column side
|
||||
$('#posts-filter').after( $('#tmpl-acf-column-2').html() );
|
||||
|
||||
|
||||
// modify row actions
|
||||
$('#the-list tr').each(function(){
|
||||
|
||||
// vars
|
||||
var $tr = $(this),
|
||||
id = $tr.attr('id'),
|
||||
description = $tr.find('.column-acf-fg-description').html();
|
||||
|
||||
|
||||
// replace Quick Edit with Duplicate (sync page has no id attribute)
|
||||
if( id ) {
|
||||
|
||||
// vars
|
||||
var post_id = id.replace('post-', '');
|
||||
var url = '<?php echo esc_url( admin_url( $this->url . '&acfduplicate=__post_id__&_wpnonce=' . wp_create_nonce('bulk-posts') ) ); ?>';
|
||||
var $span = $('<span class="acf-duplicate-field-group"><a title="<?php _e('Duplicate this item', 'acf'); ?>" href="' + url.replace('__post_id__', post_id) + '"><?php _e('Duplicate', 'acf'); ?></a> | </span>');
|
||||
|
||||
|
||||
// replace
|
||||
$tr.find('.column-title .row-actions .inline').replaceWith( $span );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add description to title
|
||||
$tr.find('.column-title .row-title').after( description );
|
||||
|
||||
});
|
||||
|
||||
|
||||
// modify bulk actions
|
||||
$('#bulk-action-selector-bottom option[value="edit"]').attr('value','acfduplicate').text('<?php _e( 'Duplicate', 'acf' ); ?>');
|
||||
|
||||
|
||||
// clean up table
|
||||
$('#adv-settings label[for="acf-fg-description-hide"]').remove();
|
||||
|
||||
|
||||
// mobile compatibility
|
||||
var status = $('.acf-icon.-dot-3').first().attr('title');
|
||||
$('td.column-acf-fg-status').attr('data-colname', status);
|
||||
|
||||
|
||||
// no field groups found
|
||||
$('#the-list tr.no-items td').attr('colspan', 4);
|
||||
|
||||
|
||||
// search
|
||||
$('.subsubsub').append(' | <li><a href="#" class="acf-toggle-search"><?php _e('Search', 'acf'); ?></a></li>');
|
||||
|
||||
|
||||
// events
|
||||
$(document).on('click', '.acf-toggle-search', function( e ){
|
||||
|
||||
// prevent default
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
// toggle
|
||||
$('.search-box').slideToggle();
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* sync_admin_footer
|
||||
*
|
||||
* This function will render extra HTML onto the page
|
||||
*
|
||||
* @type action (admin_footer)
|
||||
* @date 23/06/12
|
||||
* @since 3.1.8
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function sync_admin_footer() {
|
||||
|
||||
// vars
|
||||
$i = -1;
|
||||
$columns = array(
|
||||
'acf-fg-description',
|
||||
'acf-fg-status',
|
||||
'acf-fg-count'
|
||||
);
|
||||
$nonce = wp_create_nonce('bulk-posts');
|
||||
|
||||
?>
|
||||
<script type="text/html" id="tmpl-acf-json-tbody">
|
||||
<?php foreach( $this->sync as $field_group ):
|
||||
|
||||
// vars
|
||||
$i++;
|
||||
$key = $field_group['key'];
|
||||
$title = $field_group['title'];
|
||||
$url = admin_url( $this->url . '&post_status=sync&acfsync=' . $key . '&_wpnonce=' . $nonce );
|
||||
|
||||
?>
|
||||
<tr <?php if($i%2 == 0): ?>class="alternate"<?php endif; ?>>
|
||||
<th class="check-column" scope="row">
|
||||
<label for="cb-select-<?php echo esc_attr($key); ?>" class="screen-reader-text"><?php echo esc_html(sprintf(__('Select %s', 'acf'), $title)); ?></label>
|
||||
<input type="checkbox" value="<?php echo esc_attr($key); ?>" name="post[]" id="cb-select-<?php echo esc_attr($key); ?>">
|
||||
</th>
|
||||
<td class="post-title page-title column-title">
|
||||
<strong>
|
||||
<span class="row-title"><?php echo esc_html($title); ?></span><span class="acf-description"><?php echo esc_html($key); ?>.json</span>
|
||||
</strong>
|
||||
<div class="row-actions">
|
||||
<span class="import"><a title="<?php echo esc_attr( __('Synchronise field group', 'acf') ); ?>" href="<?php echo esc_url($url); ?>"><?php _e( 'Sync', 'acf' ); ?></a></span>
|
||||
</div>
|
||||
</td>
|
||||
<?php foreach( $columns as $column ): ?>
|
||||
<td class="column-<?php echo esc_attr($column); ?>"><?php $this->render_column( $column, $field_group ); ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</script>
|
||||
<script type="text/html" id="tmpl-acf-bulk-actions">
|
||||
<?php // source: bulk_actions() wp-admin/includes/class-wp-list-table.php ?>
|
||||
<select name="action2" id="bulk-action-selector-bottom"></select>
|
||||
<?php submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction2" ) ); ?>
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
(function($){
|
||||
|
||||
// update table HTML
|
||||
$('#the-list').html( $('#tmpl-acf-json-tbody').html() );
|
||||
|
||||
|
||||
// bulk may not exist if no field groups in DB
|
||||
if( !$('#bulk-action-selector-bottom').exists() ) {
|
||||
|
||||
$('.tablenav.bottom .actions.alignleft').html( $('#tmpl-acf-bulk-actions').html() );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// set only options
|
||||
$('#bulk-action-selector-bottom').html('<option value="-1"><?php _e('Bulk Actions'); ?></option><option value="acfsync"><?php _e('Sync', 'acf'); ?></option>');
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new acf_admin_field_groups();
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* ACF Admin Notices
|
||||
*
|
||||
* Functions and classes to manage admin notices.
|
||||
*
|
||||
* @date 10/1/19
|
||||
* @since 5.7.10
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if( !defined('ABSPATH') ) exit;
|
||||
|
||||
// Register notices store.
|
||||
acf_register_store( 'notices' );
|
||||
|
||||
/**
|
||||
* ACF_Admin_Notice
|
||||
*
|
||||
* Class used to create an admin notice.
|
||||
*
|
||||
* @date 10/1/19
|
||||
* @since 5.7.10
|
||||
*/
|
||||
if( ! class_exists('ACF_Admin_Notice') ) :
|
||||
|
||||
class ACF_Admin_Notice extends ACF_Data {
|
||||
|
||||
/** @var array Storage for data. */
|
||||
var $data = array(
|
||||
|
||||
/** @type string Text displayed in notice. */
|
||||
'text' => '',
|
||||
|
||||
/** @type string Optional HTML alternative to text.
|
||||
'html' => '', */
|
||||
|
||||
/** @type string The type of notice (warning, error, success, info). */
|
||||
'type' => 'info',
|
||||
|
||||
/** @type bool If the notice can be dismissed. */
|
||||
'dismissible' => true,
|
||||
);
|
||||
|
||||
/**
|
||||
* render
|
||||
*
|
||||
* Renders the notice HTML.
|
||||
*
|
||||
* @date 27/12/18
|
||||
* @since 5.8.0
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function render() {
|
||||
|
||||
// Ensure text contains punctuation.
|
||||
// todo: Remove this after updating translations.
|
||||
$text = $this->get('text');
|
||||
if( substr($text, -1) !== '.' && substr($text, -1) !== '>' ) {
|
||||
$text .= '.';
|
||||
}
|
||||
|
||||
// Print HTML.
|
||||
printf('<div class="acf-admin-notice notice notice-%s %s">%s</div>',
|
||||
|
||||
// Type class.
|
||||
$this->get('type'),
|
||||
|
||||
// Dismissible class.
|
||||
$this->get('dismissible') ? 'is-dismissible' : '',
|
||||
|
||||
// InnerHTML
|
||||
$this->has('html') ? $this->get('html') : wpautop($text)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
/**
|
||||
* acf_new_admin_notice
|
||||
*
|
||||
* Instantiates and returns a new model.
|
||||
*
|
||||
* @date 23/12/18
|
||||
* @since 5.8.0
|
||||
*
|
||||
* @param array $data Optional data to set.
|
||||
* @return ACF_Admin_Notice
|
||||
*/
|
||||
function acf_new_admin_notice( $data = false ) {
|
||||
|
||||
// Create notice.
|
||||
$instance = new ACF_Admin_Notice( $data );
|
||||
|
||||
// Register notice.
|
||||
acf_get_store( 'notices' )->set( $instance->cid, $instance );
|
||||
|
||||
// Return notice.
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_render_admin_notices
|
||||
*
|
||||
* Renders all admin notices HTML.
|
||||
*
|
||||
* @date 10/1/19
|
||||
* @since 5.7.10
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function acf_render_admin_notices() {
|
||||
|
||||
// Get notices.
|
||||
$notices = acf_get_store( 'notices' )->get_data();
|
||||
|
||||
// Loop over notices and render.
|
||||
if( $notices ) {
|
||||
foreach( $notices as $notice ) {
|
||||
$notice->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render notices during admin action.
|
||||
add_action('admin_notices', 'acf_render_admin_notices', 99);
|
||||
|
||||
/**
|
||||
* acf_add_admin_notice
|
||||
*
|
||||
* Creates and returns a new notice.
|
||||
*
|
||||
* @date 17/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param string $text The admin notice text.
|
||||
* @param string $class The type of notice (warning, error, success, info).
|
||||
* @return ACF_Admin_Notice
|
||||
*/
|
||||
function acf_add_admin_notice( $text = '', $type = 'info' ) {
|
||||
return acf_new_admin_notice( array( 'text' => $text, 'type' => $type ) );
|
||||
}
|
||||
@@ -0,0 +1,354 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_admin_tools') ) :
|
||||
|
||||
class acf_admin_tools {
|
||||
|
||||
|
||||
/** @var array Contains an array of admin tool instances */
|
||||
var $tools = array();
|
||||
|
||||
|
||||
/** @var string The active tool */
|
||||
var $active = '';
|
||||
|
||||
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the class functionality
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action('admin_menu', array($this, 'admin_menu'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* register_tool
|
||||
*
|
||||
* This function will store a tool tool class
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param string $class
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function register_tool( $class ) {
|
||||
|
||||
$instance = new $class();
|
||||
$this->tools[ $instance->name ] = $instance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get_tool
|
||||
*
|
||||
* This function will return a tool tool class
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param string $name
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function get_tool( $name ) {
|
||||
|
||||
return isset( $this->tools[$name] ) ? $this->tools[$name] : null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get_tools
|
||||
*
|
||||
* This function will return an array of all tools
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return array
|
||||
*/
|
||||
|
||||
function get_tools() {
|
||||
|
||||
return $this->tools;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_menu
|
||||
*
|
||||
* This function will add the ACF menu item to the WP admin
|
||||
*
|
||||
* @type action (admin_menu)
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
// bail early if no show_admin
|
||||
if( !acf_get_setting('show_admin') ) return;
|
||||
|
||||
|
||||
// add page
|
||||
$page = add_submenu_page('edit.php?post_type=acf-field-group', __('Tools','acf'), __('Tools','acf'), acf_get_setting('capability'), 'acf-tools', array($this, 'html'));
|
||||
|
||||
|
||||
// actions
|
||||
add_action('load-' . $page, array($this, 'load'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* load
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function load() {
|
||||
|
||||
// disable filters (default to raw data)
|
||||
acf_disable_filters();
|
||||
|
||||
|
||||
// include tools
|
||||
$this->include_tools();
|
||||
|
||||
|
||||
// check submit
|
||||
$this->check_submit();
|
||||
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* include_tools
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function include_tools() {
|
||||
|
||||
// include
|
||||
acf_include('includes/admin/tools/class-acf-admin-tool.php');
|
||||
acf_include('includes/admin/tools/class-acf-admin-tool-export.php');
|
||||
acf_include('includes/admin/tools/class-acf-admin-tool-import.php');
|
||||
|
||||
|
||||
// action
|
||||
do_action('acf/include_admin_tools');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check_submit
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function check_submit() {
|
||||
|
||||
// loop
|
||||
foreach( $this->get_tools() as $tool ) {
|
||||
|
||||
// load
|
||||
$tool->load();
|
||||
|
||||
|
||||
// submit
|
||||
if( acf_verify_nonce($tool->name) ) {
|
||||
$tool->submit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
// vars
|
||||
$screen = get_current_screen();
|
||||
$active = acf_maybe_get_GET('tool');
|
||||
|
||||
|
||||
// view
|
||||
$view = array(
|
||||
'screen_id' => $screen->id,
|
||||
'active' => $active
|
||||
);
|
||||
|
||||
|
||||
// register metaboxes
|
||||
foreach( $this->get_tools() as $tool ) {
|
||||
|
||||
// check active
|
||||
if( $active && $active !== $tool->name ) continue;
|
||||
|
||||
|
||||
// add metabox
|
||||
add_meta_box( 'acf-admin-tool-' . $tool->name, $tool->title, array($this, 'metabox_html'), $screen->id, 'normal', 'default', array('tool' => $tool->name) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// view
|
||||
acf_get_view( 'html-admin-tools', $view );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* meta_box_html
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function metabox_html( $post, $metabox ) {
|
||||
|
||||
// vars
|
||||
$tool = $this->get_tool($metabox['args']['tool']);
|
||||
|
||||
|
||||
?>
|
||||
<form method="post">
|
||||
<?php $tool->html(); ?>
|
||||
<?php acf_nonce_input( $tool->name ); ?>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize
|
||||
acf()->admin_tools = new acf_admin_tools();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
/*
|
||||
* acf_register_admin_tool
|
||||
*
|
||||
* alias of acf()->admin_tools->register_tool()
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_register_admin_tool( $class ) {
|
||||
|
||||
return acf()->admin_tools->register_tool( $class );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_admin_tools_url
|
||||
*
|
||||
* This function will return the admin URL to the tools page
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_get_admin_tools_url() {
|
||||
|
||||
return admin_url('edit.php?post_type=acf-field-group&page=acf-tools');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_admin_tool_url
|
||||
*
|
||||
* This function will return the admin URL to the tools page
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_get_admin_tool_url( $tool = '' ) {
|
||||
|
||||
return acf_get_admin_tools_url() . '&tool='.$tool;
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('ACF_Admin_Upgrade') ) :
|
||||
|
||||
class ACF_Admin_Upgrade {
|
||||
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* Sets up the class functionality.
|
||||
*
|
||||
* @date 31/7/18
|
||||
* @since 5.7.2
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action( 'admin_menu', array($this,'admin_menu'), 20 );
|
||||
add_action( 'network_admin_menu', array($this,'network_admin_menu'), 20 );
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_menu
|
||||
*
|
||||
* Setus up logic if DB Upgrade is needed on a single site.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function admin_menu() {
|
||||
|
||||
// check if upgrade is avaialble
|
||||
if( acf_has_upgrade() ) {
|
||||
|
||||
// add notice
|
||||
add_action('admin_notices', array($this, 'admin_notices'));
|
||||
|
||||
// add page
|
||||
$page = add_submenu_page('index.php', __('Upgrade Database','acf'), __('Upgrade Database','acf'), acf_get_setting('capability'), 'acf-upgrade', array($this,'admin_html') );
|
||||
|
||||
// actions
|
||||
add_action('load-' . $page, array($this,'admin_load'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* network_admin_menu
|
||||
*
|
||||
* Setus up logic if DB Upgrade is needed on a multi site.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function network_admin_menu() {
|
||||
|
||||
// vars
|
||||
$has_upgrade = false;
|
||||
|
||||
// loop over sites
|
||||
$sites = acf_get_sites();
|
||||
if( $sites ) {
|
||||
foreach( $sites as $site ) {
|
||||
|
||||
// switch blog
|
||||
switch_to_blog( $site['blog_id'] );
|
||||
|
||||
// check for upgrade
|
||||
if( acf_has_upgrade() ) {
|
||||
$has_upgrade = true;
|
||||
}
|
||||
|
||||
// restore blog
|
||||
restore_current_blog();
|
||||
}}
|
||||
|
||||
// check if upgrade is avaialble
|
||||
if( $has_upgrade ) {
|
||||
|
||||
// add notice
|
||||
add_action('network_admin_notices', array($this, 'network_admin_notices'));
|
||||
|
||||
// add page
|
||||
$page = add_submenu_page('index.php', __('Upgrade Database','acf'), __('Upgrade Database','acf'), acf_get_setting('capability'), 'acf-upgrade-network', array($this,'network_admin_html'));
|
||||
|
||||
// actions
|
||||
add_action('load-' . $page, array($this,'network_admin_load'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_load
|
||||
*
|
||||
* Runs during the loading of the admin page.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
function admin_load() {
|
||||
|
||||
// remove prompt
|
||||
remove_action('admin_notices', array($this, 'admin_notices'));
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
}
|
||||
|
||||
/**
|
||||
* network_admin_load
|
||||
*
|
||||
* Runs during the loading of the network admin page.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
function network_admin_load() {
|
||||
|
||||
// remove prompt
|
||||
remove_action('network_admin_notices', array($this, 'network_admin_notices'));
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_notices
|
||||
*
|
||||
* Displays the DB Upgrade prompt.
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.3
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function admin_notices() {
|
||||
|
||||
// vars
|
||||
$view = array(
|
||||
'button_text' => __("Upgrade Database", 'acf'),
|
||||
'button_url' => admin_url('index.php?page=acf-upgrade'),
|
||||
'confirm' => true
|
||||
);
|
||||
|
||||
// view
|
||||
acf_get_view('html-notice-upgrade', $view);
|
||||
}
|
||||
|
||||
/**
|
||||
* network_admin_notices
|
||||
*
|
||||
* Displays the DB Upgrade prompt on a multi site.
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.3
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function network_admin_notices() {
|
||||
|
||||
// vars
|
||||
$view = array(
|
||||
'button_text' => __("Review sites & upgrade", 'acf'),
|
||||
'button_url' => network_admin_url('index.php?page=acf-upgrade-network'),
|
||||
'confirm' => false
|
||||
);
|
||||
|
||||
// view
|
||||
acf_get_view('html-notice-upgrade', $view);
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_html
|
||||
*
|
||||
* Displays the HTML for the admin page.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function admin_html() {
|
||||
acf_get_view('html-admin-page-upgrade');
|
||||
}
|
||||
|
||||
/**
|
||||
* network_admin_html
|
||||
*
|
||||
* Displays the HTML for the network upgrade admin page.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function network_admin_html() {
|
||||
acf_get_view('html-admin-page-upgrade-network');
|
||||
}
|
||||
}
|
||||
|
||||
// instantiate
|
||||
acf_new_instance('ACF_Admin_Upgrade');
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_admin') ) :
|
||||
|
||||
class acf_admin {
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* Initialize filters, action, variables and includes
|
||||
*
|
||||
* @type function
|
||||
* @date 23/06/12
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action('admin_menu', array($this, 'admin_menu'));
|
||||
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* admin_menu
|
||||
*
|
||||
* This function will add the ACF menu item to the WP admin
|
||||
*
|
||||
* @type action (admin_menu)
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
// bail early if no show_admin
|
||||
if( !acf_get_setting('show_admin') ) return;
|
||||
|
||||
|
||||
// vars
|
||||
$slug = 'edit.php?post_type=acf-field-group';
|
||||
$cap = acf_get_setting('capability');
|
||||
|
||||
|
||||
// add parent
|
||||
add_menu_page(__("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', '80.025');
|
||||
|
||||
|
||||
// add children
|
||||
add_submenu_page($slug, __('Field Groups','acf'), __('Field Groups','acf'), $cap, $slug );
|
||||
add_submenu_page($slug, __('Add New','acf'), __('Add New','acf'), $cap, 'post-new.php?post_type=acf-field-group' );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_enqueue_scripts
|
||||
*
|
||||
* This function will add the already registered css
|
||||
*
|
||||
* @type function
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
wp_enqueue_style( 'acf-global' );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// initialize
|
||||
acf()->admin = new acf_admin();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
class acf_settings_info {
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* Initialize filters, action, variables and includes
|
||||
*
|
||||
* @type function
|
||||
* @date 23/06/12
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action('admin_menu', array($this, 'admin_menu'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_menu
|
||||
*
|
||||
* This function will add the ACF menu item to the WP admin
|
||||
*
|
||||
* @type action (admin_menu)
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
// bail early if no show_admin
|
||||
if( !acf_get_setting('show_admin') ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add page
|
||||
add_submenu_page('edit.php?post_type=acf-field-group', __('Info','acf'), __('Info','acf'), acf_get_setting('capability'),'acf-settings-info', array($this,'html'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* html
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 7/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
// vars
|
||||
$view = array(
|
||||
'version' => acf_get_setting('version'),
|
||||
'have_pro' => acf_get_setting('pro'),
|
||||
'tabs' => array(
|
||||
'new' => __("What's New", 'acf'),
|
||||
'changelog' => __("Changelog", 'acf')
|
||||
),
|
||||
'active' => 'new'
|
||||
);
|
||||
|
||||
|
||||
// set active tab
|
||||
$tab = acf_maybe_get_GET('tab');
|
||||
if( $tab && isset($view['tabs'][ $tab ]) ) {
|
||||
|
||||
$view['active'] = $tab;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// load view
|
||||
acf_get_view('settings-info', $view);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
new acf_settings_info();
|
||||
|
||||
?>
|
||||
+596
@@ -0,0 +1,596 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('ACF_Admin_Tool_Export') ) :
|
||||
|
||||
class ACF_Admin_Tool_Export extends ACF_Admin_Tool {
|
||||
|
||||
/** @var string View context */
|
||||
var $view = '';
|
||||
|
||||
|
||||
/** @var array Export data */
|
||||
var $json = '';
|
||||
|
||||
|
||||
/**
|
||||
* initialize
|
||||
*
|
||||
* This function will initialize the admin tool
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'export';
|
||||
$this->title = __("Export Field Groups", 'acf');
|
||||
|
||||
|
||||
// active
|
||||
if( $this->is_active() ) {
|
||||
$this->title .= ' - ' . __('Generate PHP', 'acf');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* submit
|
||||
*
|
||||
* This function will run when the tool's form has been submit
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function submit() {
|
||||
|
||||
// vars
|
||||
$action = acf_maybe_get_POST('action');
|
||||
|
||||
|
||||
// download
|
||||
if( $action === 'download' ) {
|
||||
|
||||
$this->submit_download();
|
||||
|
||||
// generate
|
||||
} elseif( $action === 'generate' ) {
|
||||
|
||||
$this->submit_generate();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* submit_download
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 17/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function submit_download() {
|
||||
|
||||
// vars
|
||||
$json = $this->get_selected();
|
||||
|
||||
|
||||
// validate
|
||||
if( $json === false ) {
|
||||
return acf_add_admin_notice( __("No field groups selected", 'acf'), 'warning' );
|
||||
}
|
||||
|
||||
|
||||
// headers
|
||||
$file_name = 'acf-export-' . date('Y-m-d') . '.json';
|
||||
header( "Content-Description: File Transfer" );
|
||||
header( "Content-Disposition: attachment; filename={$file_name}" );
|
||||
header( "Content-Type: application/json; charset=utf-8" );
|
||||
|
||||
|
||||
// return
|
||||
echo acf_json_encode( $json );
|
||||
die;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* submit_generate
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 17/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function submit_generate() {
|
||||
|
||||
// vars
|
||||
$keys = $this->get_selected_keys();
|
||||
|
||||
|
||||
// validate
|
||||
if( !$keys ) {
|
||||
return acf_add_admin_notice( __("No field groups selected", 'acf'), 'warning' );
|
||||
}
|
||||
|
||||
|
||||
// url
|
||||
$url = add_query_arg( 'keys', implode('+', $keys), $this->get_url() );
|
||||
|
||||
|
||||
// redirect
|
||||
wp_redirect( $url );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* load
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 21/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function load() {
|
||||
|
||||
// active
|
||||
if( $this->is_active() ) {
|
||||
|
||||
// get selected keys
|
||||
$selected = $this->get_selected_keys();
|
||||
|
||||
|
||||
// add notice
|
||||
if( $selected ) {
|
||||
$count = count($selected);
|
||||
$text = sprintf( _n( 'Exported 1 field group.', 'Exported %s field groups.', $count, 'acf' ), $count );
|
||||
acf_add_admin_notice( $text, 'success' );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html
|
||||
*
|
||||
* This function will output the metabox HTML
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
// single (generate PHP)
|
||||
if( $this->is_active() ) {
|
||||
|
||||
$this->html_single();
|
||||
|
||||
// archive
|
||||
} else {
|
||||
|
||||
$this->html_archive();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html_field_selection
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 24/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html_field_selection() {
|
||||
|
||||
// vars
|
||||
$choices = array();
|
||||
$selected = $this->get_selected_keys();
|
||||
$field_groups = acf_get_field_groups();
|
||||
|
||||
|
||||
// loop
|
||||
if( $field_groups ) {
|
||||
foreach( $field_groups as $field_group ) {
|
||||
$choices[ $field_group['key'] ] = esc_html( $field_group['title'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// render
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Select Field Groups', 'acf'),
|
||||
'type' => 'checkbox',
|
||||
'name' => 'keys',
|
||||
'prefix' => false,
|
||||
'value' => $selected,
|
||||
'toggle' => true,
|
||||
'choices' => $choices,
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html_panel_selection
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 21/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html_panel_selection() {
|
||||
|
||||
?>
|
||||
<div class="acf-panel acf-panel-selection">
|
||||
<h3 class="acf-panel-title"><?php _e('Select Field Groups', 'acf') ?> <i class="dashicons dashicons-arrow-right"></i></h3>
|
||||
<div class="acf-panel-inside">
|
||||
<?php $this->html_field_selection(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html_panel_settings
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 21/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html_panel_settings() {
|
||||
|
||||
?>
|
||||
<div class="acf-panel acf-panel-settings">
|
||||
<h3 class="acf-panel-title"><?php _e('Settings', 'acf') ?> <i class="dashicons dashicons-arrow-right"></i></h3>
|
||||
<div class="acf-panel-inside">
|
||||
<?php
|
||||
|
||||
/*
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Empty settings', 'acf'),
|
||||
'type' => 'select',
|
||||
'name' => 'minimal',
|
||||
'prefix' => false,
|
||||
'value' => '',
|
||||
'choices' => array(
|
||||
'all' => __('Include all settings', 'acf'),
|
||||
'minimal' => __('Ignore empty settings', 'acf'),
|
||||
)
|
||||
));
|
||||
*/
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html_archive
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 20/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html_archive() {
|
||||
|
||||
?>
|
||||
<p><?php _e('Select the field groups you would like to export and then select your export method. Use the download button to export to a .json file which you can then import to another ACF installation. Use the generate button to export to PHP code which you can place in your theme.', 'acf'); ?></p>
|
||||
<div class="acf-fields">
|
||||
<?php $this->html_field_selection(); ?>
|
||||
</div>
|
||||
<p class="acf-submit">
|
||||
<button type="submit" name="action" class="button button-primary" value="download"><?php _e('Export File', 'acf'); ?></button>
|
||||
<button type="submit" name="action" class="button" value="generate"><?php _e('Generate PHP', 'acf'); ?></button>
|
||||
</p>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html_single
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 20/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html_single() {
|
||||
|
||||
?>
|
||||
<div class="acf-postbox-columns">
|
||||
<div class="acf-postbox-main">
|
||||
<?php $this->html_generate(); ?>
|
||||
</div>
|
||||
<div class="acf-postbox-side">
|
||||
<?php $this->html_panel_selection(); ?>
|
||||
<p class="acf-submit">
|
||||
<button type="submit" name="action" class="button button-primary" value="generate"><?php _e('Generate PHP', 'acf'); ?></button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html_generate
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 17/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html_generate() {
|
||||
|
||||
// prevent default translation and fake __() within string
|
||||
acf_update_setting('l10n_var_export', true);
|
||||
|
||||
|
||||
// vars
|
||||
$json = $this->get_selected();
|
||||
$str_replace = array(
|
||||
" " => "\t",
|
||||
"'!!__(!!\'" => "__('",
|
||||
"!!\', !!\'" => "', '",
|
||||
"!!\')!!'" => "')",
|
||||
"array (" => "array("
|
||||
);
|
||||
$preg_replace = array(
|
||||
'/([\t\r\n]+?)array/' => 'array',
|
||||
'/[0-9]+ => array/' => 'array'
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
<p><?php _e("The following code can be used to register a local version of the selected field group(s). A local field group can provide many benefits such as faster load times, version control & dynamic fields/settings. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
||||
<textarea id="acf-export-textarea" readonly="true"><?php
|
||||
|
||||
echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n";
|
||||
|
||||
foreach( $json as $field_group ) {
|
||||
|
||||
// code
|
||||
$code = var_export($field_group, true);
|
||||
|
||||
|
||||
// change double spaces to tabs
|
||||
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
||||
|
||||
|
||||
// correctly formats "=> array("
|
||||
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
||||
|
||||
|
||||
// esc_textarea
|
||||
$code = esc_textarea( $code );
|
||||
|
||||
|
||||
// echo
|
||||
echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n";
|
||||
|
||||
}
|
||||
|
||||
echo "endif;";
|
||||
|
||||
?></textarea>
|
||||
<p class="acf-submit">
|
||||
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
||||
</p>
|
||||
<script type="text/javascript">
|
||||
(function($){
|
||||
|
||||
// vars
|
||||
var $a = $('#acf-export-copy');
|
||||
var $textarea = $('#acf-export-textarea');
|
||||
|
||||
|
||||
// remove $a if 'copy' is not supported
|
||||
if( !document.queryCommandSupported('copy') ) {
|
||||
return $a.remove();
|
||||
}
|
||||
|
||||
|
||||
// event
|
||||
$a.on('click', function( e ){
|
||||
|
||||
// prevent default
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
// select
|
||||
$textarea.get(0).select();
|
||||
|
||||
|
||||
// try
|
||||
try {
|
||||
|
||||
// copy
|
||||
var copy = document.execCommand('copy');
|
||||
if( !copy ) return;
|
||||
|
||||
|
||||
// tooltip
|
||||
acf.newTooltip({
|
||||
text: "<?php _e('Copied', 'acf' ); ?>",
|
||||
timeout: 250,
|
||||
target: $(this),
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
|
||||
// do nothing
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* get_selected_keys
|
||||
*
|
||||
* This function will return an array of field group keys that have been selected
|
||||
*
|
||||
* @date 20/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function get_selected_keys() {
|
||||
|
||||
// check $_POST
|
||||
if( $keys = acf_maybe_get_POST('keys') ) {
|
||||
return (array) $keys;
|
||||
}
|
||||
|
||||
|
||||
// check $_GET
|
||||
if( $keys = acf_maybe_get_GET('keys') ) {
|
||||
$keys = str_replace(' ', '+', $keys);
|
||||
return explode('+', $keys);
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get_selected
|
||||
*
|
||||
* This function will return the JSON data for given $_POST args
|
||||
*
|
||||
* @date 17/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return array
|
||||
*/
|
||||
|
||||
function get_selected() {
|
||||
|
||||
// vars
|
||||
$selected = $this->get_selected_keys();
|
||||
$json = array();
|
||||
|
||||
|
||||
// bail early if no keys
|
||||
if( !$selected ) return false;
|
||||
|
||||
|
||||
// construct JSON
|
||||
foreach( $selected as $key ) {
|
||||
|
||||
// load field group
|
||||
$field_group = acf_get_field_group( $key );
|
||||
|
||||
|
||||
// validate field group
|
||||
if( empty($field_group) ) continue;
|
||||
|
||||
|
||||
// load fields
|
||||
$field_group['fields'] = acf_get_fields( $field_group );
|
||||
|
||||
|
||||
// prepare for export
|
||||
$field_group = acf_prepare_field_group_for_export( $field_group );
|
||||
|
||||
|
||||
// add to json array
|
||||
$json[] = $field_group;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $json;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// initialize
|
||||
acf_register_admin_tool( 'ACF_Admin_Tool_Export' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('ACF_Admin_Tool_Import') ) :
|
||||
|
||||
class ACF_Admin_Tool_Import extends ACF_Admin_Tool {
|
||||
|
||||
|
||||
/**
|
||||
* initialize
|
||||
*
|
||||
* This function will initialize the admin tool
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'import';
|
||||
$this->title = __("Import Field Groups", 'acf');
|
||||
$this->icon = 'dashicons-upload';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html
|
||||
*
|
||||
* This function will output the metabox HTML
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
?>
|
||||
<p><?php _e('Select the Advanced Custom Fields JSON file you would like to import. When you click the import button below, ACF will import the field groups.', 'acf'); ?></p>
|
||||
<div class="acf-fields">
|
||||
<?php
|
||||
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Select File', 'acf'),
|
||||
'type' => 'file',
|
||||
'name' => 'acf_import_file',
|
||||
'value' => false,
|
||||
'uploader' => 'basic',
|
||||
));
|
||||
|
||||
?>
|
||||
</div>
|
||||
<p class="acf-submit">
|
||||
<input type="submit" class="button button-primary" value="<?php _e('Import File', 'acf'); ?>" />
|
||||
</p>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* submit
|
||||
*
|
||||
* This function will run when the tool's form has been submit
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function submit() {
|
||||
|
||||
// Check file size.
|
||||
if( empty($_FILES['acf_import_file']['size']) ) {
|
||||
return acf_add_admin_notice( __("No file selected", 'acf'), 'warning' );
|
||||
}
|
||||
|
||||
// Get file data.
|
||||
$file = $_FILES['acf_import_file'];
|
||||
|
||||
// Check errors.
|
||||
if( $file['error'] ) {
|
||||
return acf_add_admin_notice( __("Error uploading file. Please try again", 'acf'), 'warning' );
|
||||
}
|
||||
|
||||
// Check file type.
|
||||
if( pathinfo($file['name'], PATHINFO_EXTENSION) !== 'json' ) {
|
||||
return acf_add_admin_notice( __("Incorrect file type", 'acf'), 'warning' );
|
||||
}
|
||||
|
||||
// Read JSON.
|
||||
$json = file_get_contents( $file['tmp_name'] );
|
||||
$json = json_decode($json, true);
|
||||
|
||||
// Check if empty.
|
||||
if( !$json || !is_array($json) ) {
|
||||
return acf_add_admin_notice( __("Import file empty", 'acf'), 'warning' );
|
||||
}
|
||||
|
||||
// Ensure $json is an array of groups.
|
||||
if( isset($json['key']) ) {
|
||||
$json = array( $json );
|
||||
}
|
||||
|
||||
// Remeber imported field group ids.
|
||||
$ids = array();
|
||||
|
||||
// Loop over json
|
||||
foreach( $json as $field_group ) {
|
||||
|
||||
// Search database for existing field group.
|
||||
$post = acf_get_field_group_post( $field_group['key'] );
|
||||
if( $post ) {
|
||||
$field_group['ID'] = $post->ID;
|
||||
}
|
||||
|
||||
// Import field group.
|
||||
$field_group = acf_import_field_group( $field_group );
|
||||
|
||||
// append message
|
||||
$ids[] = $field_group['ID'];
|
||||
}
|
||||
|
||||
// Count number of imported field groups.
|
||||
$total = count($ids);
|
||||
|
||||
// Generate text.
|
||||
$text = sprintf( _n( 'Imported 1 field group', 'Imported %s field groups', $total, 'acf' ), $total );
|
||||
|
||||
// Add links to text.
|
||||
$links = array();
|
||||
foreach( $ids as $id ) {
|
||||
$links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>';
|
||||
}
|
||||
$text .= ' ' . implode( ', ', $links );
|
||||
|
||||
// Add notice
|
||||
acf_add_admin_notice( $text, 'success' );
|
||||
}
|
||||
}
|
||||
|
||||
// initialize
|
||||
acf_register_admin_tool( 'ACF_Admin_Tool_Import' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('ACF_Admin_Tool') ) :
|
||||
|
||||
class ACF_Admin_Tool {
|
||||
|
||||
|
||||
/** @var string Tool name */
|
||||
var $name = '';
|
||||
|
||||
|
||||
/** @var string Tool title */
|
||||
var $title = '';
|
||||
|
||||
|
||||
/** @var string Dashicon slug */
|
||||
//var $icon = '';
|
||||
|
||||
|
||||
/** @var boolean Redirect form to single */
|
||||
//var $redirect = false;
|
||||
|
||||
|
||||
/**
|
||||
* get_name
|
||||
*
|
||||
* This function will return the Tool's name
|
||||
*
|
||||
* @date 19/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function get_name() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get_title
|
||||
*
|
||||
* This function will return the Tool's title
|
||||
*
|
||||
* @date 19/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function get_title() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get_url
|
||||
*
|
||||
* This function will return the Tool's title
|
||||
*
|
||||
* @date 19/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function get_url() {
|
||||
return acf_get_admin_tool_url( $this->name );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* is_active
|
||||
*
|
||||
* This function will return true if the tool is active
|
||||
*
|
||||
* @date 19/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
function is_active() {
|
||||
return acf_maybe_get_GET('tool') === $this->name;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the class functionality
|
||||
*
|
||||
* @type function
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// initialize
|
||||
$this->initialize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initialize
|
||||
*
|
||||
* This function will initialize the admin tool
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
/* do nothing */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* load
|
||||
*
|
||||
* This function is called during the admin page load
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function load() {
|
||||
|
||||
/* do nothing */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* html
|
||||
*
|
||||
* This function will output the metabox HTML
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* submit
|
||||
*
|
||||
* This function will run when the tool's form has been submit
|
||||
*
|
||||
* @date 10/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function submit() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
// vars
|
||||
$disabled = false;
|
||||
|
||||
|
||||
// empty
|
||||
if( empty($field['conditional_logic']) ) {
|
||||
|
||||
$disabled = true;
|
||||
$field['conditional_logic'] = array(
|
||||
|
||||
// group 0
|
||||
array(
|
||||
|
||||
// rule 0
|
||||
array()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
<tr class="acf-field acf-field-true-false acf-field-setting-conditional_logic" data-type="true_false" data-name="conditional_logic">
|
||||
<td class="acf-label">
|
||||
<label><?php _e("Conditional Logic",'acf'); ?></label>
|
||||
</td>
|
||||
<td class="acf-input">
|
||||
<?php
|
||||
|
||||
acf_render_field(array(
|
||||
'type' => 'true_false',
|
||||
'name' => 'conditional_logic',
|
||||
'prefix' => $field['prefix'],
|
||||
'value' => $disabled ? 0 : 1,
|
||||
'ui' => 1,
|
||||
'class' => 'conditions-toggle',
|
||||
));
|
||||
|
||||
?>
|
||||
<div class="rule-groups" <?php if($disabled): ?>style="display:none;"<?php endif; ?>>
|
||||
|
||||
<?php foreach( $field['conditional_logic'] as $group_id => $group ):
|
||||
|
||||
// validate
|
||||
if( empty($group) ) continue;
|
||||
|
||||
|
||||
// vars
|
||||
// $group_id must be completely different to $rule_id to avoid JS issues
|
||||
$group_id = "group_{$group_id}";
|
||||
$h4 = ($group_id == "group_0") ? __("Show this field if",'acf') : __("or",'acf');
|
||||
|
||||
?>
|
||||
<div class="rule-group" data-id="<?php echo $group_id; ?>">
|
||||
|
||||
<h4><?php echo $h4; ?></h4>
|
||||
|
||||
<table class="acf-table -clear">
|
||||
<tbody>
|
||||
<?php foreach( $group as $rule_id => $rule ):
|
||||
|
||||
// valid rule
|
||||
$rule = wp_parse_args( $rule, array(
|
||||
'field' => '',
|
||||
'operator' => '',
|
||||
'value' => '',
|
||||
));
|
||||
|
||||
|
||||
// vars
|
||||
// $group_id must be completely different to $rule_id to avoid JS issues
|
||||
$rule_id = "rule_{$rule_id}";
|
||||
$prefix = "{$field['prefix']}[conditional_logic][{$group_id}][{$rule_id}]";
|
||||
|
||||
// data attributes
|
||||
$attributes = array(
|
||||
'data-id' => $rule_id,
|
||||
'data-field' => $rule['field'],
|
||||
'data-operator' => $rule['operator'],
|
||||
'data-value' => $rule['value']
|
||||
);
|
||||
|
||||
?>
|
||||
<tr class="rule" <?php acf_esc_attr_e($attributes); ?>>
|
||||
<td class="param">
|
||||
<?php
|
||||
|
||||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'prefix' => $prefix,
|
||||
'name' => 'field',
|
||||
'class' => 'condition-rule-field',
|
||||
'disabled' => $disabled,
|
||||
'value' => $rule['field'],
|
||||
'choices' => array(
|
||||
$rule['field'] => $rule['field']
|
||||
)
|
||||
));
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td class="operator">
|
||||
<?php
|
||||
|
||||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'prefix' => $prefix,
|
||||
'name' => 'operator',
|
||||
'class' => 'condition-rule-operator',
|
||||
'disabled' => $disabled,
|
||||
'value' => $rule['operator'],
|
||||
'choices' => array(
|
||||
$rule['operator'] => $rule['operator']
|
||||
)
|
||||
));
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td class="value">
|
||||
<?php
|
||||
|
||||
// create field
|
||||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'prefix' => $prefix,
|
||||
'name' => 'value',
|
||||
'class' => 'condition-rule-value',
|
||||
'disabled' => $disabled,
|
||||
'value' => $rule['value'],
|
||||
'choices' => array(
|
||||
$rule['value'] => $rule['value']
|
||||
)
|
||||
));
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td class="add">
|
||||
<a href="#" class="button add-conditional-rule"><?php _e("and",'acf'); ?></a>
|
||||
</td>
|
||||
<td class="remove">
|
||||
<a href="#" class="acf-icon -minus remove-conditional-rule"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<h4><?php _e("or",'acf'); ?></h4>
|
||||
|
||||
<a href="#" class="button add-conditional-group"><?php _e("Add rule group",'acf'); ?></a>
|
||||
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
// vars
|
||||
$prefix = 'acf_fields[' . $field['ID'] . ']';
|
||||
$id = acf_idify( $prefix );
|
||||
|
||||
// add prefix
|
||||
$field['prefix'] = $prefix;
|
||||
|
||||
// div
|
||||
$div = array(
|
||||
'class' => 'acf-field-object acf-field-object-' . acf_slugify($field['type']),
|
||||
'data-id' => $field['ID'],
|
||||
'data-key' => $field['key'],
|
||||
'data-type' => $field['type'],
|
||||
);
|
||||
|
||||
$meta = array(
|
||||
'ID' => $field['ID'],
|
||||
'key' => $field['key'],
|
||||
'parent' => $field['parent'],
|
||||
'menu_order' => $i,
|
||||
'save' => ''
|
||||
);
|
||||
|
||||
?>
|
||||
<div <?php echo acf_esc_attr( $div ); ?>>
|
||||
|
||||
<div class="meta">
|
||||
<?php foreach( $meta as $k => $v ):
|
||||
acf_hidden_input(array( 'name' => $prefix . '[' . $k . ']', 'value' => $v, 'id' => $id . '-' . $k ));
|
||||
endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="handle">
|
||||
<ul class="acf-hl acf-tbody">
|
||||
<li class="li-field-order">
|
||||
<span class="acf-icon acf-sortable-handle" title="<?php _e('Drag to reorder','acf'); ?>"><?php echo ($i + 1); ?></span>
|
||||
</li>
|
||||
<li class="li-field-label">
|
||||
<strong>
|
||||
<a class="edit-field" title="<?php _e("Edit field",'acf'); ?>" href="#"><?php echo acf_get_field_label($field, 'admin'); ?></a>
|
||||
</strong>
|
||||
<div class="row-options">
|
||||
<a class="edit-field" title="<?php _e("Edit field",'acf'); ?>" href="#"><?php _e("Edit",'acf'); ?></a>
|
||||
<a class="duplicate-field" title="<?php _e("Duplicate field",'acf'); ?>" href="#"><?php _e("Duplicate",'acf'); ?></a>
|
||||
<a class="move-field" title="<?php _e("Move field to another group",'acf'); ?>" href="#"><?php _e("Move",'acf'); ?></a>
|
||||
<a class="delete-field" title="<?php _e("Delete field",'acf'); ?>" href="#"><?php _e("Delete",'acf'); ?></a>
|
||||
</div>
|
||||
</li>
|
||||
<?php // whitespace before field name looks odd but fixes chrome bug selecting all text in row ?>
|
||||
<li class="li-field-name"> <?php echo $field['name']; ?></li>
|
||||
<li class="li-field-key"> <?php echo $field['key']; ?></li>
|
||||
<li class="li-field-type"> <?php echo acf_get_field_type_label($field['type']); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="settings">
|
||||
<table class="acf-table">
|
||||
<tbody class="acf-field-settings">
|
||||
<?php
|
||||
|
||||
// label
|
||||
acf_render_field_setting($field, array(
|
||||
'label' => __('Field Label','acf'),
|
||||
'instructions' => __('This is the name which will appear on the EDIT page','acf'),
|
||||
'name' => 'label',
|
||||
'type' => 'text',
|
||||
'class' => 'field-label'
|
||||
), true);
|
||||
|
||||
|
||||
// name
|
||||
acf_render_field_setting($field, array(
|
||||
'label' => __('Field Name','acf'),
|
||||
'instructions' => __('Single word, no spaces. Underscores and dashes allowed','acf'),
|
||||
'name' => 'name',
|
||||
'type' => 'text',
|
||||
'class' => 'field-name'
|
||||
), true);
|
||||
|
||||
|
||||
// type
|
||||
acf_render_field_setting($field, array(
|
||||
'label' => __('Field Type','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'select',
|
||||
'name' => 'type',
|
||||
'choices' => acf_get_grouped_field_types(),
|
||||
'class' => 'field-type'
|
||||
), true);
|
||||
|
||||
|
||||
// instructions
|
||||
acf_render_field_setting($field, array(
|
||||
'label' => __('Instructions','acf'),
|
||||
'instructions' => __('Instructions for authors. Shown when submitting data','acf'),
|
||||
'type' => 'textarea',
|
||||
'name' => 'instructions',
|
||||
'rows' => 5
|
||||
), true);
|
||||
|
||||
|
||||
// required
|
||||
acf_render_field_setting($field, array(
|
||||
'label' => __('Required?','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'true_false',
|
||||
'name' => 'required',
|
||||
'ui' => 1,
|
||||
'class' => 'field-required'
|
||||
), true);
|
||||
|
||||
|
||||
// 3rd party settings
|
||||
do_action('acf/render_field_settings', $field);
|
||||
|
||||
|
||||
// type specific settings
|
||||
do_action("acf/render_field_settings/type={$field['type']}", $field);
|
||||
|
||||
|
||||
// conditional logic
|
||||
acf_get_view('field-group-field-conditional-logic', array( 'field' => $field ));
|
||||
|
||||
|
||||
// wrapper
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Wrapper Attributes','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'number',
|
||||
'name' => 'width',
|
||||
'prefix' => $field['prefix'] . '[wrapper]',
|
||||
'value' => $field['wrapper']['width'],
|
||||
'prepend' => __('width', 'acf'),
|
||||
'append' => '%',
|
||||
'wrapper' => array(
|
||||
'data-name' => 'wrapper',
|
||||
'class' => 'acf-field-setting-wrapper'
|
||||
)
|
||||
), 'tr');
|
||||
|
||||
acf_render_field_wrap(array(
|
||||
'label' => '',
|
||||
'instructions' => '',
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'prefix' => $field['prefix'] . '[wrapper]',
|
||||
'value' => $field['wrapper']['class'],
|
||||
'prepend' => __('class', 'acf'),
|
||||
'wrapper' => array(
|
||||
'data-append' => 'wrapper'
|
||||
)
|
||||
), 'tr');
|
||||
|
||||
acf_render_field_wrap(array(
|
||||
'label' => '',
|
||||
'instructions' => '',
|
||||
'type' => 'text',
|
||||
'name' => 'id',
|
||||
'prefix' => $field['prefix'] . '[wrapper]',
|
||||
'value' => $field['wrapper']['id'],
|
||||
'prepend' => __('id', 'acf'),
|
||||
'wrapper' => array(
|
||||
'data-append' => 'wrapper'
|
||||
)
|
||||
), 'tr');
|
||||
|
||||
?>
|
||||
<tr class="acf-field acf-field-save">
|
||||
<td class="acf-label"></td>
|
||||
<td class="acf-input">
|
||||
<ul class="acf-hl">
|
||||
<li>
|
||||
<a class="button edit-field" title="<?php _e("Close Field",'acf'); ?>" href="#"><?php _e("Close Field",'acf'); ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,52 @@
|
||||
<div class="acf-field-list-wrap">
|
||||
|
||||
<ul class="acf-hl acf-thead">
|
||||
<li class="li-field-order"><?php _e('Order','acf'); ?></li>
|
||||
<li class="li-field-label"><?php _e('Label','acf'); ?></li>
|
||||
<li class="li-field-name"><?php _e('Name','acf'); ?></li>
|
||||
<li class="li-field-key"><?php _e('Key','acf'); ?></li>
|
||||
<li class="li-field-type"><?php _e('Type','acf'); ?></li>
|
||||
</ul>
|
||||
|
||||
<div class="acf-field-list<?php if( !$fields ){ echo ' -empty'; } ?>">
|
||||
|
||||
<div class="no-fields-message">
|
||||
<?php _e("No fields. Click the <strong>+ Add Field</strong> button to create your first field.",'acf'); ?>
|
||||
</div>
|
||||
|
||||
<?php if( $fields ):
|
||||
|
||||
foreach( $fields as $i => $field ):
|
||||
|
||||
acf_get_view('field-group-field', array( 'field' => $field, 'i' => $i ));
|
||||
|
||||
endforeach;
|
||||
|
||||
endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<ul class="acf-hl acf-tfoot">
|
||||
<li class="acf-fr">
|
||||
<a href="#" class="button button-primary button-large add-field"><?php _e('+ Add Field','acf'); ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<?php if( !$parent ):
|
||||
|
||||
// get clone
|
||||
$clone = acf_get_valid_field(array(
|
||||
'ID' => 'acfcloneindex',
|
||||
'key' => 'acfcloneindex',
|
||||
'label' => __('New Field','acf'),
|
||||
'name' => 'new_field',
|
||||
'type' => 'text'
|
||||
));
|
||||
|
||||
?>
|
||||
<script type="text/html" id="tmpl-acf-field">
|
||||
<?php acf_get_view('field-group-field', array( 'field' => $clone, 'i' => 0 )); ?>
|
||||
</script>
|
||||
<?php endif;?>
|
||||
|
||||
</div>
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
// global
|
||||
global $field_group;
|
||||
|
||||
?>
|
||||
<div class="acf-field">
|
||||
<div class="acf-label">
|
||||
<label><?php _e("Rules",'acf'); ?></label>
|
||||
<p class="description"><?php _e("Create a set of rules to determine which edit screens will use these advanced custom fields",'acf'); ?></p>
|
||||
</div>
|
||||
<div class="acf-input">
|
||||
<div class="rule-groups">
|
||||
|
||||
<?php foreach( $field_group['location'] as $i => $group ):
|
||||
|
||||
// bail ealry if no group
|
||||
if( empty($group) ) return;
|
||||
|
||||
|
||||
// view
|
||||
acf_get_view('html-location-group', array(
|
||||
'group' => $group,
|
||||
'group_id' => "group_{$i}"
|
||||
));
|
||||
|
||||
endforeach; ?>
|
||||
|
||||
<h4><?php _e("or",'acf'); ?></h4>
|
||||
|
||||
<a href="#" class="button add-location-group"><?php _e("Add rule group",'acf'); ?></a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
if( typeof acf !== 'undefined' ) {
|
||||
|
||||
acf.newPostbox({
|
||||
'id': 'acf-field-group-locations',
|
||||
'label': 'left'
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
// global
|
||||
global $field_group;
|
||||
|
||||
|
||||
// active
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Active','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'true_false',
|
||||
'name' => 'active',
|
||||
'prefix' => 'acf_field_group',
|
||||
'value' => $field_group['active'],
|
||||
'ui' => 1,
|
||||
//'ui_on_text' => __('Active', 'acf'),
|
||||
//'ui_off_text' => __('Inactive', 'acf'),
|
||||
));
|
||||
|
||||
|
||||
// style
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Style','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'select',
|
||||
'name' => 'style',
|
||||
'prefix' => 'acf_field_group',
|
||||
'value' => $field_group['style'],
|
||||
'choices' => array(
|
||||
'default' => __("Standard (WP metabox)",'acf'),
|
||||
'seamless' => __("Seamless (no metabox)",'acf'),
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// position
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Position','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'select',
|
||||
'name' => 'position',
|
||||
'prefix' => 'acf_field_group',
|
||||
'value' => $field_group['position'],
|
||||
'choices' => array(
|
||||
'acf_after_title' => __("High (after title)",'acf'),
|
||||
'normal' => __("Normal (after content)",'acf'),
|
||||
'side' => __("Side",'acf'),
|
||||
),
|
||||
'default_value' => 'normal'
|
||||
));
|
||||
|
||||
|
||||
// label_placement
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Label placement','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'select',
|
||||
'name' => 'label_placement',
|
||||
'prefix' => 'acf_field_group',
|
||||
'value' => $field_group['label_placement'],
|
||||
'choices' => array(
|
||||
'top' => __("Top aligned",'acf'),
|
||||
'left' => __("Left aligned",'acf'),
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// instruction_placement
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Instruction placement','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'select',
|
||||
'name' => 'instruction_placement',
|
||||
'prefix' => 'acf_field_group',
|
||||
'value' => $field_group['instruction_placement'],
|
||||
'choices' => array(
|
||||
'label' => __("Below labels",'acf'),
|
||||
'field' => __("Below fields",'acf'),
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// menu_order
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Order No.','acf'),
|
||||
'instructions' => __('Field groups with a lower order will appear first','acf'),
|
||||
'type' => 'number',
|
||||
'name' => 'menu_order',
|
||||
'prefix' => 'acf_field_group',
|
||||
'value' => $field_group['menu_order'],
|
||||
));
|
||||
|
||||
|
||||
// description
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Description','acf'),
|
||||
'instructions' => __('Shown in field group list','acf'),
|
||||
'type' => 'text',
|
||||
'name' => 'description',
|
||||
'prefix' => 'acf_field_group',
|
||||
'value' => $field_group['description'],
|
||||
));
|
||||
|
||||
|
||||
// hide on screen
|
||||
$choices = array(
|
||||
'permalink' => __("Permalink", 'acf'),
|
||||
'the_content' => __("Content Editor",'acf'),
|
||||
'excerpt' => __("Excerpt", 'acf'),
|
||||
'custom_fields' => __("Custom Fields", 'acf'),
|
||||
'discussion' => __("Discussion", 'acf'),
|
||||
'comments' => __("Comments", 'acf'),
|
||||
'revisions' => __("Revisions", 'acf'),
|
||||
'slug' => __("Slug", 'acf'),
|
||||
'author' => __("Author", 'acf'),
|
||||
'format' => __("Format", 'acf'),
|
||||
'page_attributes' => __("Page Attributes", 'acf'),
|
||||
'featured_image' => __("Featured Image", 'acf'),
|
||||
'categories' => __("Categories", 'acf'),
|
||||
'tags' => __("Tags", 'acf'),
|
||||
'send-trackbacks' => __("Send Trackbacks", 'acf'),
|
||||
);
|
||||
if( acf_get_setting('remove_wp_meta_box') ) {
|
||||
unset( $choices['custom_fields'] );
|
||||
}
|
||||
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Hide on screen','acf'),
|
||||
'instructions' => __('<b>Select</b> items to <b>hide</b> them from the edit screen.','acf') . '<br /><br />' . __("If multiple field groups appear on an edit screen, the first field group's options will be used (the one with the lowest order number)",'acf'),
|
||||
'type' => 'checkbox',
|
||||
'name' => 'hide_on_screen',
|
||||
'prefix' => 'acf_field_group',
|
||||
'value' => $field_group['hide_on_screen'],
|
||||
'toggle' => true,
|
||||
'choices' => $choices
|
||||
));
|
||||
|
||||
|
||||
// 3rd party settings
|
||||
do_action('acf/render_field_group_settings', $field_group);
|
||||
|
||||
?>
|
||||
<div class="acf-hidden">
|
||||
<input type="hidden" name="acf_field_group[key]" value="<?php echo $field_group['key']; ?>" />
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
if( typeof acf !== 'undefined' ) {
|
||||
|
||||
acf.newPostbox({
|
||||
'id': 'acf-field-group-options',
|
||||
'label': 'left'
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Network Admin Database Upgrade
|
||||
*
|
||||
* Shows the databse upgrade process.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
* @param void
|
||||
*/
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
|
||||
/* hide steps */
|
||||
.show-on-complete {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
<h1><?php _e("Upgrade Database", 'acf'); ?></h1>
|
||||
|
||||
<p><?php echo sprintf( __("The following sites require a DB upgrade. Check the ones you want to update and then click %s.", 'acf'), '"' . __('Upgrade Sites', 'acf') . '"'); ?></p>
|
||||
<p><input type="submit" name="upgrade" value="<?php _e('Upgrade Sites', 'acf'); ?>" class="button" id="upgrade-sites"></p>
|
||||
|
||||
<table class="wp-list-table widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="manage-column check-column" scope="col">
|
||||
<input type="checkbox" id="sites-select-all">
|
||||
</td>
|
||||
<th class="manage-column" scope="col" style="width:33%;">
|
||||
<label for="sites-select-all"><?php _e("Site", 'acf'); ?></label>
|
||||
</th>
|
||||
<th><?php _e("Description", 'acf'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td class="manage-column check-column" scope="col">
|
||||
<input type="checkbox" id="sites-select-all-2">
|
||||
</td>
|
||||
<th class="manage-column" scope="col">
|
||||
<label for="sites-select-all-2"><?php _e("Site", 'acf'); ?></label>
|
||||
</th>
|
||||
<th><?php _e("Description", 'acf'); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody id="the-list">
|
||||
<?php
|
||||
|
||||
$sites = acf_get_sites();
|
||||
if( $sites ):
|
||||
foreach( $sites as $i => $site ):
|
||||
|
||||
// switch blog
|
||||
switch_to_blog( $site['blog_id'] );
|
||||
|
||||
?>
|
||||
<tr<?php if( $i % 2 == 0 ): ?> class="alternate"<?php endif; ?>>
|
||||
<th class="check-column" scope="row">
|
||||
<?php if( acf_has_upgrade() ): ?>
|
||||
<input type="checkbox" value="<?php echo $site['blog_id']; ?>" name="checked[]">
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td>
|
||||
<strong><?php echo get_bloginfo('name'); ?></strong><br /><?php echo home_url(); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if( acf_has_upgrade() ): ?>
|
||||
<span class="response"><?php printf(__('Site requires database upgrade from %s to %s', 'acf'), acf_get_db_version(), ACF_VERSION); ?></span>
|
||||
<?php else: ?>
|
||||
<?php _e("Site is up to date", 'acf'); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
// restore
|
||||
restore_current_blog();
|
||||
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><input type="submit" name="upgrade" value="<?php _e('Upgrade Sites', 'acf'); ?>" class="button" id="upgrade-sites-2"></p>
|
||||
<p class="show-on-complete"><?php echo sprintf( __('Database Upgrade complete. <a href="%s">Return to network dashboard</a>', 'acf'), network_admin_url() ); ?></p>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
var upgrader = new acf.Model({
|
||||
events: {
|
||||
'click #upgrade-sites': 'onClick',
|
||||
'click #upgrade-sites-2': 'onClick'
|
||||
},
|
||||
$inputs: function(){
|
||||
return $('#the-list input:checked');
|
||||
},
|
||||
onClick: function( e, $el ){
|
||||
|
||||
// prevent default
|
||||
e.preventDefault();
|
||||
|
||||
// bail early if no selection
|
||||
if( !this.$inputs().length ) {
|
||||
return alert('<?php _e('Please select at least one site to upgrade.', 'acf'); ?>');
|
||||
}
|
||||
|
||||
// confirm action
|
||||
if( !confirm("<?php _e('It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf'); ?>") ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// upgrade
|
||||
this.upgrade();
|
||||
},
|
||||
upgrade: function(){
|
||||
|
||||
// vars
|
||||
var $inputs = this.$inputs();
|
||||
|
||||
// bail early if no sites selected
|
||||
if( !$inputs.length ) {
|
||||
return this.complete();
|
||||
}
|
||||
|
||||
// disable buttons
|
||||
$('.button').prop('disabled', true);
|
||||
|
||||
// vars
|
||||
var $input = $inputs.first();
|
||||
var $row = $input.closest('tr');
|
||||
var text = '';
|
||||
var success = false;
|
||||
|
||||
// show loading
|
||||
$row.find('.response').html('<i class="acf-loading"></i></span> <?php printf(__('Upgrading data to version %s', 'acf'), ACF_VERSION); ?>');
|
||||
|
||||
// send ajax request to upgrade DB
|
||||
$.ajax({
|
||||
url: acf.get('ajaxurl'),
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
data: acf.prepareForAjax({
|
||||
action: 'acf/ajax/upgrade',
|
||||
blog_id: $input.val()
|
||||
}),
|
||||
success: function( json ){
|
||||
|
||||
// success
|
||||
if( acf.isAjaxSuccess(json) ) {
|
||||
|
||||
// update
|
||||
success = true;
|
||||
|
||||
// remove input
|
||||
$input.remove();
|
||||
|
||||
// set response text
|
||||
text = '<?php _e('Upgrade complete.', 'acf'); ?>';
|
||||
if( jsonText = acf.getAjaxMessage(json) ) {
|
||||
text = jsonText;
|
||||
}
|
||||
|
||||
// error
|
||||
} else {
|
||||
|
||||
// set response text
|
||||
text = '<?php _e('Upgrade failed.', 'acf'); ?>';
|
||||
if( jsonText = acf.getAjaxError(json) ) {
|
||||
text += ' <pre>' + jsonText + '</pre>';
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function( jqXHR, textStatus, errorThrown ){
|
||||
|
||||
// set response text
|
||||
text = '<?php _e('Upgrade failed.', 'acf'); ?>';
|
||||
if( errorThrown) {
|
||||
text += ' <pre>' + errorThrown + '</pre>';
|
||||
}
|
||||
},
|
||||
complete: this.proxy(function(){
|
||||
|
||||
// display text
|
||||
$row.find('.response').html( text );
|
||||
|
||||
// if successful upgrade, proceed to next site. Otherwise, skip to complete.
|
||||
if( success ) {
|
||||
this.upgrade();
|
||||
} else {
|
||||
this.complete();
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
complete: function(){
|
||||
|
||||
// enable buttons
|
||||
$('.button').prop('disabled', false);
|
||||
|
||||
// show message
|
||||
$('.show-on-complete').show();
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
</div>
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Admin Database Upgrade
|
||||
*
|
||||
* Shows the databse upgrade process.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
* @param void
|
||||
*/
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
|
||||
/* hide steps */
|
||||
.step-1,
|
||||
.step-2,
|
||||
.step-3 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
<h1><?php _e("Upgrade Database", 'acf'); ?></h1>
|
||||
|
||||
<?php if( acf_has_upgrade() ): ?>
|
||||
|
||||
<p><?php _e('Reading upgrade tasks...', 'acf'); ?></p>
|
||||
<p class="step-1"><i class="acf-loading"></i> <?php printf(__('Upgrading data to version %s', 'acf'), ACF_VERSION); ?></p>
|
||||
<p class="step-2"></p>
|
||||
<p class="step-3"><?php echo sprintf( __('Database upgrade complete. <a href="%s">See what\'s new</a>', 'acf' ), admin_url('edit.php?post_type=acf-field-group&page=acf-settings-info') ); ?></p>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
var upgrader = new acf.Model({
|
||||
initialize: function(){
|
||||
|
||||
// allow user to read message for 1 second
|
||||
this.setTimeout( this.upgrade, 1000 );
|
||||
},
|
||||
upgrade: function(){
|
||||
|
||||
// show step 1
|
||||
$('.step-1').show();
|
||||
|
||||
// vars
|
||||
var response = '';
|
||||
var success = false;
|
||||
|
||||
// send ajax request to upgrade DB
|
||||
$.ajax({
|
||||
url: acf.get('ajaxurl'),
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
data: acf.prepareForAjax({
|
||||
action: 'acf/ajax/upgrade'
|
||||
}),
|
||||
success: function( json ){
|
||||
|
||||
// success
|
||||
if( acf.isAjaxSuccess(json) ) {
|
||||
|
||||
// update
|
||||
success = true;
|
||||
|
||||
// set response text
|
||||
if( jsonText = acf.getAjaxMessage(json) ) {
|
||||
response = jsonText;
|
||||
}
|
||||
|
||||
// error
|
||||
} else {
|
||||
|
||||
// set response text
|
||||
response = '<?php _e('Upgrade failed.', 'acf'); ?>';
|
||||
if( jsonText = acf.getAjaxError(json) ) {
|
||||
response += ' <pre>' + jsonText + '</pre>';
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function( jqXHR, textStatus, errorThrown ){
|
||||
|
||||
// set response text
|
||||
response = '<?php _e('Upgrade failed.', 'acf'); ?>';
|
||||
if( errorThrown) {
|
||||
response += ' <pre>' + errorThrown + '</pre>';
|
||||
}
|
||||
},
|
||||
complete: this.proxy(function(){
|
||||
|
||||
// remove spinner
|
||||
$('.acf-loading').hide();
|
||||
|
||||
// display response
|
||||
if( response ) {
|
||||
$('.step-2').show().html( response );
|
||||
}
|
||||
|
||||
// display success
|
||||
if( success ) {
|
||||
$('.step-3').show();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<p><?php _e('No updates available.', 'acf'); ?></p>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* html-admin-tools
|
||||
*
|
||||
* View to output admin tools for both archive and single
|
||||
*
|
||||
* @date 20/10/17
|
||||
* @since 5.6.3
|
||||
*
|
||||
* @param string $screen_id The screen ID used to display metaboxes
|
||||
* @param string $active The active Tool
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
$class = $active ? 'single' : 'grid';
|
||||
|
||||
?>
|
||||
<div class="wrap" id="acf-admin-tools">
|
||||
|
||||
<h1><?php _e('Tools', 'acf'); ?> <?php if( $active ): ?><a class="page-title-action" href="<?php echo acf_get_admin_tools_url(); ?>"><?php _e('Back to all tools', 'acf'); ?></a><?php endif; ?></h1>
|
||||
|
||||
<div class="acf-meta-box-wrap -<?php echo $class; ?>">
|
||||
<?php do_meta_boxes( $screen_id, 'normal', '' ); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<div class="rule-group" data-id="<?php echo $group_id; ?>">
|
||||
|
||||
<h4><?php echo ($group_id == 'group_0') ? __("Show this field group if",'acf') : __("or",'acf'); ?></h4>
|
||||
|
||||
<table class="acf-table -clear">
|
||||
<tbody>
|
||||
<?php foreach( $group as $i => $rule ):
|
||||
|
||||
// validate rule
|
||||
$rule = acf_validate_location_rule($rule);
|
||||
|
||||
// append id and group
|
||||
$rule['id'] = "rule_{$i}";
|
||||
$rule['group'] = $group_id;
|
||||
|
||||
// view
|
||||
acf_get_view('html-location-rule', array(
|
||||
'rule' => $rule
|
||||
));
|
||||
|
||||
endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
// vars
|
||||
$prefix = 'acf_field_group[location]['.$rule['group'].']['.$rule['id'].']';
|
||||
|
||||
?>
|
||||
<tr data-id="<?php echo $rule['id']; ?>">
|
||||
<td class="param">
|
||||
<?php
|
||||
|
||||
// vars
|
||||
$choices = acf_get_location_rule_types();
|
||||
|
||||
|
||||
// array
|
||||
if( is_array($choices) ) {
|
||||
|
||||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'name' => 'param',
|
||||
'prefix' => $prefix,
|
||||
'value' => $rule['param'],
|
||||
'choices' => $choices,
|
||||
'class' => 'refresh-location-rule'
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td class="operator">
|
||||
<?php
|
||||
|
||||
// vars
|
||||
$choices = acf_get_location_rule_operators( $rule );
|
||||
|
||||
|
||||
// array
|
||||
if( is_array($choices) ) {
|
||||
|
||||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'name' => 'operator',
|
||||
'prefix' => $prefix,
|
||||
'value' => $rule['operator'],
|
||||
'choices' => $choices
|
||||
));
|
||||
|
||||
// custom
|
||||
} else {
|
||||
|
||||
echo $choices;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td class="value">
|
||||
<?php
|
||||
|
||||
// vars
|
||||
$choices = acf_get_location_rule_values( $rule );
|
||||
|
||||
|
||||
// array
|
||||
if( is_array($choices) ) {
|
||||
|
||||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'name' => 'value',
|
||||
'prefix' => $prefix,
|
||||
'value' => $rule['value'],
|
||||
'choices' => $choices
|
||||
));
|
||||
|
||||
// custom
|
||||
} else {
|
||||
|
||||
echo $choices;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
<td class="add">
|
||||
<a href="#" class="button add-location-rule"><?php _e("and",'acf'); ?></a>
|
||||
</td>
|
||||
<td class="remove">
|
||||
<a href="#" class="acf-icon -minus remove-location-rule"></a>
|
||||
</td>
|
||||
</tr>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
// calculate add-ons (non pro only)
|
||||
$plugins = array();
|
||||
|
||||
if( !acf_get_setting('pro') ) {
|
||||
|
||||
if( is_plugin_active('acf-repeater/acf-repeater.php') ) $plugins[] = __("Repeater",'acf');
|
||||
if( is_plugin_active('acf-flexible-content/acf-flexible-content.php') ) $plugins[] = __("Flexible Content",'acf');
|
||||
if( is_plugin_active('acf-gallery/acf-gallery.php') ) $plugins[] = __("Gallery",'acf');
|
||||
if( is_plugin_active('acf-options-page/acf-options-page.php') ) $plugins[] = __("Options Page",'acf');
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="acf-upgrade-notice" class="notice">
|
||||
|
||||
<div class="col-content">
|
||||
|
||||
<img src="<?php echo acf_get_url('assets/images/acf-logo.png'); ?>" />
|
||||
<h2><?php _e("Database Upgrade Required",'acf'); ?></h2>
|
||||
<p><?php printf(__("Thank you for updating to %s v%s!", 'acf'), acf_get_setting('name'), acf_get_setting('version') ); ?><br /><?php _e("This version contains improvements to your database and requires an upgrade.", 'acf'); ?></p>
|
||||
<?php if( !empty($plugins) ): ?>
|
||||
<p><?php printf(__("Please also check all premium add-ons (%s) are updated to the latest version.", 'acf'), implode(', ', $plugins) ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="col-actions">
|
||||
<a id="acf-upgrade-button" href="<?php echo $button_url; ?>" class="button button-primary button-hero"><?php echo $button_text; ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php if( $confirm ): ?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
$("#acf-upgrade-button").on("click", function(){
|
||||
return confirm("<?php _e( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf' ); ?>");
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,54 @@
|
||||
<div class="wrap acf-settings-wrap">
|
||||
|
||||
<h1><?php _e("Add-ons",'acf'); ?></h1>
|
||||
|
||||
<div class="add-ons-list">
|
||||
|
||||
<?php if( !empty($json) ): ?>
|
||||
|
||||
<?php foreach( $json as $addon ):
|
||||
|
||||
$addon = wp_parse_args($addon, array(
|
||||
"title" => "",
|
||||
"slug" => "",
|
||||
"description" => "",
|
||||
"thumbnail" => "",
|
||||
"url" => "",
|
||||
"btn" => __("Download & Install",'acf'),
|
||||
"btn_color" => ""
|
||||
));
|
||||
|
||||
?>
|
||||
|
||||
<div class="acf-box add-on add-on-<?php echo $addon['slug']; ?>">
|
||||
|
||||
<div class="thumbnail">
|
||||
<a target="_blank" href="<?php echo $addon['url']; ?>">
|
||||
<img src="<?php echo $addon['thumbnail']; ?>" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="inner">
|
||||
<h3><a target="_blank" href="<?php echo $addon['url']; ?>"><?php echo $addon['title']; ?></a></h3>
|
||||
<p><?php echo $addon['description']; ?></p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<?php if( apply_filters("acf/is_add_on_active/slug={$addon['slug']}", false ) ): ?>
|
||||
<a class="button" disabled="disabled"><?php _e("Installed",'acf'); ?></a>
|
||||
<?php else: ?>
|
||||
<a class="button <?php echo $addon['btn_color']; ?>" target="_blank" href="<?php echo $addon['url']; ?>" ><?php _e($addon['btn']); ?></a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if( !empty($addon['footer']) ): ?>
|
||||
<p><?php echo $addon['footer']; ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,157 @@
|
||||
<div class="wrap about-wrap acf-wrap">
|
||||
|
||||
<h1><?php _e("Welcome to Advanced Custom Fields",'acf'); ?> <?php echo $version; ?></h1>
|
||||
<div class="about-text"><?php printf(__("Thank you for updating! ACF %s is bigger and better than ever before. We hope you like it.", 'acf'), $version); ?></div>
|
||||
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<?php foreach( $tabs as $tab_slug => $tab_title ): ?>
|
||||
<a class="nav-tab<?php if( $active == $tab_slug ): ?> nav-tab-active<?php endif; ?>" href="<?php echo admin_url("edit.php?post_type=acf-field-group&page=acf-settings-info&tab={$tab_slug}"); ?>"><?php echo $tab_title; ?></a>
|
||||
<?php endforeach; ?>
|
||||
</h2>
|
||||
|
||||
<?php if( $active == 'new' ): ?>
|
||||
|
||||
<div class="feature-section">
|
||||
<h2><?php _e("A Smoother Experience", 'acf'); ?> </h2>
|
||||
<div class="acf-three-col">
|
||||
<div>
|
||||
<h3><?php _e("Improved Usability", 'acf'); ?></h3>
|
||||
<p><?php _e("Including the popular Select2 library has improved both usability and speed across a number of field types including post object, page link, taxonomy and select.", 'acf'); ?></p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><?php _e("Improved Design", 'acf'); ?></h3>
|
||||
<p><?php _e("Many fields have undergone a visual refresh to make ACF look better than ever! Noticeable changes are seen on the gallery, relationship and oEmbed (new) fields!", 'acf'); ?></p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><?php _e("Improved Data", 'acf'); ?></h3>
|
||||
<p><?php _e("Redesigning the data architecture has allowed sub fields to live independently from their parents. This allows you to drag and drop fields in and out of parent fields!", 'acf'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="feature-section">
|
||||
<h2><?php _e("Goodbye Add-ons. Hello PRO", 'acf'); ?> 👋</h2>
|
||||
<div class="acf-three-col">
|
||||
<div>
|
||||
<h3><?php _e("Introducing ACF PRO", 'acf'); ?></h3>
|
||||
<p><?php _e("We're changing the way premium functionality is delivered in an exciting way!", 'acf'); ?></p>
|
||||
<p><?php printf(__('All 4 premium add-ons have been combined into a new <a href="%s">Pro version of ACF</a>. With both personal and developer licenses available, premium functionality is more affordable and accessible than ever before!', 'acf'), esc_url('https://www.advancedcustomfields.com/pro')); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Powerful Features", 'acf'); ?></h3>
|
||||
<p><?php _e("ACF PRO contains powerful features such as repeatable data, flexible content layouts, a beautiful gallery field and the ability to create extra admin options pages!", 'acf'); ?></p>
|
||||
<p><?php printf(__('Read more about <a href="%s">ACF PRO features</a>.', 'acf'), esc_url('https://www.advancedcustomfields.com/pro')); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Easy Upgrading", 'acf'); ?></h3>
|
||||
<p><?php _e('Upgrading to ACF PRO is easy. Simply purchase a license online and download the plugin!', 'acf'); ?></p>
|
||||
<p><?php printf(__('We also wrote an <a href="%s">upgrade guide</a> to answer any questions, but if you do have one, please contact our support team via the <a href="%s">help desk</a>.', 'acf'), esc_url('https://www.advancedcustomfields.com/resources/upgrade-guide-acf-pro/'), esc_url('https://www.advancedcustomfields.com/support/')); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="feature-section">
|
||||
|
||||
<h2><?php _e("New Features", 'acf'); ?> 🎉</h2>
|
||||
|
||||
<div class="acf-three-col">
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Link Field", 'acf'); ?></h3>
|
||||
<p><?php _e("The Link field provides a simple way to select or define a link (url, title, target).", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Group Field", 'acf'); ?></h3>
|
||||
<p><?php _e("The Group field provides a simple way to create a group of fields.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("oEmbed Field", 'acf'); ?></h3>
|
||||
<p><?php _e("The oEmbed field allows an easy way to embed videos, images, tweets, audio, and other content.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Clone Field", 'acf'); ?> <span class="badge"><?php _e('Pro', 'acf'); ?></span></h3>
|
||||
<p><?php _e("The clone field allows you to select and display existing fields.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("More AJAX", 'acf'); ?></h3>
|
||||
<p><?php _e("More fields use AJAX powered search to speed up page loading.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Local JSON", 'acf'); ?></h3>
|
||||
<p><?php _e("New auto export to JSON feature improves speed and allows for syncronisation.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Easy Import / Export", 'acf'); ?></h3>
|
||||
<p><?php _e("Both import and export can easily be done through a new tools page.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("New Form Locations", 'acf'); ?></h3>
|
||||
<p><?php _e("Fields can now be mapped to menus, menu items, comments, widgets and all user forms!", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("More Customization", 'acf'); ?></h3>
|
||||
<p><?php _e("New PHP (and JS) actions and filters have been added to allow for more customization.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Fresh UI", 'acf'); ?></h3>
|
||||
<p><?php _e("The entire plugin has had a design refresh including new field types, settings and design!", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("New Settings", 'acf'); ?></h3>
|
||||
<p><?php _e("Field group settings have been added for Active, Label Placement, Instructions Placement and Description.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Better Front End Forms", 'acf'); ?></h3>
|
||||
<p><?php _e("acf_form() can now create a new post on submission with lots of new settings.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Better Validation", 'acf'); ?></h3>
|
||||
<p><?php _e("Form validation is now done via PHP + AJAX in favour of only JS.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Moving Fields", 'acf'); ?></h3>
|
||||
<p><?php _e("New field group functionality allows you to move a field between groups & parents.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div><?php // intentional empty div for flex alignment ?></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php elseif( $active == 'changelog' ): ?>
|
||||
|
||||
<p class="about-description"><?php printf(__("We think you'll love the changes in %s.", 'acf'), $version); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// extract changelog and parse markdown
|
||||
$readme = file_get_contents( acf_get_path('readme.txt') );
|
||||
$changelog = '';
|
||||
if( preg_match( '/(= '.$version.' =)(.+?)(=|$)/s', $readme, $match ) && $match[2] ) {
|
||||
$changelog = acf_parse_markdown( $match[2] );
|
||||
}
|
||||
echo acf_parse_markdown($changelog);
|
||||
|
||||
endif; ?>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user