5.6.0
This commit is contained in:
parent
e70753fb64
commit
0ad8015a8e
182
acf.php
182
acf.php
|
|
@ -2,8 +2,8 @@
|
|||
/*
|
||||
Plugin Name: Advanced Custom Fields PRO
|
||||
Plugin URI: https://www.advancedcustomfields.com/
|
||||
Description: Customise WordPress with powerful, professional and intuitive fields
|
||||
Version: 5.5.14
|
||||
Description: Customise WordPress with powerful, professional and intuitive fields.
|
||||
Version: 5.6.0
|
||||
Author: Elliot Condon
|
||||
Author URI: http://www.elliotcondon.com/
|
||||
Copyright: Elliot Condon
|
||||
|
|
@ -18,7 +18,7 @@ if( ! class_exists('acf') ) :
|
|||
class acf {
|
||||
|
||||
// vars
|
||||
var $version = '5.5.14';
|
||||
var $version = '5.6.0';
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -90,9 +90,9 @@ class acf {
|
|||
'enqueue_select2' => true,
|
||||
'enqueue_datepicker' => true,
|
||||
'enqueue_datetimepicker' => true,
|
||||
'select2_version' => 3,
|
||||
'select2_version' => 4,
|
||||
'row_index_offset' => 1,
|
||||
'remove_wp_meta_box' => false // todo: set to true in 5.6.0
|
||||
'remove_wp_meta_box' => true
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -102,61 +102,68 @@ class acf {
|
|||
$this->define( 'ACF_PATH', $this->settings['path'] );
|
||||
|
||||
|
||||
// include helpers
|
||||
include_once( ACF_PATH . 'api/api-helpers.php');
|
||||
|
||||
|
||||
// api
|
||||
acf_include('api/api-value.php');
|
||||
acf_include('api/api-field.php');
|
||||
acf_include('api/api-field-group.php');
|
||||
acf_include('api/api-template.php');
|
||||
include_once( ACF_PATH . 'includes/api/api-helpers.php');
|
||||
acf_include('includes/api/api-input.php');
|
||||
acf_include('includes/api/api-value.php');
|
||||
acf_include('includes/api/api-field.php');
|
||||
acf_include('includes/api/api-field-group.php');
|
||||
acf_include('includes/api/api-template.php');
|
||||
|
||||
|
||||
// fields
|
||||
acf_include('includes/fields.php');
|
||||
acf_include('includes/fields/class-acf-field.php');
|
||||
|
||||
|
||||
// locations
|
||||
acf_include('includes/locations.php');
|
||||
acf_include('includes/locations/class-acf-location.php');
|
||||
|
||||
|
||||
// core
|
||||
acf_include('core/ajax.php');
|
||||
acf_include('core/cache.php');
|
||||
acf_include('core/compatibility.php');
|
||||
acf_include('core/deprecated.php');
|
||||
acf_include('core/field.php');
|
||||
acf_include('core/fields.php');
|
||||
acf_include('core/form.php');
|
||||
acf_include('core/input.php');
|
||||
acf_include('core/validation.php');
|
||||
acf_include('core/json.php');
|
||||
acf_include('core/local.php');
|
||||
acf_include('core/location.php');
|
||||
acf_include('core/loop.php');
|
||||
acf_include('core/media.php');
|
||||
acf_include('core/revisions.php');
|
||||
acf_include('core/third_party.php');
|
||||
acf_include('core/updates.php');
|
||||
acf_include('includes/ajax.php');
|
||||
acf_include('includes/cache.php');
|
||||
acf_include('includes/compatibility.php');
|
||||
acf_include('includes/deprecated.php');
|
||||
acf_include('includes/input.php');
|
||||
acf_include('includes/json.php');
|
||||
acf_include('includes/local.php');
|
||||
acf_include('includes/loop.php');
|
||||
acf_include('includes/media.php');
|
||||
acf_include('includes/revisions.php');
|
||||
acf_include('includes/third_party.php');
|
||||
acf_include('includes/updates.php');
|
||||
acf_include('includes/validation.php');
|
||||
|
||||
|
||||
// forms
|
||||
acf_include('forms/attachment.php');
|
||||
acf_include('forms/comment.php');
|
||||
acf_include('forms/post.php');
|
||||
acf_include('forms/taxonomy.php');
|
||||
acf_include('forms/user.php');
|
||||
acf_include('forms/widget.php');
|
||||
acf_include('includes/forms/form-attachment.php');
|
||||
acf_include('includes/forms/form-comment.php');
|
||||
acf_include('includes/forms/form-customizer.php');
|
||||
acf_include('includes/forms/form-front.php');
|
||||
acf_include('includes/forms/form-nav-menu.php');
|
||||
acf_include('includes/forms/form-post.php');
|
||||
acf_include('includes/forms/form-taxonomy.php');
|
||||
acf_include('includes/forms/form-user.php');
|
||||
acf_include('includes/forms/form-widget.php');
|
||||
|
||||
|
||||
// admin
|
||||
if( is_admin() ) {
|
||||
|
||||
acf_include('admin/admin.php');
|
||||
acf_include('admin/field-group.php');
|
||||
acf_include('admin/field-groups.php');
|
||||
acf_include('admin/install.php');
|
||||
acf_include('admin/settings-tools.php');
|
||||
acf_include('admin/settings-info.php');
|
||||
acf_include('includes/admin/admin.php');
|
||||
acf_include('includes/admin/admin-field-group.php');
|
||||
acf_include('includes/admin/admin-field-groups.php');
|
||||
acf_include('includes/admin/install.php');
|
||||
acf_include('includes/admin/settings-tools.php');
|
||||
acf_include('includes/admin/settings-info.php');
|
||||
|
||||
|
||||
// network
|
||||
if( is_network_admin() ) {
|
||||
|
||||
acf_include('admin/install-network.php');
|
||||
acf_include('includes/admin/install-network.php');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -218,42 +225,69 @@ class acf {
|
|||
|
||||
|
||||
// include wpml support
|
||||
if( defined('ICL_SITEPRESS_VERSION') ) acf_include('core/wpml.php');
|
||||
if( defined('ICL_SITEPRESS_VERSION') ) {
|
||||
acf_include('includes/wpml.php');
|
||||
}
|
||||
|
||||
|
||||
// field types
|
||||
acf_include('fields/text.php');
|
||||
acf_include('fields/textarea.php');
|
||||
acf_include('fields/number.php');
|
||||
acf_include('fields/email.php');
|
||||
acf_include('fields/url.php');
|
||||
acf_include('fields/password.php');
|
||||
acf_include('fields/wysiwyg.php');
|
||||
acf_include('fields/oembed.php');
|
||||
acf_include('fields/image.php');
|
||||
acf_include('fields/file.php');
|
||||
acf_include('fields/select.php');
|
||||
acf_include('fields/checkbox.php');
|
||||
acf_include('fields/radio.php');
|
||||
acf_include('fields/true_false.php');
|
||||
acf_include('fields/post_object.php');
|
||||
acf_include('fields/page_link.php');
|
||||
acf_include('fields/relationship.php');
|
||||
acf_include('fields/taxonomy.php');
|
||||
acf_include('fields/user.php');
|
||||
acf_include('fields/google-map.php');
|
||||
acf_include('fields/date_picker.php');
|
||||
acf_include('fields/date_time_picker.php');
|
||||
acf_include('fields/time_picker.php');
|
||||
acf_include('fields/color_picker.php');
|
||||
acf_include('fields/message.php');
|
||||
acf_include('fields/tab.php');
|
||||
|
||||
|
||||
// 3rd party field types
|
||||
// fields
|
||||
acf_include('includes/fields/class-acf-field-text.php');
|
||||
acf_include('includes/fields/class-acf-field-textarea.php');
|
||||
acf_include('includes/fields/class-acf-field-number.php');
|
||||
acf_include('includes/fields/class-acf-field-email.php');
|
||||
acf_include('includes/fields/class-acf-field-url.php');
|
||||
acf_include('includes/fields/class-acf-field-password.php');
|
||||
acf_include('includes/fields/class-acf-field-wysiwyg.php');
|
||||
acf_include('includes/fields/class-acf-field-oembed.php');
|
||||
acf_include('includes/fields/class-acf-field-image.php');
|
||||
acf_include('includes/fields/class-acf-field-link.php');
|
||||
acf_include('includes/fields/class-acf-field-file.php');
|
||||
acf_include('includes/fields/class-acf-field-select.php');
|
||||
acf_include('includes/fields/class-acf-field-checkbox.php');
|
||||
acf_include('includes/fields/class-acf-field-radio.php');
|
||||
acf_include('includes/fields/class-acf-field-true_false.php');
|
||||
acf_include('includes/fields/class-acf-field-post_object.php');
|
||||
acf_include('includes/fields/class-acf-field-page_link.php');
|
||||
acf_include('includes/fields/class-acf-field-relationship.php');
|
||||
acf_include('includes/fields/class-acf-field-taxonomy.php');
|
||||
acf_include('includes/fields/class-acf-field-user.php');
|
||||
acf_include('includes/fields/class-acf-field-google-map.php');
|
||||
acf_include('includes/fields/class-acf-field-date_picker.php');
|
||||
acf_include('includes/fields/class-acf-field-date_time_picker.php');
|
||||
acf_include('includes/fields/class-acf-field-time_picker.php');
|
||||
acf_include('includes/fields/class-acf-field-color_picker.php');
|
||||
acf_include('includes/fields/class-acf-field-message.php');
|
||||
//acf_include('includes/fields/class-acf-field-separator.php');
|
||||
acf_include('includes/fields/class-acf-field-tab.php');
|
||||
acf_include('includes/fields/class-acf-field-group.php');
|
||||
do_action('acf/include_field_types', $major);
|
||||
|
||||
|
||||
// locations
|
||||
acf_include('includes/locations/class-acf-location-post-type.php');
|
||||
acf_include('includes/locations/class-acf-location-post-template.php');
|
||||
acf_include('includes/locations/class-acf-location-post-status.php');
|
||||
acf_include('includes/locations/class-acf-location-post-format.php');
|
||||
acf_include('includes/locations/class-acf-location-post-category.php');
|
||||
acf_include('includes/locations/class-acf-location-post-taxonomy.php');
|
||||
acf_include('includes/locations/class-acf-location-post.php');
|
||||
acf_include('includes/locations/class-acf-location-page-template.php');
|
||||
acf_include('includes/locations/class-acf-location-page-type.php');
|
||||
acf_include('includes/locations/class-acf-location-page-parent.php');
|
||||
acf_include('includes/locations/class-acf-location-page.php');
|
||||
acf_include('includes/locations/class-acf-location-current-user.php');
|
||||
acf_include('includes/locations/class-acf-location-current-user-role.php');
|
||||
acf_include('includes/locations/class-acf-location-user-form.php');
|
||||
acf_include('includes/locations/class-acf-location-user-role.php');
|
||||
acf_include('includes/locations/class-acf-location-taxonomy.php');
|
||||
acf_include('includes/locations/class-acf-location-attachment.php');
|
||||
acf_include('includes/locations/class-acf-location-comment.php');
|
||||
acf_include('includes/locations/class-acf-location-widget.php');
|
||||
acf_include('includes/locations/class-acf-location-nav-menu.php');
|
||||
acf_include('includes/locations/class-acf-location-nav-menu-item.php');
|
||||
do_action('acf/include_location_rules', $major);
|
||||
|
||||
|
||||
// local fields
|
||||
do_action('acf/include_fields', $major);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,160 +0,0 @@
|
|||
<?php
|
||||
|
||||
// vars
|
||||
$rule_types = apply_filters('acf/location/rule_types', array(
|
||||
__("Post",'acf') => array(
|
||||
'post_type' => __("Post Type",'acf'),
|
||||
'post_template' => __("Post Template",'acf'),
|
||||
'post_status' => __("Post Status",'acf'),
|
||||
'post_format' => __("Post Format",'acf'),
|
||||
'post_category' => __("Post Category",'acf'),
|
||||
'post_taxonomy' => __("Post Taxonomy",'acf'),
|
||||
'post' => __("Post",'acf')
|
||||
),
|
||||
__("Page",'acf') => array(
|
||||
'page_template' => __("Page Template",'acf'),
|
||||
'page_type' => __("Page Type",'acf'),
|
||||
'page_parent' => __("Page Parent",'acf'),
|
||||
'page' => __("Page",'acf')
|
||||
),
|
||||
__("User",'acf') => array(
|
||||
'current_user' => __("Current User",'acf'),
|
||||
'current_user_role' => __("Current User Role",'acf'),
|
||||
'user_form' => __("User Form",'acf'),
|
||||
'user_role' => __("User Role",'acf')
|
||||
),
|
||||
__("Forms",'acf') => array(
|
||||
'attachment' => __("Attachment",'acf'),
|
||||
'taxonomy' => __("Taxonomy Term",'acf'),
|
||||
'comment' => __("Comment",'acf'),
|
||||
'widget' => __("Widget",'acf')
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// WP < 4.7
|
||||
if( acf_version_compare('wp', '<', '4.7') ) {
|
||||
|
||||
unset( $rule_types[ __("Post",'acf') ]['post_template'] );
|
||||
|
||||
}
|
||||
|
||||
$rule_operators = apply_filters( 'acf/location/rule_operators', array(
|
||||
'==' => __("is equal to",'acf'),
|
||||
'!=' => __("is not equal to",'acf'),
|
||||
));
|
||||
|
||||
?>
|
||||
<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 $group_id => $group ):
|
||||
|
||||
// validate
|
||||
if( empty($group) ) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// $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 group 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' => '',
|
||||
));
|
||||
|
||||
|
||||
// $group_id must be completely different to $rule_id to avoid JS issues
|
||||
$rule_id = "rule_{$rule_id}";
|
||||
|
||||
?>
|
||||
<tr data-id="<?php echo $rule_id; ?>">
|
||||
<td class="param"><?php
|
||||
|
||||
// create field
|
||||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'prefix' => "acf_field_group[location][{$group_id}][{$rule_id}]",
|
||||
'name' => 'param',
|
||||
'value' => $rule['param'],
|
||||
'choices' => $rule_types,
|
||||
'class' => 'location-rule-param'
|
||||
));
|
||||
|
||||
?></td>
|
||||
<td class="operator"><?php
|
||||
|
||||
// create field
|
||||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'prefix' => "acf_field_group[location][{$group_id}][{$rule_id}]",
|
||||
'name' => 'operator',
|
||||
'value' => $rule['operator'],
|
||||
'choices' => $rule_operators,
|
||||
'class' => 'location-rule-operator'
|
||||
));
|
||||
|
||||
?></td>
|
||||
<td class="value"><?php
|
||||
|
||||
$this->render_location_value(array(
|
||||
'group_id' => $group_id,
|
||||
'rule_id' => $rule_id,
|
||||
'value' => $rule['value'],
|
||||
'param' => $rule['param'],
|
||||
'class' => 'location-rule-value'
|
||||
));
|
||||
|
||||
?></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>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<?php 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.postbox.render({
|
||||
'id': 'acf-field-group-locations',
|
||||
'label': 'left'
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
|
@ -1,11 +1,16 @@
|
|||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* vars
|
||||
* Vars
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/* colors */
|
||||
/* acf-field */
|
||||
/* responsive */
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Mixins
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Global
|
||||
|
|
@ -14,6 +19,17 @@
|
|||
#adv-settings .show-field-keys label {
|
||||
padding: 0 5px;
|
||||
}
|
||||
#acf-field-group-fields > .inside,
|
||||
#acf-field-group-locations > .inside,
|
||||
#acf-field-group-options > .inside {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.acf-field p.description {
|
||||
font-style: normal;
|
||||
font-size: 12px;
|
||||
color: #777777;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Postbox: Publish
|
||||
|
|
@ -37,67 +53,74 @@
|
|||
* Postbox: Fields
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
.acf-field p.description {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-style: normal;
|
||||
font-size: 12px;
|
||||
line-height: 1.4em;
|
||||
color: #777777;
|
||||
display: block;
|
||||
}
|
||||
#acf-field-group-fields > .inside,
|
||||
#acf-field-group-locations > .inside,
|
||||
#acf-field-group-options > .inside {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
#acf-field-group-fields {
|
||||
border: 0 none;
|
||||
box-shadow: none;
|
||||
/* metabox */
|
||||
/* links */
|
||||
/* no fields */
|
||||
/* table header */
|
||||
/* show keys */
|
||||
/* fields */
|
||||
}
|
||||
#acf-field-group-fields > .handlediv,
|
||||
#acf-field-group-fields > .hndle {
|
||||
display: none;
|
||||
}
|
||||
.no-fields-message {
|
||||
#acf-field-group-fields a {
|
||||
text-decoration: none;
|
||||
}
|
||||
#acf-field-group-fields a:active,
|
||||
#acf-field-group-fields a:focus {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
#acf-field-group-fields .no-fields-message {
|
||||
padding: 15px 15px;
|
||||
background: #fff;
|
||||
}
|
||||
.acf-field-list-wrap {
|
||||
#acf-field-group-fields .li-field-order {
|
||||
width: 20%;
|
||||
}
|
||||
#acf-field-group-fields .li-field-label {
|
||||
width: 30%;
|
||||
}
|
||||
#acf-field-group-fields .li-field-name {
|
||||
width: 25%;
|
||||
}
|
||||
#acf-field-group-fields .li-field-type {
|
||||
width: 25%;
|
||||
}
|
||||
#acf-field-group-fields .li-field-key {
|
||||
display: none;
|
||||
}
|
||||
#acf-field-group-fields.show-field-keys .li-field-label,
|
||||
#acf-field-group-fields.show-field-keys .li-field-name,
|
||||
#acf-field-group-fields.show-field-keys .li-field-type,
|
||||
#acf-field-group-fields.show-field-keys .li-field-key {
|
||||
width: 20%;
|
||||
}
|
||||
#acf-field-group-fields.show-field-keys .li-field-key {
|
||||
display: block;
|
||||
}
|
||||
#acf-field-group-fields .acf-field-list-wrap {
|
||||
border: #DFDFDF solid 1px;
|
||||
}
|
||||
/* table header */
|
||||
.li-field-order {
|
||||
width: 22%;
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
.li-field-label {
|
||||
width: 28%;
|
||||
}
|
||||
.li-field-name {
|
||||
width: 25%;
|
||||
}
|
||||
.li-field-type {
|
||||
width: 25%;
|
||||
}
|
||||
/* field list */
|
||||
.acf-field-list {
|
||||
#acf-field-group-fields .acf-field-list {
|
||||
background: #F9F9F9;
|
||||
margin-top: -1px;
|
||||
}
|
||||
.acf-field-list a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.acf-field-list a:active,
|
||||
.acf-field-list a:focus {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
/* field object */
|
||||
.acf-field-object {
|
||||
border-top: #F0F0F0 solid 1px;
|
||||
background: #fff;
|
||||
/* sortable */
|
||||
/* meta */
|
||||
/* handle */
|
||||
/* open */
|
||||
/* hover */
|
||||
/* settings */
|
||||
/* conditional logic */
|
||||
}
|
||||
.acf-field-object.ui-sortable-helper {
|
||||
border-top-color: #fff;
|
||||
|
|
@ -109,24 +132,21 @@
|
|||
background: #F9F9F9;
|
||||
border-top-color: transparent;
|
||||
}
|
||||
.acf-field-object[data-key="acfcloneindex"] {
|
||||
display: none !important;
|
||||
}
|
||||
/* field object (open) */
|
||||
.acf-field-object.open + .acf-field-object {
|
||||
border-top-color: #E1E1E1;
|
||||
}
|
||||
/* field object meta */
|
||||
.acf-field-object .meta {
|
||||
.acf-field-object > .meta {
|
||||
display: none;
|
||||
}
|
||||
/* field object handle */
|
||||
.acf-field-object .handle li {
|
||||
.acf-field-object > .handle a {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
-o-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
.acf-field-object > .handle li {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.acf-field-object .handle .acf-icon {
|
||||
.acf-field-object > .handle .acf-icon {
|
||||
margin: 1px 0 0;
|
||||
cursor: move;
|
||||
background: transparent;
|
||||
|
|
@ -139,29 +159,28 @@
|
|||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
.acf-field-object .handle strong {
|
||||
.acf-field-object > .handle strong {
|
||||
display: block;
|
||||
padding-bottom: 6px;
|
||||
font-size: 14px;
|
||||
line-height: 14px;
|
||||
min-height: 14px;
|
||||
}
|
||||
.acf-field-object.open > .handle .acf-required {
|
||||
color: #fff;
|
||||
}
|
||||
.acf-field-object .handle .row-options {
|
||||
.acf-field-object > .handle .row-options {
|
||||
visibility: hidden;
|
||||
}
|
||||
.acf-field-object:hover > .handle .row-options {
|
||||
visibility: visible;
|
||||
}
|
||||
.acf-field-object .handle .row-options a {
|
||||
.acf-field-object > .handle .row-options a {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.acf-field-object .handle .delete-field:hover {
|
||||
.acf-field-object > .handle .row-options a.delete-field {
|
||||
color: #a00;
|
||||
}
|
||||
.acf-field-object > .handle .row-options a.delete-field:hover {
|
||||
color: #f00;
|
||||
}
|
||||
/* field object handle (open) */
|
||||
.acf-field-object.open + .acf-field-object {
|
||||
border-top-color: #E1E1E1;
|
||||
}
|
||||
.acf-field-object.open > .handle {
|
||||
background: #2a9bd9;
|
||||
border: #2696d3 solid 1px;
|
||||
|
|
@ -172,19 +191,20 @@
|
|||
}
|
||||
.acf-field-object.open > .handle a {
|
||||
color: #fff !important;
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
-o-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
.acf-field-object.open > .handle .row-options a:hover {
|
||||
text-decoration: underline;
|
||||
.acf-field-object.open > .handle a:hover {
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
.acf-field-object.open > .handle .acf-icon {
|
||||
border-color: #fff;
|
||||
color: #fff;
|
||||
}
|
||||
/* field object settings */
|
||||
.acf-field-object.open > .handle .acf-required {
|
||||
color: #fff;
|
||||
}
|
||||
.acf-field-object:hover > .handle .row-options {
|
||||
visibility: visible;
|
||||
}
|
||||
.acf-field-object > .settings {
|
||||
display: none;
|
||||
width: 100%;
|
||||
|
|
@ -192,35 +212,9 @@
|
|||
.acf-field-object > .settings > .acf-table {
|
||||
border: none;
|
||||
}
|
||||
/* conditional logic */
|
||||
.acf-field-object .rule-groups {
|
||||
margin-top: 20px;
|
||||
}
|
||||
/* field object keys */
|
||||
.acf-field-object .handle .pre-field-key {
|
||||
border: #E1E1E1 solid 1px;
|
||||
margin: 4px 0 0 -6px;
|
||||
padding: 5px 5px 5px 11px;
|
||||
font: inherit;
|
||||
float: left;
|
||||
border-radius: 0 3px 3px 0;
|
||||
display: none;
|
||||
border-left: none;
|
||||
font-size: 12px;
|
||||
line-height: 12px;
|
||||
}
|
||||
.acf-field-object.open > .handle .pre-field-key {
|
||||
border-color: #FAFCFD;
|
||||
}
|
||||
.show-field-keys .acf-field-object .handle .pre-field-key {
|
||||
display: block;
|
||||
}
|
||||
.show-field-keys .li-field-order {
|
||||
width: 24%;
|
||||
}
|
||||
.show-field-keys .li-field-label {
|
||||
width: 26%;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Postbox: Locations
|
||||
|
|
@ -344,6 +338,16 @@ table.conditional-logic-rules tbody td {
|
|||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Field: Separator
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
.acf-field-object-separator tr[data-name="name"],
|
||||
.acf-field-object-separator tr[data-name="instructions"],
|
||||
.acf-field-object-separator tr[data-name="required"] {
|
||||
display: none !important;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Field: Date Picker
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* vars
|
||||
* Vars
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/* colors */
|
||||
|
|
@ -8,6 +8,11 @@
|
|||
/* responsive */
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Mixins
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* General
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
|
@ -170,22 +175,13 @@ img.acf-fw {
|
|||
background: #2F353E;
|
||||
border-radius: 5px;
|
||||
color: #fff;
|
||||
padding: 5px 15px;
|
||||
padding: 5px 10px;
|
||||
position: absolute;
|
||||
z-index: 999999;
|
||||
font-size: 12px;
|
||||
}
|
||||
.acf-tooltip.top {
|
||||
margin-top: -8px;
|
||||
}
|
||||
.acf-tooltip.right {
|
||||
margin-right: -8px;
|
||||
}
|
||||
.acf-tooltip.bottom {
|
||||
margin-bottom: -8px;
|
||||
}
|
||||
.acf-tooltip.left {
|
||||
margin-left: -8px;
|
||||
z-index: 998;
|
||||
/* tip */
|
||||
/* positions */
|
||||
}
|
||||
.acf-tooltip:before {
|
||||
border: solid;
|
||||
|
|
@ -194,6 +190,9 @@ img.acf-fw {
|
|||
content: "";
|
||||
position: absolute;
|
||||
}
|
||||
.acf-tooltip.top {
|
||||
margin-top: -8px;
|
||||
}
|
||||
.acf-tooltip.top:before {
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
|
|
@ -201,6 +200,9 @@ img.acf-fw {
|
|||
border-top-color: #2F353E;
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
.acf-tooltip.right {
|
||||
margin-right: -8px;
|
||||
}
|
||||
.acf-tooltip.right:before {
|
||||
top: 50%;
|
||||
margin-top: -6px;
|
||||
|
|
@ -208,6 +210,9 @@ img.acf-fw {
|
|||
border-right-color: #2F353E;
|
||||
border-left-width: 0;
|
||||
}
|
||||
.acf-tooltip.bottom {
|
||||
margin-bottom: -8px;
|
||||
}
|
||||
.acf-tooltip.bottom:before {
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
|
|
@ -215,6 +220,9 @@ img.acf-fw {
|
|||
border-bottom-color: #2F353E;
|
||||
border-top-width: 0;
|
||||
}
|
||||
.acf-tooltip.left {
|
||||
margin-left: -8px;
|
||||
}
|
||||
.acf-tooltip.left:before {
|
||||
top: 50%;
|
||||
margin-top: -6px;
|
||||
|
|
@ -222,6 +230,20 @@ img.acf-fw {
|
|||
border-left-color: #2F353E;
|
||||
border-right-width: 0;
|
||||
}
|
||||
/* confirm */
|
||||
.acf-tooltip.-confirm {
|
||||
z-index: 999;
|
||||
}
|
||||
.acf-tooltip.-confirm a {
|
||||
text-decoration: none;
|
||||
color: #9ea3a8;
|
||||
}
|
||||
.acf-tooltip.-confirm a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.acf-tooltip.-confirm a.-red {
|
||||
color: #F55E4F;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* callout
|
||||
|
|
@ -261,8 +283,8 @@ img.acf-fw {
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
@font-face {
|
||||
font-family: 'acf';
|
||||
src: url('../font/acf.eot?50902143');
|
||||
src: url('../font/acf.eot?50902143#iefix') format('embedded-opentype'), url('../font/acf.woff?50902143') format('woff'), url('../font/acf.ttf?50902143') format('truetype'), url('../font/acf.svg?50902143#acf') format('svg');
|
||||
src: url('../font/acf.eot?57601716');
|
||||
src: url('../font/acf.eot?57601716#iefix') format('embedded-opentype'), url('../font/acf.woff2?57601716') format('woff2'), url('../font/acf.woff?57601716') format('woff'), url('../font/acf.ttf?57601716') format('truetype'), url('../font/acf.svg?57601716#acf') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
|
@ -366,6 +388,10 @@ img.acf-fw {
|
|||
content: '\e811';
|
||||
}
|
||||
/* '' */
|
||||
.acf-icon.-link-ext:before {
|
||||
content: '\f08e';
|
||||
}
|
||||
/* '' */
|
||||
/* collapse */
|
||||
.acf-icon.-collapse:before {
|
||||
content: '\e810';
|
||||
|
|
@ -404,20 +430,32 @@ a.acf-icon {
|
|||
position: relative;
|
||||
overflow: hidden;
|
||||
transition: none;
|
||||
/* clear */
|
||||
/* light*/
|
||||
/* states */
|
||||
/* remove WP outline box-shadow */
|
||||
/* red */
|
||||
}
|
||||
/* minor tweaks */
|
||||
.acf-icon.-pencil {
|
||||
font-size: 15px;
|
||||
a.acf-icon.-clear {
|
||||
color: #444;
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
.acf-icon.-location {
|
||||
font-size: 18px;
|
||||
a.acf-icon.light {
|
||||
border: none;
|
||||
padding: 1px;
|
||||
background: #F5F5F5;
|
||||
color: #72777c;
|
||||
}
|
||||
/* states */
|
||||
a.acf-icon:hover {
|
||||
border-color: transparent;
|
||||
background: #b4b9be;
|
||||
background: #2a9bd9;
|
||||
color: #fff;
|
||||
}
|
||||
a.acf-icon:active {
|
||||
color: #fff;
|
||||
background-color: #238cc6;
|
||||
}
|
||||
a.acf-icon:active,
|
||||
a.acf-icon:focus {
|
||||
outline: none;
|
||||
|
|
@ -427,22 +465,25 @@ a.acf-icon.-minus:hover,
|
|||
a.acf-icon.-cancel:hover {
|
||||
background-color: #F55E4F;
|
||||
}
|
||||
a.acf-icon.-minus:active,
|
||||
a.acf-icon.-cancel:active {
|
||||
background-color: #f44837;
|
||||
}
|
||||
/* minor tweaks */
|
||||
.acf-icon.-pencil {
|
||||
font-size: 15px;
|
||||
}
|
||||
.acf-icon.-location {
|
||||
font-size: 18px;
|
||||
}
|
||||
/* sizes */
|
||||
.acf-icon.small {
|
||||
.acf-icon.small,
|
||||
.acf-icon.-small {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
line-height: 18px;
|
||||
font-size: 14px;
|
||||
}
|
||||
/* styles */
|
||||
.acf-icon.light {
|
||||
border: 0 none;
|
||||
padding: 1px;
|
||||
background: #F5F5F5;
|
||||
}
|
||||
.acf-icon.light:hover {
|
||||
background: #0073AA;
|
||||
}
|
||||
/* dark */
|
||||
.acf-icon.dark {
|
||||
border-color: transparent;
|
||||
|
|
@ -547,8 +588,8 @@ a.acf-icon.-cancel.grey:hover {
|
|||
}
|
||||
.acf-box h2 {
|
||||
color: #333333;
|
||||
font-size: 25px;
|
||||
line-height: 29px;
|
||||
font-size: 26px;
|
||||
line-height: 1.25em;
|
||||
margin: 0.25em 0 0.75em;
|
||||
padding: 0;
|
||||
}
|
||||
|
|
@ -558,25 +599,21 @@ a.acf-icon.-cancel.grey:hover {
|
|||
.acf-box p {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
.acf-box .footer {
|
||||
background: #F5F5F5;
|
||||
border-top: 1px solid #E1E1E1;
|
||||
overflow: hidden;
|
||||
padding: 15px;
|
||||
position: relative;
|
||||
}
|
||||
.acf-box .footer.-blue {
|
||||
border-top: 0 none;
|
||||
background-color: #2a9bd9;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
.acf-box .footer.-blue p {
|
||||
margin: 0;
|
||||
}
|
||||
.acf-box .footer.-blue a {
|
||||
.acf-box a {
|
||||
text-decoration: none;
|
||||
text-shadow: none;
|
||||
color: inherit;
|
||||
}
|
||||
.acf-box i.dashicons-external {
|
||||
margin-top: -1px;
|
||||
}
|
||||
.acf-box .footer {
|
||||
background: #fff;
|
||||
border-top: 1px solid #eee;
|
||||
padding: 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.acf-box .footer p {
|
||||
margin: 0;
|
||||
}
|
||||
/* error */
|
||||
.acf-error-message {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* vars
|
||||
* Vars
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/* colors */
|
||||
|
|
@ -8,6 +8,11 @@
|
|||
/* responsive */
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Mixins
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* acf-field
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
|
@ -17,6 +22,7 @@
|
|||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
.acf-field {
|
||||
margin: 0 0 20px;
|
||||
|
|
@ -64,19 +70,6 @@
|
|||
bottom: -10px;
|
||||
left: 10px;
|
||||
}
|
||||
/* acf-table */
|
||||
.acf-table tr.acf-field > td.acf-label,
|
||||
.acf-table tr.acf-field > td.acf-input {
|
||||
padding: 15px 12px;
|
||||
}
|
||||
.acf-table tr.acf-field > td.acf-label {
|
||||
background: #F9F9F9;
|
||||
border-top-color: #F0F0F0;
|
||||
width: 24%;
|
||||
}
|
||||
.acf-table tr.acf-field > td.acf-input {
|
||||
border-left-color: #E1E1E1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* acf-fields
|
||||
|
|
@ -85,12 +78,6 @@
|
|||
.acf-fields {
|
||||
position: relative;
|
||||
}
|
||||
.acf-fields:after {
|
||||
content: "";
|
||||
display: block;
|
||||
line-height: 0;
|
||||
clear: both;
|
||||
}
|
||||
.acf-fields > .acf-field {
|
||||
margin: 0;
|
||||
padding: 15px 12px;
|
||||
|
|
@ -102,6 +89,16 @@
|
|||
.acf-fields > .acf-field:first-child {
|
||||
border-top-width: 0;
|
||||
}
|
||||
.acf-fields:after {
|
||||
content: "";
|
||||
display: block;
|
||||
line-height: 0;
|
||||
clear: both;
|
||||
}
|
||||
.acf-fields.-border {
|
||||
border: #dfdfdf solid 1px;
|
||||
background: #fff;
|
||||
}
|
||||
td.acf-fields {
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
|
@ -111,10 +108,13 @@ td.acf-fields {
|
|||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
.acf-fields.-left > .acf-field {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-left: 20%;
|
||||
/* mobile */
|
||||
}
|
||||
html[dir="rtl"] .acf-fields.-left > .acf-field {
|
||||
padding-left: 12px;
|
||||
padding-right: 20%;
|
||||
}
|
||||
.acf-fields.-left > .acf-field:after {
|
||||
content: "";
|
||||
display: block;
|
||||
|
|
@ -133,7 +133,7 @@ td.acf-fields {
|
|||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 24%;
|
||||
width: 20%;
|
||||
/* rtl */
|
||||
}
|
||||
html[dir="rtl"] .acf-fields.-left > .acf-field:before {
|
||||
|
|
@ -144,24 +144,29 @@ html[dir="rtl"] .acf-fields.-left > .acf-field:before {
|
|||
}
|
||||
.acf-fields.-left > .acf-field > .acf-label,
|
||||
.acf-fields.-left > .acf-field > .acf-input {
|
||||
margin: 0;
|
||||
padding: 15px 12px;
|
||||
float: left;
|
||||
position: relative;
|
||||
/* rtl */
|
||||
margin: 0;
|
||||
}
|
||||
html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-label,
|
||||
html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
|
||||
float: right;
|
||||
}
|
||||
.acf-fields.-left > .acf-field > .acf-label {
|
||||
width: 24%;
|
||||
width: 25%;
|
||||
margin-left: -25%;
|
||||
padding: 0 12px;
|
||||
}
|
||||
html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-label {
|
||||
margin-left: 0;
|
||||
margin-right: -25%;
|
||||
}
|
||||
.acf-fields.-left > .acf-field > .acf-input {
|
||||
width: 76%;
|
||||
width: 100%;
|
||||
padding-left: 12px;
|
||||
}
|
||||
.acf-fields.-left > .acf-field[data-width] {
|
||||
width: 100% !important;
|
||||
html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
|
||||
padding-left: 0;
|
||||
padding-right: 12px;
|
||||
}
|
||||
@media screen and (max-width: 782px) {
|
||||
.acf-fields.-left > .acf-field {
|
||||
|
|
@ -180,6 +185,41 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
|
|||
margin: 0 0 10px;
|
||||
}
|
||||
}
|
||||
/* acf-table */
|
||||
.acf-table tr.acf-field > td.acf-label,
|
||||
.acf-table tr.acf-field > td.acf-input {
|
||||
padding: 15px 12px;
|
||||
}
|
||||
.acf-table tr.acf-field > td.acf-label {
|
||||
background: #F9F9F9;
|
||||
width: 20%;
|
||||
}
|
||||
.acf-table tr.acf-field > td.acf-input {
|
||||
border-left-color: #E1E1E1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* acf-fields (clear)
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
.acf-fields.-clear > .acf-field {
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
.acf-fields.-clear > .acf-field:before {
|
||||
display: none;
|
||||
}
|
||||
.acf-fields.-clear > .acf-field > .acf-label {
|
||||
padding: 0;
|
||||
}
|
||||
.acf-fields.-clear > .acf-field > .acf-input {
|
||||
padding: 0;
|
||||
}
|
||||
/* left */
|
||||
.acf-fields.-clear.-left > .acf-field > .acf-label {
|
||||
padding-right: 24px;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* acf-postbox
|
||||
|
|
@ -230,6 +270,7 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
|
|||
box-shadow: none;
|
||||
/* hide hndle */
|
||||
/* inside */
|
||||
/* tab */
|
||||
}
|
||||
.acf-postbox.seamless > .hndle,
|
||||
.acf-postbox.seamless > .handlediv {
|
||||
|
|
@ -238,27 +279,27 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
|
|||
.acf-postbox.seamless > .inside {
|
||||
display: block !important;
|
||||
/* stop metabox from hiding when closed */
|
||||
margin: -10px !important;
|
||||
margin-left: -12px !important;
|
||||
margin-right: -12px !important;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-field {
|
||||
border: 0 none !important;
|
||||
padding: 10px;
|
||||
}
|
||||
.acf-postbox.seamless .acf-tab-wrap {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
}
|
||||
.acf-postbox.seamless .acf-tab-wrap .acf-tab-group {
|
||||
border-top: 0 none;
|
||||
}
|
||||
/* seamless (left) */
|
||||
.acf-postbox.seamless > .acf-fields.-left {
|
||||
/* hide sidebar bg */
|
||||
/* tweak padding */
|
||||
/* mobile */
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields.-left > .acf-field:before {
|
||||
display: none;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields.-left > .acf-field > .acf-label {
|
||||
padding: 0 12px 0 0;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields.-left > .acf-field > .acf-input {
|
||||
padding: 0 0 0 12px;
|
||||
}
|
||||
@media screen and (max-width: 782px) {
|
||||
.acf-postbox.seamless > .acf-fields.-left {
|
||||
/* remove padding */
|
||||
|
|
@ -434,12 +475,12 @@ html[dir="rtl"] input.acf-is-prepended.acf-is-appended {
|
|||
opacity: 0.5;
|
||||
color: #A9A9A9;
|
||||
}
|
||||
.acf-url.valid i {
|
||||
opacity: 1;
|
||||
}
|
||||
.acf-url input[type="url"] {
|
||||
padding-left: 25px;
|
||||
}
|
||||
.acf-url.-valid i {
|
||||
opacity: 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Select
|
||||
|
|
@ -573,6 +614,12 @@ html[dir="rtl"] .select2-container.-acf .select2-choice .select2-arrow {
|
|||
.select2-container--default.-acf .select2-selection--multiple {
|
||||
/* multiple choice item */
|
||||
}
|
||||
.select2-container--default.-acf .select2-selection--multiple .select2-search--inline:first-child {
|
||||
float: none;
|
||||
}
|
||||
.select2-container--default.-acf .select2-selection--multiple .select2-search--inline:first-child input {
|
||||
width: 100% !important;
|
||||
}
|
||||
.select2-container--default.-acf .select2-selection--multiple .select2-selection__choice {
|
||||
background-color: #f7f7f7;
|
||||
border-color: #cccccc;
|
||||
|
|
@ -595,6 +642,40 @@ html[dir="rtl"] .select2-container.-acf .select2-choice .select2-arrow {
|
|||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Link
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
.link-wrap {
|
||||
border: #dddddd solid 1px;
|
||||
border-radius: 3px;
|
||||
padding: 5px;
|
||||
line-height: 26px;
|
||||
background: #fff;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
.link-wrap .link-title {
|
||||
padding: 0 5px;
|
||||
}
|
||||
.acf-link {
|
||||
/* value */
|
||||
/* external */
|
||||
}
|
||||
.acf-link .link-wrap,
|
||||
.acf-link .acf-icon.-link-ext {
|
||||
display: none;
|
||||
}
|
||||
.acf-link.-value .button {
|
||||
display: none;
|
||||
}
|
||||
.acf-link.-value .link-wrap {
|
||||
display: inline-block;
|
||||
}
|
||||
.acf-link.-external .acf-icon.-link-ext {
|
||||
display: inline-block;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Radio
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
|
|
@ -741,38 +822,6 @@ html[dir="rtl"] ul.acf-checkbox-list input[type="radio"] {
|
|||
position: absolute;
|
||||
margin: 0;
|
||||
}
|
||||
/*
|
||||
.acf-field[data-name="alt"] .acf-switch {
|
||||
background: #fff;
|
||||
border: #dddddd solid 1px;
|
||||
height: 30px;
|
||||
|
||||
span {
|
||||
padding: 3px 10px;
|
||||
}
|
||||
|
||||
.acf-switch-slider {
|
||||
background: #f9f9f9;
|
||||
border: #bbbbbb solid 1px;
|
||||
box-shadow: none;
|
||||
margin: 3px;
|
||||
}
|
||||
|
||||
|
||||
&.-on {
|
||||
border-color: #2c91fc;
|
||||
background: @acf_blue_input2;
|
||||
|
||||
.acf-switch-slider {
|
||||
background: #fff;
|
||||
border-color: darken(@acf_blue_input2, 20%);
|
||||
margin-left: -4px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
/*--------------------------------------------------------------------------
|
||||
*
|
||||
* Google Map
|
||||
|
|
@ -895,19 +944,29 @@ html[dir="rtl"] .pac-container .pac-item {
|
|||
.acf-relationship .filters {
|
||||
border: #DFDFDF solid 1px;
|
||||
background: #fff;
|
||||
/* widths */
|
||||
}
|
||||
.acf-relationship .filters .inner {
|
||||
padding: 7px 7px 7px 0;
|
||||
margin: 0;
|
||||
}
|
||||
.acf-relationship .filters li:first-child .inner {
|
||||
padding-left: 7px;
|
||||
}
|
||||
.acf-relationship .filters input {
|
||||
border-color: transparent;
|
||||
box-shadow: none;
|
||||
.acf-relationship .filters:after {
|
||||
clear: both;
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
.acf-relationship .filters .filter {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
float: left;
|
||||
width: 100%;
|
||||
/* inner padding */
|
||||
}
|
||||
.acf-relationship .filters .filter span {
|
||||
display: block;
|
||||
padding: 7px 7px 7px 0;
|
||||
}
|
||||
.acf-relationship .filters .filter:first-child span {
|
||||
padding-left: 7px;
|
||||
}
|
||||
.acf-relationship .filters .filter input,
|
||||
.acf-relationship .filters .filter select {
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
padding: 2px;
|
||||
|
|
@ -916,11 +975,26 @@ html[dir="rtl"] .pac-container .pac-item {
|
|||
float: none;
|
||||
/* potential fix for media popup? */
|
||||
}
|
||||
.acf-relationship .filters .filter:focus,
|
||||
.acf-relationship .filters .filter:active {
|
||||
.acf-relationship .filters .filter input:focus,
|
||||
.acf-relationship .filters .filter select:focus,
|
||||
.acf-relationship .filters .filter input:active,
|
||||
.acf-relationship .filters .filter select:active {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.acf-relationship .filters .filter input {
|
||||
border-color: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
.acf-relationship .filters.-f2 .filter {
|
||||
width: 50%;
|
||||
}
|
||||
.acf-relationship .filters.-f3 .filter {
|
||||
width: 25%;
|
||||
}
|
||||
.acf-relationship .filters.-f3 .filter.-search {
|
||||
width: 50%;
|
||||
}
|
||||
.acf-relationship .list {
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
|
|
@ -1007,6 +1081,11 @@ html[dir="rtl"] .pac-container .pac-item {
|
|||
/* choices */
|
||||
/* values */
|
||||
}
|
||||
.acf-relationship .selection:after {
|
||||
clear: both;
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
.acf-relationship .selection .values,
|
||||
.acf-relationship .selection .choices {
|
||||
width: 50%;
|
||||
|
|
@ -1086,135 +1165,104 @@ html[dir="rtl"] .acf-relationship .selection .values .acf-icon {
|
|||
.acf-field-tab {
|
||||
display: none !important;
|
||||
}
|
||||
.acf-field-tab + .acf-field {
|
||||
border-top-width: 0px;
|
||||
.hidden-by-tab {
|
||||
display: none !important;
|
||||
}
|
||||
.acf-tab-wrap {
|
||||
clear: both;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
.acf-tab-wrap:first-child {
|
||||
margin: 0;
|
||||
}
|
||||
.acf-tab-group {
|
||||
border-bottom: #ccc solid 1px;
|
||||
padding: 0 5px 0 10px;
|
||||
position: relative;
|
||||
margin-bottom: -1px;
|
||||
z-index: 1;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-tab-group {
|
||||
padding: 0 10px 0 5px;
|
||||
padding: 10px 10px 0;
|
||||
}
|
||||
.acf-tab-group li {
|
||||
margin: 0 5px 0 0;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-tab-group li {
|
||||
margin: 0 0 0 5px;
|
||||
margin: 0 0 0 0.5em;
|
||||
/* rtl */
|
||||
/* first */
|
||||
/* active */
|
||||
}
|
||||
.acf-tab-group li a {
|
||||
padding: 6px 10px;
|
||||
padding: 5px 10px;
|
||||
display: block;
|
||||
color: #555555;
|
||||
color: #555;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
font-weight: 600;
|
||||
line-height: 24px;
|
||||
border: #ccc solid 1px;
|
||||
border-bottom: 0 none;
|
||||
text-decoration: none;
|
||||
background: #F1F1F1;
|
||||
border-radius: 3px 3px 0 0;
|
||||
background: #e5e5e5;
|
||||
transition: none;
|
||||
}
|
||||
.acf-tab-group li a:hover {
|
||||
background: #FFFFFF;
|
||||
background: #FFF;
|
||||
}
|
||||
.acf-tab-group li a:focus {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
html[dir="rtl"] .acf-tab-group li {
|
||||
margin: 0 0.5em 0 0;
|
||||
}
|
||||
.acf-tab-group li:first-child {
|
||||
margin: 0 !important;
|
||||
}
|
||||
.acf-tab-group li.active a {
|
||||
background: #F1F1F1;
|
||||
color: #000;
|
||||
border-color: #CCCCCC;
|
||||
border-bottom-color: #F7F7F7;
|
||||
padding-bottom: 7px;
|
||||
padding-bottom: 6px;
|
||||
margin-bottom: -1px;
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
.hidden-by-tab {
|
||||
display: none !important;
|
||||
}
|
||||
.compat-item .acf-tab-wrap td {
|
||||
display: block;
|
||||
}
|
||||
/* acf-fields */
|
||||
/* inside acf-fields */
|
||||
.acf-fields > .acf-tab-wrap {
|
||||
background: #F9F9F9;
|
||||
margin: 0;
|
||||
}
|
||||
.acf-fields > .acf-tab-wrap .acf-tab-group {
|
||||
padding-top: 10px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
margin-bottom: -1px;
|
||||
border-top: #DFDFDF solid 1px;
|
||||
border-bottom: #DFDFDF solid 1px;
|
||||
}
|
||||
.acf-fields > .acf-tab-wrap:first-child .acf-tab-group {
|
||||
border-top-width: 0;
|
||||
.acf-fields > .acf-tab-wrap .acf-tab-group li a {
|
||||
background: #f1f1f1;
|
||||
}
|
||||
.acf-fields > .acf-tab-wrap .acf-tab-group li a:hover {
|
||||
background: #FFF;
|
||||
}
|
||||
.acf-fields > .acf-tab-wrap .acf-tab-group li.active a {
|
||||
background: #FFFFFF;
|
||||
}
|
||||
/* left aligned labels */
|
||||
.acf-fields > .acf-tab-wrap:first-child .acf-tab-group {
|
||||
border-top: none;
|
||||
}
|
||||
/* inside acf-fields.-left */
|
||||
.acf-fields.-left > .acf-tab-wrap .acf-tab-group {
|
||||
padding-left: 24%;
|
||||
padding-left: 20%;
|
||||
/* mobile */
|
||||
/* rtl */
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-fields.-left > .acf-tab-wrap .acf-tab-group {
|
||||
padding-left: 5px;
|
||||
padding-right: 24%;
|
||||
.acf-fields.-left > .acf-tab-wrap .acf-tab-group li:first-child {
|
||||
margin: 0;
|
||||
}
|
||||
/* mobile */
|
||||
@media screen and (max-width: 782px) {
|
||||
@media screen and (max-width: 850px) {
|
||||
.acf-fields.-left > .acf-tab-wrap .acf-tab-group {
|
||||
padding-left: 10px;
|
||||
}
|
||||
/* rtl */
|
||||
}
|
||||
html[dir="rtl"] .acf-fields.-left > .acf-tab-wrap .acf-tab-group {
|
||||
padding-left: 0;
|
||||
padding-right: 20%;
|
||||
/* mobile */
|
||||
}
|
||||
@media screen and (max-width: 850px) {
|
||||
html[dir="rtl"] .acf-fields.-left > .acf-tab-wrap .acf-tab-group {
|
||||
padding-left: 5px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
}
|
||||
/* sidebar */
|
||||
.acf-fields.-sidebar {
|
||||
padding-left: 150px !important;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-fields.-sidebar {
|
||||
padding-right: 150px !important;
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
.acf-fields.-sidebar:before {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 149px;
|
||||
height: 100%;
|
||||
border-right: #DFDFDF solid 1px;
|
||||
background: #F9F9F9;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-fields.-sidebar:before {
|
||||
border-left: #CCCCCC solid 1px;
|
||||
border-right-width: 0;
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
/* left */
|
||||
/* space between field and tabs */
|
||||
.acf-field + .acf-tab-wrap.-left:before {
|
||||
content: "";
|
||||
display: block;
|
||||
|
|
@ -1225,132 +1273,138 @@ html[dir="rtl"] .acf-fields.-sidebar:before {
|
|||
width: 100%;
|
||||
height: 1px;
|
||||
}
|
||||
.acf-tab-wrap.-left .acf-tab-group {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 150px;
|
||||
border: 0 none;
|
||||
padding: 0 !important;
|
||||
/* important overrides 'left aligned labels' */
|
||||
margin: 1px 0 0;
|
||||
/* sidebar */
|
||||
.acf-fields.-sidebar {
|
||||
padding: 0 0 0 20% !important;
|
||||
position: relative;
|
||||
/* before */
|
||||
/* rtl */
|
||||
/* tab wrap left */
|
||||
/* .acf-fields.-left */
|
||||
/* first tab group */
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-tab-wrap.-left .acf-tab-group {
|
||||
.acf-fields.-sidebar:before {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 20%;
|
||||
bottom: 0;
|
||||
border-right: #DFDFDF solid 1px;
|
||||
background: #F9F9F9;
|
||||
z-index: 1;
|
||||
}
|
||||
html[dir="rtl"] .acf-fields.-sidebar {
|
||||
padding: 0 20% 0 0 !important;
|
||||
}
|
||||
html[dir="rtl"] .acf-fields.-sidebar:before {
|
||||
border-left: #DFDFDF solid 1px;
|
||||
border-right-width: 0;
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
.acf-tab-wrap.-left .acf-tab-group li {
|
||||
.acf-fields.-sidebar > .acf-tab-wrap.-left .acf-tab-group {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 20%;
|
||||
border: 0 none;
|
||||
padding: 0 !important;
|
||||
/* important overrides 'left aligned labels' */
|
||||
margin: 0;
|
||||
/* rtl */
|
||||
}
|
||||
html[dir="rtl"] .acf-fields.-sidebar > .acf-tab-wrap.-left .acf-tab-group {
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
.acf-fields.-sidebar > .acf-tab-wrap.-left .acf-tab-group li {
|
||||
float: none;
|
||||
margin: -1px 0 0;
|
||||
}
|
||||
.acf-tab-wrap.-left .acf-tab-group li a {
|
||||
border: 1px solid #DFDFDF;
|
||||
.acf-fields.-sidebar > .acf-tab-wrap.-left .acf-tab-group li a {
|
||||
border: 1px solid #ededed;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
color: #0074a2;
|
||||
color: #0073aa;
|
||||
padding: 10px;
|
||||
font-weight: normal;
|
||||
border-width: 1px 0;
|
||||
margin-right: 1px;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.acf-tab-wrap.-left .acf-tab-group li.active a {
|
||||
.acf-fields.-sidebar > .acf-tab-wrap.-left .acf-tab-group li a:hover {
|
||||
color: #00a0d2;
|
||||
}
|
||||
.acf-fields.-sidebar > .acf-tab-wrap.-left .acf-tab-group li.active a {
|
||||
border-color: #DFDFDF;
|
||||
color: #000;
|
||||
margin-right: 0;
|
||||
margin-right: -1px;
|
||||
background: #fff;
|
||||
}
|
||||
.acf-tab-wrap.-left:first-child .acf-tab-group li:first-child a {
|
||||
border-top-width: 0;
|
||||
html[dir="rtl"] .acf-fields.-sidebar > .acf-tab-wrap.-left .acf-tab-group li.active a {
|
||||
margin-right: 0;
|
||||
margin-left: -1px;
|
||||
}
|
||||
/* sidebar + left (.acf-fields.-left.-sidebar) */
|
||||
.acf-fields.-left.-sidebar:before {
|
||||
.acf-fields.-sidebar.-left {
|
||||
padding: 0 0 0 180px !important;
|
||||
/* rtl */
|
||||
}
|
||||
html[dir="rtl"] .acf-fields.-sidebar.-left {
|
||||
padding: 0 180px 0 0 !important;
|
||||
}
|
||||
.acf-fields.-sidebar.-left:before {
|
||||
background: #F1F1F1;
|
||||
border-color: #dfdfdf;
|
||||
width: 180px;
|
||||
}
|
||||
.acf-fields.-left.-sidebar > .acf-tab-wrap.-left li.active a {
|
||||
.acf-fields.-sidebar.-left .acf-tab-wrap.-left .acf-tab-group {
|
||||
width: 180px;
|
||||
}
|
||||
.acf-fields.-sidebar.-left .acf-tab-wrap.-left .acf-tab-group li a {
|
||||
border-color: #e4e4e4;
|
||||
}
|
||||
.acf-fields.-sidebar.-left .acf-tab-wrap.-left .acf-tab-group li.active a {
|
||||
background: #F9F9F9;
|
||||
}
|
||||
/* seamless */
|
||||
.acf-postbox.seamless > .acf-fields.-sidebar {
|
||||
padding: 0 0 0 162px !important;
|
||||
.acf-fields.-sidebar .acf-tab-wrap.-left:first-child .acf-tab-group li:first-child a {
|
||||
border-top-width: 0;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-postbox.seamless > .acf-fields.-sidebar {
|
||||
padding: 0 162px 0 0 !important;
|
||||
/* seamless */
|
||||
.acf-postbox.seamless {
|
||||
/* standard */
|
||||
/* left label */
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap {
|
||||
background: transparent;
|
||||
margin: 20px 0 0 -12px;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-postbox.seamless > .acf-fields > .acf-tab-wrap {
|
||||
margin: 20px -12px 0 0;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap .acf-tab-group {
|
||||
border-top: 0 none;
|
||||
padding-left: 12px;
|
||||
border-color: #ccc;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-postbox.seamless > .acf-fields > .acf-tab-wrap .acf-tab-group {
|
||||
padding-left: 5px;
|
||||
padding-right: 12px;
|
||||
background: #f1f1f1;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap .acf-tab-group li a {
|
||||
background: #E4E4E4;
|
||||
background: #e5e5e5;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap .acf-tab-group li a:hover {
|
||||
background: #fff;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap .acf-tab-group li.active a {
|
||||
background: #F1F1F1;
|
||||
border-color: #ccc;
|
||||
background: #f1f1f1;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left {
|
||||
height: 1px;
|
||||
.acf-postbox.seamless > .acf-fields.-left {
|
||||
/* left label, top tab */
|
||||
/* left label, left tab */
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left:before {
|
||||
background: #ccc;
|
||||
.acf-postbox.seamless > .acf-fields.-left .acf-tab-wrap.-left .acf-tab-group {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left .acf-tab-group li a {
|
||||
border-left-width: 1px;
|
||||
background: #F1F1F1;
|
||||
.acf-postbox.seamless > .acf-fields.-left .acf-tab-wrap.-left .acf-tab-group li a {
|
||||
border-width: 1px 0 1px 1px !important;
|
||||
border-color: #cccccc;
|
||||
background: #e5e5e5;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left .acf-tab-group li a {
|
||||
border-left-width: 0;
|
||||
border-right-width: 1px;
|
||||
.acf-postbox.seamless > .acf-fields.-left .acf-tab-wrap.-left .acf-tab-group li.active a {
|
||||
background: #f1f1f1;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left .acf-tab-group li.active a {
|
||||
border-color: #ccc;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left .acf-tab-group li:first-child a {
|
||||
border-radius: 3px 0 0 0;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left .acf-tab-group li:first-child a {
|
||||
border-radius: 0 3px 0 0;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left .acf-tab-group li:last-child a {
|
||||
border-radius: 0 0 0 3px;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left .acf-tab-group li:last-child a {
|
||||
border-radius: 0 0 3px 0;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left .acf-tab-group li:first-child:last-child a {
|
||||
border-radius: 3px 0 0 3px;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left .acf-tab-group li:first-child:last-child a {
|
||||
border-radius: 0 3px 3px 0;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields > .acf-tab-wrap.-left:first-child .acf-tab-group li:first-child a {
|
||||
border-top-width: 1px;
|
||||
}
|
||||
.acf-postbox.seamless > .acf-fields.-sidebar:before {
|
||||
background: transparent;
|
||||
border-color: #ccc;
|
||||
.compat-item .acf-tab-wrap td {
|
||||
display: block;
|
||||
}
|
||||
/* within gallery sidebar */
|
||||
.acf-gallery-side .acf-tab-wrap {
|
||||
|
|
@ -1527,6 +1581,11 @@ html[dir="rtl"] .form-table > tbody > tr.acf-tab-wrap .acf-tab-group {
|
|||
.acf-image-uploader {
|
||||
position: relative;
|
||||
}
|
||||
.acf-image-uploader:after {
|
||||
clear: both;
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
.acf-image-uploader .view {
|
||||
float: left;
|
||||
position: relative;
|
||||
|
|
@ -1647,11 +1706,28 @@ html[dir="rtl"] .acf-file-uploader .file-info ul {
|
|||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Clone field
|
||||
* Separator field
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
.acf-clone-fields {
|
||||
border: #dfdfdf solid 1px;
|
||||
.acf-field-separator {
|
||||
/* fields */
|
||||
/* sidebar */
|
||||
}
|
||||
.acf-field-separator .acf-label {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.acf-field-separator .acf-label label {
|
||||
font-weight: normal;
|
||||
}
|
||||
.acf-field-separator .acf-input {
|
||||
display: none;
|
||||
}
|
||||
.acf-fields > .acf-field-separator {
|
||||
background: #f9f9f9;
|
||||
border-bottom: 1px solid #dfdfdf;
|
||||
border-top: 1px solid #dfdfdf;
|
||||
margin-bottom: -1px;
|
||||
z-index: 2;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
|
|
@ -2168,6 +2244,77 @@ p.submit .acf-spinner {
|
|||
.customize-control .acf-field {
|
||||
margin: 1em 0;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Nav Menu
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
.acf-menu-settings {
|
||||
border-top: 1px solid #eee;
|
||||
margin-top: 2em;
|
||||
/* fields */
|
||||
/* seamless */
|
||||
}
|
||||
.acf-menu-settings > .acf-fields > .acf-field {
|
||||
padding-left: 20%;
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
.acf-menu-settings > .acf-fields > .acf-field > .acf-label {
|
||||
width: 25%;
|
||||
margin-left: -25%;
|
||||
}
|
||||
.acf-menu-settings > .acf-fields > .acf-field > .acf-label label {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
.acf-menu-settings.-seamless {
|
||||
border-top: none;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.acf-menu-settings.-seamless > h2 {
|
||||
display: none;
|
||||
}
|
||||
.menu-item-settings {
|
||||
/* fields */
|
||||
}
|
||||
.menu-item-settings > .field-acf > .acf-field {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
.menu-item-settings > .field-acf > .acf-field > .acf-label {
|
||||
margin: 0;
|
||||
}
|
||||
.menu-item-settings > .field-acf > .acf-field > .acf-label label {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Confirm remove
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
.acf-temp-remove {
|
||||
position: relative;
|
||||
opacity: 1;
|
||||
-webkit-transition: all 0.25s ease;
|
||||
-moz-transition: all 0.25s ease;
|
||||
-o-transition: all 0.25s ease;
|
||||
transition: all 0.25s ease;
|
||||
overflow: hidden;
|
||||
/* overlay prevents hover */
|
||||
}
|
||||
.acf-temp-remove:after {
|
||||
display: block;
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 99;
|
||||
}
|
||||
/*--------------------------------------------------------------------------
|
||||
*
|
||||
* Conditional Logic
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ Font license info
|
|||
|
||||
## Font Awesome
|
||||
|
||||
Copyright (C) 2012 by Dave Gandy
|
||||
Copyright (C) 2016 by Dave Gandy
|
||||
|
||||
Author: Dave Gandy
|
||||
License: SIL ()
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ This webfont is generated by http://fontello.com open source project.
|
|||
|
||||
|
||||
================================================================================
|
||||
Please, note, that you should obey original font licences, used to make this
|
||||
Please, note, that you should obey original font licenses, used to make this
|
||||
webfont pack. Details available in LICENSE.txt file.
|
||||
|
||||
- Usually, it's enough to publish content of LICENSE.txt file somewhere on your
|
||||
site in "About" section.
|
||||
|
||||
- If your project is open-source, usually, it will be ok to make LICENSE.txt
|
||||
file publically available in your repository.
|
||||
file publicly available in your repository.
|
||||
|
||||
- Fonts, used in Fontello, don't require a clickable link on your site.
|
||||
But any kind of additional authors crediting is welcome.
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,29 +1,48 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Copyright (C) 2015 by original authors @ fontello.com</metadata>
|
||||
<metadata>Copyright (C) 2017 by original authors @ fontello.com</metadata>
|
||||
<defs>
|
||||
<font id="acf" horiz-adv-x="1000" >
|
||||
<font-face font-family="acf" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
|
||||
<missing-glyph horiz-adv-x="1000" />
|
||||
<glyph glyph-name="plus" unicode="" d="m550 400q30 0 30-50t-30-50l-210 0 0-210q0-30-50-30t-50 30l0 210-210 0q-30 0-30 50t30 50l210 0 0 210q0 30 50 30t50-30l0-210 210 0z" horiz-adv-x="580" />
|
||||
<glyph glyph-name="minus" unicode="" d="m550 400q30 0 30-50t-30-50l-520 0q-30 0-30 50t30 50l520 0z" horiz-adv-x="580" />
|
||||
<glyph glyph-name="cancel" unicode="" d="m452 194q18-18 18-43t-18-43q-18-16-43-16t-43 16l-132 152-132-152q-18-16-43-16t-43 16q-16 18-16 43t16 43l138 156-138 158q-16 18-16 43t16 43q18 16 43 16t43-16l132-152 132 152q18 16 43 16t43-16q18-18 18-43t-18-43l-138-158z" horiz-adv-x="470" />
|
||||
<glyph glyph-name="pencil" unicode="" d="m938 605q22-22 22-55t-22-55l-570-570q-22-21-60-38t-73-17l-235 0 0 234q0 35 17 74t38 60l570 570q23 22 55 22t55-22z m-794-426l65-64 431 433-64 63z m91-205q14 0 33 8-10 10-27 26t-50 50-56 56l-22 22q-9-21-9-32l0-78 52-52 79 0z m74 40l432 432-63 64-433-431z m469 469l67 67-165 165-67-66z" horiz-adv-x="960" />
|
||||
<glyph glyph-name="location" unicode="" d="m250 750q104 0 177-73t73-177q0-106-62-243t-126-223l-62-84q-10 12-27 35t-60 89-76 130-60 147-27 149q0 104 73 177t177 73z m0-388q56 0 96 40t40 96-40 95-96 39-95-39-39-95 39-96 95-40z" horiz-adv-x="500" />
|
||||
<glyph glyph-name="down" unicode="" d="m564 422l-234-224q-18-18-40-18t-40 18l-234 224q-16 16-16 41t16 41q38 38 78 0l196-188 196 188q40 38 78 0 16-16 16-41t-16-41z" horiz-adv-x="580" />
|
||||
<glyph glyph-name="left" unicode="" d="m242 626q14 16 39 16t41-16q38-36 0-80l-186-196 186-194q38-44 0-80-16-16-40-16t-40 16l-226 236q-16 16-16 38 0 24 16 40 206 214 226 236z" horiz-adv-x="341" />
|
||||
<glyph glyph-name="right" unicode="" d="m98 626l226-236q16-16 16-40 0-22-16-38l-226-236q-16-16-40-16t-40 16q-36 36 0 80l186 194-186 196q-36 44 0 80 16 16 41 16t39-16z" horiz-adv-x="340" />
|
||||
<glyph glyph-name="up" unicode="" d="m564 280q16-16 16-41t-16-41q-38-38-78 0l-196 188-196-188q-40-38-78 0-16 16-16 41t16 41l234 224q16 16 40 16t40-16z" horiz-adv-x="580" />
|
||||
<glyph glyph-name="sync" unicode="" d="m843 261q0-3 0-4-36-150-150-243t-267-93q-81 0-157 31t-136 88l-72-72q-11-11-25-11t-25 11-11 25v250q0 14 11 25t25 11h250q14 0 25-11t10-25-10-25l-77-77q40-37 90-57t105-20q74 0 139 37t104 99q6 10 29 66 5 13 17 13h107q8 0 13-6t5-12z m14 446v-250q0-14-10-25t-26-11h-250q-14 0-25 11t-10 25 10 25l77 77q-82 77-194 77-75 0-140-37t-104-99q-6-10-29-66-5-13-17-13h-111q-7 0-13 6t-5 12v4q36 150 151 243t268 93q81 0 158-31t137-88l72 72q11 11 25 11t26-11 10-25z" horiz-adv-x="857.1" />
|
||||
<glyph glyph-name="globe" unicode="" d="m480 830q200 0 340-141t140-339q0-200-140-340t-340-140q-198 0-339 140t-141 340q0 198 141 339t339 141z m410-480q0 132-78 239t-202 149q-18-24-16-32 4-38 18-51t30-7l32 12t20 2q22-24 0-47t-45-56-1-77q34-64 96-64 28-2 43-36t17-66q10-80-14-140-22-44 14-76 86 112 86 250z m-466 404q-112-14-199-84t-127-174q6 0 22-2t28-3 26-4 24-8 12-13q4-12-14-45t-18-61q0-30 38-56t38-46q0-28 8-68t8-44q0-12 36-54t52-42q10 0 11 22t-2 54-3 40q0 32 14 74 12 42 59 70t55 46q16 34 9 61t-17 43-34 28-41 17-37 9-22 4q-16 6-42 7t-36-3-27 11-17 29q0 10 15 27t35 37 28 30q8 14 17 21t22 16 27 21q4 4 25 17t27 23z m-72-794q66-20 128-20 128 0 226 68-26 44-118 34-24-2-65-17t-47-17q-74-16-76-16-12-2-26-14t-22-18z" horiz-adv-x="960" />
|
||||
<glyph glyph-name="picture" unicode="" d="m0-68l0 836 1000 0 0-836-1000 0z m76 78l848 0 0 680-848 0 0-680z m90 80l0 59 150 195 102-86 193 291 223-228 0-231-668 0z m0 416q0 37 24 62t62 24q33 0 58-24t24-62q0-33-24-57t-58-25q-37 0-62 25t-24 57z" horiz-adv-x="1000" />
|
||||
<glyph glyph-name="check" unicode="" d="m249 0q-34 0-56 28l-180 236q-16 24-12 52t26 46 51 14 47-28l118-154 296 474q16 24 43 30t53-8q24-16 30-43t-8-53l-350-560q-20-32-56-32z" horiz-adv-x="667" />
|
||||
<glyph glyph-name="dot-3" unicode="" d="m110 460q46 0 78-32t32-78q0-44-32-77t-78-33-78 33-32 77q0 46 32 78t78 32z m350 0q46 0 78-32t32-78q0-44-33-77t-77-33-77 33-33 77q0 46 32 78t78 32z m350 0q46 0 78-32t32-78q0-44-32-77t-78-33-78 33-32 77q0 46 32 78t78 32z" horiz-adv-x="920" />
|
||||
<glyph glyph-name="arrow-combo" unicode="" d="m230 850l230-364-460 0z m0-1000l-230 366 460 0z" horiz-adv-x="460" />
|
||||
<glyph glyph-name="arrow-down" unicode="" d="m540 587l-269-473-271 473 540 0z" horiz-adv-x="540" />
|
||||
<glyph glyph-name="arrow-up" unicode="" d="m0 114l269 473 271-473-540 0z" horiz-adv-x="540" />
|
||||
<glyph glyph-name="search" unicode="" d="m772 78q30-34 6-62l-46-46q-36-32-68 0l-190 190q-74-42-156-42-128 0-223 95t-95 223 90 219 218 91 224-95 96-223q0-88-46-162z m-678 358q0-88 68-156t156-68 151 63 63 153q0 88-68 155t-156 67-151-63-63-151z" horiz-adv-x="789" />
|
||||
<glyph glyph-name="plus" unicode="" d="M550 400q30 0 30-50t-30-50l-210 0 0-210q0-30-50-30t-50 30l0 210-210 0q-30 0-30 50t30 50l210 0 0 210q0 30 50 30t50-30l0-210 210 0z" horiz-adv-x="580" />
|
||||
|
||||
<glyph glyph-name="minus" unicode="" d="M550 400q30 0 30-50t-30-50l-520 0q-30 0-30 50t30 50l520 0z" horiz-adv-x="580" />
|
||||
|
||||
<glyph glyph-name="cancel" unicode="" d="M452 194q18-18 18-43t-18-43q-18-16-43-16t-43 16l-132 152-132-152q-18-16-43-16t-43 16q-16 18-16 43t16 43l138 156-138 158q-16 18-16 43t16 43q18 16 43 16t43-16l132-152 132 152q18 16 43 16t43-16q18-18 18-43t-18-43l-138-158z" horiz-adv-x="470" />
|
||||
|
||||
<glyph glyph-name="pencil" unicode="" d="M938 605q22-22 22-55t-22-55l-570-570q-22-21-60-38t-73-17l-235 0 0 234q0 35 17 74t38 60l570 570q23 22 55 22t55-22z m-794-426l65-64 431 433-64 63z m91-205q14 0 33 8-10 10-27 26t-50 50-56 56l-22 22q-9-21-9-32l0-78 52-52 79 0z m74 40l432 432-63 64-433-431z m469 469l67 67-165 165-67-66z" horiz-adv-x="960" />
|
||||
|
||||
<glyph glyph-name="location" unicode="" d="M250 750q104 0 177-73t73-177q0-106-62-243t-126-223l-62-84q-10 12-27 35t-60 89-76 130-60 147-27 149q0 104 73 177t177 73z m0-388q56 0 96 40t40 96-40 95-96 39-95-39-39-95 39-96 95-40z" horiz-adv-x="500" />
|
||||
|
||||
<glyph glyph-name="down" unicode="" d="M564 422l-234-224q-18-18-40-18t-40 18l-234 224q-16 16-16 41t16 41q38 38 78 0l196-188 196 188q40 38 78 0 16-16 16-41t-16-41z" horiz-adv-x="580" />
|
||||
|
||||
<glyph glyph-name="left" unicode="" d="M242 626q14 16 39 16t41-16q38-36 0-80l-186-196 186-194q38-44 0-80-16-16-40-16t-40 16l-226 236q-16 16-16 38 0 24 16 40 206 214 226 236z" horiz-adv-x="341" />
|
||||
|
||||
<glyph glyph-name="right" unicode="" d="M98 626l226-236q16-16 16-40 0-22-16-38l-226-236q-16-16-40-16t-40 16q-36 36 0 80l186 194-186 196q-36 44 0 80 16 16 41 16t39-16z" horiz-adv-x="340" />
|
||||
|
||||
<glyph glyph-name="up" unicode="" d="M564 280q16-16 16-41t-16-41q-38-38-78 0l-196 188-196-188q-40-38-78 0-16 16-16 41t16 41l234 224q16 16 40 16t40-16z" horiz-adv-x="580" />
|
||||
|
||||
<glyph glyph-name="sync" unicode="" d="M843 261q0-3 0-4-36-150-150-243t-267-93q-81 0-157 31t-136 88l-72-72q-11-11-25-11t-25 11-11 25v250q0 14 11 25t25 11h250q14 0 25-11t10-25-10-25l-77-77q40-36 90-57t105-20q74 0 139 37t104 99q6 10 30 66 4 13 16 13h107q8 0 13-6t5-12z m14 446v-250q0-14-10-25t-26-11h-250q-14 0-25 11t-10 25 10 25l77 77q-82 77-194 77-75 0-140-37t-104-99q-6-10-29-66-5-13-17-13h-111q-7 0-13 6t-5 12v4q36 150 151 243t268 93q81 0 158-31t137-88l72 72q11 11 25 11t26-11 10-25z" horiz-adv-x="857.1" />
|
||||
|
||||
<glyph glyph-name="globe" unicode="" d="M480 830q200 0 340-141t140-339q0-200-140-340t-340-140q-198 0-339 140t-141 340q0 198 141 339t339 141z m410-480q0 132-78 239t-202 149q-18-24-16-32 4-38 18-51t30-7l32 12t20 2q22-24 0-47t-45-56-1-77q34-64 96-64 28-2 43-36t17-66q10-80-14-140-22-44 14-76 86 112 86 250z m-466 404q-112-14-199-84t-127-174q6 0 22-2t28-3 26-4 24-8 12-13q4-12-14-45t-18-61q0-30 38-56t38-46q0-28 8-68t8-44q0-12 36-54t52-42q10 0 11 22t-2 54-3 40q0 32 14 74 12 42 59 70t55 46q16 34 9 61t-17 43-34 28-41 17-37 9-22 4q-16 6-42 7t-36-3-27 11-17 29q0 10 15 27t35 37 28 30q8 14 17 21t22 16 27 21q4 4 25 17t27 23z m-72-794q66-20 128-20 128 0 226 68-26 44-118 34-24-2-65-17t-47-17q-74-16-76-16-12-2-26-14t-22-18z" horiz-adv-x="960" />
|
||||
|
||||
<glyph glyph-name="picture" unicode="" d="M0-68l0 836 1000 0 0-836-1000 0z m76 78l848 0 0 680-848 0 0-680z m90 80l0 59 150 195 102-86 193 291 223-228 0-231-668 0z m0 416q0 37 24 62t62 24q33 0 58-24t24-62q0-33-24-57t-58-25q-37 0-62 25t-24 57z" horiz-adv-x="1000" />
|
||||
|
||||
<glyph glyph-name="check" unicode="" d="M249 0q-34 0-56 28l-180 236q-16 24-12 52t26 46 51 14 47-28l118-154 296 474q16 24 43 30t53-8q24-16 30-43t-8-53l-350-560q-20-32-56-32z" horiz-adv-x="667" />
|
||||
|
||||
<glyph glyph-name="dot-3" unicode="" d="M110 460q46 0 78-32t32-78q0-44-32-77t-78-33-78 33-32 77q0 46 32 78t78 32z m350 0q46 0 78-32t32-78q0-44-33-77t-77-33-77 33-33 77q0 46 32 78t78 32z m350 0q46 0 78-32t32-78q0-44-32-77t-78-33-78 33-32 77q0 46 32 78t78 32z" horiz-adv-x="920" />
|
||||
|
||||
<glyph glyph-name="arrow-combo" unicode="" d="M230 850l230-364-460 0z m0-1000l-230 366 460 0z" horiz-adv-x="460" />
|
||||
|
||||
<glyph glyph-name="arrow-down" unicode="" d="M540 587l-269-473-271 473 540 0z" horiz-adv-x="540" />
|
||||
|
||||
<glyph glyph-name="arrow-up" unicode="" d="M0 114l269 473 271-473-540 0z" horiz-adv-x="540" />
|
||||
|
||||
<glyph glyph-name="search" unicode="" d="M772 78q30-34 6-62l-46-46q-36-32-68 0l-190 190q-74-42-156-42-128 0-223 95t-95 223 90 219 218 91 224-95 96-223q0-88-46-162z m-678 358q0-88 68-156t156-68 151 63 63 153q0 88-68 155t-156 67-151-63-63-151z" horiz-adv-x="789" />
|
||||
|
||||
<glyph glyph-name="link-ext" unicode="" d="M786 332v-178q0-67-47-114t-114-47h-464q-67 0-114 47t-47 114v464q0 66 47 113t114 48h393q7 0 12-5t5-13v-36q0-8-5-13t-12-5h-393q-37 0-63-26t-27-63v-464q0-37 27-63t63-27h464q37 0 63 27t26 63v178q0 8 5 13t13 5h36q8 0 13-5t5-13z m214 482v-285q0-15-11-25t-25-11-25 11l-98 98-364-364q-5-6-13-6t-12 6l-64 64q-6 5-6 12t6 13l364 364-98 98q-11 11-11 25t11 25 25 11h285q15 0 25-11t11-25z" horiz-adv-x="1000" />
|
||||
</font>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -113,6 +113,12 @@
|
|||
"css": "picture",
|
||||
"code": 59403,
|
||||
"src": "elusive"
|
||||
},
|
||||
{
|
||||
"uid": "e15f0d620a7897e2035c18c80142f6d9",
|
||||
"css": "link-ext",
|
||||
"code": 61582,
|
||||
"src": "fontawesome"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1106,8 +1106,9 @@
|
|||
|
||||
// add to remove list
|
||||
if( id ) {
|
||||
|
||||
$('#input-delete-fields').val( $('#input-delete-fields').val() + '|' + id );
|
||||
|
||||
var $input = $('#_acf_delete_fields');
|
||||
$input.val( $input.val() + '|' + id );
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1998,10 +1999,10 @@
|
|||
acf.field_group.locations = acf.model.extend({
|
||||
|
||||
events: {
|
||||
'click .add-location-rule': 'add_rule',
|
||||
'click .add-location-group': 'add_group',
|
||||
'click .remove-location-rule': 'remove_rule',
|
||||
'change .location-rule-param': 'change_rule'
|
||||
'click .add-location-rule': 'add_rule',
|
||||
'click .add-location-group': 'add_group',
|
||||
'click .remove-location-rule': 'remove_rule',
|
||||
'change .refresh-location-rule': 'change_rule'
|
||||
},
|
||||
|
||||
|
||||
|
|
@ -2118,34 +2119,37 @@
|
|||
change_rule: function( e ){
|
||||
|
||||
// vars
|
||||
var $select = e.$el,
|
||||
$tr = $select.closest('tr'),
|
||||
rule_id = $tr.attr('data-id'),
|
||||
$group = $tr.closest('.rule-group'),
|
||||
group_id = $group.attr('data-id');
|
||||
var $rule = e.$el.closest('tr');
|
||||
var $group = $rule.closest('.rule-group');
|
||||
var prefix = $rule.find('td.param select').attr('name').replace('[param]', '');
|
||||
|
||||
|
||||
// add loading gif
|
||||
var $div = $('<div class="acf-loading"></div>');
|
||||
|
||||
$tr.find('td.value').html( $div );
|
||||
// ajax data
|
||||
var ajaxdata = {
|
||||
action: 'acf/field_group/render_location_rule',
|
||||
rule: acf.serialize( $rule, prefix ),
|
||||
};
|
||||
|
||||
|
||||
// load location html
|
||||
// append to data
|
||||
ajaxdata.rule.id = $rule.attr('data-id');
|
||||
ajaxdata.rule.group = $group.attr('data-id');
|
||||
|
||||
|
||||
// ajax
|
||||
$.ajax({
|
||||
url: acf.get('ajaxurl'),
|
||||
data: acf.prepare_for_ajax({
|
||||
'action': 'acf/field_group/render_location_value',
|
||||
'rule_id': rule_id,
|
||||
'group_id': group_id,
|
||||
'param': $select.val(),
|
||||
'value': ''
|
||||
}),
|
||||
data: acf.prepare_for_ajax(ajaxdata),
|
||||
type: 'post',
|
||||
dataType: 'html',
|
||||
success: function(html){
|
||||
|
||||
$div.replaceWith(html);
|
||||
success: function( html ){
|
||||
|
||||
// bail early if no html
|
||||
if( !html ) return;
|
||||
|
||||
|
||||
// update
|
||||
$rule.replaceWith( html );
|
||||
|
||||
}
|
||||
});
|
||||
|
|
@ -2563,6 +2567,51 @@
|
|||
});
|
||||
|
||||
|
||||
/*
|
||||
* Radio
|
||||
*
|
||||
* This field type requires some extra logic for its settings
|
||||
*
|
||||
* @type function
|
||||
* @date 24/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
var acf_settings_checkbox = acf.field_group.field_object.extend({
|
||||
|
||||
type: 'checkbox',
|
||||
|
||||
actions: {
|
||||
'render_settings': 'render'
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .acf-field-setting-allow_custom input': 'render'
|
||||
},
|
||||
|
||||
render: function( $el ){
|
||||
|
||||
// other_choice checked
|
||||
if( this.setting('allow_custom input[type="checkbox"]').prop('checked') ) {
|
||||
|
||||
this.setting('save_custom').show();
|
||||
|
||||
// other_choice not checked
|
||||
} else {
|
||||
|
||||
this.setting('save_custom').hide();
|
||||
this.setting('save_custom input[type="checkbox"]').prop('checked', false).trigger('change');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* True false
|
||||
*
|
||||
|
|
@ -2822,11 +2871,7 @@
|
|||
render: function(){
|
||||
|
||||
// vars
|
||||
var options = acf.serialize_form( $('#adv-settings') );
|
||||
|
||||
|
||||
// convert types
|
||||
options.show_field_keys = parseInt(options.show_field_keys);
|
||||
var options = acf.serialize( $('#adv-settings') );
|
||||
|
||||
|
||||
// toggle class
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
139
core/fields.php
139
core/fields.php
|
|
@ -1,139 +0,0 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_fields') ) :
|
||||
|
||||
class acf_fields {
|
||||
|
||||
var $types = array();
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the class functionality
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* register_field_type
|
||||
*
|
||||
* This function will store a field type class
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $instance (object)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function register_field_type( $instance ) {
|
||||
|
||||
// bail ealry if no field name
|
||||
if( !$instance->name ) return false;
|
||||
|
||||
|
||||
// bail ealry if already exists
|
||||
if( isset($this->types[ $instance->name ]) ) return false;
|
||||
|
||||
|
||||
// append
|
||||
$this->types[ $instance->name ] = $instance;
|
||||
|
||||
|
||||
// return
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_field_type
|
||||
*
|
||||
* This function will return a field type class
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $name (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function get_field_type( $name ) {
|
||||
|
||||
// bail ealry if doesn't exist
|
||||
if( !isset($this->types[ $name ]) ) return false;
|
||||
|
||||
|
||||
// return
|
||||
return $this->types[ $name ];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
acf()->fields = new acf_fields();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* acf_register_field_type
|
||||
*
|
||||
* alias of acf()->fields->register_field_type()
|
||||
*
|
||||
* @type function
|
||||
* @date 6/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_register_field_type( $instance ) {
|
||||
|
||||
return acf()->fields->register_field_type( $instance );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_type
|
||||
*
|
||||
* alias of acf()->fields->get_field_type()
|
||||
*
|
||||
* @type function
|
||||
* @date 6/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_get_field_type( $name ) {
|
||||
|
||||
return acf()->fields->get_field_type( $name );
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
1302
core/location.php
1302
core/location.php
File diff suppressed because it is too large
Load Diff
787
forms/widget.php
787
forms/widget.php
|
|
@ -1,787 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Widget Form Class
|
||||
*
|
||||
* All the logic for adding fields to widgets
|
||||
*
|
||||
* @class acf_form_widget
|
||||
* @package ACF
|
||||
* @subpackage Forms
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_form_widget') ) :
|
||||
|
||||
class acf_form_widget {
|
||||
|
||||
|
||||
/*
|
||||
* __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() {
|
||||
|
||||
// vars
|
||||
$this->preview_values = array();
|
||||
$this->preview_reference = array();
|
||||
$this->preview_errors = array();
|
||||
|
||||
|
||||
// actions
|
||||
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
||||
add_action('in_widget_form', array($this, 'edit_widget'), 10, 3);
|
||||
add_action('customize_save', array($this, 'customize_save'), 1, 1);
|
||||
add_action('customize_preview_init', array($this, 'customize_preview_init'), 1, 1);
|
||||
|
||||
|
||||
// filters
|
||||
add_filter('widget_update_callback', array($this, 'widget_update_callback'), 10, 4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 26/01/13
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// validate screen
|
||||
if( acf_is_screen('widgets') || acf_is_screen('customize') ) {
|
||||
|
||||
// valid
|
||||
|
||||
} else {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
|
||||
|
||||
// actions
|
||||
add_action('acf/input/admin_footer', array($this, 'admin_footer'), 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* edit_widget
|
||||
*
|
||||
* This function will render the fields for a widget form
|
||||
*
|
||||
* @type function
|
||||
* @date 11/06/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $widget (object)
|
||||
* @param $return (null)
|
||||
* @param $instance (object)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function edit_widget( $widget, $return, $instance ) {
|
||||
|
||||
// vars
|
||||
$post_id = 0;
|
||||
|
||||
|
||||
// get id
|
||||
if( $widget->number !== '__i__' ) {
|
||||
|
||||
$post_id = "widget_{$widget->id}";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// get field groups
|
||||
$field_groups = acf_get_field_groups(array(
|
||||
'widget' => $widget->id_base
|
||||
));
|
||||
|
||||
|
||||
// render
|
||||
if( !empty($field_groups) ) {
|
||||
|
||||
// render post data
|
||||
acf_form_data(array(
|
||||
'post_id' => $post_id,
|
||||
'nonce' => 'widget'
|
||||
));
|
||||
|
||||
|
||||
foreach( $field_groups as $field_group ) {
|
||||
|
||||
$fields = acf_get_fields( $field_group );
|
||||
|
||||
acf_render_fields( $post_id, $fields, 'div', $field_group['instruction_placement'] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// jQuery selector looks odd, but is necessary due to WP adding an incremental number into the ID
|
||||
// - not possible to find number via PHP parameters
|
||||
if( $widget->updated ): ?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
acf.do_action('append', $('[id^="widget"][id$="<?php echo $widget->id; ?>"]') );
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php endif;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* widget_update_callback
|
||||
*
|
||||
* This function will hook into the widget update filter and save ACF data
|
||||
*
|
||||
* @type function
|
||||
* @date 27/05/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $instance (array) widget settings
|
||||
* @param $new_instance (array) widget settings
|
||||
* @param $old_instance (array) widget settings
|
||||
* @param $widget (object) widget info
|
||||
* @return $instance
|
||||
*/
|
||||
|
||||
function widget_update_callback( $instance, $new_instance, $old_instance, $widget ) {
|
||||
|
||||
// bail early if empty
|
||||
if( empty($_POST['acf']) ) return $instance;
|
||||
|
||||
|
||||
// bail early if no nonce
|
||||
if( !acf_verify_nonce('widget') ) return $instance;
|
||||
|
||||
|
||||
// customizer autosave preview
|
||||
if( !empty($_POST['wp_customize']) ) {
|
||||
|
||||
return $this->customizer_widget_update_callback($instance, $new_instance, $old_instance, $widget);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail early if not valid
|
||||
if( !acf_validate_save_post() ) return $instance;
|
||||
|
||||
|
||||
// save
|
||||
acf_save_post( "widget_{$widget->id}" );
|
||||
|
||||
|
||||
// return
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* customizer_widget_update_callback
|
||||
*
|
||||
* customizer specific verison of above function
|
||||
*
|
||||
* @type function
|
||||
* @date 27/05/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $instance (array) widget settings
|
||||
* @param $new_instance (array) widget settings
|
||||
* @param $old_instance (array) widget settings
|
||||
* @param $widget (object) widget info
|
||||
* @return $instance
|
||||
*/
|
||||
|
||||
function customizer_widget_update_callback( $instance, $new_instance, $old_instance, $widget ) {
|
||||
|
||||
// bail early if not valid
|
||||
if( !acf_validate_save_post() ) {
|
||||
|
||||
// vars
|
||||
$errors = acf_get_validation_errors();
|
||||
$total = count($errors);
|
||||
|
||||
|
||||
// message
|
||||
$message = __('Validation failed', 'acf') . '. ';
|
||||
$message .= sprintf(_n( '1 field requires attention.', '%d fields require attention.', $total, 'acf' ), $total);
|
||||
|
||||
|
||||
// add missing WP JS to remove spinning
|
||||
// also set state to 'saved' which disables the save button
|
||||
$message .= '<script type="text/javascript">';
|
||||
$message .= '(function($) {';
|
||||
$message .= '$(".customize-control.previewer-loading").removeClass("previewer-loading"); ';
|
||||
$message .= 'wp.customize.state("saved").set( true ); ';
|
||||
$message .= '})(jQuery);';
|
||||
$message .= '</script>';
|
||||
|
||||
|
||||
// return JSON error
|
||||
wp_send_json_error(array(
|
||||
'message' => $message
|
||||
));
|
||||
|
||||
} else {
|
||||
|
||||
$instance['acf'] = array(
|
||||
'ID' => 'widget_' . $widget->id,
|
||||
'values' => false,
|
||||
'reference' => array()
|
||||
);
|
||||
|
||||
|
||||
// append acf $_POST data to instance
|
||||
// this allows preview JS data to contain acf values
|
||||
$instance['acf']['values'] = $_POST['acf'];
|
||||
|
||||
|
||||
// backup name => key reference
|
||||
// this will allow the customizer preview to correctly load the field when attempting to run acf_load_value and acf_format_value functions on newly added widgets
|
||||
foreach( $_POST['acf'] as $k => $v ) {
|
||||
|
||||
// get field
|
||||
$field = acf_get_field( $k );
|
||||
|
||||
|
||||
// continue if no field
|
||||
if( !$field ) continue;
|
||||
|
||||
|
||||
// update
|
||||
$instance['acf']['reference'][ $field['name'] ] = $field['key'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_customizer_widgets
|
||||
*
|
||||
* This function will return an array of widget settings
|
||||
*
|
||||
* @type function
|
||||
* @date 22/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $customizer (object)
|
||||
* @return $value (mixed)
|
||||
*/
|
||||
|
||||
function get_customizer_widgets( $customizer ) {
|
||||
|
||||
// vars
|
||||
$widgets = array();
|
||||
$settings = $customizer->settings();
|
||||
|
||||
|
||||
// bail ealry if no settings
|
||||
if( empty($settings) ) return false;
|
||||
|
||||
|
||||
// loop over settings
|
||||
foreach( array_keys($settings) as $i ) {
|
||||
|
||||
// vars
|
||||
$setting = $settings[ $i ];
|
||||
|
||||
|
||||
// bail ealry if not widget
|
||||
if( substr($setting->id, 0, 7) !== 'widget_' ) continue;
|
||||
|
||||
|
||||
// get value
|
||||
$value = $setting->post_value();
|
||||
|
||||
|
||||
// set data
|
||||
$setting->acf = acf_maybe_get($value, 'acf');
|
||||
|
||||
|
||||
// append
|
||||
$widgets[] = $setting;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail ealry if no preview values
|
||||
if( empty($widgets) ) return false;
|
||||
|
||||
|
||||
// return
|
||||
return $widgets;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* customize_preview_init
|
||||
*
|
||||
* This function is called when customizer preview is initialized
|
||||
*
|
||||
* @type function
|
||||
* @date 22/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $customizer (object)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function customize_preview_init( $customizer ) {
|
||||
|
||||
// get widgets
|
||||
$widgets = $this->get_customizer_widgets($customizer);
|
||||
|
||||
|
||||
// bail ealry if no widgets
|
||||
if( empty($widgets) ) return;
|
||||
|
||||
|
||||
// append values
|
||||
foreach( $widgets as $widget ) {
|
||||
|
||||
// bail early if no acf
|
||||
if( empty($widget->acf) ) continue;
|
||||
|
||||
|
||||
// append acf_value to preview_values
|
||||
$this->preview_values[ $widget->acf['ID'] ] = $widget->acf['values'];
|
||||
$this->preview_reference[ $widget->acf['ID'] ] = $widget->acf['reference'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail ealry if no preview_values
|
||||
if( empty($this->preview_values) ) return;
|
||||
|
||||
|
||||
// add filter
|
||||
add_filter('acf/load_value', array($this, 'load_value'), 10, 3);
|
||||
add_filter('acf/get_field_reference', array($this, 'get_field_reference'), 10, 3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_field_reference
|
||||
*
|
||||
* This function will return a field_key for a given field name + post_id
|
||||
* Normally, ACF would lookup the DB fro this connection, but a new preview widget has not yet saved anything to the DB
|
||||
*
|
||||
* @type function
|
||||
* @date 12/05/2016
|
||||
* @since 5.3.8
|
||||
*
|
||||
* @param $field_key (string)
|
||||
* @param $field_name (string)
|
||||
* @param $post_id (mixed)
|
||||
* @return $field_key
|
||||
*/
|
||||
|
||||
function get_field_reference( $field_key, $field_name, $post_id ) {
|
||||
|
||||
// look for reference
|
||||
if( isset($this->preview_reference[ $post_id ][ $field_name ]) ) {
|
||||
|
||||
$field_key = $this->preview_reference[ $post_id ][ $field_name ];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field_key;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* load_value
|
||||
*
|
||||
* This function will override a field's value with the preview_value set in previous functions
|
||||
*
|
||||
* @type function
|
||||
* @date 22/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function load_value( $value, $post_id, $field ) {
|
||||
|
||||
// acf/load_value filter is run first (before type, name, key)
|
||||
// use this filter to append to the key filter and ensure this is run last
|
||||
// could use set_cache in the future to remove this load_filter completley
|
||||
// but don't want to clog up cache with multiple widget's values
|
||||
|
||||
|
||||
// look for value
|
||||
if( isset($this->preview_values[ $post_id ][ $field['key'] ]) ) {
|
||||
|
||||
// add filter to override the $value
|
||||
add_filter('acf/load_value/key='.$field['key'], array($this, 'load_value_2'), 99, 3);
|
||||
|
||||
|
||||
// return null and prevent any DB logic from field type functions
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function load_value_2( $value, $post_id, $field ) {
|
||||
|
||||
// look for value
|
||||
$value = $this->preview_values[ $post_id ][ $field['key'] ];
|
||||
|
||||
|
||||
// remove this filter (only run once)
|
||||
remove_filter('acf/load_value/key='.$field['key'], array($this, 'load_value_2'), 99, 3);
|
||||
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* customize_save
|
||||
*
|
||||
* This function is called when customizer saves a widget.
|
||||
* Normally, the widget_update_callback filter would be used, but the customizer disables this and runs a custom action
|
||||
* class-customizer-settings.php will save the widget data via the function set_root_value which uses update_option
|
||||
*
|
||||
* @type function
|
||||
* @date 22/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $customizer (object)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function customize_save( $customizer ) {
|
||||
|
||||
// get widgets
|
||||
$widgets = $this->get_customizer_widgets($customizer);
|
||||
|
||||
|
||||
// bail ealry if no widgets
|
||||
if( empty($widgets) ) return;
|
||||
|
||||
|
||||
// append values
|
||||
foreach( $widgets as $widget ) {
|
||||
|
||||
// bail early if no acf_value
|
||||
if( !$widget->acf ) continue;
|
||||
|
||||
// fake post data
|
||||
$_POST['acf'] = $widget->acf['values'];
|
||||
|
||||
|
||||
// save
|
||||
acf_save_post( $widget->acf['ID'] );
|
||||
|
||||
|
||||
// get widget base
|
||||
$id_data = $widget->id_data();
|
||||
|
||||
|
||||
// remove [acf] data from saved widget array
|
||||
add_filter('pre_update_option_' . $id_data['base'], array($this, 'pre_update_option'), 10, 3);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* pre_update_option
|
||||
*
|
||||
* this function will remove the [acf] data from widget insance
|
||||
*
|
||||
* @type function
|
||||
* @date 22/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function pre_update_option( $value, $option, $old_value ) {
|
||||
|
||||
// bail ealry if no value
|
||||
if( empty($value) ) return $value;
|
||||
|
||||
|
||||
// loop over widgets
|
||||
// WP saves all widgets (of the same type) as an array of widgets
|
||||
foreach( $value as $i => $widget ) {
|
||||
|
||||
// bail ealry if no acf
|
||||
if( !isset($widget['acf']) ) continue;
|
||||
|
||||
|
||||
// remove widget
|
||||
unset($value[ $i ]['acf']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_footer
|
||||
*
|
||||
* This function will add some custom HTML to the footer of the edit page
|
||||
*
|
||||
* @type function
|
||||
* @date 11/06/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
acf.add_filter('get_fields', function( $fields ){
|
||||
|
||||
// widgets
|
||||
$fields = $fields.not('#available-widgets .acf-field');
|
||||
|
||||
|
||||
// customizer
|
||||
$fields = $fields.not('.widget-tpl .acf-field');
|
||||
|
||||
|
||||
// return
|
||||
return $fields;
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#widgets-right').on('click', '.widget-control-save', function( e ){
|
||||
|
||||
// vars
|
||||
var $form = $(this).closest('form');
|
||||
|
||||
|
||||
// bail early if not active
|
||||
if( !acf.validation.active ) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ignore validation (only ignore once)
|
||||
if( acf.validation.ignore ) {
|
||||
|
||||
acf.validation.ignore = 0;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail early if this form does not contain ACF data
|
||||
if( !$form.find('#acf-form-data').exists() ) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// stop WP JS validation
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
|
||||
// store submit trigger so it will be clicked if validation is passed
|
||||
acf.validation.$trigger = $(this);
|
||||
|
||||
|
||||
// run validation
|
||||
acf.validation.fetch( $form );
|
||||
|
||||
|
||||
// stop all other click events on this input
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.widget-top', function(){
|
||||
|
||||
var $el = $(this).parent().children('.widget-inside');
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
acf.get_fields('', $el).each(function(){
|
||||
|
||||
acf.do_action('show_field', $(this));
|
||||
|
||||
});
|
||||
|
||||
}, 250);
|
||||
|
||||
});
|
||||
|
||||
$(document).on('widget-added', function( e, $widget ){
|
||||
|
||||
// - use delay to avoid rendering issues with customizer (ensures div is visible)
|
||||
setTimeout(function(){
|
||||
|
||||
acf.do_action('append', $widget );
|
||||
|
||||
}, 100);
|
||||
|
||||
});
|
||||
|
||||
$(document).on('widget-saved widget-updated', function( e, $widget ){
|
||||
|
||||
// unlock form
|
||||
acf.validation.toggle( $widget, 'unlock' );
|
||||
|
||||
|
||||
// submit
|
||||
acf.do_action('submit', $widget );
|
||||
|
||||
});
|
||||
|
||||
<?php if( acf_is_screen('customize') ): ?>
|
||||
|
||||
// customizer saves widget on any input change, so unload is not needed
|
||||
acf.unload.active = 0;
|
||||
|
||||
|
||||
// hack customizer function to remove bug caused by WYSIWYG field using aunique ID
|
||||
// customizer compares returned AJAX HTML with the HTML of the widget form.
|
||||
// the _getInputsSignature() function is used to generate a string based of input name + id.
|
||||
// because ACF generates a unique ID on the WYSIWYG field, this string will not match causing the preview function to bail.
|
||||
// an attempt was made to remove the WYSIWYG unique ID, but this caused multiple issues in the wp-admin and altimately doesn't make sense with the tinymce rule that all editors must have a unique ID.
|
||||
// source: wp-admin/js/customize-widgets.js
|
||||
|
||||
// vars
|
||||
var WidgetControl = wp.customize.Widgets.WidgetControl.prototype;
|
||||
|
||||
|
||||
// backup functions
|
||||
WidgetControl.__getInputsSignature = WidgetControl._getInputsSignature;
|
||||
WidgetControl.__setInputState = WidgetControl._setInputState;
|
||||
|
||||
|
||||
// modify __getInputsSignature
|
||||
WidgetControl._getInputsSignature = function( inputs ) {
|
||||
|
||||
// vars
|
||||
var signature = this.__getInputsSignature( inputs );
|
||||
safe = [];
|
||||
|
||||
|
||||
// split
|
||||
signature = signature.split(';');
|
||||
|
||||
|
||||
// loop
|
||||
for( var i in signature ) {
|
||||
|
||||
// vars
|
||||
var bit = signature[i];
|
||||
|
||||
|
||||
// bail ealry if acf is found
|
||||
if( bit.indexOf('acf') !== -1 ) continue;
|
||||
|
||||
|
||||
// append
|
||||
safe.push( bit );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update
|
||||
signature = safe.join(';');
|
||||
|
||||
|
||||
// return
|
||||
return signature;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// modify _setInputState
|
||||
// this function deosn't seem to run on widget title/content, only custom fields
|
||||
// either way, this function is not needed and will break ACF fields
|
||||
WidgetControl._setInputState = function( input, state ) {
|
||||
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new acf_form_widget();
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
|
@ -37,7 +37,7 @@ class acf_admin_field_group {
|
|||
|
||||
// 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_value', array($this, 'ajax_render_location_value'));
|
||||
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'));
|
||||
|
||||
|
||||
|
|
@ -219,9 +219,10 @@ class acf_admin_field_group {
|
|||
|
||||
// render post data
|
||||
acf_form_data(array(
|
||||
'post_id' => $post->ID,
|
||||
'nonce' => 'field_group',
|
||||
'ajax' => 0
|
||||
'post_id' => $post->ID,
|
||||
'nonce' => 'field_group',
|
||||
'ajax' => 0,
|
||||
'delete_fields' => 0
|
||||
));
|
||||
|
||||
}
|
||||
|
|
@ -242,12 +243,6 @@ class acf_admin_field_group {
|
|||
|
||||
function form_data( $args ) {
|
||||
|
||||
// add extra inputs
|
||||
?>
|
||||
<input type="hidden" name="_acf_delete_fields" value="0" id="input-delete-fields" />
|
||||
<?php
|
||||
|
||||
|
||||
// do action
|
||||
do_action('acf/field_group/form_data', $args);
|
||||
|
||||
|
|
@ -600,8 +595,8 @@ class acf_admin_field_group {
|
|||
}
|
||||
|
||||
|
||||
// don't use view because we need access to $this context
|
||||
include( acf_get_path('admin/views/field-group-options.php') );
|
||||
// view
|
||||
acf_get_view('field-group-options');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -645,403 +640,14 @@ class acf_admin_field_group {
|
|||
}
|
||||
|
||||
|
||||
// don't use view because we need access to $this context
|
||||
include( acf_get_path('admin/views/field-group-locations.php') );
|
||||
// view
|
||||
acf_get_view('field-group-locations');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_location_value
|
||||
*
|
||||
* This function will render out an input containing location rule values for the given args
|
||||
*
|
||||
* @type function
|
||||
* @date 30/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $options (array)
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function render_location_value( $options ) {
|
||||
|
||||
// vars
|
||||
$options = wp_parse_args( $options, array(
|
||||
'group_id' => 0,
|
||||
'rule_id' => 0,
|
||||
'value' => null,
|
||||
'param' => null,
|
||||
));
|
||||
|
||||
|
||||
// vars
|
||||
$choices = array();
|
||||
|
||||
|
||||
// some case's have the same outcome
|
||||
if( $options['param'] == "page_parent" ) {
|
||||
|
||||
$options['param'] = "page";
|
||||
|
||||
}
|
||||
|
||||
|
||||
switch( $options['param'] ) {
|
||||
|
||||
|
||||
/*
|
||||
* Post
|
||||
*/
|
||||
|
||||
case "post_type" :
|
||||
|
||||
// get post types
|
||||
// - removed show_ui to allow 3rd party code to register a post type using a custom admin edit page
|
||||
$post_types = acf_get_post_types(array(
|
||||
//'show_ui' => 1,
|
||||
'exclude' => array('attachment')
|
||||
));
|
||||
|
||||
|
||||
// get choices
|
||||
$choices = acf_get_pretty_post_types( $post_types );
|
||||
|
||||
|
||||
// end
|
||||
break;
|
||||
|
||||
|
||||
case "post" :
|
||||
|
||||
// get post types
|
||||
$post_types = acf_get_post_types(array(
|
||||
'exclude' => array('page', 'attachment')
|
||||
));
|
||||
|
||||
|
||||
// get posts grouped by post type
|
||||
$groups = acf_get_grouped_posts(array(
|
||||
'post_type' => $post_types
|
||||
));
|
||||
|
||||
|
||||
if( !empty($groups) ) {
|
||||
|
||||
foreach( array_keys($groups) as $group_title ) {
|
||||
|
||||
// vars
|
||||
$posts = acf_extract_var( $groups, $group_title );
|
||||
|
||||
|
||||
// override post data
|
||||
foreach( array_keys($posts) as $post_id ) {
|
||||
|
||||
// update
|
||||
$posts[ $post_id ] = acf_get_post_title( $posts[ $post_id ] );
|
||||
|
||||
};
|
||||
|
||||
|
||||
// append to $choices
|
||||
$choices[ $group_title ] = $posts;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "post_template" :
|
||||
|
||||
// vars
|
||||
$templates = wp_get_theme()->get_post_templates();
|
||||
$default = apply_filters( 'default_page_template_title', __('Default Template', 'acf') );
|
||||
|
||||
|
||||
// choices
|
||||
$choices = array('default' => $default);
|
||||
|
||||
|
||||
// templates
|
||||
if( !empty($templates) ) {
|
||||
|
||||
foreach( $templates as $post_type => $post_type_templates ) {
|
||||
|
||||
$choices = array_merge($choices, $post_type_templates);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// break
|
||||
break;
|
||||
|
||||
case "post_category" :
|
||||
|
||||
$terms = acf_get_taxonomy_terms( 'category' );
|
||||
|
||||
if( !empty($terms) ) {
|
||||
|
||||
$choices = array_pop($terms);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "post_format" :
|
||||
|
||||
$choices = get_post_format_strings();
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "post_status" :
|
||||
|
||||
global $wp_post_statuses;
|
||||
|
||||
if( !empty($wp_post_statuses) ) {
|
||||
|
||||
foreach( $wp_post_statuses as $status ) {
|
||||
|
||||
$choices[ $status->name ] = $status->label;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "post_taxonomy" :
|
||||
|
||||
$choices = acf_get_taxonomy_terms();
|
||||
|
||||
// unset post_format
|
||||
if( isset($choices['post_format']) ) {
|
||||
|
||||
unset( $choices['post_format']) ;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
/*
|
||||
* Page
|
||||
*/
|
||||
|
||||
case "page" :
|
||||
|
||||
|
||||
// get posts grouped by post type
|
||||
$groups = acf_get_grouped_posts(array(
|
||||
'post_type' => 'page'
|
||||
));
|
||||
|
||||
|
||||
if( !empty($groups) ) {
|
||||
|
||||
foreach( array_keys($groups) as $group_title ) {
|
||||
|
||||
// vars
|
||||
$posts = acf_extract_var( $groups, $group_title );
|
||||
|
||||
|
||||
// override post data
|
||||
foreach( array_keys($posts) as $post_id ) {
|
||||
|
||||
// update
|
||||
$posts[ $post_id ] = acf_get_post_title( $posts[ $post_id ] );
|
||||
|
||||
};
|
||||
|
||||
|
||||
// append to $choices
|
||||
$choices = $posts;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "page_type" :
|
||||
|
||||
$choices = array(
|
||||
'front_page' => __("Front Page",'acf'),
|
||||
'posts_page' => __("Posts Page",'acf'),
|
||||
'top_level' => __("Top Level Page (no parent)",'acf'),
|
||||
'parent' => __("Parent Page (has children)",'acf'),
|
||||
'child' => __("Child Page (has parent)",'acf'),
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "page_parent" :
|
||||
|
||||
// refer to "page"
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "page_template" :
|
||||
|
||||
// vars
|
||||
$templates = wp_get_theme()->get_page_templates();
|
||||
$default = apply_filters( 'default_page_template_title', __('Default Template', 'acf') );
|
||||
|
||||
|
||||
// merge
|
||||
$choices = array_merge(array('default' => $default), $templates);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
/*
|
||||
* User
|
||||
*/
|
||||
|
||||
case "current_user" :
|
||||
|
||||
// viewing
|
||||
$choices = array(
|
||||
'logged_in' => __('Logged in', 'acf'),
|
||||
'viewing_front' => __('Viewing front end', 'acf'),
|
||||
'viewing_back' => __('Viewing back end', 'acf')
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case "current_user_role" :
|
||||
|
||||
// global
|
||||
global $wp_roles;
|
||||
|
||||
|
||||
// specific roles
|
||||
$choices = $wp_roles->get_names();
|
||||
|
||||
|
||||
// multi-site
|
||||
if( is_multisite() ) {
|
||||
|
||||
$choices = array_merge(array(
|
||||
'super_admin' => __('Super Admin', 'acf')
|
||||
), $choices);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "user_role" :
|
||||
|
||||
global $wp_roles;
|
||||
|
||||
$choices = array_merge( array('all' => __('All', 'acf')), $wp_roles->get_names() );
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "user_form" :
|
||||
|
||||
$choices = array(
|
||||
'all' => __('All', 'acf'),
|
||||
'edit' => __('Add / Edit', 'acf'),
|
||||
'register' => __('Register', 'acf')
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
/*
|
||||
* Forms
|
||||
*/
|
||||
|
||||
case "attachment" :
|
||||
|
||||
$choices = array('all' => __('All', 'acf'));
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "taxonomy" :
|
||||
|
||||
$choices = array_merge( array('all' => __('All', 'acf')), acf_get_taxonomies() );
|
||||
|
||||
|
||||
// unset post_format
|
||||
if( isset($choices['post_format']) ) {
|
||||
|
||||
unset( $choices['post_format']);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "comment" :
|
||||
|
||||
// vars
|
||||
$choices = array(
|
||||
'all' => __('All', 'acf')
|
||||
);
|
||||
|
||||
|
||||
// append post types
|
||||
$choices = array_merge( $choices, acf_get_pretty_post_types() );
|
||||
|
||||
|
||||
// end
|
||||
break;
|
||||
|
||||
|
||||
case "widget" :
|
||||
|
||||
global $wp_widget_factory;
|
||||
|
||||
$choices = array(
|
||||
'all' => __('All', 'acf'),
|
||||
);
|
||||
|
||||
|
||||
if( !empty( $wp_widget_factory->widgets ) ) {
|
||||
|
||||
foreach( $wp_widget_factory->widgets as $widget ) {
|
||||
|
||||
$choices[ $widget->id_base ] = $widget->name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// allow custom location rules
|
||||
$choices = apply_filters( 'acf/location/rule_values/' . $options['param'], $choices );
|
||||
|
||||
|
||||
// create field
|
||||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'prefix' => "acf_field_group[location][{$options['group_id']}][{$options['rule_id']}]",
|
||||
'name' => 'value',
|
||||
'value' => $options['value'],
|
||||
'choices' => $choices,
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ajax_render_location_value
|
||||
* ajax_render_location_rule
|
||||
*
|
||||
* This function can be accessed via an AJAX action and will return the result from the render_location_value function
|
||||
*
|
||||
|
|
@ -1053,18 +659,20 @@ class acf_admin_field_group {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function ajax_render_location_value() {
|
||||
function ajax_render_location_rule() {
|
||||
|
||||
// validate
|
||||
if( !acf_verify_ajax() ) {
|
||||
|
||||
die();
|
||||
|
||||
}
|
||||
if( !acf_verify_ajax() ) die();
|
||||
|
||||
|
||||
// call function
|
||||
$this->render_location_value( $_POST );
|
||||
// valid rule
|
||||
$rule = acf_get_valid_location_rule($_POST['rule']);
|
||||
|
||||
|
||||
// view
|
||||
acf_get_view( 'html-location-rule', array(
|
||||
'rule' => $rule
|
||||
));
|
||||
|
||||
|
||||
// die
|
||||
|
|
@ -1187,14 +795,12 @@ class acf_admin_field_group {
|
|||
// update field
|
||||
acf_update_field($field);
|
||||
|
||||
$v1 = $field['label'];
|
||||
$v2 = '<a href="' . admin_url("post.php?post={$field_group['ID']}&action=edit") . '" target="_blank">' . $field_group['title'] . '</a>';
|
||||
|
||||
// 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'), $v1, $v2 ). '</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();
|
||||
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ class acf_admin_field_groups {
|
|||
function check_duplicate() {
|
||||
|
||||
// message
|
||||
if( $ids = acf_maybe_get($_GET, 'acfduplicatecomplete') ) {
|
||||
if( $ids = acf_maybe_get_GET('acfduplicatecomplete') ) {
|
||||
|
||||
// explode
|
||||
$ids = explode(',', $ids);
|
||||
|
|
@ -155,14 +155,14 @@ class acf_admin_field_groups {
|
|||
|
||||
|
||||
// check single
|
||||
if( $id = acf_maybe_get($_GET, 'acfduplicate') ) {
|
||||
if( $id = acf_maybe_get_GET('acfduplicate') ) {
|
||||
|
||||
$ids[] = $id;
|
||||
|
||||
// check multiple
|
||||
} elseif( acf_maybe_get($_GET, 'action2') === 'acfduplicate' ) {
|
||||
} elseif( acf_maybe_get_GET('action2') === 'acfduplicate' ) {
|
||||
|
||||
$ids = acf_maybe_get($_GET, 'post');
|
||||
$ids = acf_maybe_get_GET('post');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ class acf_admin_field_groups {
|
|||
function check_sync() {
|
||||
|
||||
// message
|
||||
if( $ids = acf_maybe_get($_GET, 'acfsynccomplete') ) {
|
||||
if( $ids = acf_maybe_get_GET('acfsynccomplete') ) {
|
||||
|
||||
// explode
|
||||
$ids = explode(',', $ids);
|
||||
|
|
@ -279,14 +279,14 @@ class acf_admin_field_groups {
|
|||
|
||||
|
||||
// check single
|
||||
if( $key = acf_maybe_get($_GET, 'acfsync') ) {
|
||||
if( $key = acf_maybe_get_GET('acfsync') ) {
|
||||
|
||||
$sync_keys[] = $key;
|
||||
|
||||
// check multiple
|
||||
} elseif( acf_maybe_get($_GET, 'action2') === 'acfsync' ) {
|
||||
} elseif( acf_maybe_get_GET('action2') === 'acfsync' ) {
|
||||
|
||||
$sync_keys = acf_maybe_get($_GET, 'post');
|
||||
$sync_keys = acf_maybe_get_GET('post');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ class acf_admin_field_groups {
|
|||
$total = count($this->sync);
|
||||
|
||||
// active
|
||||
if( acf_maybe_get($_GET, 'post_status') === 'sync' ) {
|
||||
if( acf_maybe_get_GET('post_status') === 'sync' ) {
|
||||
|
||||
// actions
|
||||
add_action('admin_footer', array($this, 'sync_admin_footer'), 5);
|
||||
|
|
@ -506,7 +506,7 @@ class acf_admin_field_groups {
|
|||
'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="' . __('Status', 'acf') . '"></i>',
|
||||
'acf-fg-status' => '<i class="acf-icon -dot-3 small acf-js-tooltip" title="' . esc_attr__('Status', 'acf') . '"></i>',
|
||||
'acf-fg-count' => __('Fields', 'acf'),
|
||||
);
|
||||
|
||||
|
|
@ -545,7 +545,7 @@ class acf_admin_field_groups {
|
|||
|
||||
if( $field_group['description'] ) {
|
||||
|
||||
echo '<span class="acf-description">' . $field_group['description'] . '</span>';
|
||||
echo '<span class="acf-description">' . acf_esc_html($field_group['description']) . '</span>';
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -554,24 +554,24 @@ class acf_admin_field_groups {
|
|||
|
||||
if( isset($this->sync[ $field_group['key'] ]) ) {
|
||||
|
||||
echo '<i class="acf-icon -sync grey small acf-js-tooltip" title="' . __('Sync available', 'acf') .'"></i> ';
|
||||
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="' . __('Active', 'acf') .'"></i> ';
|
||||
//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="' . __('Inactive', 'acf') . '"></i> ';
|
||||
echo '<i class="acf-icon -minus yellow small acf-js-tooltip" title="' . esc_attr__('Inactive', 'acf') . '"></i> ';
|
||||
|
||||
}
|
||||
|
||||
// fields
|
||||
} elseif( $column == 'acf-fg-count' ) {
|
||||
|
||||
echo acf_get_field_count( $field_group );
|
||||
echo esc_html( acf_get_field_count( $field_group ) );
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -596,8 +596,7 @@ class acf_admin_field_groups {
|
|||
// vars
|
||||
$url_home = 'https://www.advancedcustomfields.com';
|
||||
$url_support = 'https://support.advancedcustomfields.com';
|
||||
$url_docs = $url_home . '/resources/';
|
||||
|
||||
$icon = '<i aria-hidden="true" class="dashicons dashicons-external"></i>';
|
||||
|
||||
?>
|
||||
<script type="text/html" id="tmpl-acf-column-2">
|
||||
|
|
@ -605,28 +604,28 @@ class acf_admin_field_groups {
|
|||
<div class="acf-box">
|
||||
<div class="inner">
|
||||
<h2><?php echo acf_get_setting('name'); ?></h2>
|
||||
|
||||
<h3><?php _e("Changelog",'acf'); ?></h3>
|
||||
<p><?php printf(__('See what\'s new in <a href="%s">version %s</a>.','acf'), admin_url('edit.php?post_type=acf-field-group&page=acf-settings-info&tab=changelog'), acf_get_setting('version')); ?></p>
|
||||
<p><?php _e('Customise WordPress with powerful, professional and intuitive fields.'); ?></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 $url_docs; ?>" target="_blank"><?php _e("Documentation",'acf'); ?></a></li>
|
||||
|
||||
<li><a href="<?php echo $url_docs; ?>#getting-started" target="_blank"><?php _e("Getting Started",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo $url_docs; ?>#field-types" target="_blank"><?php _e("Field Types",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo $url_docs; ?>#functions" target="_blank"><?php _e("Functions",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo $url_docs; ?>#actions" target="_blank"><?php _e("Actions",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo $url_docs; ?>#filters" target="_blank"><?php _e("Filters",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo $url_docs; ?>#features" target="_blank"><?php _e("Features",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo $url_docs; ?>#how-to" target="_blank"><?php _e("How to",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo $url_docs; ?>#tutorials" target="_blank"><?php _e("Tutorials",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo $url_docs; ?>#faq" target="_blank"><?php _e("FAQ",'acf'); ?></a></li>
|
||||
<li><a href="<?php echo $url_support; ?>" target="_blank"><?php _e("Support",'acf'); ?></a></li>
|
||||
<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_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 -blue">
|
||||
<p><?php echo sprintf( __('Thank you for creating with <a href="%s">ACF</a>.','acf'), $url_home ); ?></p>
|
||||
<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>
|
||||
|
|
@ -665,10 +664,8 @@ class acf_admin_field_groups {
|
|||
|
||||
// vars
|
||||
var post_id = id.replace('post-', '');
|
||||
|
||||
|
||||
// create el
|
||||
var $span = $('<span class="acf-duplicate-field-group"><a title="<?php _e('Duplicate this item', 'acf'); ?>" href="<?php echo admin_url($this->url . '&acfduplicate='); ?>' + post_id + '&_wpnonce=<?php echo wp_create_nonce('bulk-posts'); ?>"><?php _e('Duplicate', 'acf'); ?></a> | </span>');
|
||||
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
|
||||
|
|
@ -745,25 +742,34 @@ class acf_admin_field_groups {
|
|||
'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 ): $i++; ?>
|
||||
<?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 $field_group['key']; ?>" class="screen-reader-text"><?php printf( __( 'Select %s', 'acf' ), $field_group['title'] ); ?></label>
|
||||
<input type="checkbox" value="<?php echo $field_group['key']; ?>" name="post[]" id="cb-select-<?php echo $field_group['key']; ?>">
|
||||
<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 $field_group['title']; ?></span><span class="acf-description"><?php echo $field_group['key']; ?>.json</span>
|
||||
<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 admin_url($this->url . '&post_status=sync&acfsync=' . $field_group['key'] . '&_wpnonce=' . wp_create_nonce('bulk-posts')); ?>"><?php _e( 'Sync', 'acf' ); ?></a></span>
|
||||
<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 $column; ?>"><?php $this->render_column( $column, $field_group ); ?></td>
|
||||
<td class="column-<?php echo esc_attr($column); ?>"><?php $this->render_column( $column, $field_group ); ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
|
@ -177,7 +177,7 @@ class acf_admin {
|
|||
}
|
||||
|
||||
?>
|
||||
<div class="notice is-dismissible <?php echo $notice['class']; ?>"><?php echo $open . $notice['text'] . $close; ?></div>
|
||||
<div class="notice is-dismissible <?php echo esc_attr($notice['class']); ?>"><?php echo $open . $notice['text'] . $close; ?></div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ function acf_update_500_field_groups() {
|
|||
// loop
|
||||
foreach( $ofgs as $ofg ){
|
||||
|
||||
$nfg = acf_update_500_field_group( $ofg );
|
||||
acf_update_500_field_group( $ofg );
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -163,10 +163,6 @@ function acf_update_500_field_group( $ofg ) {
|
|||
}
|
||||
|
||||
|
||||
// global
|
||||
global $wpdb;
|
||||
|
||||
|
||||
// get field from postmeta
|
||||
$rows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key LIKE %s", $ofg->ID, 'field_%'), ARRAY_A);
|
||||
|
||||
|
|
@ -429,7 +425,6 @@ function acf_update_550_taxonomy( $taxonomy ) { //acf_log('acf_update_550_taxono
|
|||
|
||||
|
||||
// vars
|
||||
$meta = array();
|
||||
$search = $taxonomy . '_%';
|
||||
$_search = '_' . $search;
|
||||
|
||||
|
|
@ -119,7 +119,8 @@ class acf_admin_install {
|
|||
// view
|
||||
$view = array(
|
||||
'button_text' => __("Upgrade Database", 'acf'),
|
||||
'button_url' => admin_url('index.php?page=acf-upgrade')
|
||||
'button_url' => admin_url('index.php?page=acf-upgrade'),
|
||||
'confirm' => true
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -248,7 +249,7 @@ class acf_admin_install {
|
|||
function run_update( $callback = '' ) {
|
||||
|
||||
// include update functions
|
||||
acf_include('admin/install-updates.php');
|
||||
acf_include('includes/admin/install-updates.php');
|
||||
|
||||
|
||||
// bail early if not found
|
||||
|
|
@ -80,9 +80,10 @@ class acf_settings_info {
|
|||
|
||||
|
||||
// set active tab
|
||||
if( !empty($_GET['tab']) && array_key_exists($_GET['tab'], $view['tabs']) ) {
|
||||
$tab = acf_maybe_get_GET('tab');
|
||||
if( $tab && isset($view['tabs'][ $tab ]) ) {
|
||||
|
||||
$view['active'] = $_GET['tab'];
|
||||
$view['active'] = $tab;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ class acf_settings_tools {
|
|||
|
||||
} elseif( acf_verify_nonce('export') ) {
|
||||
|
||||
if( isset($_POST['generate']) ) {
|
||||
if( acf_maybe_get_POST('generate') ) {
|
||||
|
||||
$this->generate();
|
||||
|
||||
|
|
@ -405,20 +405,17 @@ class acf_settings_tools {
|
|||
|
||||
function get_json() {
|
||||
|
||||
// validate
|
||||
if( empty($_POST['acf_export_keys']) ) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$keys = acf_maybe_get_POST('acf_export_keys');
|
||||
$json = array();
|
||||
|
||||
|
||||
// bail early if no keys
|
||||
if( !$keys ) return false;
|
||||
|
||||
|
||||
// construct JSON
|
||||
foreach( $_POST['acf_export_keys'] as $key ) {
|
||||
foreach( $keys as $key ) {
|
||||
|
||||
// load field group
|
||||
$field_group = acf_get_field_group( $key );
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
<?php
|
||||
|
||||
// vars
|
||||
$field = acf_extract_var( $args, 'field');
|
||||
$groups = acf_extract_var( $field, 'conditional_logic');
|
||||
$disabled = empty($groups) ? 1 : 0;
|
||||
$disabled = false;
|
||||
|
||||
|
||||
// UI needs at least 1 conditional logic rule
|
||||
if( empty($groups) ) {
|
||||
// empty
|
||||
if( empty($field['conditional_logic']) ) {
|
||||
|
||||
$groups = array(
|
||||
$disabled = true;
|
||||
$field['conditional_logic'] = array(
|
||||
|
||||
// group 0
|
||||
array(
|
||||
|
|
@ -43,7 +42,7 @@ if( empty($groups) ) {
|
|||
?>
|
||||
<div class="rule-groups" <?php if($disabled): ?>style="display:none;"<?php endif; ?>>
|
||||
|
||||
<?php foreach( $groups as $group_id => $group ):
|
||||
<?php foreach( $field['conditional_logic'] as $group_id => $group ):
|
||||
|
||||
// validate
|
||||
if( empty($group) ) continue;
|
||||
|
|
@ -1,14 +1,5 @@
|
|||
<?php
|
||||
|
||||
// vars
|
||||
$field = false;
|
||||
$i = 0;
|
||||
|
||||
|
||||
// extract args
|
||||
extract( $args );
|
||||
|
||||
|
||||
// add prefix
|
||||
$field['prefix'] = "acf_fields[{$field['ID']}]";
|
||||
|
||||
|
|
@ -30,7 +21,7 @@ $meta = array(
|
|||
);
|
||||
|
||||
|
||||
// replace
|
||||
// class
|
||||
$atts['class'] = str_replace('_', '-', $atts['class']);
|
||||
|
||||
?>
|
||||
|
|
@ -48,7 +39,6 @@ $atts['class'] = str_replace('_', '-', $atts['class']);
|
|||
<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>
|
||||
<pre class="pre-field-key"><?php echo $field['key']; ?></pre>
|
||||
</li>
|
||||
<li class="li-field-label">
|
||||
<strong>
|
||||
|
|
@ -62,13 +52,8 @@ $atts['class'] = str_replace('_', '-', $atts['class']);
|
|||
</div>
|
||||
</li>
|
||||
<li class="li-field-name"><?php echo $field['name']; ?></li>
|
||||
<li class="li-field-type">
|
||||
<?php if( acf_field_type_exists($field['type']) ): ?>
|
||||
<?php echo acf_get_field_type_label($field['type']); ?>
|
||||
<?php else: ?>
|
||||
<b><?php _e('Error', 'acf'); ?></b> <?php _e('Field type does not exist', 'acf'); ?>
|
||||
<?php endif; ?>
|
||||
</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>
|
||||
|
||||
|
|
@ -106,7 +91,7 @@ $atts['class'] = str_replace('_', '-', $atts['class']);
|
|||
'required' => 1,
|
||||
'type' => 'select',
|
||||
'name' => 'type',
|
||||
'choices' => acf_get_grouped_field_types(),
|
||||
'choices' => acf_get_field_types(),
|
||||
'class' => 'field-type'
|
||||
), true);
|
||||
|
||||
|
|
@ -1,20 +1,10 @@
|
|||
<?php
|
||||
|
||||
// vars
|
||||
$fields = false;
|
||||
$parent = 0;
|
||||
|
||||
|
||||
// use fields if passed in
|
||||
extract( $args );
|
||||
|
||||
?>
|
||||
<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>
|
||||
|
||||
|
|
@ -55,7 +45,7 @@ extract( $args );
|
|||
|
||||
?>
|
||||
<script type="text/html" id="tmpl-acf-field">
|
||||
<?php acf_get_view('field-group-field', array( 'field' => $clone )); ?>
|
||||
<?php acf_get_view('field-group-field', array( 'field' => $clone, 'i' => 0 )); ?>
|
||||
</script>
|
||||
<?php endif;?>
|
||||
|
||||
|
|
@ -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.postbox.render({
|
||||
'id': 'acf-field-group-locations',
|
||||
'label': 'left'
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
|
@ -1,5 +1,9 @@
|
|||
<?php
|
||||
|
||||
// global
|
||||
global $field_group;
|
||||
|
||||
|
||||
// active
|
||||
acf_render_field_wrap(array(
|
||||
'label' => __('Active','acf'),
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<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 ):
|
||||
|
||||
// append id
|
||||
$rule['id'] = "rule_{$i}";
|
||||
$rule['group'] = $group_id;
|
||||
|
||||
|
||||
// valid rule
|
||||
$rule = acf_get_valid_location_rule($rule);
|
||||
|
||||
|
||||
// view
|
||||
acf_get_view('html-location-rule', array(
|
||||
'rule' => $rule
|
||||
));
|
||||
|
||||
endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
<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' => $rule['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' => $rule['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' => $rule['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>
|
||||
|
|
@ -3,10 +3,6 @@
|
|||
// vars
|
||||
$button = __('Upgrade Sites');
|
||||
|
||||
|
||||
// extract
|
||||
extract($args);
|
||||
|
||||
?>
|
||||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
|
|
@ -1,15 +1,5 @@
|
|||
<?php
|
||||
|
||||
// vars
|
||||
$button_url = '';
|
||||
$button_text = '';
|
||||
$confirm = true;
|
||||
|
||||
|
||||
// extract
|
||||
extract($args);
|
||||
|
||||
|
||||
// calculate add-ons (non pro only)
|
||||
$plugins = array();
|
||||
|
||||
|
|
@ -23,7 +13,7 @@ if( !acf_get_setting('pro') ) {
|
|||
}
|
||||
|
||||
?>
|
||||
<div id="acf-upgrade-notice" class="acf-cf">
|
||||
<div id="acf-upgrade-notice">
|
||||
|
||||
<div class="inner">
|
||||
|
||||
|
|
@ -60,6 +50,8 @@ if( !acf_get_setting('pro') ) {
|
|||
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -1,8 +1,3 @@
|
|||
<?php
|
||||
|
||||
extract($args);
|
||||
|
||||
?>
|
||||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
<h1><?php _e("Advanced Custom Fields Database Upgrade",'acf'); ?></h1>
|
||||
|
|
@ -1,14 +1,8 @@
|
|||
<?php
|
||||
|
||||
// vars
|
||||
$json = acf_extract_var( $args, 'json');
|
||||
|
||||
?>
|
||||
<div class="wrap acf-settings-wrap">
|
||||
|
||||
<h1><?php _e("Add-ons",'acf'); ?></h1>
|
||||
|
||||
<div class="add-ons-list acf-cf">
|
||||
<div class="add-ons-list">
|
||||
|
||||
<?php if( !empty($json) ): ?>
|
||||
|
||||
|
|
@ -1,9 +1,3 @@
|
|||
<?php
|
||||
|
||||
// extract args
|
||||
extract( $args );
|
||||
|
||||
?>
|
||||
<div class="wrap about-wrap acf-wrap">
|
||||
|
||||
<h1><?php _e("Welcome to Advanced Custom Fields",'acf'); ?> <?php echo $version; ?></h1>
|
||||
|
|
@ -1,9 +1,5 @@
|
|||
<?php
|
||||
|
||||
// vars
|
||||
$field_groups = acf_extract_var( $args, 'field_groups');
|
||||
|
||||
|
||||
// replace
|
||||
$str_replace = array(
|
||||
" " => "\t",
|
||||
|
|
@ -39,7 +39,7 @@ if( $field_groups ) {
|
|||
|
||||
<form method="post" action="">
|
||||
<div class="acf-hidden">
|
||||
<input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce( 'export' ); ?>" />
|
||||
<?php acf_nonce_input('export'); ?>
|
||||
</div>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
|
|
@ -68,7 +68,7 @@ if( $field_groups ) {
|
|||
|
||||
<form method="post" action="" enctype="multipart/form-data">
|
||||
<div class="acf-hidden">
|
||||
<input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce( 'import' ); ?>" />
|
||||
<?php acf_nonce_input('import'); ?>
|
||||
</div>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
|
|
@ -264,6 +264,71 @@ function acf_filter_field_groups( $field_groups, $args = false ) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_group_visibility
|
||||
*
|
||||
* This function will look at the given field group's location rules and compare them against
|
||||
* the args given to see if this field group is to be shown or not.
|
||||
*
|
||||
* @type function
|
||||
* @date 7/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $field group (array)
|
||||
* @param $args (array)
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function acf_get_field_group_visibility( $field_group, $args = array() ) {
|
||||
|
||||
// bail early if not active
|
||||
if( !$field_group['active'] ) return false;
|
||||
|
||||
|
||||
// bail early if no location rules
|
||||
if( empty($field_group['location']) ) return false;
|
||||
|
||||
|
||||
// get screen
|
||||
$screen = acf_get_location_screen( $args, $field_group );
|
||||
|
||||
|
||||
// loop through location rules
|
||||
foreach( $field_group['location'] as $group_id => $group ) {
|
||||
|
||||
// continue if no rules
|
||||
if( empty($group) ) continue;
|
||||
|
||||
|
||||
// vars
|
||||
$match_group = true;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $group as $rule_id => $rule ) {
|
||||
|
||||
// bail ealry if no match
|
||||
if( !acf_match_location_rule( $rule, $screen ) ) {
|
||||
|
||||
$match_group = false;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// this group matches screen. Ignore remaining groups and retunr true
|
||||
if( $match_group ) return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_group
|
||||
*
|
||||
|
|
@ -284,11 +284,7 @@ function acf_get_field_label( $field ) {
|
|||
$label = $field['label'];
|
||||
|
||||
|
||||
if( $field['required'] ) {
|
||||
|
||||
$label .= ' <span class="acf-required">*</span>';
|
||||
|
||||
}
|
||||
if( $field['required'] ) $label .= ' <span class="acf-required">*</span>';
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
|
|
@ -1782,6 +1778,25 @@ function acf_get_sub_field( $selector, $field ) {
|
|||
$sub_field = false;
|
||||
|
||||
|
||||
// check sub_fields
|
||||
if( isset($field['sub_fields']) ) {
|
||||
|
||||
// loop
|
||||
foreach( $field['sub_fields'] as $_sub_field ) {
|
||||
|
||||
// check name and key
|
||||
if( acf_is_field($_sub_field, $selector) ) {
|
||||
|
||||
$sub_field = $_sub_field;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$sub_field = apply_filters( "acf/get_sub_field", $sub_field, $selector, $field );
|
||||
$sub_field = apply_filters( "acf/get_sub_field/type={$field['type']}", $sub_field, $selector, $field );
|
||||
|
|
@ -1793,6 +1808,45 @@ function acf_get_sub_field( $selector, $field ) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_is_field
|
||||
*
|
||||
* This function will compare a $selector against a $field array
|
||||
*
|
||||
* @type function
|
||||
* @date 1/7/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_is_field( $field, $selector = '' ) {
|
||||
|
||||
// vars
|
||||
$keys = array(
|
||||
'ID',
|
||||
'name',
|
||||
'key',
|
||||
'_name',
|
||||
'__name',
|
||||
);
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $keys as $k ) {
|
||||
|
||||
if( isset($field[ $k ]) && $field[ $k ] === $selector ) return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_ancestors
|
||||
*
|
||||
|
|
@ -207,7 +207,7 @@ function acf_has_done( $name ) {
|
|||
|
||||
function acf_get_path( $path ) {
|
||||
|
||||
return acf_get_setting('path') . $path;
|
||||
return ACF_PATH . $path;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -432,7 +432,7 @@ function acf_get_view( $path = '', $args = array() ) {
|
|||
// allow view file name shortcut
|
||||
if( substr($path, -4) !== '.php' ) {
|
||||
|
||||
$path = acf_get_path("admin/views/{$path}.php");
|
||||
$path = acf_get_path("includes/admin/views/{$path}.php");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -440,6 +440,7 @@ function acf_get_view( $path = '', $args = array() ) {
|
|||
// include
|
||||
if( file_exists($path) ) {
|
||||
|
||||
extract( $args );
|
||||
include( $path );
|
||||
|
||||
}
|
||||
|
|
@ -495,104 +496,27 @@ function acf_merge_atts( $atts, $extra = array() ) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_esc_attr
|
||||
*
|
||||
* This function will return a render of an array of attributes to be used in markup
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_esc_attr( $atts ) {
|
||||
|
||||
// is string?
|
||||
if( is_string($atts) ) {
|
||||
|
||||
$atts = trim( $atts );
|
||||
return esc_attr( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// validate
|
||||
if( empty($atts) ) {
|
||||
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$e = array();
|
||||
|
||||
|
||||
// loop through and render
|
||||
foreach( $atts as $k => $v ) {
|
||||
|
||||
// object
|
||||
if( is_array($v) || is_object($v) ) {
|
||||
|
||||
$v = json_encode($v);
|
||||
|
||||
// boolean
|
||||
} elseif( is_bool($v) ) {
|
||||
|
||||
$v = $v ? 1 : 0;
|
||||
|
||||
// string
|
||||
} elseif( is_string($v) ) {
|
||||
|
||||
$v = trim($v);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
$e[] = $k . '="' . esc_attr( $v ) . '"';
|
||||
}
|
||||
|
||||
|
||||
// echo
|
||||
return implode(' ', $e);
|
||||
|
||||
}
|
||||
|
||||
function acf_esc_attr_e( $atts ) {
|
||||
|
||||
echo acf_esc_attr( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* acf_hidden_input
|
||||
* acf_nonce_input
|
||||
*
|
||||
* description
|
||||
* This function will create a basic nonce input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
* @date 24/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_get_hidden_input( $atts ) {
|
||||
function acf_nonce_input( $nonce = '' ) {
|
||||
|
||||
$atts['type'] = 'hidden';
|
||||
|
||||
return '<input ' . acf_esc_attr( $atts ) . ' />';
|
||||
|
||||
}
|
||||
|
||||
function acf_hidden_input( $atts ) {
|
||||
|
||||
echo acf_get_hidden_input( $atts );
|
||||
echo '<input type="hidden" name="_acf_nonce" value="' . wp_create_nonce( $nonce ) . '" />';
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -840,7 +764,7 @@ function acf_get_post_type_label( $post_type ) {
|
|||
/*
|
||||
* acf_verify_nonce
|
||||
*
|
||||
* This function will look at the $_POST['_acfnonce'] value and return true or false
|
||||
* This function will look at the $_POST['_acf_nonce'] value and return true or false
|
||||
*
|
||||
* @type function
|
||||
* @date 15/10/13
|
||||
|
|
@ -850,53 +774,18 @@ function acf_get_post_type_label( $post_type ) {
|
|||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function acf_verify_nonce( $value, $post_id = 0 ) {
|
||||
function acf_verify_nonce( $value) {
|
||||
|
||||
// vars
|
||||
$nonce = acf_maybe_get( $_POST, '_acfnonce' );
|
||||
$nonce = acf_maybe_get_POST('_acf_nonce');
|
||||
|
||||
|
||||
// bail early nonce does not match (post|user|comment|term)
|
||||
if( !$nonce || !wp_verify_nonce($nonce, $value) ) return false;
|
||||
|
||||
|
||||
// if saving specific post
|
||||
if( $post_id ) {
|
||||
|
||||
// vars
|
||||
$form_post_id = (int) acf_maybe_get( $_POST, 'post_ID' );
|
||||
$post_parent = wp_is_post_revision( $post_id );
|
||||
|
||||
|
||||
// 1. no $_POST['post_id'] (shopp plugin)
|
||||
if( !$form_post_id ) {
|
||||
|
||||
// do nothing (don't remove this if statement!)
|
||||
|
||||
// 2. direct match (this is the post we were editing)
|
||||
} elseif( $post_id === $form_post_id ) {
|
||||
|
||||
// do nothing (don't remove this if statement!)
|
||||
|
||||
// 3. revision (this is an preview autosave)
|
||||
} elseif( $post_parent === $form_post_id ) {
|
||||
|
||||
// do nothing (don't remove this if statement!)
|
||||
|
||||
// 4. no match (this post is a custom created one during the save proccess via either WP or 3rd party)
|
||||
} else {
|
||||
|
||||
// return false early and prevent $_POST['_acfnonce'] from being reset
|
||||
// this will allow another save_post to save the real post
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// reset nonce (only allow 1 save)
|
||||
$_POST['_acfnonce'] = false;
|
||||
$_POST['_acf_nonce'] = false;
|
||||
|
||||
|
||||
// return
|
||||
|
|
@ -1524,34 +1413,28 @@ function acf_decode_taxonomy_term( $value ) {
|
|||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_array( $var = false, $delimiter = ',' ) {
|
||||
function acf_get_array( $var = false, $delimiter = '' ) {
|
||||
|
||||
// is array?
|
||||
// array
|
||||
if( is_array($var) ) {
|
||||
|
||||
return $var;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail early if empty
|
||||
if( empty($var) && !is_numeric($var) ) {
|
||||
|
||||
if( acf_is_empty($var) ) {
|
||||
return array();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// string
|
||||
if( is_string($var) && $delimiter ) {
|
||||
|
||||
return explode($delimiter, $var);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// place in array
|
||||
return array( $var );
|
||||
return (array) $var;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -3470,18 +3353,21 @@ function acf_is_screen( $id = '' ) {
|
|||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_maybe_get( $array, $key = 0, $default = null ) {
|
||||
function acf_maybe_get( $array = array(), $key = 0, $default = null ) {
|
||||
|
||||
// if exists
|
||||
if( isset($array[ $key ]) ) {
|
||||
return isset( $array[$key] ) ? $array[$key] : $default;
|
||||
|
||||
return $array[ $key ];
|
||||
}
|
||||
|
||||
function acf_maybe_get_POST( $key = '', $default = null ) {
|
||||
|
||||
}
|
||||
return isset( $_POST[$key] ) ? $_POST[$key] : $default;
|
||||
|
||||
}
|
||||
|
||||
function acf_maybe_get_GET( $key = '', $default = null ) {
|
||||
|
||||
// return
|
||||
return $default;
|
||||
return isset( $_GET[$key] ) ? $_GET[$key] : $default;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,504 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* acf_esc_html
|
||||
*
|
||||
* This function will encode <script> tags for safe output
|
||||
*
|
||||
* @type function
|
||||
* @date 25/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param string (string)
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_esc_html( $string = '' ) {
|
||||
|
||||
// cast
|
||||
$string = (string) $string;
|
||||
|
||||
|
||||
// replace
|
||||
$string = str_replace('<script', htmlspecialchars('<script'), $string);
|
||||
$string = str_replace('</script', htmlspecialchars('</script'), $string);
|
||||
|
||||
|
||||
// return
|
||||
return $string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_esc_atts
|
||||
*
|
||||
* This function will escape an array of attributes and return as HTML
|
||||
*
|
||||
* @type function
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $atts (array)
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_esc_atts( $atts = array() ) {
|
||||
|
||||
// vars
|
||||
$html = '';
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $atts as $k => $v ) {
|
||||
|
||||
// string
|
||||
if( is_string($v) ) {
|
||||
|
||||
$v = trim($v);
|
||||
|
||||
// boolean
|
||||
} elseif( is_bool($v) ) {
|
||||
|
||||
$v = $v ? 1 : 0;
|
||||
|
||||
// object
|
||||
} elseif( is_array($v) || is_object($v) ) {
|
||||
|
||||
$v = json_encode($v);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
$html .= esc_attr( $k ) . '="' . esc_attr( $v ) . '" ';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return trim( $html );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_esc_atts_e
|
||||
*
|
||||
* This function will echo acf_esc_atts
|
||||
*
|
||||
* @type function
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $atts (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_esc_atts_e( $atts = array() ) {
|
||||
|
||||
echo acf_esc_atts( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_text_input
|
||||
*
|
||||
* This function will return HTML for a text input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_text_input( $atts = array() ) {
|
||||
|
||||
$atts['type'] = isset($atts['type']) ? $atts['type'] : 'text';
|
||||
return '<input ' . acf_esc_atts( $atts ) . ' />';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_text_input
|
||||
*
|
||||
* This function will output HTML for a text input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_text_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_text_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_hidden_input
|
||||
*
|
||||
* This function will return HTML for a hidden input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_hidden_input( $atts = array() ) {
|
||||
|
||||
$atts['type'] = 'hidden';
|
||||
return acf_get_text_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_hidden_input
|
||||
*
|
||||
* This function will output HTML for a generic input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_hidden_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_hidden_input( $atts ) . "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_textarea_input
|
||||
*
|
||||
* This function will return HTML for a textarea input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_textarea_input( $atts = array() ) {
|
||||
|
||||
$value = acf_extract_var( $atts, 'value', '' );
|
||||
return '<textarea ' . acf_esc_atts( $atts ) . '>' . esc_textarea( $value ) . '</textarea>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_textarea_input
|
||||
*
|
||||
* This function will output HTML for a textarea input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_textarea_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_textarea_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_checkbox_input
|
||||
*
|
||||
* This function will return HTML for a checkbox input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_checkbox_input( $atts = array() ) {
|
||||
|
||||
$label = acf_extract_var( $atts, 'label', '' );
|
||||
$atts['type'] = acf_maybe_get( $atts, 'type', 'checkbox' );
|
||||
return '<label><input ' . acf_esc_attr( $atts ) . '/>' . acf_esc_html( $label ) . '</label>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_checkbox_input
|
||||
*
|
||||
* This function will output HTML for a checkbox input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_checkbox_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_checkbox_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_radio_input
|
||||
*
|
||||
* This function will return HTML for a radio input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_radio_input( $atts = array() ) {
|
||||
|
||||
$atts['type'] = 'radio';
|
||||
return acf_get_checkbox_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_radio_input
|
||||
*
|
||||
* This function will output HTML for a radio input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_radio_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_radio_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_select_input
|
||||
*
|
||||
* This function will return HTML for a select input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function acf_get_select_input( $atts = array() ) {
|
||||
|
||||
// vars
|
||||
$value = (array) acf_extract_var( $atts, 'value' );
|
||||
$choices = (array) acf_extract_var( $atts, 'choices' );
|
||||
|
||||
|
||||
// html
|
||||
$html = '';
|
||||
$html .= '<select ' . acf_esc_atts( $atts ) . '>' . "\n";
|
||||
$html .= acf_walk_select_input( $choices, $value );
|
||||
$html .= '</select>' . "\n";
|
||||
|
||||
|
||||
// return
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_walk_select_input
|
||||
*
|
||||
* This function will return the HTML for a select input's choices
|
||||
*
|
||||
* @type function
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_walk_select_input( $choices = array(), $values = array(), $depth = 0 ) {
|
||||
|
||||
// bail ealry if no choices
|
||||
if( empty($choices) ) return '';
|
||||
|
||||
|
||||
// vars
|
||||
$html = '';
|
||||
|
||||
|
||||
// sanitize values for 'selected' matching
|
||||
if( $depth == 0 ) {
|
||||
$values = array_map('esc_attr', $values);
|
||||
}
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $choices as $value => $label ) {
|
||||
|
||||
// optgroup
|
||||
if( is_array($label) ){
|
||||
|
||||
$html .= '<optgroup label="' . esc_attr($value) . '">' . "\n";
|
||||
$html .= acf_walk_select_input( $label, $values, $depth+1 );
|
||||
$html .= '</optgroup>';
|
||||
|
||||
// option
|
||||
} else {
|
||||
|
||||
// vars
|
||||
$atts = array( 'value' => $value );
|
||||
$pos = array_search( esc_attr($value), $values );
|
||||
|
||||
|
||||
// selected
|
||||
if( $pos !== false ) {
|
||||
$atts['selected'] = 'selected';
|
||||
$atts['data-i'] = $pos;
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
$html .= '<option ' . acf_esc_attr($atts) . '>' . esc_html($label) . '</option>' . "\n";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_select_input
|
||||
*
|
||||
* This function will output HTML for a select input
|
||||
*
|
||||
* @type function
|
||||
* @date 3/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_select_input( $atts = array() ) {
|
||||
|
||||
echo acf_get_select_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
function acf_test_esc_html( $string = '' ) {
|
||||
|
||||
$s = '';
|
||||
|
||||
|
||||
$time_start = microtime(true);
|
||||
$s .= wp_kses_post( $string );
|
||||
$s .= ' = ('. (microtime(true) - $time_start) .')';
|
||||
|
||||
$s .= '-----';
|
||||
|
||||
|
||||
$time_start = microtime(true);
|
||||
$s .= str_replace(array('<script', '</script'), array(htmlspecialchars('<script'), htmlspecialchars('</script')), $string);
|
||||
$s .= ' = ('. (microtime(true) - $time_start) .')';
|
||||
|
||||
|
||||
$time_start = microtime(true);
|
||||
if( strpos($string, '<script') ) {
|
||||
$s .= str_replace(array('<script', '</script'), array(htmlspecialchars('<script'), htmlspecialchars('</script')), $string);
|
||||
}
|
||||
$s .= ' = ('. (microtime(true) - $time_start) .')';
|
||||
|
||||
return $s;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* acf_esc_attr
|
||||
*
|
||||
* Deprecated since 5.6.0
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_esc_attr( $atts ) {
|
||||
|
||||
return acf_esc_atts( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_esc_attr_e
|
||||
*
|
||||
* Deprecated since 5.6.0
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $atts (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_esc_attr_e( $atts ) {
|
||||
|
||||
acf_esc_atts_e( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -367,7 +367,7 @@ function get_field_objects( $post_id = false, $format_value = true, $load_value
|
|||
* have_rows
|
||||
*
|
||||
* This function will instantiate a global variable containing the rows of a repeater or flexible content field,
|
||||
* afterwhich, it will determine if another row exists to loop through
|
||||
* after which, it will determine if another row exists to loop through
|
||||
*
|
||||
* @type function
|
||||
* @date 2/09/13
|
||||
|
|
@ -459,18 +459,18 @@ function have_rows( $selector, $post_id = false ) {
|
|||
|
||||
} elseif( $change == 'selector' ) {
|
||||
|
||||
if( $previous_loop && $previous_loop['selector'] == $selector && $previous_loop['post_id'] == $post_id ) {
|
||||
|
||||
// case: Change in $field_name was due to a nested loop ending
|
||||
// action: move up one level through the loops
|
||||
acf_remove_loop('active');
|
||||
|
||||
} elseif( $sub_exists ) {
|
||||
if( $sub_exists ) {
|
||||
|
||||
// case: Change in $field_name was due to this being a nested loop
|
||||
// action: move down one level into a new loop
|
||||
$new_child_loop = true;
|
||||
|
||||
} elseif( $previous_loop && $previous_loop['selector'] == $selector && $previous_loop['post_id'] == $post_id ) {
|
||||
|
||||
// case: Change in $field_name was due to a nested loop ending
|
||||
// action: move up one level through the loops
|
||||
acf_remove_loop('active');
|
||||
|
||||
} else {
|
||||
|
||||
// case: Chang in $field_name is the most obvious, this is a new loop for a different field within the $post
|
||||
|
|
@ -489,53 +489,59 @@ function have_rows( $selector, $post_id = false ) {
|
|||
}
|
||||
|
||||
|
||||
// add parent loop
|
||||
if( $new_parent_loop ) {
|
||||
// add loop
|
||||
if( $new_parent_loop || $new_child_loop ) {
|
||||
|
||||
// vars
|
||||
$field = get_field_object( $selector, $post_id, false );
|
||||
$value = acf_extract_var( $field, 'value' );
|
||||
$field = null;
|
||||
$value = null;
|
||||
$name = '';
|
||||
|
||||
|
||||
// parent loop
|
||||
if( $new_parent_loop ) {
|
||||
|
||||
$field = get_field_object( $selector, $post_id, false );
|
||||
$value = acf_extract_var( $field, 'value' );
|
||||
$name = $field['name'];
|
||||
|
||||
// child loop
|
||||
} else {
|
||||
|
||||
$field = $sub_field;
|
||||
$value = $active_loop['value'][ $active_loop['i'] ][ $sub_field['key'] ];
|
||||
$name = $active_loop['name'] . '_' . $active_loop['i'] . '_' . $sub_field['name'];
|
||||
$post_id = $active_loop['post_id'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail early if value is either empty or a non array
|
||||
if( !acf_is_array($value) ) return false;
|
||||
|
||||
|
||||
// allow for non repeatable data (group)
|
||||
if( acf_get_field_type_prop($field['type'], 'have_rows') === 'single' ) {
|
||||
$value = array( $value );
|
||||
}
|
||||
|
||||
|
||||
// add loop
|
||||
acf_add_loop(array(
|
||||
$active_loop = acf_add_loop(array(
|
||||
'selector' => $selector,
|
||||
'name' => $field['name'], // used by update_sub_field
|
||||
'name' => $name, // used by update_sub_field
|
||||
'value' => $value,
|
||||
'field' => $field,
|
||||
'i' => -1,
|
||||
'post_id' => $post_id,
|
||||
'key' => $key
|
||||
));
|
||||
|
||||
// add child loop
|
||||
} elseif( $new_child_loop ) {
|
||||
|
||||
// vars
|
||||
$value = $active_loop['value'][ $active_loop['i'] ][ $sub_field['key'] ];
|
||||
$post_id = $active_loop['post_id'];
|
||||
|
||||
|
||||
// add loop
|
||||
acf_add_loop(array(
|
||||
'selector' => $selector,
|
||||
'name' => $active_loop['name'] . '_' . $active_loop['i'] . '_' . $sub_field['name'], // used by update_sub_field
|
||||
'value' => $value,
|
||||
'field' => $sub_field,
|
||||
'i' => -1,
|
||||
'post_id' => $post_id,
|
||||
'key' => $key
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update vars
|
||||
$active_loop = acf_get_loop('active');
|
||||
}
|
||||
|
||||
|
||||
// return true if next row exists
|
||||
if( $active_loop && is_array($active_loop['value']) && isset($active_loop['value'][ $active_loop['i']+1 ]) ) {
|
||||
if( $active_loop && isset($active_loop['value'][ $active_loop['i']+1 ]) ) {
|
||||
|
||||
return true;
|
||||
|
||||
|
|
@ -606,14 +612,26 @@ function get_row( $format = false ) {
|
|||
// format
|
||||
if( $format ) {
|
||||
|
||||
// format entire value
|
||||
// - solves problem where cached value is incomplete
|
||||
// - no performance issues here thanks to cache
|
||||
$value = acf_format_value( $loop['value'], $loop['post_id'], $loop['field'] );
|
||||
// vars
|
||||
$field = $loop['field'];
|
||||
|
||||
|
||||
// get value
|
||||
$value = acf_maybe_get( $value, $loop['i'] );
|
||||
// single row
|
||||
if( acf_get_field_type_prop($field['type'], 'have_rows') === 'single' ) {
|
||||
|
||||
// format value
|
||||
$value = acf_format_value( $value, $loop['post_id'], $field );
|
||||
|
||||
// multiple rows
|
||||
} else {
|
||||
|
||||
// format entire value
|
||||
// - solves problem where cached value is incomplete
|
||||
// - no performance issues here thanks to cache
|
||||
$value = acf_format_value( $loop['value'], $loop['post_id'], $field );
|
||||
$value = acf_maybe_get( $value, $loop['i'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -7,7 +7,8 @@ if( ! class_exists('acf_cache') ) :
|
|||
class acf_cache {
|
||||
|
||||
// vars
|
||||
var $reference = array();
|
||||
var $reference = array(),
|
||||
$active = true;
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -31,6 +32,66 @@ class acf_cache {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* is_active
|
||||
*
|
||||
* This function will return true if caching is enabled
|
||||
*
|
||||
* @type function
|
||||
* @date 26/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (bool)
|
||||
*/
|
||||
|
||||
function is_active() {
|
||||
|
||||
return $this->active;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* enable
|
||||
*
|
||||
* This function will enable ACF caching
|
||||
*
|
||||
* @type function
|
||||
* @date 26/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function enable() {
|
||||
|
||||
$this->active = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* disable
|
||||
*
|
||||
* This function will disable ACF caching
|
||||
*
|
||||
* @type function
|
||||
* @date 26/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function disable() {
|
||||
|
||||
$this->active = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_key
|
||||
*
|
||||
|
|
@ -76,6 +137,10 @@ class acf_cache {
|
|||
|
||||
function isset_cache( $key = '' ) {
|
||||
|
||||
// bail early if not active
|
||||
if( !$this->is_active() ) return false;
|
||||
|
||||
|
||||
// vars
|
||||
$key = $this->get_key($key);
|
||||
$found = false;
|
||||
|
|
@ -106,6 +171,10 @@ class acf_cache {
|
|||
|
||||
function get_cache( $key = '' ) {
|
||||
|
||||
// bail early if not active
|
||||
if( !$this->is_active() ) return false;
|
||||
|
||||
|
||||
// vars
|
||||
$key = $this->get_key($key);
|
||||
$found = false;
|
||||
|
|
@ -137,8 +206,15 @@ class acf_cache {
|
|||
|
||||
function set_cache( $key = '', $data = '' ) {
|
||||
|
||||
// bail early if not active
|
||||
if( !$this->is_active() ) return false;
|
||||
|
||||
|
||||
// set
|
||||
wp_cache_set($key, $data, 'acf');
|
||||
|
||||
|
||||
// return
|
||||
return $key;
|
||||
|
||||
}
|
||||
|
|
@ -160,8 +236,15 @@ class acf_cache {
|
|||
|
||||
function set_cache_reference( $key = '', $reference = '' ) {
|
||||
|
||||
// bail early if not active
|
||||
if( !$this->is_active() ) return false;
|
||||
|
||||
|
||||
// add
|
||||
$this->reference[ $key ] = $reference;
|
||||
|
||||
|
||||
// resturn
|
||||
return $key;
|
||||
|
||||
}
|
||||
|
|
@ -182,6 +265,11 @@ class acf_cache {
|
|||
|
||||
function delete_cache( $key = '' ) {
|
||||
|
||||
// bail early if not active
|
||||
if( !$this->is_active() ) return false;
|
||||
|
||||
|
||||
// delete
|
||||
return wp_cache_delete( $key, 'acf' );
|
||||
|
||||
}
|
||||
|
|
@ -195,6 +283,65 @@ acf()->cache = new acf_cache();
|
|||
endif; // class_exists check
|
||||
|
||||
|
||||
/*
|
||||
* acf_is_cache_active
|
||||
*
|
||||
* alias of acf()->cache->is_active()
|
||||
*
|
||||
* @type function
|
||||
* @date 26/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_is_cache_active() {
|
||||
|
||||
return acf()->cache->is_active();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_disable_cache
|
||||
*
|
||||
* alias of acf()->cache->disable()
|
||||
*
|
||||
* @type function
|
||||
* @date 26/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_disable_cache() {
|
||||
|
||||
return acf()->cache->disable();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_enable_cache
|
||||
*
|
||||
* alias of acf()->cache->enable()
|
||||
*
|
||||
* @type function
|
||||
* @date 26/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_enable_cache() {
|
||||
|
||||
return acf()->cache->enable();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_isset_cache
|
||||
|
|
@ -0,0 +1,366 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_fields') ) :
|
||||
|
||||
class acf_fields {
|
||||
|
||||
|
||||
/** @var array Contains an array of field type instances */
|
||||
var $types = array();
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the class functionality
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
/* do nothing */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* register_field_type
|
||||
*
|
||||
* This function will store a field type class
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $class (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function register_field_type( $class ) {
|
||||
|
||||
if( $class instanceOf acf_field ) {
|
||||
|
||||
$this->types[ $class->name ] = $class;
|
||||
|
||||
} else {
|
||||
|
||||
$instance = new $class();
|
||||
$this->types[ $instance->name ] = $instance;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_field_type
|
||||
*
|
||||
* This function will return a field type class
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $name (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function get_field_type( $name ) {
|
||||
|
||||
return isset( $this->types[$name] ) ? $this->types[$name] : null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* is_field_type
|
||||
*
|
||||
* This function will return true if a field type exists
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $name (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function is_field_type( $name ) {
|
||||
|
||||
return isset( $this->types[$name] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* register_field_type_info
|
||||
*
|
||||
* This function will store a basic array of info about the field type
|
||||
* to later be overriden by the avbove register_field_type function
|
||||
*
|
||||
* @type function
|
||||
* @date 29/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $info (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function register_field_type_info( $info ) {
|
||||
|
||||
// convert to object
|
||||
$instance = (object) $info;
|
||||
$this->types[ $instance->name ] = $instance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_field_types
|
||||
*
|
||||
* This function will return an array of all field type infos
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $name (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function get_field_types() {
|
||||
|
||||
// vars
|
||||
$groups = array();
|
||||
$l10n = array(
|
||||
'basic' => __('Basic', 'acf'),
|
||||
'content' => __('Content', 'acf'),
|
||||
'choice' => __('Choice', 'acf'),
|
||||
'relational' => __('Relational', 'acf'),
|
||||
'jquery' => __('jQuery', 'acf'),
|
||||
'layout' => __('Layout', 'acf'),
|
||||
);
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $this->types as $type ) {
|
||||
|
||||
// bail ealry if not public
|
||||
if( !$type->public ) continue;
|
||||
|
||||
|
||||
// translate
|
||||
$cat = $type->category;
|
||||
$cat = isset( $l10n[$cat] ) ? $l10n[$cat] : $cat;
|
||||
|
||||
|
||||
// append
|
||||
$groups[ $cat ][ $type->name ] = $type->label;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// filter
|
||||
$groups = apply_filters('acf/get_field_types', $groups);
|
||||
|
||||
|
||||
// return
|
||||
return $groups;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
acf()->fields = new acf_fields();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
/*
|
||||
* acf_register_field_type
|
||||
*
|
||||
* alias of acf()->fields->register_field_type()
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_register_field_type( $class ) {
|
||||
|
||||
return acf()->fields->register_field_type( $class );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_type
|
||||
*
|
||||
* alias of acf()->fields->get_field_type()
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_get_field_type( $name ) {
|
||||
|
||||
return acf()->fields->get_field_type( $name );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_register_field_type_info
|
||||
*
|
||||
* alias of acf()->fields->register_field_type_info()
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_register_field_type_info( $info ) {
|
||||
|
||||
return acf()->fields->register_field_type_info( $info );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_types
|
||||
*
|
||||
* alias of acf()->fields->get_field_types()
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_get_field_types() {
|
||||
|
||||
return acf()->fields->get_field_types();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_is_field_type
|
||||
*
|
||||
* alias of acf()->fields->is_field_type()
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_is_field_type( $name = '' ) {
|
||||
|
||||
return acf()->fields->is_field_type( $name );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_type_prop
|
||||
*
|
||||
* This function will return a field type's property
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_field_type_prop( $name = '', $prop = '' ) {
|
||||
|
||||
$type = acf_get_field_type( $name );
|
||||
return ($type && isset($type->$prop)) ? $type->$prop : null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_type_label
|
||||
*
|
||||
* This function will return the label of a field type
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_field_type_label( $name = '' ) {
|
||||
|
||||
$type = acf_get_field_type( $name );
|
||||
return $type ? $type->label : '<span class="acf-tooltip-js" title="'.__('Field type does not exist', 'acf').'">'.__('Unknown', 'acf').'</span>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_field_type_exists (deprecated)
|
||||
*
|
||||
* deprecated in favour of acf_is_field_type()
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $type (string)
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function acf_field_type_exists( $type = '' ) {
|
||||
return acf_is_field_type( $type );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_grouped_field_types (deprecated)
|
||||
*
|
||||
* deprecated in favour of acf_get_field_types()
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_grouped_field_types() {
|
||||
return acf_get_field_types();
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Checkbox Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_checkbox
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_checkbox') ) :
|
||||
|
||||
class acf_field_checkbox extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_checkbox extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'checkbox';
|
||||
|
|
@ -45,9 +34,6 @@ class acf_field_checkbox extends acf_field {
|
|||
'return_format' => 'value'
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -68,8 +54,13 @@ class acf_field_checkbox extends acf_field {
|
|||
|
||||
function render_field( $field ) {
|
||||
|
||||
// reset vars
|
||||
$this->_values = array();
|
||||
$this->_all_checked = true;
|
||||
|
||||
|
||||
// ensure array
|
||||
$field['value'] = acf_get_array($field['value'], false);
|
||||
$field['value'] = acf_get_array($field['value']);
|
||||
$field['choices'] = acf_get_array($field['choices']);
|
||||
|
||||
|
||||
|
|
@ -78,144 +69,256 @@ class acf_field_checkbox extends acf_field {
|
|||
|
||||
|
||||
// vars
|
||||
$i = 0;
|
||||
$li = '';
|
||||
$all_checked = true;
|
||||
$ul = array(
|
||||
'class' => 'acf-checkbox-list',
|
||||
);
|
||||
|
||||
|
||||
// append to class
|
||||
$ul['class'] .= ' ' . ($field['layout'] == 'horizontal' ? 'acf-hl' : 'acf-bl');
|
||||
$ul['class'] .= ' ' . $field['class'];
|
||||
|
||||
|
||||
// checkbox saves an array
|
||||
$field['name'] .= '[]';
|
||||
|
||||
|
||||
// foreach choices
|
||||
// choices
|
||||
if( !empty($field['choices']) ) {
|
||||
|
||||
foreach( $field['choices'] as $value => $label ) {
|
||||
|
||||
// increase counter
|
||||
$i++;
|
||||
|
||||
|
||||
// vars
|
||||
$atts = array(
|
||||
'type' => 'checkbox',
|
||||
'id' => $field['id'],
|
||||
'name' => $field['name'],
|
||||
'value' => $value,
|
||||
);
|
||||
|
||||
|
||||
// is choice selected?
|
||||
if( in_array($value, $field['value']) ) {
|
||||
|
||||
$atts['checked'] = 'checked';
|
||||
|
||||
} else {
|
||||
|
||||
$all_checked = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if( isset($field['disabled']) && acf_in_array($value, $field['disabled']) ) {
|
||||
|
||||
$atts['disabled'] = 'disabled';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// each input ID is generated with the $key, however, the first input must not use $key so that it matches the field's label for attribute
|
||||
if( $i > 1 ) {
|
||||
|
||||
$atts['id'] .= '-' . $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append HTML
|
||||
$li .= '<li><label><input ' . acf_esc_attr( $atts ) . '/>' . $label . '</label></li>';
|
||||
|
||||
}
|
||||
// choices
|
||||
$li .= $this->render_field_choices( $field );
|
||||
|
||||
|
||||
// toggle all
|
||||
// toggle
|
||||
if( $field['toggle'] ) {
|
||||
|
||||
// vars
|
||||
$label = __("Toggle All", 'acf');
|
||||
$atts = array(
|
||||
'type' => 'checkbox',
|
||||
'class' => 'acf-checkbox-toggle'
|
||||
);
|
||||
|
||||
|
||||
// custom label
|
||||
if( is_string($field['toggle']) ) {
|
||||
|
||||
$label = $field['toggle'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// checked
|
||||
if( $all_checked ) {
|
||||
|
||||
$atts['checked'] = 'checked';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append HTML
|
||||
$li = '<li><label><input ' . acf_esc_attr( $atts ) . '/>' . $label . '</label></li>' . $li;
|
||||
|
||||
$li = $this->render_field_toggle( $field ) . $li;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// allow_custom
|
||||
// custom
|
||||
if( $field['allow_custom'] ) {
|
||||
$li .= $this->render_field_custom( $field );
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
echo '<ul ' . acf_esc_attr( $ul ) . '>' . "\n" . $li . '</ul>' . "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_choices
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 15/7/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function render_field_choices( $field ) {
|
||||
|
||||
// walk
|
||||
return $this->walk( $field['choices'], $field );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_toggle
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 15/7/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function render_field_toggle( $field ) {
|
||||
|
||||
// vars
|
||||
$atts = array(
|
||||
'type' => 'checkbox',
|
||||
'class' => 'acf-checkbox-toggle',
|
||||
'label' => __("Toggle All", 'acf')
|
||||
);
|
||||
|
||||
|
||||
// custom label
|
||||
if( is_string($field['toggle']) ) {
|
||||
$atts['label'] = $field['toggle'];
|
||||
}
|
||||
|
||||
|
||||
// checked
|
||||
if( $this->_all_checked ) {
|
||||
$atts['checked'] = 'checked';
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return '<li>' . acf_get_checkbox_input($atts) . '</li>' . "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_custom
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 15/7/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function render_field_custom( $field ) {
|
||||
|
||||
// vars
|
||||
$html = '';
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $field['value'] as $value ) {
|
||||
|
||||
// ignore if already eixsts
|
||||
if( isset($field['choices'][ $value ]) ) continue;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $field['value'] as $value ) {
|
||||
|
||||
// ignore if already eixsts
|
||||
if( isset($field['choices'][ $value ]) ) continue;
|
||||
// vars
|
||||
$esc_value = esc_attr($value);
|
||||
$text_input = array(
|
||||
'name' => $field['name'],
|
||||
'value' => $value,
|
||||
);
|
||||
|
||||
|
||||
// bail ealry if choice already exists
|
||||
if( in_array( $esc_value, $this->_values ) ) continue;
|
||||
|
||||
|
||||
// append
|
||||
$html .= '<li><input class="acf-checkbox-custom" type="checkbox" checked="checked" />' . acf_get_text_input($text_input) . '</li>' . "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append button
|
||||
$html .= '<li><a href="#" class="button acf-add-checkbox">' . esc_attr__('Add new choice', 'acf') . '</a></li>' . "\n";
|
||||
|
||||
|
||||
// return
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function walk( $choices = array(), $args = array(), $depth = 0 ) {
|
||||
|
||||
// bail ealry if no choices
|
||||
if( empty($choices) ) return '';
|
||||
|
||||
|
||||
// defaults
|
||||
$args = wp_parse_args($args, array(
|
||||
'id' => '',
|
||||
'type' => 'checkbox',
|
||||
'name' => '',
|
||||
'value' => array(),
|
||||
'disabled' => array(),
|
||||
));
|
||||
|
||||
|
||||
// vars
|
||||
$html = '';
|
||||
|
||||
|
||||
// sanitize values for 'selected' matching
|
||||
if( $depth == 0 ) {
|
||||
$args['value'] = array_map('esc_attr', $args['value']);
|
||||
$args['disabled'] = array_map('esc_attr', $args['disabled']);
|
||||
}
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $choices as $value => $label ) {
|
||||
|
||||
// open
|
||||
$html .= '<li>';
|
||||
|
||||
|
||||
// optgroup
|
||||
if( is_array($label) ){
|
||||
|
||||
$html .= '<ul>' . "\n";
|
||||
$html .= $this->walk( $label, $args, $depth+1 );
|
||||
$html .= '</ul>';
|
||||
|
||||
// option
|
||||
} else {
|
||||
|
||||
// vars
|
||||
$esc_value = esc_attr($value);
|
||||
$atts = array(
|
||||
'type' => 'text',
|
||||
'name' => $field['name'],
|
||||
'value' => $value,
|
||||
'id' => $args['id'] . '-' . str_replace(' ', '-', $value),
|
||||
'type' => $args['type'],
|
||||
'name' => $args['name'],
|
||||
'value' => $value,
|
||||
'label' => $label,
|
||||
);
|
||||
|
||||
|
||||
// selected
|
||||
if( in_array( $esc_value, $args['value'] ) ) {
|
||||
$atts['checked'] = 'checked';
|
||||
} else {
|
||||
$this->_all_checked = false;
|
||||
}
|
||||
|
||||
|
||||
// disabled
|
||||
if( in_array( $esc_value, $args['disabled'] ) ) {
|
||||
$atts['disabled'] = 'disabled';
|
||||
}
|
||||
|
||||
|
||||
// store value added
|
||||
$this->_values[] = $esc_value;
|
||||
|
||||
|
||||
// append
|
||||
$li .= '<li><input class="acf-checkbox-custom" type="checkbox" checked="checked" /><input ' . acf_esc_attr( $atts ) . '/></li>';
|
||||
$html .= acf_get_checkbox_input($atts);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append button
|
||||
$li .= '<li><a href="#" class="button acf-add-checkbox">' . __('Add new choice', 'acf') . '</a></li>';
|
||||
// close
|
||||
$html .= '</li>' . "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// class
|
||||
$field['class'] .= ' acf-checkbox-list';
|
||||
$field['class'] .= ($field['layout'] == 'horizontal') ? ' acf-hl' : ' acf-bl';
|
||||
|
||||
|
||||
// return
|
||||
echo '<ul ' . acf_esc_attr(array( 'class' => $field['class'] )) . '>' . $li . '</ul>';
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* render_field_settings()
|
||||
*
|
||||
|
|
@ -389,6 +492,10 @@ class acf_field_checkbox extends acf_field {
|
|||
$v = wp_unslash($v);
|
||||
|
||||
|
||||
// sanitize (remove tags)
|
||||
$v = sanitize_text_field($v);
|
||||
|
||||
|
||||
// append
|
||||
$field['choices'][ $v ] = $v;
|
||||
|
||||
|
|
@ -453,7 +560,7 @@ class acf_field_checkbox extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_checkbox() );
|
||||
acf_register_field_type( 'acf_field_checkbox' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Color Picker Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_color_picker
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_color_picker') ) :
|
||||
|
||||
class acf_field_color_picker extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_color_picker extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'color_picker';
|
||||
|
|
@ -39,10 +28,6 @@ class acf_field_color_picker extends acf_field {
|
|||
'default_value' => '',
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -112,16 +97,15 @@ class acf_field_color_picker extends acf_field {
|
|||
function render_field( $field ) {
|
||||
|
||||
// vars
|
||||
$text = acf_get_sub_array( $field, array('id', 'class', 'name', 'value') );
|
||||
$hidden = acf_get_sub_array( $field, array('name', 'value') );
|
||||
$e = '';
|
||||
$text_input = acf_get_sub_array( $field, array('id', 'class', 'name', 'value') );
|
||||
$hidden_input = acf_get_sub_array( $field, array('name', 'value') );
|
||||
|
||||
|
||||
// render
|
||||
// html
|
||||
?>
|
||||
<div class="acf-color_picker">
|
||||
<?php acf_hidden_input($hidden); ?>
|
||||
<input type="text" <?php echo acf_esc_attr($text); ?> />
|
||||
<?php acf_hidden_input( $hidden_input ); ?>
|
||||
<?php acf_text_input( $text_input ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
|
@ -157,7 +141,7 @@ class acf_field_color_picker extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_color_picker() );
|
||||
acf_register_field_type( 'acf_field_color_picker' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Date Picker Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_date_picker
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_date_picker') ) :
|
||||
|
||||
class acf_field_date_picker extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_date_picker extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'date_picker';
|
||||
|
|
@ -52,9 +41,6 @@ class acf_field_date_picker extends acf_field {
|
|||
// actions
|
||||
add_action('init', array($this, 'init'));
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -145,22 +131,21 @@ class acf_field_date_picker extends acf_field {
|
|||
|
||||
|
||||
// vars
|
||||
$e = '';
|
||||
$div = array(
|
||||
'class' => 'acf-date-picker acf-input-wrap',
|
||||
'data-date_format' => acf_convert_date_to_js($field['display_format']),
|
||||
'data-first_day' => $field['first_day'],
|
||||
);
|
||||
$hidden = array(
|
||||
|
||||
$hidden_input = array(
|
||||
'id' => $field['id'],
|
||||
'class' => 'input-alt',
|
||||
'type' => 'hidden',
|
||||
'name' => $field['name'],
|
||||
'value' => $hidden_value,
|
||||
);
|
||||
$input = array(
|
||||
|
||||
$text_input = array(
|
||||
'class' => 'input',
|
||||
'type' => 'text',
|
||||
'value' => $display_value,
|
||||
);
|
||||
|
||||
|
|
@ -172,23 +157,22 @@ class acf_field_date_picker extends acf_field {
|
|||
$div['data-save_format'] = $field['save_format'];
|
||||
|
||||
// revert hidden input value to raw DB value
|
||||
$hidden['value'] = $field['value'];
|
||||
$hidden_input['value'] = $field['value'];
|
||||
|
||||
// remove formatted value (will do this via JS)
|
||||
$input['value'] = '';
|
||||
$text_input['value'] = '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// html
|
||||
$e .= '<div ' . acf_esc_attr($div) . '>';
|
||||
$e .= '<input ' . acf_esc_attr($hidden). '/>';
|
||||
$e .= '<input ' . acf_esc_attr($input). '/>';
|
||||
$e .= '</div>';
|
||||
?>
|
||||
<div <?php acf_esc_attr_e( $div ); ?>>
|
||||
<?php acf_hidden_input( $hidden_input ); ?>
|
||||
<?php acf_text_input( $text_input ); ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
|
||||
// return
|
||||
echo $e;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -314,7 +298,7 @@ class acf_field_date_picker extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_date_picker() );
|
||||
acf_register_field_type( 'acf_field_date_picker' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Date Time Picker Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_date_and_time_picker
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_date_and_time_picker') ) :
|
||||
|
||||
class acf_field_date_and_time_picker extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_date_and_time_picker extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'date_time_picker';
|
||||
|
|
@ -62,9 +51,6 @@ class acf_field_date_and_time_picker extends acf_field {
|
|||
)
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -133,36 +119,34 @@ class acf_field_date_and_time_picker extends acf_field {
|
|||
|
||||
|
||||
// vars
|
||||
$e = '';
|
||||
$div = array(
|
||||
'class' => 'acf-date-time-picker acf-input-wrap',
|
||||
'data-date_format' => acf_convert_date_to_js($formats['date']),
|
||||
'data-time_format' => acf_convert_time_to_js($formats['time']),
|
||||
'data-first_day' => $field['first_day'],
|
||||
);
|
||||
$hidden = array(
|
||||
|
||||
$hidden_input = array(
|
||||
'id' => $field['id'],
|
||||
'class' => 'input-alt',
|
||||
'type' => 'hidden',
|
||||
'name' => $field['name'],
|
||||
'value' => $hidden_value,
|
||||
);
|
||||
$input = array(
|
||||
|
||||
$text_input = array(
|
||||
'class' => 'input',
|
||||
'type' => 'text',
|
||||
'value' => $display_value,
|
||||
);
|
||||
|
||||
|
||||
// html
|
||||
$e .= '<div ' . acf_esc_attr($div) . '>';
|
||||
$e .= '<input ' . acf_esc_attr($hidden). '/>';
|
||||
$e .= '<input ' . acf_esc_attr($input). '/>';
|
||||
$e .= '</div>';
|
||||
?>
|
||||
<div <?php acf_esc_attr_e( $div ); ?>>
|
||||
<?php acf_hidden_input( $hidden_input ); ?>
|
||||
<?php acf_text_input( $text_input ); ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
|
||||
// return
|
||||
echo $e;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -264,7 +248,7 @@ class acf_field_date_and_time_picker extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_date_and_time_picker() );
|
||||
acf_register_field_type( 'acf_field_date_and_time_picker' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,23 +1,12 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Email Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_email
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_email') ) :
|
||||
|
||||
class acf_field_email extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
* initialize
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_email extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'email';
|
||||
|
|
@ -41,9 +30,6 @@ class acf_field_email extends acf_field {
|
|||
'append' => ''
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -63,53 +49,48 @@ class acf_field_email extends acf_field {
|
|||
|
||||
// vars
|
||||
$atts = array();
|
||||
$o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' );
|
||||
$s = array( 'readonly', 'disabled' );
|
||||
$e = '';
|
||||
$keys = array( 'type', 'id', 'class', 'name', 'value', 'placeholder', 'pattern' );
|
||||
$keys2 = array( 'readonly', 'disabled' );
|
||||
$html = '';
|
||||
|
||||
|
||||
// prepend
|
||||
if( $field['prepend'] !== "" ) {
|
||||
if( $field['prepend'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-prepended';
|
||||
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
||||
$html .= '<div class="acf-input-prepend">' . acf_esc_html($field['prepend']) . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
if( $field['append'] !== "" ) {
|
||||
if( $field['append'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-appended';
|
||||
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
||||
$html .= '<div class="acf-input-append">' . acf_esc_html($field['append']) . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append atts
|
||||
foreach( $o as $k ) {
|
||||
|
||||
$atts[ $k ] = $field[ $k ];
|
||||
|
||||
// atts
|
||||
foreach( $keys as $k ) {
|
||||
if( isset($field[ $k ]) ) $atts[ $k ] = $field[ $k ];
|
||||
}
|
||||
|
||||
|
||||
// append special atts
|
||||
foreach( $s as $k ) {
|
||||
|
||||
// atts2
|
||||
foreach( $keys2 as $k ) {
|
||||
if( !empty($field[ $k ]) ) $atts[ $k ] = $k;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// render
|
||||
$e .= '<div class="acf-input-wrap">';
|
||||
$e .= '<input ' . acf_esc_attr( $atts ) . ' />';
|
||||
$e .= '</div>';
|
||||
$html .= '<div class="acf-input-wrap">' . acf_get_text_input( $atts ) . '</div>';
|
||||
|
||||
|
||||
// return
|
||||
echo $e;
|
||||
echo $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -169,7 +150,7 @@ class acf_field_email extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_email() );
|
||||
acf_register_field_type( 'acf_field_email' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF File Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_file
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_file') ) :
|
||||
|
||||
class acf_field_file extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_file extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'file';
|
||||
|
|
@ -52,10 +41,6 @@ class acf_field_file extends acf_field {
|
|||
|
||||
// filters
|
||||
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +81,7 @@ class acf_field_file extends acf_field {
|
|||
);
|
||||
|
||||
$div = array(
|
||||
'class' => 'acf-file-uploader acf-cf',
|
||||
'class' => 'acf-file-uploader',
|
||||
'data-library' => $field['library'],
|
||||
'data-mime_types' => $field['mime_types'],
|
||||
'data-uploader' => $uploader
|
||||
|
|
@ -453,7 +438,7 @@ class acf_field_file extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_file() );
|
||||
acf_register_field_type( 'acf_field_file' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Google Map Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_google_map
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_google_map') ) :
|
||||
|
||||
class acf_field_google_map extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_google_map extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'google_map';
|
||||
|
|
@ -52,9 +41,6 @@ class acf_field_google_map extends acf_field {
|
|||
'browser_support' => __("Sorry, this browser does not support geolocation",'acf'),
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -327,7 +313,7 @@ class acf_field_google_map extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_google_map() );
|
||||
acf_register_field_type( 'acf_field_google_map' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -0,0 +1,546 @@
|
|||
<?php
|
||||
|
||||
if( ! class_exists('acf_field__group') ) :
|
||||
|
||||
class acf_field__group extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'group';
|
||||
$this->label = __("Group",'acf');
|
||||
$this->category = 'layout';
|
||||
$this->defaults = array(
|
||||
'sub_fields' => array(),
|
||||
'layout' => 'block'
|
||||
);
|
||||
$this->have_rows = 'single';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* load_field()
|
||||
*
|
||||
* This filter is appied to the $field after it is loaded from the database
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $field - the field array holding all the field options
|
||||
*
|
||||
* @return $field - the field array holding all the field options
|
||||
*/
|
||||
|
||||
function load_field( $field ) {
|
||||
|
||||
// vars
|
||||
$sub_fields = acf_get_fields( $field );
|
||||
|
||||
|
||||
// append
|
||||
if( $sub_fields ) {
|
||||
|
||||
$field['sub_fields'] = $sub_fields;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* load_value()
|
||||
*
|
||||
* This filter is applied to the $value after it is loaded from the db
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $value (mixed) the value found in the database
|
||||
* @param $post_id (mixed) the $post_id from which the value was loaded
|
||||
* @param $field (array) the field array holding all the field options
|
||||
* @return $value
|
||||
*/
|
||||
|
||||
function load_value( $value, $post_id, $field ) {
|
||||
|
||||
// bail early if no sub fields
|
||||
if( empty($field['sub_fields']) ) return $value;
|
||||
|
||||
|
||||
// modify names
|
||||
$field = $this->prepare_field_for_db( $field );
|
||||
|
||||
|
||||
// load sub fields
|
||||
$value = array();
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $field['sub_fields'] as &$sub_field ) {
|
||||
|
||||
// load
|
||||
$value[ $sub_field['key'] ] = acf_get_value( $post_id, $sub_field );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* format_value()
|
||||
*
|
||||
* This filter is appied to the $value after it is loaded from the db and before it is returned to the template
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $value (mixed) the value which was loaded from the database
|
||||
* @param $post_id (mixed) the $post_id from which the value was loaded
|
||||
* @param $field (array) the field array holding all the field options
|
||||
*
|
||||
* @return $value (mixed) the modified value
|
||||
*/
|
||||
|
||||
function format_value( $value, $post_id, $field ) {
|
||||
|
||||
// bail early if no value
|
||||
if( empty($value) ) return false;
|
||||
|
||||
|
||||
// modify names
|
||||
$field = $this->prepare_field_for_db( $field );
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $field['sub_fields'] as $sub_field ) {
|
||||
|
||||
// extract value
|
||||
$sub_value = acf_extract_var( $value, $sub_field['key'] );
|
||||
|
||||
|
||||
// format value
|
||||
$sub_value = acf_format_value( $sub_value, $post_id, $sub_field );
|
||||
|
||||
|
||||
// append to $row
|
||||
$value[ $sub_field['_name'] ] = $sub_value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_value()
|
||||
*
|
||||
* This filter is appied to the $value before it is updated in the db
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $value - the value which will be saved in the database
|
||||
* @param $field - the field array holding all the field options
|
||||
* @param $post_id - the $post_id of which the value will be saved
|
||||
*
|
||||
* @return $value - the modified value
|
||||
*/
|
||||
|
||||
function update_value( $value, $post_id, $field ) {
|
||||
|
||||
// bail early if no value
|
||||
if( !acf_is_array($value) ) return null;
|
||||
|
||||
|
||||
// bail ealry if no sub fields
|
||||
if( empty($field['sub_fields']) ) return null;
|
||||
|
||||
|
||||
// modify names
|
||||
$field = $this->prepare_field_for_db( $field );
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $field['sub_fields'] as &$sub_field ) {
|
||||
|
||||
// vars
|
||||
$v = false;
|
||||
|
||||
|
||||
// key (backend)
|
||||
if( isset($value[ $sub_field['key'] ]) ) {
|
||||
|
||||
$v = $value[ $sub_field['key'] ];
|
||||
|
||||
// name (frontend)
|
||||
} elseif( isset($value[ $sub_field['_name'] ]) ) {
|
||||
|
||||
$v = $value[ $sub_field['_name'] ];
|
||||
|
||||
// empty
|
||||
} else {
|
||||
|
||||
// input is not set (hidden by conditioanl logic)
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update value
|
||||
acf_update_value( $v, $post_id, $sub_field );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* prepare_field_for_db
|
||||
*
|
||||
* This function will modify sub fields ready for update / load
|
||||
*
|
||||
* @type function
|
||||
* @date 4/11/16
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
*/
|
||||
|
||||
function prepare_field_for_db( $field ) {
|
||||
|
||||
// bail early if no sub fields
|
||||
if( empty($field['sub_fields']) ) return $field;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $field['sub_fields'] as &$sub_field ) {
|
||||
|
||||
// prefix name
|
||||
$sub_field['name'] = $field['name'] . '_' . $sub_field['_name'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field()
|
||||
*
|
||||
* Create the HTML interface for your field
|
||||
*
|
||||
* @param $field - an array holding all the field's data
|
||||
*
|
||||
* @type action
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*/
|
||||
|
||||
function render_field( $field ) {
|
||||
|
||||
// bail early if no sub fields
|
||||
if( empty($field['sub_fields']) ) return;
|
||||
|
||||
|
||||
// load values
|
||||
foreach( $field['sub_fields'] as &$sub_field ) {
|
||||
|
||||
// add value
|
||||
if( isset($field['value'][ $sub_field['key'] ]) ) {
|
||||
|
||||
// this is a normal value
|
||||
$sub_field['value'] = $field['value'][ $sub_field['key'] ];
|
||||
|
||||
} elseif( isset($sub_field['default_value']) ) {
|
||||
|
||||
// no value, but this sub field has a default value
|
||||
$sub_field['value'] = $sub_field['default_value'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update prefix to allow for nested values
|
||||
$sub_field['prefix'] = $field['name'];
|
||||
|
||||
|
||||
// restore required
|
||||
if( $field['required'] ) $sub_field['required'] = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// render
|
||||
if( $field['layout'] == 'table' ) {
|
||||
|
||||
$this->render_field_table( $field );
|
||||
|
||||
} else {
|
||||
|
||||
$this->render_field_block( $field );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_block
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 12/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function render_field_block( $field ) {
|
||||
|
||||
// vars
|
||||
$label_placement = $field['layout'] == 'block' ? 'top' : 'left';
|
||||
|
||||
|
||||
// html
|
||||
echo '<div class="acf-fields -'.$label_placement.' -border">';
|
||||
|
||||
foreach( $field['sub_fields'] as $sub_field ) {
|
||||
|
||||
acf_render_field_wrap( $sub_field );
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_table
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 12/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function render_field_table( $field ) {
|
||||
|
||||
?>
|
||||
<table class="acf-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach( $field['sub_fields'] as $sub_field ):
|
||||
|
||||
// prepare field (allow sub fields to be removed)
|
||||
$sub_field = acf_prepare_field($sub_field);
|
||||
|
||||
|
||||
// bail ealry if no field
|
||||
if( !$sub_field ) continue;
|
||||
|
||||
|
||||
// vars
|
||||
$atts = array();
|
||||
$atts['class'] = 'acf-th';
|
||||
$atts['data-name'] = $sub_field['_name'];
|
||||
$atts['data-type'] = $sub_field['type'];
|
||||
$atts['data-key'] = $sub_field['key'];
|
||||
|
||||
|
||||
// Add custom width
|
||||
if( $sub_field['wrapper']['width'] ) {
|
||||
|
||||
$atts['data-width'] = $sub_field['wrapper']['width'];
|
||||
$atts['style'] = 'width: ' . $sub_field['wrapper']['width'] . '%;';
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<th <?php acf_esc_attr_e( $atts ); ?>>
|
||||
<?php echo acf_get_field_label( $sub_field ); ?>
|
||||
<?php if( $sub_field['instructions'] ): ?>
|
||||
<p class="description"><?php echo $sub_field['instructions']; ?></p>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="acf-row">
|
||||
<?php
|
||||
|
||||
foreach( $field['sub_fields'] as $sub_field ) {
|
||||
|
||||
acf_render_field_wrap( $sub_field, 'td' );
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_settings()
|
||||
*
|
||||
* Create extra options for your field. This is rendered when editing a field.
|
||||
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
||||
*
|
||||
* @type action
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $field - an array holding all the field's data
|
||||
*/
|
||||
|
||||
function render_field_settings( $field ) {
|
||||
|
||||
// vars
|
||||
$args = array(
|
||||
'fields' => $field['sub_fields'],
|
||||
'parent' => $field['ID']
|
||||
);
|
||||
|
||||
|
||||
?><tr class="acf-field acf-field-setting-sub_fields" data-setting="group" data-name="sub_fields">
|
||||
<td class="acf-label">
|
||||
<label><?php _e("Sub Fields",'acf'); ?></label>
|
||||
<p class="description"></p>
|
||||
</td>
|
||||
<td class="acf-input">
|
||||
<?php
|
||||
|
||||
acf_get_view('field-group-fields', $args);
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
|
||||
// layout
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Layout','acf'),
|
||||
'instructions' => __('Specify the style used to render the selected fields', 'acf'),
|
||||
'type' => 'radio',
|
||||
'name' => 'layout',
|
||||
'layout' => 'horizontal',
|
||||
'choices' => array(
|
||||
'block' => __('Block','acf'),
|
||||
'table' => __('Table','acf'),
|
||||
'row' => __('Row','acf')
|
||||
)
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* validate_value
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 11/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function validate_value( $valid, $value, $field, $input ){
|
||||
|
||||
// bail early if no $value
|
||||
if( empty($value) ) return $valid;
|
||||
|
||||
|
||||
// bail early if no sub fields
|
||||
if( empty($field['sub_fields']) ) return $valid;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $field['sub_fields'] as $sub_field ) {
|
||||
|
||||
// get sub field
|
||||
$k = $sub_field['key'];
|
||||
|
||||
|
||||
// bail early if value not set (conditional logic?)
|
||||
if( !isset($value[ $k ]) ) continue;
|
||||
|
||||
|
||||
// required
|
||||
if( $field['required'] ) {
|
||||
$sub_field['required'] = 1;
|
||||
}
|
||||
|
||||
|
||||
// validate
|
||||
acf_validate_value( $value[ $k ], $sub_field, "{$input}[{$k}]" );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $valid;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( 'acf_field__group' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Image Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_image
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_image') ) :
|
||||
|
||||
class acf_field_image extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_image extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'image';
|
||||
|
|
@ -59,10 +48,6 @@ class acf_field_image extends acf_field {
|
|||
// filters
|
||||
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
|
||||
add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +82,7 @@ class acf_field_image extends acf_field {
|
|||
$url = '';
|
||||
$alt = '';
|
||||
$div = array(
|
||||
'class' => 'acf-image-uploader acf-cf',
|
||||
'class' => 'acf-image-uploader',
|
||||
'data-preview_size' => $field['preview_size'],
|
||||
'data-library' => $field['library'],
|
||||
'data-mime_types' => $field['mime_types'],
|
||||
|
|
@ -483,7 +468,7 @@ class acf_field_image extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_image() );
|
||||
acf_register_field_type( 'acf_field_image' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -0,0 +1,292 @@
|
|||
<?php
|
||||
|
||||
if( ! class_exists('acf_field_link') ) :
|
||||
|
||||
class acf_field_link extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'link';
|
||||
$this->label = __("Link",'acf');
|
||||
$this->category = 'relational';
|
||||
$this->defaults = array(
|
||||
'return_format' => 'array',
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_link
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 16/5/17
|
||||
* @since 5.5.13
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function get_link( $value = '' ) {
|
||||
|
||||
// vars
|
||||
$link = array(
|
||||
'title' => '',
|
||||
'url' => '',
|
||||
'target' => ''
|
||||
);
|
||||
|
||||
|
||||
// array (ACF 5.6.0)
|
||||
if( is_array($value) ) {
|
||||
|
||||
$link = array_merge($link, $value);
|
||||
|
||||
// post id (ACF < 5.6.0)
|
||||
} elseif( is_numeric($value) ) {
|
||||
|
||||
$link['title'] = get_the_title( $value );
|
||||
$link['url'] = get_permalink( $value );
|
||||
|
||||
// string (ACF < 5.6.0)
|
||||
} elseif( is_string($value) ) {
|
||||
|
||||
$link['url'] = $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $link;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field()
|
||||
*
|
||||
* Create the HTML interface for your field
|
||||
*
|
||||
* @param $field - an array holding all the field's data
|
||||
*
|
||||
* @type action
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*/
|
||||
|
||||
function render_field( $field ){
|
||||
|
||||
// vars
|
||||
$div = array(
|
||||
'id' => $field['id'],
|
||||
'class' => $field['class'] . ' acf-link',
|
||||
);
|
||||
|
||||
|
||||
// render scripts/styles
|
||||
acf_enqueue_uploader();
|
||||
|
||||
|
||||
// get link
|
||||
$link = $this->get_link( $field['value'] );
|
||||
|
||||
|
||||
// classes
|
||||
if( $link['url'] ) {
|
||||
$div['class'] .= ' -value';
|
||||
}
|
||||
|
||||
if( $link['target'] === '_blank' ) {
|
||||
$div['class'] .= ' -external';
|
||||
}
|
||||
|
||||
/*<textarea id="<?php echo esc_attr($field['id']); ?>-textarea"><?php
|
||||
echo esc_textarea('<a href="'.$link['url'].'" target="'.$link['target'].'">'.$link['title'].'</a>');
|
||||
?></textarea>*/
|
||||
?>
|
||||
<div <?php acf_esc_attr_e($div); ?>>
|
||||
|
||||
<div class="acf-hidden">
|
||||
<a class="link-node" href="<?php echo esc_url($link['url']); ?>" target="<?php echo esc_attr($link['target']); ?>"><?php echo esc_html($link['title']); ?></a>
|
||||
<?php foreach( $link as $k => $v ): ?>
|
||||
<?php acf_hidden_input(array( 'class' => "input-$k", 'name' => $field['name'] . "[$k]", 'value' => $v )); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<a href="#" class="button" data-name="add" target=""><?php _e('Select Link', 'acf'); ?></a>
|
||||
|
||||
<div class="link-wrap">
|
||||
<span class="link-title"><?php echo esc_html($link['title']); ?></span>
|
||||
<a class="link-url" href="<?php echo esc_url($link['url']); ?>" target="_blank"><?php echo esc_html($link['url']); ?></a>
|
||||
<i class="acf-icon -link-ext acf-js-tooltip" title="<?php _e('Opens in a new window/tab', 'acf'); ?>"></i><?php
|
||||
?><a class="acf-icon -pencil -clear acf-js-tooltip" data-name="edit" href="#" title="<?php _e('Edit', 'acf'); ?>"></a><?php
|
||||
?><a class="acf-icon -cancel -clear acf-js-tooltip" data-name="remove" href="#" title="<?php _e('Remove', 'acf'); ?>"></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_settings()
|
||||
*
|
||||
* Create extra options for your field. This is rendered when editing a field.
|
||||
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
||||
*
|
||||
* @type action
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $field - an array holding all the field's data
|
||||
*/
|
||||
|
||||
function render_field_settings( $field ) {
|
||||
|
||||
// return_format
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Return Value','acf'),
|
||||
'instructions' => __('Specify the returned value on front end','acf'),
|
||||
'type' => 'radio',
|
||||
'name' => 'return_format',
|
||||
'layout' => 'horizontal',
|
||||
'choices' => array(
|
||||
'array' => __("Link Array",'acf'),
|
||||
'url' => __("Link URL",'acf'),
|
||||
)
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* format_value()
|
||||
*
|
||||
* This filter is appied to the $value after it is loaded from the db and before it is returned to the template
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $value (mixed) the value which was loaded from the database
|
||||
* @param $post_id (mixed) the $post_id from which the value was loaded
|
||||
* @param $field (array) the field array holding all the field options
|
||||
*
|
||||
* @return $value (mixed) the modified value
|
||||
*/
|
||||
|
||||
function format_value( $value, $post_id, $field ) {
|
||||
|
||||
// bail early if no value
|
||||
if( empty($value) ) return $value;
|
||||
|
||||
|
||||
// get link
|
||||
$link = $this->get_link( $value );
|
||||
|
||||
|
||||
// format value
|
||||
if( $field['return_format'] == 'url' ) {
|
||||
|
||||
return $link['url'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return link
|
||||
return $link;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* validate_value
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 11/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function validate_value( $valid, $value, $field, $input ){
|
||||
|
||||
// bail early if not required
|
||||
if( !$field['required'] ) return $valid;
|
||||
|
||||
|
||||
// URL is required
|
||||
if( empty($value) || empty($value['url']) ) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $valid;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_value()
|
||||
*
|
||||
* This filter is appied to the $value before it is updated in the db
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $value - the value which will be saved in the database
|
||||
* @param $post_id - the $post_id of which the value will be saved
|
||||
* @param $field - the field array holding all the field options
|
||||
*
|
||||
* @return $value - the modified value
|
||||
*/
|
||||
|
||||
function update_value( $value, $post_id, $field ) {
|
||||
|
||||
// URL is required
|
||||
if( empty($value) || empty($value['url']) ) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( 'acf_field_link' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Message Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_message
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_message') ) :
|
||||
|
||||
class acf_field_message extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_message extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'message';
|
||||
|
|
@ -41,9 +30,6 @@ class acf_field_message extends acf_field {
|
|||
'new_lines' => 'wpautop',
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -207,7 +193,7 @@ class acf_field_message extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_message() );
|
||||
acf_register_field_type( 'acf_field_message' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,23 +1,12 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Number Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_number
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_number') ) :
|
||||
|
||||
class acf_field_number extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
* initialize
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_number extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'number';
|
||||
|
|
@ -44,9 +33,6 @@ class acf_field_number extends acf_field {
|
|||
'append' => ''
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -66,16 +52,14 @@ class acf_field_number extends acf_field {
|
|||
|
||||
// vars
|
||||
$atts = array();
|
||||
$o = array( 'type', 'id', 'class', 'min', 'max', 'step', 'name', 'value', 'placeholder' );
|
||||
$s = array( 'readonly', 'disabled' );
|
||||
$e = '';
|
||||
$keys = array( 'type', 'id', 'class', 'name', 'value', 'min', 'max', 'step', 'placeholder', 'pattern' );
|
||||
$keys2 = array( 'readonly', 'disabled' );
|
||||
$html = '';
|
||||
|
||||
|
||||
// step
|
||||
if( !$field['step'] ) {
|
||||
|
||||
$field['step'] = 'any';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -83,7 +67,7 @@ class acf_field_number extends acf_field {
|
|||
if( $field['prepend'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-prepended';
|
||||
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
||||
$html .= '<div class="acf-input-prepend">' . acf_esc_html($field['prepend']) . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -92,35 +76,29 @@ class acf_field_number extends acf_field {
|
|||
if( $field['append'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-appended';
|
||||
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
||||
$html .= '<div class="acf-input-append">' . acf_esc_html($field['append']) . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append atts
|
||||
foreach( $o as $k ) {
|
||||
|
||||
$atts[ $k ] = $field[ $k ];
|
||||
|
||||
// atts
|
||||
foreach( $keys as $k ) {
|
||||
if( isset($field[ $k ]) ) $atts[ $k ] = $field[ $k ];
|
||||
}
|
||||
|
||||
|
||||
// append special atts
|
||||
foreach( $s as $k ) {
|
||||
|
||||
// atts2
|
||||
foreach( $keys2 as $k ) {
|
||||
if( !empty($field[ $k ]) ) $atts[ $k ] = $k;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// render
|
||||
$e .= '<div class="acf-input-wrap">';
|
||||
$e .= '<input ' . acf_esc_attr( $atts ) . ' />';
|
||||
$e .= '</div>';
|
||||
$html .= '<div class="acf-input-wrap">' . acf_get_text_input( $atts ) . '</div>';
|
||||
|
||||
|
||||
// return
|
||||
echo $e;
|
||||
echo $html;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -307,6 +285,7 @@ class acf_field_number extends acf_field {
|
|||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -314,7 +293,7 @@ class acf_field_number extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_number() );
|
||||
acf_register_field_type( 'acf_field_number' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF oEmbed Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_oembed
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_oembed') ) :
|
||||
|
||||
class acf_field_oembed extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_oembed extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'oembed';
|
||||
|
|
@ -46,10 +35,6 @@ class acf_field_oembed extends acf_field {
|
|||
// extra
|
||||
add_action('wp_ajax_acf/fields/oembed/search', array($this, 'ajax_query'));
|
||||
add_action('wp_ajax_nopriv_acf/fields/oembed/search', array($this, 'ajax_query'));
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +327,7 @@ class acf_field_oembed extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_oembed() );
|
||||
acf_register_field_type( 'acf_field_oembed' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Output Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_output
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_output') ) :
|
||||
|
||||
class acf_field_output extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_output extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'output';
|
||||
|
|
@ -39,9 +28,6 @@ class acf_field_output extends acf_field {
|
|||
'html' => false
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -84,7 +70,7 @@ class acf_field_output extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_output() );
|
||||
acf_register_field_type( 'acf_field_output' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Page Link Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_page_link
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_page_link') ) :
|
||||
|
||||
class acf_field_page_link extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_page_link extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'page_link';
|
||||
|
|
@ -47,10 +36,6 @@ class acf_field_page_link extends acf_field {
|
|||
// extra
|
||||
add_action('wp_ajax_acf/fields/page_link/query', array($this, 'ajax_query'));
|
||||
add_action('wp_ajax_nopriv_acf/fields/page_link/query', array($this, 'ajax_query'));
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -688,7 +673,7 @@ class acf_field_page_link extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_page_link() );
|
||||
acf_register_field_type( 'acf_field_page_link' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,23 +1,12 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Password Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_password
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_password') ) :
|
||||
|
||||
class acf_field_password extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
* initialize
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_password extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'password';
|
||||
|
|
@ -38,13 +27,8 @@ class acf_field_password extends acf_field {
|
|||
'placeholder' => '',
|
||||
'prepend' => '',
|
||||
'append' => '',
|
||||
'readonly' => 0,
|
||||
'disabled' => 0,
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -62,55 +46,8 @@ class acf_field_password extends acf_field {
|
|||
|
||||
function render_field( $field ) {
|
||||
|
||||
// vars
|
||||
$atts = array();
|
||||
$o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' );
|
||||
$s = array( 'readonly', 'disabled' );
|
||||
$e = '';
|
||||
acf_get_field_type('text')->render_field( $field );
|
||||
|
||||
|
||||
// prepend
|
||||
if( $field['prepend'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-prepended';
|
||||
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
if( $field['append'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-appended';
|
||||
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append atts
|
||||
foreach( $o as $k ) {
|
||||
|
||||
$atts[ $k ] = $field[ $k ];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append special atts
|
||||
foreach( $s as $k ) {
|
||||
|
||||
if( !empty($field[ $k ]) ) $atts[ $k ] = $k;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// render
|
||||
$e .= '<div class="acf-input-wrap">';
|
||||
$e .= '<input ' . acf_esc_attr( $atts ) . ' />';
|
||||
$e .= '</div>';
|
||||
|
||||
|
||||
// return
|
||||
echo $e;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -160,7 +97,7 @@ class acf_field_password extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_password() );
|
||||
acf_register_field_type( 'acf_field_password' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Post Object Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_post_object
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_post_object') ) :
|
||||
|
||||
class acf_field_post_object extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_post_object extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'post_object';
|
||||
|
|
@ -49,10 +38,6 @@ class acf_field_post_object extends acf_field {
|
|||
add_action('wp_ajax_acf/fields/post_object/query', array($this, 'ajax_query'));
|
||||
add_action('wp_ajax_nopriv_acf/fields/post_object/query', array($this, 'ajax_query'));
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -631,7 +616,7 @@ class acf_field_post_object extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_post_object() );
|
||||
acf_register_field_type( 'acf_field_post_object' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Radio Button Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_radio
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_radio') ) :
|
||||
|
||||
class acf_field_radio extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_radio extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'radio';
|
||||
|
|
@ -45,10 +34,6 @@ class acf_field_radio extends acf_field {
|
|||
'return_format' => 'value'
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -395,6 +380,10 @@ class acf_field_radio extends acf_field {
|
|||
$value = wp_unslash($value);
|
||||
|
||||
|
||||
// sanitize (remove tags)
|
||||
$value = sanitize_text_field($value);
|
||||
|
||||
|
||||
// update $field
|
||||
$field['choices'][ $value ] = $value;
|
||||
|
||||
|
|
@ -490,7 +479,7 @@ class acf_field_radio extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_radio() );
|
||||
acf_register_field_type( 'acf_field_radio' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Relationship Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_relationship
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_relationship') ) :
|
||||
|
||||
class acf_field_relationship extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_relationship extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'relationship';
|
||||
|
|
@ -55,10 +44,6 @@ class acf_field_relationship extends acf_field {
|
|||
// extra
|
||||
add_action('wp_ajax_acf/fields/relationship/query', array($this, 'ajax_query'));
|
||||
add_action('wp_ajax_nopriv_acf/fields/relationship/query', array($this, 'ajax_query'));
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -414,147 +399,108 @@ class acf_field_relationship extends acf_field {
|
|||
// data types
|
||||
$field['post_type'] = acf_get_array( $field['post_type'] );
|
||||
$field['taxonomy'] = acf_get_array( $field['taxonomy'] );
|
||||
$field['filters'] = acf_get_array( $field['filters'] );
|
||||
|
||||
|
||||
// width for select filters
|
||||
$width = array(
|
||||
'search' => 0,
|
||||
'post_type' => 0,
|
||||
'taxonomy' => 0
|
||||
// filters
|
||||
$filters = array(
|
||||
'count' => count($field['filters']),
|
||||
'search' => false,
|
||||
'post_type' => false,
|
||||
'taxonomy' => false
|
||||
);
|
||||
|
||||
if( !empty($field['filters']) ) {
|
||||
foreach( $field['filters'] as $filter ) {
|
||||
$filters[ $filter ] = true;
|
||||
}
|
||||
|
||||
|
||||
// filter - post_type
|
||||
if( $filters['post_type'] ) {
|
||||
|
||||
$width = array(
|
||||
'search' => 50,
|
||||
'post_type' => 25,
|
||||
'taxonomy' => 25
|
||||
// choices
|
||||
$choices = array(
|
||||
'' => __('Select post type', 'acf')
|
||||
);
|
||||
|
||||
foreach( array_keys($width) as $k ) {
|
||||
|
||||
if( ! in_array($k, $field['filters']) ) {
|
||||
|
||||
$width[ $k ] = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// get post types
|
||||
$post_types = acf_get_pretty_post_types($field['post_type']);
|
||||
|
||||
|
||||
// search
|
||||
if( $width['search'] == 0 ) {
|
||||
|
||||
$width['post_type'] = ( $width['post_type'] == 0 ) ? 0 : 50;
|
||||
$width['taxonomy'] = ( $width['taxonomy'] == 0 ) ? 0 : 50;
|
||||
|
||||
}
|
||||
|
||||
// post_type
|
||||
if( $width['post_type'] == 0 ) {
|
||||
|
||||
$width['taxonomy'] = ( $width['taxonomy'] == 0 ) ? 0 : 50;
|
||||
|
||||
}
|
||||
// append
|
||||
$choices = $choices + $post_types;
|
||||
|
||||
|
||||
// taxonomy
|
||||
if( $width['taxonomy'] == 0 ) {
|
||||
|
||||
$width['post_type'] = ( $width['post_type'] == 0 ) ? 0 : 50;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// search
|
||||
if( $width['post_type'] == 0 && $width['taxonomy'] == 0 ) {
|
||||
|
||||
$width['search'] = ( $width['search'] == 0 ) ? 0 : 100;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// post type filter
|
||||
$post_types = array();
|
||||
|
||||
if( $width['post_type'] ) {
|
||||
|
||||
if( !empty($field['post_type']) ) {
|
||||
|
||||
$post_types = $field['post_type'];
|
||||
|
||||
}
|
||||
|
||||
$post_types = acf_get_pretty_post_types($post_types);
|
||||
// set filter
|
||||
$filters['post_type'] = $choices;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// taxonomy filter
|
||||
$taxonomies = array();
|
||||
$term_groups = array();
|
||||
|
||||
if( $width['taxonomy'] ) {
|
||||
if( $filters['taxonomy'] ) {
|
||||
|
||||
// taxonomies
|
||||
// vars
|
||||
$groups = array();
|
||||
$taxonomies = array();
|
||||
$choices = array(
|
||||
'' => __('Select taxonomy', 'acf')
|
||||
);
|
||||
|
||||
|
||||
// get taxonomies from setting
|
||||
if( !empty($field['taxonomy']) ) {
|
||||
|
||||
// get the field's terms
|
||||
$term_groups = acf_get_array( $field['taxonomy'] );
|
||||
$term_groups = acf_decode_taxonomy_terms( $term_groups );
|
||||
|
||||
|
||||
// update taxonomies
|
||||
$term_groups = acf_decode_taxonomy_terms( $field['taxonomy'] );
|
||||
$taxonomies = array_keys($term_groups);
|
||||
|
||||
// check empty
|
||||
$taxonomies = empty($taxonomies) ? false : $taxonomies;
|
||||
|
||||
} elseif( !empty($field['post_type']) ) {
|
||||
|
||||
// loop over post types and find connected taxonomies
|
||||
// loop
|
||||
foreach( $field['post_type'] as $post_type ) {
|
||||
|
||||
// get connected taxonomies
|
||||
$post_taxonomies = get_object_taxonomies( $post_type );
|
||||
|
||||
// bail early if no taxonomies
|
||||
if( empty($post_taxonomies) ) {
|
||||
|
||||
continue;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $post_taxonomies as $name ) {
|
||||
$taxonomies[ $name ] = 1;
|
||||
}
|
||||
|
||||
foreach( $post_taxonomies as $post_taxonomy ) {
|
||||
|
||||
if( !in_array($post_taxonomy, $taxonomies) ) {
|
||||
|
||||
$taxonomies[] = $post_taxonomy;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$taxonomies = acf_get_taxonomies();
|
||||
// convert back to array
|
||||
$taxonomies = array_keys($taxonomies);
|
||||
|
||||
// check empty
|
||||
$taxonomies = empty($taxonomies) ? false : $taxonomies;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// terms
|
||||
$term_groups = acf_get_taxonomy_terms( $taxonomies );
|
||||
if( $taxonomies !== false ) {
|
||||
$groups = acf_get_taxonomy_terms( $taxonomies );
|
||||
}
|
||||
|
||||
|
||||
// update $term_groups with specific terms
|
||||
if( !empty($field['taxonomy']) ) {
|
||||
|
||||
foreach( array_keys($term_groups) as $taxonomy ) {
|
||||
foreach( $groups as $taxonomy => $terms ) {
|
||||
|
||||
foreach( array_keys($term_groups[ $taxonomy ]) as $term ) {
|
||||
foreach( $terms as $slug => $name ) {
|
||||
|
||||
if( ! in_array($term, $field['taxonomy']) ) {
|
||||
if( !in_array($slug, $field['taxonomy']) ) {
|
||||
|
||||
unset($term_groups[ $taxonomy ][ $term ]);
|
||||
unset($groups[ $taxonomy ][ $slug ]);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -563,121 +509,94 @@ class acf_field_relationship extends acf_field {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
$choices = $choices + $groups;
|
||||
|
||||
|
||||
// set filter
|
||||
$filters['taxonomy'] = $choices;
|
||||
|
||||
}
|
||||
// end taxonomy filter
|
||||
|
||||
|
||||
?>
|
||||
<div <?php acf_esc_attr_e($atts); ?>>
|
||||
|
||||
<div class="acf-hidden">
|
||||
<input type="hidden" name="<?php echo $field['name']; ?>" value="" />
|
||||
</div>
|
||||
<?php acf_hidden_input( array('name' => $field['name'], 'value' => '') ); ?>
|
||||
|
||||
<?php if( $width['search'] || $width['post_type'] || $width['taxonomy'] ): ?>
|
||||
<div class="filters">
|
||||
<?php
|
||||
|
||||
/* filters */
|
||||
if( $filters['count'] ): ?>
|
||||
<div class="filters -f<?php echo esc_attr($filters['count']); ?>">
|
||||
<?php
|
||||
|
||||
/* search */
|
||||
if( $filters['search'] ): ?>
|
||||
<div class="filter -search">
|
||||
<span>
|
||||
<?php acf_text_input( array('placeholder' => __("Search...",'acf'), 'data-filter' => 's') ); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif;
|
||||
|
||||
<ul class="acf-hl">
|
||||
|
||||
<?php if( $width['search'] ): ?>
|
||||
<li style="width:<?php echo $width['search']; ?>%;">
|
||||
<div class="inner">
|
||||
<input class="filter" data-filter="s" placeholder="<?php _e("Search...",'acf'); ?>" type="text" />
|
||||
</div>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if( $width['post_type'] ): ?>
|
||||
<li style="width:<?php echo $width['post_type']; ?>%;">
|
||||
<div class="inner">
|
||||
<select class="filter" data-filter="post_type">
|
||||
<option value=""><?php _e('Select post type','acf'); ?></option>
|
||||
<?php foreach( $post_types as $k => $v ): ?>
|
||||
<option value="<?php echo $k; ?>"><?php echo $v; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if( $width['taxonomy'] ): ?>
|
||||
<li style="width:<?php echo $width['taxonomy']; ?>%;">
|
||||
<div class="inner">
|
||||
<select class="filter" data-filter="taxonomy">
|
||||
<option value=""><?php _e('Select taxonomy','acf'); ?></option>
|
||||
<?php foreach( $term_groups as $k_opt => $v_opt ): ?>
|
||||
<optgroup label="<?php echo $k_opt; ?>">
|
||||
<?php foreach( $v_opt as $k => $v ): ?>
|
||||
<option value="<?php echo $k; ?>"><?php echo $v; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
/* post_type */
|
||||
if( $filters['post_type'] ): ?>
|
||||
<div class="filter -post_type">
|
||||
<span>
|
||||
<?php acf_select_input( array('choices' => $filters['post_type'], 'data-filter' => 'post_type') ); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif;
|
||||
|
||||
|
||||
/* post_type */
|
||||
if( $filters['taxonomy'] ): ?>
|
||||
<div class="filter -taxonomy">
|
||||
<span>
|
||||
<?php acf_select_input( array('choices' => $filters['taxonomy'], 'data-filter' => 'taxonomy') ); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="selection acf-cf">
|
||||
|
||||
<div class="selection">
|
||||
<div class="choices">
|
||||
|
||||
<ul class="acf-bl list"></ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="values">
|
||||
|
||||
<ul class="acf-bl list">
|
||||
|
||||
<?php if( !empty($field['value']) ):
|
||||
|
||||
// get posts
|
||||
$posts = acf_get_posts(array(
|
||||
'post__in' => $field['value'],
|
||||
'post_type' => $field['post_type']
|
||||
));
|
||||
|
||||
|
||||
// set choices
|
||||
if( !empty($posts) ):
|
||||
|
||||
foreach( array_keys($posts) as $i ):
|
||||
|
||||
// vars
|
||||
$post = acf_extract_var( $posts, $i );
|
||||
|
||||
|
||||
?><li>
|
||||
<input type="hidden" name="<?php echo $field['name']; ?>[]" value="<?php echo $post->ID; ?>" />
|
||||
<span data-id="<?php echo $post->ID; ?>" class="acf-rel-item">
|
||||
<?php echo $this->get_post_title( $post, $field ); ?>
|
||||
<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a>
|
||||
</span>
|
||||
</li><?php
|
||||
|
||||
endforeach;
|
||||
|
||||
endif;
|
||||
<?php if( !empty($field['value']) ):
|
||||
|
||||
endif; ?>
|
||||
// get posts
|
||||
$posts = acf_get_posts(array(
|
||||
'post__in' => $field['value'],
|
||||
'post_type' => $field['post_type']
|
||||
));
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $posts as $post ): ?>
|
||||
<li>
|
||||
<?php acf_hidden_input( array('name' => $field['name'].'[]', 'value' => $post->ID) ); ?>
|
||||
<span data-id="<?php echo esc_attr($post->ID); ?>" class="acf-rel-item">
|
||||
<?php echo $this->get_post_title( $post, $field ); ?>
|
||||
<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a>
|
||||
</span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* render_field_settings()
|
||||
|
|
@ -936,7 +855,7 @@ class acf_field_relationship extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_relationship() );
|
||||
acf_register_field_type( 'acf_field_relationship' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Select Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_select
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_select') ) :
|
||||
|
||||
class acf_field_select extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_select extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'select';
|
||||
|
|
@ -64,10 +53,6 @@ class acf_field_select extends acf_field {
|
|||
// ajax
|
||||
add_action('wp_ajax_acf/fields/select/query', array($this, 'ajax_query'));
|
||||
add_action('wp_ajax_nopriv_acf/fields/select/query', array($this, 'ajax_query'));
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -194,29 +179,26 @@ class acf_field_select extends acf_field {
|
|||
if( !$field ) return false;
|
||||
|
||||
|
||||
// get choices
|
||||
$choices = acf_get_array($field['choices']);
|
||||
if( empty($field['choices']) ) return false;
|
||||
|
||||
|
||||
// vars
|
||||
$results = array();
|
||||
$s = false;
|
||||
$is_search = false;
|
||||
$s = null;
|
||||
|
||||
|
||||
// search
|
||||
if( $options['s'] !== '' ) {
|
||||
|
||||
// strip slashes (search may be integer)
|
||||
$s = wp_unslash( strval($options['s']) );
|
||||
|
||||
|
||||
// update vars
|
||||
$is_search = true;
|
||||
$s = strval( $options['s'] );
|
||||
$s = wp_unslash( $s );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail ealry if no choices
|
||||
if( empty($field['choices']) ) return false;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $field['choices'] as $k => $v ) {
|
||||
|
||||
|
|
@ -225,7 +207,7 @@ class acf_field_select extends acf_field {
|
|||
|
||||
|
||||
// if searching, but doesn't exist
|
||||
if( $is_search && stripos($v, $s) === false ) continue;
|
||||
if( is_string($s) && stripos($v, $s) === false ) continue;
|
||||
|
||||
|
||||
// append
|
||||
|
|
@ -264,23 +246,19 @@ class acf_field_select extends acf_field {
|
|||
function render_field( $field ) {
|
||||
|
||||
// convert
|
||||
$field['value'] = acf_get_array($field['value'], false);
|
||||
$field['choices'] = acf_get_array($field['choices']);
|
||||
$value = acf_get_array($field['value']);
|
||||
$choices = acf_get_array($field['choices']);
|
||||
|
||||
|
||||
// placeholder
|
||||
if( empty($field['placeholder']) ) {
|
||||
|
||||
$field['placeholder'] = _x('Select', 'verb', 'acf');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add empty value (allows '' to be selected)
|
||||
if( empty($field['value']) ) {
|
||||
|
||||
$field['value'] = array('');
|
||||
|
||||
if( empty($value) ) {
|
||||
$value = array('');
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -289,13 +267,13 @@ class acf_field_select extends acf_field {
|
|||
if( $field['allow_null'] && !$field['multiple'] ) {
|
||||
|
||||
$prepend = array('' => '- ' . $field['placeholder'] . ' -');
|
||||
$field['choices'] = $prepend + $field['choices'];
|
||||
$choices = $prepend + $choices;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$atts = array(
|
||||
$select = array(
|
||||
'id' => $field['id'],
|
||||
'class' => $field['class'],
|
||||
'name' => $field['name'],
|
||||
|
|
@ -310,33 +288,23 @@ class acf_field_select extends acf_field {
|
|||
// multiple
|
||||
if( $field['multiple'] ) {
|
||||
|
||||
$atts['multiple'] = 'multiple';
|
||||
$atts['size'] = 5;
|
||||
$atts['name'] .= '[]';
|
||||
$select['multiple'] = 'multiple';
|
||||
$select['size'] = 5;
|
||||
$select['name'] .= '[]';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// special atts
|
||||
foreach( array( 'readonly', 'disabled' ) as $k ) {
|
||||
|
||||
if( !empty($field[ $k ]) ) $atts[ $k ] = $k;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// custom ajax action
|
||||
if( !empty($field['ajax_action']) ) {
|
||||
|
||||
$atts['data-ajax_action'] = $field['ajax_action'];
|
||||
|
||||
}
|
||||
if( !empty($field['readonly']) ) $select['readonly'] = 'readonly';
|
||||
if( !empty($field['disabled']) ) $select['disabled'] = 'disabled';
|
||||
if( !empty($field['ajax_action']) ) $select['data-ajax_action'] = $field['ajax_action'];
|
||||
|
||||
|
||||
// hidden input
|
||||
if( $field['ui'] ) {
|
||||
|
||||
$v = $field['value'];
|
||||
$v = $value;
|
||||
|
||||
if( $field['multiple'] ) {
|
||||
|
||||
|
|
@ -364,86 +332,16 @@ class acf_field_select extends acf_field {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// open
|
||||
echo '<select ' . acf_esc_attr($atts) . '>';
|
||||
// append
|
||||
$select['value'] = $value;
|
||||
$select['choices'] = $choices;
|
||||
|
||||
|
||||
// walk
|
||||
$this->walk( $field['choices'], $field['value'] );
|
||||
|
||||
|
||||
// close
|
||||
echo '</select>';
|
||||
// render
|
||||
acf_select_input( $select );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* walk
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 22/12/2015
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function walk( $choices, $values ) {
|
||||
|
||||
// bail ealry if no choices
|
||||
if( empty($choices) ) return;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $choices as $k => $v ) {
|
||||
|
||||
// optgroup
|
||||
if( is_array($v) ){
|
||||
|
||||
// optgroup
|
||||
echo '<optgroup label="' . esc_attr($k) . '">';
|
||||
|
||||
|
||||
// walk
|
||||
$this->walk( $v, $values );
|
||||
|
||||
|
||||
// close optgroup
|
||||
echo '</optgroup>';
|
||||
|
||||
|
||||
// break
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$search = html_entity_decode($k);
|
||||
$pos = array_search($search, $values);
|
||||
$atts = array( 'value' => $k );
|
||||
|
||||
|
||||
// validate selected
|
||||
if( $pos !== false ) {
|
||||
|
||||
$atts['selected'] = 'selected';
|
||||
$atts['data-i'] = $pos;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// option
|
||||
echo '<option ' . acf_esc_attr($atts) . '>' . $v . '</option>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_settings()
|
||||
|
|
@ -737,7 +635,7 @@ class acf_field_select extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_select() );
|
||||
acf_register_field_type( 'acf_field_select' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
if( ! class_exists('acf_field_separator') ) :
|
||||
|
||||
class acf_field_separator extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'separator';
|
||||
$this->label = __("Separator",'acf');
|
||||
$this->category = 'layout';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field()
|
||||
*
|
||||
* Create the HTML interface for your field
|
||||
*
|
||||
* @param $field - an array holding all the field's data
|
||||
*
|
||||
* @type action
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*/
|
||||
|
||||
function render_field( $field ) {
|
||||
|
||||
/* do nothing */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* load_field()
|
||||
*
|
||||
* This filter is appied to the $field after it is loaded from the database
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $field - the field array holding all the field options
|
||||
*
|
||||
* @return $field - the field array holding all the field options
|
||||
*/
|
||||
|
||||
function load_field( $field ) {
|
||||
|
||||
// remove name to avoid caching issue
|
||||
$field['name'] = '';
|
||||
|
||||
|
||||
// remove required to avoid JS issues
|
||||
$field['required'] = 0;
|
||||
|
||||
|
||||
// set value other than 'null' to avoid ACF loading / caching issue
|
||||
$field['value'] = false;
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( 'acf_field_separator' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Tab Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_tab
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_tab') ) :
|
||||
|
||||
class acf_field_tab extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_tab extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'tab';
|
||||
|
|
@ -40,9 +29,6 @@ class acf_field_tab extends acf_field {
|
|||
'endpoint' => 0 // added in 5.2.8
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -68,7 +54,7 @@ class acf_field_tab extends acf_field {
|
|||
);
|
||||
|
||||
?>
|
||||
<div <?php acf_esc_attr_e( $atts ); ?>><?php echo $field['label']; ?></div>
|
||||
<div <?php acf_esc_attr_e( $atts ); ?>><?php echo acf_esc_html($field['label']); ?></div>
|
||||
<?php
|
||||
|
||||
|
||||
|
|
@ -168,7 +154,7 @@ class acf_field_tab extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_tab() );
|
||||
acf_register_field_type( 'acf_field_tab' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,20 +1,12 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Taxonomy Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_tab
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_taxonomy') ) :
|
||||
|
||||
class acf_field_taxonomy extends acf_field {
|
||||
|
||||
// vars
|
||||
var $save_post_terms = array();
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
|
|
@ -29,7 +21,7 @@ class acf_field_taxonomy extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'taxonomy';
|
||||
|
|
@ -54,13 +46,8 @@ class acf_field_taxonomy extends acf_field {
|
|||
add_action('wp_ajax_acf/fields/taxonomy/add_term', array($this, 'ajax_add_term'));
|
||||
|
||||
|
||||
// custom set_terms
|
||||
$this->save_post_terms = array();
|
||||
// actions
|
||||
add_action('acf/save_post', array($this, 'save_post'), 15, 1);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -709,6 +696,10 @@ class acf_field_taxonomy extends acf_field {
|
|||
$taxonomy_obj = get_taxonomy($field['taxonomy']);
|
||||
|
||||
|
||||
// include walker
|
||||
acf_include('includes/walkers/class-acf-walker-taxonomy-field.php');
|
||||
|
||||
|
||||
// vars
|
||||
$args = array(
|
||||
'taxonomy' => $field['taxonomy'],
|
||||
|
|
@ -1009,60 +1000,8 @@ class acf_field_taxonomy extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_taxonomy() );
|
||||
acf_register_field_type( 'acf_field_taxonomy' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
|
||||
if( ! class_exists('acf_taxonomy_field_walker') ) :
|
||||
|
||||
class acf_taxonomy_field_walker extends Walker {
|
||||
|
||||
var $field = null,
|
||||
$tree_type = 'category',
|
||||
$db_fields = array ( 'parent' => 'parent', 'id' => 'term_id' );
|
||||
|
||||
function __construct( $field ) {
|
||||
|
||||
$this->field = $field;
|
||||
|
||||
}
|
||||
|
||||
function start_el( &$output, $term, $depth = 0, $args = array(), $current_object_id = 0) {
|
||||
|
||||
// vars
|
||||
$selected = in_array( $term->term_id, $this->field['value'] );
|
||||
|
||||
|
||||
// append
|
||||
$output .= '<li data-id="' . $term->term_id . '"><label><input type="' . $this->field['field_type'] . '" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checked"' : '') . ' /> <span>' . $term->name . '</span></label>';
|
||||
|
||||
}
|
||||
|
||||
function end_el( &$output, $term, $depth = 0, $args = array() ) {
|
||||
|
||||
// append
|
||||
$output .= '</li>' . "\n";
|
||||
|
||||
}
|
||||
|
||||
function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
|
||||
// append
|
||||
$output .= '<ul class="children acf-bl">' . "\n";
|
||||
|
||||
}
|
||||
|
||||
function end_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
|
||||
// append
|
||||
$output .= '</ul>' . "\n";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
|
@ -1,23 +1,12 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Text Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_text
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_text') ) :
|
||||
|
||||
class acf_field_text extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
* initialize
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_text extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'text';
|
||||
|
|
@ -42,9 +31,6 @@ class acf_field_text extends acf_field {
|
|||
'append' => ''
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -64,24 +50,16 @@ class acf_field_text extends acf_field {
|
|||
|
||||
// vars
|
||||
$atts = array();
|
||||
$o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' );
|
||||
$s = array( 'readonly', 'disabled' );
|
||||
$e = '';
|
||||
|
||||
|
||||
// maxlength
|
||||
if( $field['maxlength'] ) {
|
||||
|
||||
$o[] = 'maxlength';
|
||||
|
||||
}
|
||||
$keys = array( 'type', 'id', 'class', 'name', 'value', 'placeholder', 'maxlength', 'pattern' );
|
||||
$keys2 = array( 'readonly', 'disabled' );
|
||||
$html = '';
|
||||
|
||||
|
||||
// prepend
|
||||
if( $field['prepend'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-prepended';
|
||||
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
||||
$html .= '<div class="acf-input-prepend">' . acf_esc_html($field['prepend']) . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -90,35 +68,30 @@ class acf_field_text extends acf_field {
|
|||
if( $field['append'] !== '' ) {
|
||||
|
||||
$field['class'] .= ' acf-is-appended';
|
||||
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
||||
$html .= '<div class="acf-input-append">' . acf_esc_html($field['append']) . '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append atts
|
||||
foreach( $o as $k ) {
|
||||
|
||||
$atts[ $k ] = $field[ $k ];
|
||||
|
||||
// atts
|
||||
foreach( $keys as $k ) {
|
||||
if( isset($field[ $k ]) ) $atts[ $k ] = $field[ $k ];
|
||||
}
|
||||
|
||||
|
||||
// append special atts
|
||||
foreach( $s as $k ) {
|
||||
|
||||
// atts2
|
||||
foreach( $keys2 as $k ) {
|
||||
if( !empty($field[ $k ]) ) $atts[ $k ] = $k;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// render
|
||||
$e .= '<div class="acf-input-wrap">';
|
||||
$e .= '<input ' . acf_esc_attr( $atts ) . ' />';
|
||||
$e .= '</div>';
|
||||
$html .= '<div class="acf-input-wrap">' . acf_get_text_input( $atts ) . '</div>';
|
||||
|
||||
|
||||
// return
|
||||
echo $e;
|
||||
echo $html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -187,7 +160,7 @@ class acf_field_text extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_text() );
|
||||
acf_register_field_type( 'acf_field_text' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,23 +1,12 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Text Area Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_textarea
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_textarea') ) :
|
||||
|
||||
class acf_field_textarea extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
* initialize
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_textarea extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'textarea';
|
||||
|
|
@ -42,9 +31,6 @@ class acf_field_textarea extends acf_field {
|
|||
'rows' => ''
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -64,53 +50,34 @@ class acf_field_textarea extends acf_field {
|
|||
|
||||
// vars
|
||||
$atts = array();
|
||||
$o = array( 'id', 'class', 'name', 'placeholder', 'rows' );
|
||||
$s = array( 'readonly', 'disabled' );
|
||||
$e = '';
|
||||
|
||||
|
||||
// maxlength
|
||||
if( $field['maxlength'] ) {
|
||||
|
||||
$o[] = 'maxlength';
|
||||
|
||||
}
|
||||
$keys = array( 'id', 'class', 'name', 'value', 'placeholder', 'rows', 'maxlength' );
|
||||
$keys2 = array( 'readonly', 'disabled' );
|
||||
|
||||
|
||||
// rows
|
||||
if( empty($field['rows']) ) {
|
||||
|
||||
if( !$field['rows'] ) {
|
||||
$field['rows'] = 8;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append atts
|
||||
foreach( $o as $k ) {
|
||||
|
||||
$atts[ $k ] = $field[ $k ];
|
||||
|
||||
// atts
|
||||
foreach( $keys as $k ) {
|
||||
if( isset($field[ $k ]) ) $atts[ $k ] = $field[ $k ];
|
||||
}
|
||||
|
||||
|
||||
// append special atts
|
||||
foreach( $s as $k ) {
|
||||
|
||||
// atts2
|
||||
foreach( $keys2 as $k ) {
|
||||
if( !empty($field[ $k ]) ) $atts[ $k ] = $k;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$e .= '<textarea ' . acf_esc_attr( $atts ) . ' >';
|
||||
$e .= esc_textarea( $field['value'] );
|
||||
$e .= '</textarea>';
|
||||
|
||||
|
||||
// return
|
||||
echo $e;
|
||||
echo acf_get_textarea_input( $atts );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_settings()
|
||||
*
|
||||
|
|
@ -126,14 +93,6 @@ class acf_field_textarea extends acf_field {
|
|||
|
||||
function render_field_settings( $field ) {
|
||||
|
||||
// ACF4 migration
|
||||
if( empty($field['ID']) ) {
|
||||
|
||||
$field['new_lines'] = 'wpautop';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// default_value
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Default Value','acf'),
|
||||
|
|
@ -233,7 +192,7 @@ class acf_field_textarea extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_textarea() );
|
||||
acf_register_field_type( 'acf_field_textarea' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Time Picker Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_time_picker
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_time_picker') ) :
|
||||
|
||||
class acf_field_time_picker extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_time_picker extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'time_picker';
|
||||
|
|
@ -40,9 +29,6 @@ class acf_field_time_picker extends acf_field {
|
|||
'return_format' => 'g:i a'
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -64,26 +50,23 @@ class acf_field_time_picker extends acf_field {
|
|||
$display_value = '';
|
||||
|
||||
if( $field['value'] ) {
|
||||
|
||||
$display_value = acf_format_date( $field['value'], $field['display_format'] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$e = '';
|
||||
$div = array(
|
||||
'class' => 'acf-time-picker acf-input-wrap',
|
||||
'data-time_format' => acf_convert_time_to_js($field['display_format'])
|
||||
);
|
||||
$hidden = array(
|
||||
$hidden_input = array(
|
||||
'id' => $field['id'],
|
||||
'class' => 'input-alt',
|
||||
'type' => 'hidden',
|
||||
'name' => $field['name'],
|
||||
'value' => $field['value'],
|
||||
);
|
||||
$input = array(
|
||||
$text_input = array(
|
||||
'class' => 'input',
|
||||
'type' => 'text',
|
||||
'value' => $display_value,
|
||||
|
|
@ -91,14 +74,13 @@ class acf_field_time_picker extends acf_field {
|
|||
|
||||
|
||||
// html
|
||||
$e .= '<div ' . acf_esc_attr($div) . '>';
|
||||
$e .= '<input ' . acf_esc_attr($hidden). '/>';
|
||||
$e .= '<input ' . acf_esc_attr($input). '/>';
|
||||
$e .= '</div>';
|
||||
?>
|
||||
<div <?php acf_esc_attr_e( $div ); ?>>
|
||||
<?php acf_hidden_input( $hidden_input ); ?>
|
||||
<?php acf_text_input( $text_input ); ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
|
||||
// return
|
||||
echo $e;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -180,7 +162,7 @@ class acf_field_time_picker extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_time_picker() );
|
||||
acf_register_field_type( 'acf_field_time_picker' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF True / False Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_true_false
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_true_false') ) :
|
||||
|
||||
class acf_field_true_false extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_true_false extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'true_false';
|
||||
|
|
@ -42,10 +31,6 @@ class acf_field_true_false extends acf_field {
|
|||
'ui_on_text' => '',
|
||||
'ui_off_text' => '',
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -277,7 +262,7 @@ class acf_field_true_false extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_true_false() );
|
||||
acf_register_field_type( 'acf_field_true_false' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,23 +1,12 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF URL Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_url
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_url') ) :
|
||||
|
||||
class acf_field_url extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
* initialize
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_url extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'url';
|
||||
|
|
@ -39,9 +28,6 @@ class acf_field_url extends acf_field {
|
|||
'placeholder' => '',
|
||||
);
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -61,35 +47,31 @@ class acf_field_url extends acf_field {
|
|||
|
||||
// vars
|
||||
$atts = array();
|
||||
$o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' );
|
||||
$s = array( 'readonly', 'disabled' );
|
||||
$e = '';
|
||||
$keys = array( 'type', 'id', 'class', 'name', 'value', 'placeholder', 'pattern' );
|
||||
$keys2 = array( 'readonly', 'disabled' );
|
||||
$html = '';
|
||||
|
||||
|
||||
// append atts
|
||||
foreach( $o as $k ) {
|
||||
|
||||
$atts[ $k ] = $field[ $k ];
|
||||
|
||||
// atts
|
||||
foreach( $keys as $k ) {
|
||||
if( isset($field[ $k ]) ) $atts[ $k ] = $field[ $k ];
|
||||
}
|
||||
|
||||
|
||||
// append special atts
|
||||
foreach( $s as $k ) {
|
||||
|
||||
// atts2
|
||||
foreach( $keys2 as $k ) {
|
||||
if( !empty($field[ $k ]) ) $atts[ $k ] = $k;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// render
|
||||
$e .= '<div class="acf-input-wrap acf-url">';
|
||||
$e .= '<i class="acf-icon -globe small"></i><input ' . acf_esc_attr( $atts ) . ' />';
|
||||
$e .= '</div>';
|
||||
$html .= '<div class="acf-input-wrap acf-url">';
|
||||
$html .= '<i class="acf-icon -globe -small"></i>' . acf_get_text_input( $atts ) ;
|
||||
$html .= '</div>';
|
||||
|
||||
|
||||
// return
|
||||
echo $e;
|
||||
echo $html;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +158,7 @@ class acf_field_url extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_url() );
|
||||
acf_register_field_type( 'acf_field_url' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF User Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_user
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_user') ) :
|
||||
|
||||
class acf_field_user extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_user extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'user';
|
||||
|
|
@ -45,10 +34,6 @@ class acf_field_user extends acf_field {
|
|||
// extra
|
||||
add_action('wp_ajax_acf/fields/user/query', array($this, 'ajax_query'));
|
||||
add_action('wp_ajax_nopriv_acf/fields/user/query', array($this, 'ajax_query'));
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -594,7 +579,7 @@ class acf_field_user extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_user() );
|
||||
acf_register_field_type( 'acf_field_user' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF WYSIWYG Field Class
|
||||
*
|
||||
* All the logic for this field type
|
||||
*
|
||||
* @class acf_field_wysiwyg
|
||||
* @extends acf_field
|
||||
* @package ACF
|
||||
* @subpackage Fields
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_field_wysiwyg') ) :
|
||||
|
||||
class acf_field_wysiwyg extends acf_field {
|
||||
|
|
@ -29,7 +18,7 @@ class acf_field_wysiwyg extends acf_field {
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'wysiwyg';
|
||||
|
|
@ -46,10 +35,6 @@ class acf_field_wysiwyg extends acf_field {
|
|||
|
||||
// add acf_the_content filters
|
||||
$this->add_filters();
|
||||
|
||||
|
||||
// do not delete!
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -527,7 +512,7 @@ class acf_field_wysiwyg extends acf_field {
|
|||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( new acf_field_wysiwyg() );
|
||||
acf_register_field_type( 'acf_field_wysiwyg' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ class acf_field {
|
|||
/*
|
||||
* __construct
|
||||
*
|
||||
* This construcor registeres many actions and filters
|
||||
* This function will initialize the field type
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
|
|
@ -28,8 +28,17 @@ class acf_field {
|
|||
|
||||
function __construct() {
|
||||
|
||||
// info
|
||||
$this->add_filter('acf/get_field_types', array($this, 'get_field_types'), 10, 1);
|
||||
// initialize
|
||||
$this->initialize();
|
||||
|
||||
|
||||
// register info
|
||||
acf_register_field_type_info(array(
|
||||
'label' => $this->label,
|
||||
'name' => $this->name,
|
||||
'category' => $this->category,
|
||||
'public' => $this->public
|
||||
));
|
||||
|
||||
|
||||
// value
|
||||
|
|
@ -68,6 +77,26 @@ class acf_field {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* initialize
|
||||
*
|
||||
* This function will initialize the field type
|
||||
*
|
||||
* @type function
|
||||
* @date 27/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
/* do nothing */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* add_filter
|
||||
*
|
||||
|
|
@ -180,36 +209,6 @@ class acf_field {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_field_types()
|
||||
*
|
||||
* This function will append the current field type to the list of available field types
|
||||
*
|
||||
* @type function
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $fields (array)
|
||||
* @return $fields
|
||||
*/
|
||||
|
||||
function get_field_types( $types ) {
|
||||
|
||||
// append
|
||||
$types[ $this->name ] = array(
|
||||
'label' => $this->label,
|
||||
'name' => $this->name,
|
||||
'category' => $this->category,
|
||||
'public' => $this->public
|
||||
);
|
||||
|
||||
|
||||
// return
|
||||
return $types;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* validate_field
|
||||
*
|
||||
|
|
@ -275,157 +274,4 @@ class acf_field {
|
|||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_types
|
||||
*
|
||||
* This function will return an array containing info about all field types
|
||||
*
|
||||
* @type function
|
||||
* @date 22/10/16
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_field_types() {
|
||||
|
||||
// vars
|
||||
$cache_key = 'acf_get_field_types';
|
||||
|
||||
|
||||
// check cache
|
||||
if( acf_isset_cache($cache_key) ) return acf_get_cache($cache_key);
|
||||
|
||||
|
||||
// get types
|
||||
$types = apply_filters('acf/get_field_types', array());
|
||||
|
||||
|
||||
// update cache
|
||||
acf_set_cache($cache_key, $types);
|
||||
|
||||
|
||||
// return
|
||||
return $types;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_grouped_field_types
|
||||
*
|
||||
* This function will return a grouped array of fields types (category => name)
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_grouped_field_types() {
|
||||
|
||||
// vars
|
||||
$types = array();
|
||||
$l10n = array(
|
||||
'basic' => __('Basic', 'acf'),
|
||||
'content' => __('Content', 'acf'),
|
||||
'choice' => __('Choice', 'acf'),
|
||||
'relational' => __('Relational', 'acf'),
|
||||
'jquery' => __('jQuery', 'acf'),
|
||||
'layout' => __('Layout', 'acf'),
|
||||
);
|
||||
|
||||
|
||||
// get field type information
|
||||
$types_info = acf_get_field_types();
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $types_info as $info ) {
|
||||
|
||||
// bail early if not public
|
||||
if( !$info['public'] ) continue;
|
||||
|
||||
|
||||
// vars
|
||||
$cat = $info['category'];
|
||||
|
||||
|
||||
// default to basic
|
||||
if( !$cat ) $cat = 'basic';
|
||||
|
||||
|
||||
// translate
|
||||
$cat = isset($l10n[ $cat ]) ? $l10n[ $cat ] : $cat;
|
||||
|
||||
|
||||
// append
|
||||
$types[ $cat ][ $info['name'] ] = $info['label'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $types;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_field_type_label
|
||||
*
|
||||
* This function will return the label of a field type
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_field_type_label( $type = '' ) {
|
||||
|
||||
// vars
|
||||
$types = acf_get_field_types();
|
||||
|
||||
|
||||
// bail early if doesn't exist
|
||||
if( !isset($types[ $type ]) ) return '';
|
||||
|
||||
|
||||
// return
|
||||
return $types[ $type ]['label'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_field_type_exists
|
||||
*
|
||||
* This function will check if the field_type exists
|
||||
*
|
||||
* @type function
|
||||
* @date 1/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $type (string)
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function acf_field_type_exists( $type = '' ) {
|
||||
|
||||
// vars
|
||||
$types = acf_get_field_types();
|
||||
|
||||
|
||||
// return
|
||||
return isset($types[ $type ]);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,470 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_form_customizer') ) :
|
||||
|
||||
class acf_form_customizer {
|
||||
|
||||
|
||||
/*
|
||||
* __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() {
|
||||
|
||||
// vars
|
||||
$this->preview_values = array();
|
||||
$this->preview_fields = array();
|
||||
$this->preview_errors = array();
|
||||
|
||||
|
||||
// actions
|
||||
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
||||
add_action('customize_preview_init', array($this, 'customize_preview_init'), 1, 1);
|
||||
add_action('customize_save', array($this, 'customize_save'), 1, 1);
|
||||
|
||||
|
||||
// save
|
||||
add_filter('widget_update_callback', array($this, 'save_widget'), 10, 4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 26/01/13
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// validate screen
|
||||
if( !acf_is_screen('customize') ) return;
|
||||
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
|
||||
|
||||
// actions
|
||||
add_action('acf/input/admin_footer', array($this, 'admin_footer'), 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* save_widget
|
||||
*
|
||||
* This function will hook into the widget update filter and save ACF data
|
||||
*
|
||||
* @type function
|
||||
* @date 27/05/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $instance (array) widget settings
|
||||
* @param $new_instance (array) widget settings
|
||||
* @param $old_instance (array) widget settings
|
||||
* @param $widget (object) widget info
|
||||
* @return $instance
|
||||
*/
|
||||
|
||||
function save_widget( $instance, $new_instance, $old_instance, $widget ) {
|
||||
|
||||
// bail ealry if not valid (customize + acf values + nonce)
|
||||
if( !isset($_POST['wp_customize']) || !isset($new_instance['acf']) || !acf_verify_nonce('widget') ) return $instance;
|
||||
|
||||
|
||||
// vars
|
||||
$data = array(
|
||||
'post_id' => "widget_{$widget->id}",
|
||||
'values' => array(),
|
||||
'fields' => array()
|
||||
);
|
||||
|
||||
|
||||
// append values
|
||||
$data['values'] = $new_instance['acf'];
|
||||
|
||||
|
||||
// append fields (name => key relationship) - used later in 'acf/get_field_reference' for customizer previews
|
||||
foreach( $data['values'] as $k => $v ) {
|
||||
|
||||
// get field
|
||||
$field = acf_get_field( $k );
|
||||
|
||||
|
||||
// continue if no field
|
||||
if( !$field ) continue;
|
||||
|
||||
|
||||
// update
|
||||
$data['fields'][ $field['name'] ] = $field['key'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append data to instance
|
||||
$instance['acf'] = $data;
|
||||
|
||||
|
||||
|
||||
// return
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_customizer_widgets
|
||||
*
|
||||
* This function will return an array of widget settings
|
||||
*
|
||||
* @type function
|
||||
* @date 22/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $customizer (object)
|
||||
* @return $value (mixed)
|
||||
*/
|
||||
|
||||
function get_customizer_widgets( $customizer ) {
|
||||
|
||||
// vars
|
||||
$widgets = array();
|
||||
$settings = $customizer->settings();
|
||||
|
||||
|
||||
// bail ealry if no settings
|
||||
if( empty($settings) ) return false;
|
||||
|
||||
|
||||
// loop over settings
|
||||
foreach( array_keys($settings) as $i ) {
|
||||
|
||||
// vars
|
||||
$setting = $settings[ $i ];
|
||||
|
||||
|
||||
// bail ealry if not widget
|
||||
if( substr($setting->id, 0, 7) !== 'widget_' ) continue;
|
||||
|
||||
|
||||
// get value
|
||||
$value = $setting->post_value();
|
||||
|
||||
|
||||
// set data
|
||||
$setting->acf = acf_maybe_get($value, 'acf');
|
||||
|
||||
|
||||
// append
|
||||
$widgets[] = $setting;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail ealry if no preview values
|
||||
if( empty($widgets) ) return false;
|
||||
|
||||
|
||||
// return
|
||||
return $widgets;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* customize_preview_init
|
||||
*
|
||||
* This function is called when customizer preview is initialized
|
||||
*
|
||||
* @type function
|
||||
* @date 22/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $customizer (object)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function customize_preview_init( $customizer ) {
|
||||
|
||||
// get customizer settings (widgets)
|
||||
$settings = $customizer->settings();
|
||||
|
||||
|
||||
// bail ealry if no settings
|
||||
if( empty($settings) ) return;
|
||||
|
||||
|
||||
// append values
|
||||
foreach( $settings as $setting ) {
|
||||
|
||||
// get $_POST value
|
||||
$value = $setting->post_value();
|
||||
|
||||
|
||||
// bail early if no acf
|
||||
if( !isset($value['acf']) ) continue;
|
||||
|
||||
|
||||
// append acf_value to preview_values
|
||||
$this->preview_values[ $value['acf']['post_id'] ] = $value['acf']['values'];
|
||||
$this->preview_fields[ $value['acf']['post_id'] ] = $value['acf']['fields'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail ealry if no preview_values
|
||||
if( empty($this->preview_values) ) return;
|
||||
|
||||
|
||||
// add filter
|
||||
add_filter('acf/get_field_reference', array($this, 'get_field_reference'), 10, 3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_field_reference
|
||||
*
|
||||
* This function will return a field_key for a given field name + post_id
|
||||
* Normally, ACF would lookup the DB fro this connection, but a new preview widget has not yet saved anything to the DB
|
||||
*
|
||||
* @type function
|
||||
* @date 12/05/2016
|
||||
* @since 5.3.8
|
||||
*
|
||||
* @param $field_key (string)
|
||||
* @param $field_name (string)
|
||||
* @param $post_id (mixed)
|
||||
* @return $field_key
|
||||
*/
|
||||
|
||||
function get_field_reference( $field_key, $field_name, $post_id ) {
|
||||
|
||||
// look for reference
|
||||
if( isset($this->preview_fields[ $post_id ][ $field_name ]) ) {
|
||||
|
||||
// update key
|
||||
$field_key = $this->preview_fields[ $post_id ][ $field_name ];
|
||||
$field_value = $this->preview_values[ $post_id ][ $field_key ];
|
||||
|
||||
|
||||
// cache value
|
||||
acf_set_cache("get_value/post_id={$post_id}/name={$field_name}", $field_value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field_key;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* customize_save
|
||||
*
|
||||
* This function is called when customizer saves a widget.
|
||||
* Normally, the widget_update_callback filter would be used, but the customizer disables this and runs a custom action
|
||||
* class-customizer-settings.php will save the widget data via the function set_root_value which uses update_option
|
||||
*
|
||||
* @type function
|
||||
* @date 22/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $customizer (object)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function customize_save( $customizer ) {
|
||||
|
||||
// get customizer settings (widgets)
|
||||
$settings = $customizer->settings();
|
||||
|
||||
|
||||
// bail ealry if no settings
|
||||
if( empty($settings) ) return;
|
||||
|
||||
|
||||
// append values
|
||||
foreach( $settings as $setting ) {
|
||||
|
||||
// get $_POST value
|
||||
$value = $setting->post_value();
|
||||
|
||||
|
||||
// bail early if no acf
|
||||
if( !isset($value['acf']) ) continue;
|
||||
|
||||
|
||||
// save acf data
|
||||
acf_save_post( $value['acf']['post_id'], $value['acf']['values'] );
|
||||
|
||||
|
||||
// remove [acf] data from saved widget array
|
||||
$id_data = $setting->id_data();
|
||||
add_filter('pre_update_option_' . $id_data['base'], array($this, 'pre_update_option'), 10, 3);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* pre_update_option
|
||||
*
|
||||
* this function will remove the [acf] data from widget insance
|
||||
*
|
||||
* @type function
|
||||
* @date 22/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function pre_update_option( $value, $option, $old_value ) {
|
||||
|
||||
// bail ealry if no value
|
||||
if( empty($value) ) return $value;
|
||||
|
||||
|
||||
// loop over widgets
|
||||
// WP saves all widgets (of the same type) as an array of widgets
|
||||
foreach( $value as $i => $widget ) {
|
||||
|
||||
// bail ealry if no acf
|
||||
if( !isset($widget['acf']) ) continue;
|
||||
|
||||
|
||||
// remove widget
|
||||
unset($value[ $i ]['acf']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_footer
|
||||
*
|
||||
* This function will add some custom HTML to the footer of the edit page
|
||||
*
|
||||
* @type function
|
||||
* @date 11/06/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
// customizer saves widget on any input change, so unload is not needed
|
||||
acf.unload.active = 0;
|
||||
|
||||
|
||||
// hack customizer function to remove bug caused by WYSIWYG field using aunique ID
|
||||
// customizer compares returned AJAX HTML with the HTML of the widget form.
|
||||
// the _getInputsSignature() function is used to generate a string based of input name + id.
|
||||
// because ACF generates a unique ID on the WYSIWYG field, this string will not match causing the preview function to bail.
|
||||
// an attempt was made to remove the WYSIWYG unique ID, but this caused multiple issues in the wp-admin and altimately doesn't make sense with the tinymce rule that all editors must have a unique ID.
|
||||
// source: wp-admin/js/customize-widgets.js
|
||||
|
||||
// vars
|
||||
var WidgetControl = wp.customize.Widgets.WidgetControl.prototype;
|
||||
|
||||
|
||||
// backup functions
|
||||
WidgetControl.__getInputsSignature = WidgetControl._getInputsSignature;
|
||||
WidgetControl.__setInputState = WidgetControl._setInputState;
|
||||
|
||||
|
||||
// modify __getInputsSignature
|
||||
WidgetControl._getInputsSignature = function( inputs ) {
|
||||
|
||||
// vars
|
||||
var signature = this.__getInputsSignature( inputs );
|
||||
safe = [];
|
||||
|
||||
|
||||
// split
|
||||
signature = signature.split(';');
|
||||
|
||||
|
||||
// loop
|
||||
for( var i in signature ) {
|
||||
|
||||
// vars
|
||||
var bit = signature[i];
|
||||
|
||||
|
||||
// bail ealry if acf is found
|
||||
if( bit.indexOf('acf') !== -1 ) continue;
|
||||
|
||||
|
||||
// append
|
||||
safe.push( bit );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update
|
||||
signature = safe.join(';');
|
||||
|
||||
|
||||
// return
|
||||
return signature;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// modify _setInputState
|
||||
// this function deosn't seem to run on widget title/content, only custom fields
|
||||
// either way, this function is not needed and will break ACF fields
|
||||
WidgetControl._setInputState = function( input, state ) {
|
||||
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new acf_form_customizer();
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
|
@ -2,13 +2,15 @@
|
|||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_form') ) :
|
||||
if( ! class_exists('acf_form_front') ) :
|
||||
|
||||
class acf_form {
|
||||
class acf_form_front {
|
||||
|
||||
// vars
|
||||
var $forms = array(),
|
||||
$fields = array();
|
||||
/** @var array An array of registered form settings */
|
||||
private $forms = array();
|
||||
|
||||
/** @var array An array of default fields */
|
||||
public $fields = array();
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -357,7 +359,7 @@ class acf_form {
|
|||
function check_submit_form() {
|
||||
|
||||
// bail ealry if form not submit
|
||||
if( !isset($_POST['_acfform']) ) return;
|
||||
if( !isset($_POST['_acf_form']) ) return;
|
||||
|
||||
|
||||
// verify nonce
|
||||
|
|
@ -390,7 +392,7 @@ class acf_form {
|
|||
function submit_form() {
|
||||
|
||||
// vars
|
||||
$form = @json_decode(acf_decrypt($_POST['_acfform']), true);
|
||||
$form = @json_decode(acf_decrypt($_POST['_acf_form']), true);
|
||||
|
||||
|
||||
// bail ealry if form is corrupt
|
||||
|
|
@ -610,7 +612,7 @@ class acf_form {
|
|||
acf_form_data(array(
|
||||
'post_id' => $args['post_id'],
|
||||
'nonce' => 'acf_form',
|
||||
'_acfform' => acf_encrypt(json_encode($args))
|
||||
'form' => acf_encrypt(json_encode($args))
|
||||
));
|
||||
|
||||
?>
|
||||
|
|
@ -651,7 +653,7 @@ class acf_form {
|
|||
}
|
||||
|
||||
// initialize
|
||||
acf()->form = new acf_form();
|
||||
acf()->form_front = new acf_form_front();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
|
@ -672,25 +674,25 @@ endif; // class_exists check
|
|||
|
||||
function acf_form_head() {
|
||||
|
||||
acf()->form->enqueue_form();
|
||||
acf()->form_front->enqueue_form();
|
||||
|
||||
}
|
||||
|
||||
function acf_form( $args = array() ) {
|
||||
|
||||
acf()->form->render_form( $args );
|
||||
acf()->form_front->render_form( $args );
|
||||
|
||||
}
|
||||
|
||||
function acf_get_form( $id = '' ) {
|
||||
|
||||
acf()->form->get_form( $id );
|
||||
acf()->form_front->get_form( $id );
|
||||
|
||||
}
|
||||
|
||||
function acf_register_form( $args ) {
|
||||
|
||||
acf()->form->add_form( $args );
|
||||
acf()->form_front->add_form( $args );
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,285 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_form_nav_menu') ) :
|
||||
|
||||
class acf_form_nav_menu {
|
||||
|
||||
/*
|
||||
* __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('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
||||
add_action('wp_update_nav_menu', array($this, 'update_nav_menu'));
|
||||
add_action('acf/validate_save_post', array($this, 'acf_validate_save_post'), 5);
|
||||
|
||||
|
||||
// filters
|
||||
add_filter('wp_edit_nav_menu_walker', array($this, 'wp_edit_nav_menu_walker'), 10, 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 26/01/13
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// validate screen
|
||||
if( !acf_is_screen('nav-menus') ) return;
|
||||
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
|
||||
|
||||
// actions
|
||||
add_action('admin_footer', array($this, 'admin_footer'), 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_nav_menu
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 26/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function update_nav_menu( $menu_id ) {
|
||||
|
||||
// vars
|
||||
$post_id = acf_get_term_post_id( 'nav_menu', $menu_id );
|
||||
|
||||
|
||||
// verify and remove nonce
|
||||
if( !acf_verify_nonce('nav_menu') ) return $menu_id;
|
||||
|
||||
|
||||
// validate and show errors
|
||||
acf_validate_save_post( true );
|
||||
|
||||
|
||||
// save
|
||||
acf_save_post( $post_id );
|
||||
|
||||
|
||||
// save nav menu items
|
||||
$this->update_nav_menu_items( $menu_id );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_nav_menu_items
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 26/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function update_nav_menu_items( $menu_id ) {
|
||||
|
||||
// bail ealry if not set
|
||||
if( empty($_POST['menu-item-acf']) ) return;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $_POST['menu-item-acf'] as $post_id => $values ) {
|
||||
|
||||
acf_save_post( $post_id, $values );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* wp_edit_nav_menu_walker
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 26/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function wp_edit_nav_menu_walker( $class, $menu_id = 0 ) {
|
||||
|
||||
// global
|
||||
global $acf_menu;
|
||||
|
||||
|
||||
// set var
|
||||
$acf_menu = $menu_id;
|
||||
|
||||
|
||||
// include walker
|
||||
if( class_exists('Walker_Nav_Menu_Edit') ) {
|
||||
acf_include('includes/walkers/class-acf-walker-nav-menu-edit.php');
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return 'ACF_Walker_Nav_Menu_Edit';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_validate_save_post
|
||||
*
|
||||
* This function will loop over $_POST data and validate
|
||||
*
|
||||
* @type action 'acf/validate_save_post' 5
|
||||
* @date 7/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_validate_save_post() {
|
||||
|
||||
// bail ealry if not set
|
||||
if( empty($_POST['menu-item-acf']) ) return;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $_POST['menu-item-acf'] as $post_id => $values ) {
|
||||
|
||||
// vars
|
||||
$prefix = 'menu-item-acf['.$post_id.']';
|
||||
|
||||
|
||||
// validate
|
||||
acf_validate_values( $values, $prefix );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_footer
|
||||
*
|
||||
* This function will add some custom HTML to the footer of the edit page
|
||||
*
|
||||
* @type function
|
||||
* @date 11/06/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
// global
|
||||
global $acf_menu;
|
||||
|
||||
|
||||
// vars
|
||||
$post_id = acf_get_term_post_id( 'nav_menu', $acf_menu );
|
||||
|
||||
|
||||
// get field groups
|
||||
$field_groups = acf_get_field_groups(array(
|
||||
'nav_menu' => $acf_menu
|
||||
));
|
||||
|
||||
|
||||
?>
|
||||
<script type="text/html" id="tmpl-acf-menu-settings">
|
||||
<?php
|
||||
|
||||
// data (always needed to save nav menu items)
|
||||
acf_form_data(array(
|
||||
'post_id' => $post_id,
|
||||
'nonce' => 'nav_menu',
|
||||
));
|
||||
|
||||
|
||||
// render
|
||||
if( !empty($field_groups) ) {
|
||||
|
||||
// loop
|
||||
foreach( $field_groups as $field_group ) {
|
||||
|
||||
$fields = acf_get_fields( $field_group );
|
||||
|
||||
echo '<div class="acf-menu-settings -'.$field_group['style'].'">';
|
||||
|
||||
echo '<h2>' . $field_group['title'] . '</h2>';
|
||||
|
||||
echo '<div class="acf-fields -left -clear">';
|
||||
|
||||
acf_render_fields( $post_id, $fields, 'div', $field_group['instruction_placement'] );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
// append html
|
||||
$('#post-body-content').append( $('#tmpl-acf-menu-settings').html() );
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new acf_form_nav_menu();
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
|
@ -479,7 +479,7 @@ if( typeof acf !== 'undefined' ) {
|
|||
|
||||
function wp_insert_post_empty_content( $maybe_empty, $postarr ) {
|
||||
|
||||
if( $maybe_empty && !empty($_POST['_acfchanged']) ) {
|
||||
if( $maybe_empty && acf_maybe_get_POST('_acf_changed') ) {
|
||||
|
||||
$maybe_empty = false;
|
||||
|
||||
|
|
@ -508,18 +508,31 @@ if( typeof acf !== 'undefined' ) {
|
|||
|
||||
// vars
|
||||
$allow = true;
|
||||
$reject = array( 'auto-draft', 'revision', 'acf-field', 'acf-field-group' );
|
||||
$wp_preview = acf_maybe_get($_POST, 'wp-preview');
|
||||
|
||||
|
||||
// check post type
|
||||
if( in_array($post->post_type, $reject) ) $allow = false;
|
||||
// disallow if is post type
|
||||
$post_types = array( 'auto-draft', 'revision', 'acf-field', 'acf-field-group' );
|
||||
if( in_array($post->post_type, $post_types) ) $allow = false;
|
||||
|
||||
|
||||
// allow preview
|
||||
if( $post->post_type == 'revision' && $wp_preview == 'dopreview' ) $allow = true;
|
||||
// disallow if not the form post
|
||||
$form_post_id = (int) acf_maybe_get_POST('post_ID');
|
||||
if( $form_post_id && $form_post_id !== $post->ID ) $allow = false;
|
||||
|
||||
|
||||
// revision (preview)
|
||||
if( $post->post_type == 'revision' ) {
|
||||
|
||||
// allow if doing preview
|
||||
if( acf_maybe_get_POST('wp-preview') == 'dopreview' ) $allow = true;
|
||||
|
||||
|
||||
// disallow if not a revision of the form post
|
||||
if( $form_post_id && $form_post_id !== $post->post_parent ) $allow = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $allow;
|
||||
|
||||
|
|
@ -545,8 +558,8 @@ if( typeof acf !== 'undefined' ) {
|
|||
if( !$this->allow_save_post($post) ) return $post_id;
|
||||
|
||||
|
||||
// ensure saving to the correct post
|
||||
if( !acf_verify_nonce('post', $post_id) ) return $post_id;
|
||||
// verify nonce
|
||||
if( !acf_verify_nonce('post') ) return $post_id;
|
||||
|
||||
|
||||
// validate for published post (allow draft to save without validation)
|
||||
|
|
@ -0,0 +1,385 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ACF Widget Form Class
|
||||
*
|
||||
* All the logic for adding fields to widgets
|
||||
*
|
||||
* @class acf_form_widget
|
||||
* @package ACF
|
||||
* @subpackage Forms
|
||||
*/
|
||||
|
||||
if( ! class_exists('acf_form_widget') ) :
|
||||
|
||||
class acf_form_widget {
|
||||
|
||||
|
||||
/*
|
||||
* __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() {
|
||||
|
||||
// vars
|
||||
$this->preview_values = array();
|
||||
$this->preview_reference = array();
|
||||
$this->preview_errors = array();
|
||||
|
||||
|
||||
// actions
|
||||
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
||||
add_action('in_widget_form', array($this, 'edit_widget'), 10, 3);
|
||||
add_action('acf/validate_save_post', array($this, 'acf_validate_save_post'), 5);
|
||||
|
||||
|
||||
// filters
|
||||
add_filter('widget_update_callback', array($this, 'save_widget'), 10, 4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 26/01/13
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
// validate screen
|
||||
if( acf_is_screen('widgets') || acf_is_screen('customize') ) {
|
||||
|
||||
// valid
|
||||
|
||||
} else {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
|
||||
|
||||
// actions
|
||||
add_action('acf/input/admin_footer', array($this, 'admin_footer'), 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_validate_save_post
|
||||
*
|
||||
* This function will loop over $_POST data and validate
|
||||
*
|
||||
* @type action 'acf/validate_save_post' 5
|
||||
* @date 7/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_validate_save_post() {
|
||||
|
||||
// bai lealry if not widget
|
||||
if( !isset($_POST['_acf_widget_id']) ) return;
|
||||
|
||||
|
||||
// vars
|
||||
$id = $_POST['_acf_widget_id'];
|
||||
$number = $_POST['_acf_widget_number'];
|
||||
$prefix = $_POST['_acf_widget_prefix'];
|
||||
|
||||
|
||||
// validate
|
||||
acf_validate_values( $_POST[ $id ][ $number ]['acf'], $prefix );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* edit_widget
|
||||
*
|
||||
* This function will render the fields for a widget form
|
||||
*
|
||||
* @type function
|
||||
* @date 11/06/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $widget (object)
|
||||
* @param $return (null)
|
||||
* @param $instance (object)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function edit_widget( $widget, $return, $instance ) {
|
||||
|
||||
// vars
|
||||
$post_id = 0;
|
||||
$prefix = 'widget-' . $widget->id_base . '[' . $widget->number . '][acf]';
|
||||
|
||||
|
||||
// get id
|
||||
if( $widget->number !== '__i__' ) {
|
||||
|
||||
$post_id = "widget_{$widget->id}";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// get field groups
|
||||
$field_groups = acf_get_field_groups(array(
|
||||
'widget' => $widget->id_base
|
||||
));
|
||||
|
||||
|
||||
// render
|
||||
if( !empty($field_groups) ) {
|
||||
|
||||
// render post data
|
||||
acf_form_data(array(
|
||||
'post_id' => $post_id,
|
||||
'nonce' => 'widget',
|
||||
'widget_id' => 'widget-' . $widget->id_base,
|
||||
'widget_number' => $widget->number,
|
||||
'widget_prefix' => $prefix
|
||||
));
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $field_groups as $field_group ) {
|
||||
|
||||
// load fields
|
||||
$fields = acf_get_fields( $field_group );
|
||||
|
||||
|
||||
// bail if not fields
|
||||
if( empty($fields) ) continue;
|
||||
|
||||
|
||||
// change prefix
|
||||
foreach( $fields as &$field ) $field['prefix'] = $prefix;
|
||||
|
||||
|
||||
// render
|
||||
acf_render_fields( $post_id, $fields, 'div', $field_group['instruction_placement'] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// jQuery selector looks odd, but is necessary due to WP adding an incremental number into the ID
|
||||
// - not possible to find number via PHP parameters
|
||||
if( $widget->updated ): ?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
acf.do_action('append', $('[id^="widget"][id$="<?php echo $widget->id; ?>"]') );
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php endif;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* save_widget
|
||||
*
|
||||
* This function will hook into the widget update filter and save ACF data
|
||||
*
|
||||
* @type function
|
||||
* @date 27/05/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $instance (array) widget settings
|
||||
* @param $new_instance (array) widget settings
|
||||
* @param $old_instance (array) widget settings
|
||||
* @param $widget (object) widget info
|
||||
* @return $instance
|
||||
*/
|
||||
|
||||
function save_widget( $instance, $new_instance, $old_instance, $widget ) {
|
||||
|
||||
// bail ealry if not valid (!customize + acf values + nonce)
|
||||
if( isset($_POST['wp_customize']) || !isset($new_instance['acf']) || !acf_verify_nonce('widget') ) return $instance;
|
||||
|
||||
|
||||
// save
|
||||
acf_save_post( "widget_{$widget->id}", $new_instance['acf'] );
|
||||
|
||||
|
||||
// return
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_footer
|
||||
*
|
||||
* This function will add some custom HTML to the footer of the edit page
|
||||
*
|
||||
* @type function
|
||||
* @date 11/06/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
acf.add_filter('get_fields', function( $fields ){
|
||||
|
||||
// widgets
|
||||
$fields = $fields.not('#available-widgets .acf-field');
|
||||
|
||||
|
||||
// customizer
|
||||
$fields = $fields.not('.widget-tpl .acf-field');
|
||||
|
||||
|
||||
// return
|
||||
return $fields;
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#widgets-right').on('click', '.widget-control-save', function( e ){
|
||||
|
||||
// vars
|
||||
var $form = $(this).closest('form');
|
||||
|
||||
|
||||
// bail early if not active
|
||||
if( !acf.validation.active ) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ignore validation (only ignore once)
|
||||
if( acf.validation.ignore ) {
|
||||
|
||||
acf.validation.ignore = 0;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail early if this form does not contain ACF data
|
||||
if( !$form.find('#acf-form-data').exists() ) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// stop WP JS validation
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
|
||||
// store submit trigger so it will be clicked if validation is passed
|
||||
acf.validation.$trigger = $(this);
|
||||
|
||||
|
||||
// run validation
|
||||
acf.validation.fetch( $form );
|
||||
|
||||
|
||||
// stop all other click events on this input
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.widget-top', function(){
|
||||
|
||||
var $el = $(this).parent().children('.widget-inside');
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
acf.get_fields('', $el).each(function(){
|
||||
|
||||
acf.do_action('show_field', $(this));
|
||||
|
||||
});
|
||||
|
||||
}, 250);
|
||||
|
||||
});
|
||||
|
||||
$(document).on('widget-added', function( e, $widget ){
|
||||
|
||||
// - use delay to avoid rendering issues with customizer (ensures div is visible)
|
||||
setTimeout(function(){
|
||||
|
||||
acf.do_action('append', $widget );
|
||||
|
||||
}, 100);
|
||||
|
||||
});
|
||||
|
||||
$(document).on('widget-saved widget-updated', function( e, $widget ){
|
||||
|
||||
// unlock form
|
||||
acf.validation.toggle( $widget, 'unlock' );
|
||||
|
||||
|
||||
// submit
|
||||
acf.do_action('submit', $widget );
|
||||
|
||||
});
|
||||
|
||||
|
||||
// sortable
|
||||
$('div.widgets-sortables').on('sortstart', function( event, ui ) {
|
||||
|
||||
acf.do_action('sortstart', ui.item, ui.placeholder);
|
||||
|
||||
}).on('sortstop', function( event, ui ) {
|
||||
|
||||
acf.do_action('sortstop', ui.item, ui.placeholder);
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new acf_form_widget();
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
|
@ -31,7 +31,7 @@ class acf_input {
|
|||
|
||||
|
||||
// actions
|
||||
add_action('acf/save_post', array($this, 'save_post'), 10, 1);
|
||||
add_action('acf/save_post', array($this, 'save_post'), 10, 2);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +90,7 @@ class acf_input {
|
|||
'nonce' => 'post', // nonce used for $_POST validation
|
||||
'validation' => 1, // runs AJAX validation
|
||||
'ajax' => 0, // fetches new field groups via AJAX
|
||||
'changed' => 0,
|
||||
));
|
||||
|
||||
|
||||
|
|
@ -261,7 +262,11 @@ class acf_input {
|
|||
'validation_failed' => __('Validation failed', 'acf'),
|
||||
'validation_failed_1' => __('1 field requires attention', 'acf'),
|
||||
'validation_failed_2' => __('%d fields require attention', 'acf'),
|
||||
'restricted' => __('Restricted','acf')
|
||||
'restricted' => __('Restricted','acf'),
|
||||
'yes' => __('Yes','acf'),
|
||||
'no' => __('No','acf'),
|
||||
'remove' => __('Remove','acf'),
|
||||
'cancel' => __('Cancel','acf')
|
||||
));
|
||||
|
||||
|
||||
|
|
@ -302,14 +307,10 @@ do_action('acf/input/admin_footer');
|
|||
* @return n/a
|
||||
*/
|
||||
|
||||
function save_post( $post_id ) {
|
||||
function save_post( $post_id, $values ) {
|
||||
|
||||
// bail early if empty
|
||||
if( empty($_POST['acf']) ) return;
|
||||
|
||||
|
||||
// save $_POST data
|
||||
foreach( $_POST['acf'] as $k => $v ) {
|
||||
// loop
|
||||
foreach( $values as $k => $v ) {
|
||||
|
||||
// get field
|
||||
$field = acf_get_field( $k );
|
||||
|
|
@ -457,24 +458,13 @@ function acf_form_data( $args = array() ) {
|
|||
|
||||
|
||||
// hidden inputs
|
||||
$inputs = array(
|
||||
'_acfnonce' => wp_create_nonce($args['nonce']),
|
||||
'_acfchanged' => 0
|
||||
);
|
||||
|
||||
|
||||
// append custom
|
||||
foreach( $args as $k => $v ) {
|
||||
|
||||
if( substr($k, 0, 4) === '_acf' ) $inputs[ $k ] = $v;
|
||||
|
||||
}
|
||||
|
||||
$inputs = $args;
|
||||
$inputs['nonce'] = wp_create_nonce($inputs['nonce']);
|
||||
|
||||
?>
|
||||
<div id="acf-form-data" class="acf-hidden">
|
||||
<?php foreach( $inputs as $k => $v ): ?>
|
||||
<input type="hidden" name="<?php echo esc_attr($k); ?>" value="<?php echo esc_attr($v); ?>" />
|
||||
<input type="hidden" id="_acf_<?php echo esc_attr($k); ?>" name="_acf_<?php echo esc_attr($k); ?>" value="<?php echo esc_attr($v); ?>" />
|
||||
<?php endforeach; ?>
|
||||
<?php do_action('acf/input/form_data', $args); ?>
|
||||
</div>
|
||||
|
|
@ -496,10 +486,15 @@ function acf_form_data( $args = array() ) {
|
|||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_save_post( $post_id = 0 ) {
|
||||
function acf_save_post( $post_id = 0, $values = null ) {
|
||||
|
||||
// bail early if no acf values
|
||||
if( empty($_POST['acf']) ) return false;
|
||||
// default
|
||||
if( $values === null )
|
||||
$values = acf_maybe_get_POST('acf');
|
||||
|
||||
|
||||
// bail early if no values
|
||||
if( empty($values) ) return false;
|
||||
|
||||
|
||||
// set form data
|
||||
|
|
@ -509,7 +504,7 @@ function acf_save_post( $post_id = 0 ) {
|
|||
|
||||
|
||||
// hook for 3rd party customization
|
||||
do_action('acf/save_post', $post_id);
|
||||
do_action('acf/save_post', $post_id, $values);
|
||||
|
||||
|
||||
// return
|
||||
|
|
@ -0,0 +1,356 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_locations') ) :
|
||||
|
||||
class acf_locations {
|
||||
|
||||
|
||||
/** @var array Contains an array of location rule instances */
|
||||
var $locations = 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() {
|
||||
|
||||
/* do nothing */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* register_location
|
||||
*
|
||||
* This function will store a location rule class
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $instance (object)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function register_location( $class ) {
|
||||
|
||||
$instance = new $class();
|
||||
$this->locations[ $instance->name ] = $instance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_rule
|
||||
*
|
||||
* This function will return a location rule class
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $name (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function get_location( $name ) {
|
||||
|
||||
return isset( $this->locations[$name] ) ? $this->locations[$name] : null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_rules
|
||||
*
|
||||
* This function will return a grouped array of location rules (category => name => label)
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function get_locations() {
|
||||
|
||||
// vars
|
||||
$groups = array();
|
||||
$l10n = array(
|
||||
'post' => __('Post', 'acf'),
|
||||
'page' => __('Page', 'acf'),
|
||||
'user' => __('User', 'acf'),
|
||||
'forms' => __('Forms', 'acf'),
|
||||
);
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $this->locations as $location ) {
|
||||
|
||||
// bail ealry if not public
|
||||
if( !$location->public ) continue;
|
||||
|
||||
|
||||
// translate
|
||||
$cat = $location->category;
|
||||
$cat = isset( $l10n[$cat] ) ? $l10n[$cat] : $cat;
|
||||
|
||||
|
||||
// append
|
||||
$groups[ $cat ][ $location->name ] = $location->label;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// filter
|
||||
$groups = apply_filters('acf/location/rule_types', $groups);
|
||||
|
||||
|
||||
// return
|
||||
return $groups;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize
|
||||
acf()->locations = new acf_locations();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
/*
|
||||
* acf_register_location_rule
|
||||
*
|
||||
* alias of acf()->locations->register_location()
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_register_location_rule( $class ) {
|
||||
|
||||
return acf()->locations->register_location( $class );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_location_rule
|
||||
*
|
||||
* alias of acf()->locations->get_location()
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_get_location_rule( $name ) {
|
||||
|
||||
return acf()->locations->get_location( $name );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_location_rule_types
|
||||
*
|
||||
* alias of acf()->locations->get_locations()
|
||||
*
|
||||
* @type function
|
||||
* @date 31/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_get_location_rule_types() {
|
||||
|
||||
return acf()->locations->get_locations();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_valid_location_rule
|
||||
*
|
||||
* This function will return a valid location rule array
|
||||
*
|
||||
* @type function
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $rule (array)
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_valid_location_rule( $rule ) {
|
||||
|
||||
// defaults
|
||||
$rule = wp_parse_args( $rule, array(
|
||||
'id' => '',
|
||||
'group' => '',
|
||||
'param' => '',
|
||||
'operator' => '==',
|
||||
'value' => '',
|
||||
));
|
||||
|
||||
|
||||
// prefix for inputs
|
||||
$rule['prefix'] = 'acf_field_group[location]['.$rule['group'].']['.$rule['id'].']';
|
||||
|
||||
|
||||
// return
|
||||
return $rule;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_location_rule_operators
|
||||
*
|
||||
* This function will return the operators for a given rule
|
||||
*
|
||||
* @type function
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $rule (array)
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_location_rule_operators( $rule ) {
|
||||
|
||||
// vars
|
||||
$operators = array(
|
||||
'==' => __("is equal to",'acf'),
|
||||
'!=' => __("is not equal to",'acf'),
|
||||
);
|
||||
|
||||
|
||||
// filter
|
||||
$operators = apply_filters( "acf/location/rule_operators/{$rule['param']}", $operators, $rule );
|
||||
$operators = apply_filters( "acf/location/rule_operators", $operators, $rule );
|
||||
|
||||
|
||||
// return
|
||||
return $operators;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_location_rule_values
|
||||
*
|
||||
* This function will return the values for a given rule
|
||||
*
|
||||
* @type function
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $rule (array)
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_location_rule_values( $rule ) {
|
||||
|
||||
// vars
|
||||
$values = array();
|
||||
|
||||
|
||||
// filter
|
||||
$values = apply_filters( "acf/location/rule_values/{$rule['param']}", $values, $rule );
|
||||
$values = apply_filters( "acf/location/rule_values", $values, $rule );
|
||||
|
||||
|
||||
// return
|
||||
return $values;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_match_location_rule
|
||||
*
|
||||
* This function will match a given rule to the $screen
|
||||
*
|
||||
* @type function
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $rule (array)
|
||||
* @param $screen (array)
|
||||
* @return (boolean)
|
||||
*/
|
||||
|
||||
function acf_match_location_rule( $rule, $screen ) {
|
||||
|
||||
// vars
|
||||
$result = false;
|
||||
|
||||
|
||||
// filter
|
||||
$result = apply_filters( "acf/location/rule_match/{$rule['param']}", $result, $rule, $screen );
|
||||
$result = apply_filters( "acf/location/rule_match", $result, $rule, $screen );
|
||||
|
||||
|
||||
// return
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_location_screen
|
||||
*
|
||||
* This function will return a valid location screen array
|
||||
*
|
||||
* @type function
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $screen (array)
|
||||
* @param $field_group (array)
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_location_screen( $screen, $field_group ) {
|
||||
|
||||
// vars
|
||||
$screen = wp_parse_args($screen, array(
|
||||
'lang' => acf_get_setting('current_language'),
|
||||
'ajax' => false
|
||||
));
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$screen = apply_filters('acf/location/screen', $screen, $field_group);
|
||||
|
||||
|
||||
// return
|
||||
return $screen;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_location_attachment') ) :
|
||||
|
||||
class acf_location_attachment extends acf_location {
|
||||
|
||||
|
||||
/*
|
||||
* __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 initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'attachment';
|
||||
$this->label = __("Attachment",'acf');
|
||||
$this->category = 'forms';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rule_match
|
||||
*
|
||||
* This function is used to match this location $rule to the current $screen
|
||||
*
|
||||
* @type function
|
||||
* @date 3/01/13
|
||||
* @since 3.5.7
|
||||
*
|
||||
* @param $match (boolean)
|
||||
* @param $rule (array)
|
||||
* @return $options (array)
|
||||
*/
|
||||
|
||||
function rule_match( $result, $rule, $screen ) {
|
||||
|
||||
// vars
|
||||
$attachment = acf_maybe_get( $screen, 'attachment' );
|
||||
|
||||
|
||||
// validate
|
||||
if( !$attachment ) return false;
|
||||
|
||||
|
||||
// get attachment mime type
|
||||
$mime_type = get_post_mime_type( $attachment );
|
||||
|
||||
|
||||
// no specific mime
|
||||
if( !strpos($rule['value'], '/') ) {
|
||||
|
||||
// explode into [0] => type, [1] => mime
|
||||
$bits = explode('/', $mime_type);
|
||||
|
||||
|
||||
// if type matches, fake the $mime_type to match
|
||||
if( $rule['value'] === $bits[0] ) {
|
||||
|
||||
$mime_type = $rule['value'];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// match
|
||||
return $this->compare( $mime_type, $rule );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rule_operators
|
||||
*
|
||||
* This function returns the available values for this rule type
|
||||
*
|
||||
* @type function
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function rule_values( $choices, $rule ) {
|
||||
|
||||
// vars
|
||||
$mimes = get_allowed_mime_types();
|
||||
$choices = array(
|
||||
'all' => __('All', 'acf')
|
||||
);
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $mimes as $type => $mime ) {
|
||||
|
||||
$group = current( explode('/', $mime) );
|
||||
$choices[ $group ][ $group ] = sprintf( __('All %s formats', 'acf'), $group);
|
||||
$choices[ $group ][ $mime ] = "$type ($mime)";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $choices;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize
|
||||
acf_register_location_rule( 'acf_location_attachment' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_location_comment') ) :
|
||||
|
||||
class acf_location_comment extends acf_location {
|
||||
|
||||
|
||||
/*
|
||||
* __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 initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'comment';
|
||||
$this->label = __("Comment",'acf');
|
||||
$this->category = 'forms';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rule_match
|
||||
*
|
||||
* This function is used to match this location $rule to the current $screen
|
||||
*
|
||||
* @type function
|
||||
* @date 3/01/13
|
||||
* @since 3.5.7
|
||||
*
|
||||
* @param $match (boolean)
|
||||
* @param $rule (array)
|
||||
* @return $options (array)
|
||||
*/
|
||||
|
||||
function rule_match( $result, $rule, $screen ) {
|
||||
|
||||
// vars
|
||||
$comment = acf_maybe_get( $screen, 'comment' );
|
||||
|
||||
|
||||
// bail early if not comment
|
||||
if( !$comment ) return false;
|
||||
|
||||
|
||||
// return
|
||||
return $this->compare( $comment, $rule );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rule_operators
|
||||
*
|
||||
* This function returns the available values for this rule type
|
||||
*
|
||||
* @type function
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function rule_values( $choices, $rule ) {
|
||||
|
||||
// vars
|
||||
$choices = array( 'all' => __('All', 'acf') );
|
||||
$choices = array_merge( $choices, acf_get_pretty_post_types() );
|
||||
// change this to post types that support comments
|
||||
|
||||
// return
|
||||
return $choices;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize
|
||||
acf_register_location_rule( 'acf_location_comment' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue