This commit is contained in:
Elliot Condon 2017-06-09 16:32:18 +02:00 committed by Remco Tolsma
parent b3dd72138d
commit 42acb5d756
36 changed files with 4354 additions and 3199 deletions

116
acf.php
View File

@ -3,7 +3,7 @@
Plugin Name: Advanced Custom Fields PRO
Plugin URI: https://www.advancedcustomfields.com/
Description: Customise WordPress with powerful, professional and intuitive fields
Version: 5.5.11
Version: 5.5.14
Author: Elliot Condon
Author URI: http://www.elliotcondon.com/
Copyright: Elliot Condon
@ -17,6 +17,9 @@ if( ! class_exists('acf') ) :
class acf {
// vars
var $version = '5.5.14';
/*
* __construct
@ -58,41 +61,49 @@ class acf {
// basic
'name' => __('Advanced Custom Fields', 'acf'),
'version' => '5.5.11',
'version' => $this->version,
// urls
'file' => __FILE__,
'basename' => plugin_basename( __FILE__ ),
'path' => plugin_dir_path( __FILE__ ),
'dir' => plugin_dir_url( __FILE__ ),
// options
'show_admin' => true,
'show_updates' => true,
'stripslashes' => false,
'local' => true,
'json' => true,
'save_json' => '',
'load_json' => array(),
'default_language' => '',
'current_language' => '',
'capability' => 'manage_options',
'uploader' => 'wp',
'autoload' => false,
'l10n' => true,
'l10n_textdomain' => '',
'google_api_key' => '',
'google_api_client' => '',
'enqueue_google_maps' => true,
'show_admin' => true,
'show_updates' => true,
'stripslashes' => false,
'local' => true,
'json' => true,
'save_json' => '',
'load_json' => array(),
'default_language' => '',
'current_language' => '',
'capability' => 'manage_options',
'uploader' => 'wp',
'autoload' => false,
'l10n' => true,
'l10n_textdomain' => '',
'google_api_key' => '',
'google_api_client' => '',
'enqueue_google_maps' => true,
'enqueue_select2' => true,
'enqueue_datepicker' => true,
'enqueue_datetimepicker' => true,
'select2_version' => 3,
'row_index_offset' => 1
'row_index_offset' => 1,
'remove_wp_meta_box' => false // todo: set to true in 5.6.0
);
// constants
$this->define( 'ACF', true );
$this->define( 'ACF_VERSION', $this->settings['version'] );
$this->define( 'ACF_PATH', $this->settings['path'] );
// include helpers
include_once('api/api-helpers.php');
include_once( ACF_PATH . 'api/api-helpers.php');
// api
@ -202,16 +213,12 @@ class acf {
acf_update_setting('dir', plugin_dir_url( __FILE__ ));
// set text domain
load_textdomain( 'acf', acf_get_path( 'lang/acf-' . acf_get_locale() . '.mo' ) );
// textdomain
$this->load_plugin_textdomain();
// include wpml support
if( defined('ICL_SITEPRESS_VERSION') ) {
acf_include('core/wpml.php');
}
if( defined('ICL_SITEPRESS_VERSION') ) acf_include('core/wpml.php');
// field types
@ -223,7 +230,6 @@ class acf {
acf_include('fields/password.php');
acf_include('fields/wysiwyg.php');
acf_include('fields/oembed.php');
//acf_include('fields/output.php');
acf_include('fields/image.php');
acf_include('fields/file.php');
acf_include('fields/select.php');
@ -258,6 +264,37 @@ class acf {
}
/*
* load_plugin_textdomain
*
* This function will load the textdomain file
*
* @type function
* @date 3/5/17
* @since 5.5.13
*
* @param n/a
* @return n/a
*/
function load_plugin_textdomain() {
// vars
$domain = 'acf';
$locale = apply_filters( 'plugin_locale', acf_get_locale(), $domain );
$mofile = $domain . '-' . $locale . '.mo';
// load from the languages directory first
load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile );
// load from plugin lang folder
load_textdomain( $domain, acf_get_path( 'lang/' . $mofile ) );
}
/*
* register_post_types
*
@ -454,6 +491,27 @@ class acf {
}
/*
* define
*
* This function will safely define a constant
*
* @type function
* @date 3/5/17
* @since 5.5.13
*
* @param $name (string)
* @param $value (mixed)
* @return n/a
*/
function define( $name, $value = true ) {
if( !defined($name) ) define( $name, $value );
}
/*
* get_setting
*

View File

@ -427,11 +427,17 @@ function acf_parse_type( $v ) {
* @return n/a
*/
function acf_get_view( $view_name = '', $args = array() ) {
// vars
$path = acf_get_path("admin/views/{$view_name}.php");
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");
}
// include
if( file_exists($path) ) {
include( $path );
@ -1123,7 +1129,7 @@ function acf_get_full_version( $version = '1' ) {
function acf_get_locale() {
return function_exists('get_user_locale') ? get_user_locale() : get_locale();
return is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
}

View File

@ -347,10 +347,28 @@ table.conditional-logic-rules tbody td {
* Field: Date Picker
*
*---------------------------------------------------------------------------------------------*/
.acf-field-object-date_picker .acf-radio-list span {
.acf-field-object-date-picker .acf-radio-list li,
.acf-field-object-time-picker .acf-radio-list li,
.acf-field-object-date-time-picker .acf-radio-list li {
line-height: 25px;
}
.acf-field-object-date-picker .acf-radio-list span,
.acf-field-object-time-picker .acf-radio-list span,
.acf-field-object-date-time-picker .acf-radio-list span {
display: inline-block;
min-width: 10em;
}
.acf-field-object-date-picker .acf-radio-list input[type="text"],
.acf-field-object-time-picker .acf-radio-list input[type="text"],
.acf-field-object-date-time-picker .acf-radio-list input[type="text"] {
width: 100px;
}
.acf-field-object-date-time-picker .acf-radio-list span {
min-width: 15em;
}
.acf-field-object-date-time-picker .acf-radio-list input[type="text"] {
width: 200px;
}
/*--------------------------------------------------------------------------------------------
*
* RTL

View File

@ -485,6 +485,22 @@ html[dir="rtl"] input.acf-is-prepended.acf-is-appended {
border-color: #bbb;
background: #f9f9f9;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset;
/* sortable item*/
/* sortable shadow */
}
.select2-container.-acf .select2-choices .select2-search-choice.ui-sortable-helper {
background: #5897fb;
border-color: #3f87fa;
color: #fff;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}
.select2-container.-acf .select2-choices .select2-search-choice.ui-sortable-helper a {
visibility: hidden;
}
.select2-container.-acf .select2-choices .select2-search-choice.ui-sortable-placeholder {
background-color: #f7f7f7;
border-color: #f7f7f7;
visibility: visible !important;
}
.select2-container.-acf .select2-choices .select2-search-choice-focus {
border-color: #999;
@ -551,11 +567,31 @@ html[dir="rtl"] .select2-container.-acf .select2-choice .select2-arrow {
* Select2 (v4)
*
*---------------------------------------------------------------------------------------------*/
.select2-selection.-acf li {
.select2-container.-acf li {
margin-bottom: 0;
}
.select2-selection.-acf input {
box-shadow: none;
.select2-container--default.-acf .select2-selection--multiple {
/* multiple choice item */
}
.select2-container--default.-acf .select2-selection--multiple .select2-selection__choice {
background-color: #f7f7f7;
border-color: #cccccc;
/* sortable item*/
/* sortable shadow */
}
.select2-container--default.-acf .select2-selection--multiple .select2-selection__choice.ui-sortable-helper {
background: #5897fb;
border-color: #3f87fa;
color: #fff;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}
.select2-container--default.-acf .select2-selection--multiple .select2-selection__choice.ui-sortable-helper span {
visibility: hidden;
}
.select2-container--default.-acf .select2-selection--multiple .select2-selection__choice.ui-sortable-placeholder {
background-color: #f7f7f7;
border-color: #f7f7f7;
visibility: visible !important;
}
/*---------------------------------------------------------------------------------------------
*
@ -1042,10 +1078,6 @@ html[dir="rtl"] .acf-relationship .selection .values .acf-icon {
.acf-editor-wrap.tmce-active .wp-editor-area {
color: #333 !important;
}
/* fix z-index behind media modal */
div.mce-toolbar-grp.mce-inline-toolbar-grp {
z-index: 170000;
}
/*---------------------------------------------------------------------------------------------
*
* Tab

View File

@ -18,6 +18,8 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap; }
.select2-container .select2-selection--single .select2-selection__clear {
position: relative; }
.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered {
padding-right: 8px;
padding-left: 20px; }
@ -40,7 +42,8 @@
box-sizing: border-box;
border: none;
font-size: 100%;
margin-top: 5px; }
margin-top: 5px;
padding: 0; }
.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button {
-webkit-appearance: none; }
@ -113,14 +116,14 @@
filter: alpha(opacity=0); }
.select2-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px; }
border: 0 !important;
clip: rect(0 0 0 0) !important;
height: 1px !important;
margin: -1px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important; }
.select2-container--default .select2-selection--single {
background-color: #fff;
@ -152,19 +155,24 @@
position: absolute;
top: 50%;
width: 0; }
.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear {
float: left; }
.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow {
left: 1px;
right: auto; }
.select2-container--default.select2-container--disabled .select2-selection--single {
background-color: #eee;
cursor: default; }
.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear {
display: none; }
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
border-color: transparent transparent #888 transparent;
border-width: 0 4px 5px 4px; }
.select2-container--default .select2-selection--multiple {
background-color: white;
border: 1px solid #aaa;
@ -176,6 +184,8 @@
margin: 0;
padding: 0 5px;
width: 100%; }
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
list-style: none; }
.select2-container--default .select2-selection--multiple .select2-selection__placeholder {
color: #999;
margin-top: 5px;
@ -203,43 +213,60 @@
margin-right: 2px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
color: #333; }
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder {
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
float: right; }
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
margin-left: 5px;
margin-right: auto; }
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
margin-left: 2px;
margin-right: auto; }
.select2-container--default.select2-container--focus .select2-selection--multiple {
border: solid black 1px;
outline: 0; }
.select2-container--default.select2-container--disabled .select2-selection--multiple {
background-color: #eee;
cursor: default; }
.select2-container--default.select2-container--disabled .select2-selection__choice__remove {
display: none; }
.select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple {
border-top-left-radius: 0;
border-top-right-radius: 0; }
.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0; }
.select2-container--default .select2-search--dropdown .select2-search__field {
border: 1px solid #aaa; }
.select2-container--default .select2-search--inline .select2-search__field {
background: transparent;
border: none;
outline: 0; }
outline: 0;
box-shadow: none;
-webkit-appearance: textfield; }
.select2-container--default .select2-results > .select2-results__options {
max-height: 200px;
overflow-y: auto; }
.select2-container--default .select2-results__option[role=group] {
padding: 0; }
.select2-container--default .select2-results__option[aria-disabled=true] {
color: #999; }
.select2-container--default .select2-results__option[aria-selected=true] {
background-color: #ddd; }
.select2-container--default .select2-results__option .select2-results__option {
padding-left: 1em; }
.select2-container--default .select2-results__option .select2-results__option .select2-results__group {
@ -259,24 +286,26 @@
.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
margin-left: -5em;
padding-left: 6em; }
.select2-container--default .select2-results__option--highlighted[aria-selected] {
background-color: #5897fb;
color: white; }
.select2-container--default .select2-results__group {
cursor: default;
display: block;
padding: 6px; }
.select2-container--classic .select2-selection--single {
background-color: #f6f6f6;
background-color: #f7f7f7;
border: 1px solid #aaa;
border-radius: 4px;
outline: 0;
background-image: -webkit-linear-gradient(top, #ffffff 50%, #eeeeee 100%);
background-image: -o-linear-gradient(top, #ffffff 50%, #eeeeee 100%);
background-image: linear-gradient(to bottom, #ffffff 50%, #eeeeee 100%);
background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%);
background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%);
background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0); }
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
.select2-container--classic .select2-selection--single:focus {
border: 1px solid #5897fb; }
.select2-container--classic .select2-selection--single .select2-selection__rendered {
@ -304,7 +333,7 @@
background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#cccccc', GradientType=0); }
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); }
.select2-container--classic .select2-selection--single .select2-selection__arrow b {
border-color: #888 transparent transparent transparent;
border-style: solid;
@ -316,8 +345,10 @@
position: absolute;
top: 50%;
width: 0; }
.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear {
float: left; }
.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow {
border: none;
border-right: 1px solid #aaa;
@ -326,6 +357,7 @@
border-bottom-left-radius: 4px;
left: 1px;
right: auto; }
.select2-container--classic.select2-container--open .select2-selection--single {
border: 1px solid #5897fb; }
.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow {
@ -334,24 +366,27 @@
.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b {
border-color: transparent transparent #888 transparent;
border-width: 0 4px 5px 4px; }
.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single {
border-top: none;
border-top-left-radius: 0;
border-top-right-radius: 0;
background-image: -webkit-linear-gradient(top, #ffffff 0%, #eeeeee 50%);
background-image: -o-linear-gradient(top, #ffffff 0%, #eeeeee 50%);
background-image: linear-gradient(to bottom, #ffffff 0%, #eeeeee 50%);
background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%);
background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%);
background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0); }
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single {
border-bottom: none;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
background-image: -webkit-linear-gradient(top, #eeeeee 50%, #ffffff 100%);
background-image: -o-linear-gradient(top, #eeeeee 50%, #ffffff 100%);
background-image: linear-gradient(to bottom, #eeeeee 50%, #ffffff 100%);
background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%);
background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%);
background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0); }
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); }
.select2-container--classic .select2-selection--multiple {
background-color: white;
border: 1px solid #aaa;
@ -383,49 +418,67 @@
margin-right: 2px; }
.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover {
color: #555; }
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
float: right; }
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
margin-left: 5px;
margin-right: auto; }
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
margin-left: 2px;
margin-right: auto; }
.select2-container--classic.select2-container--open .select2-selection--multiple {
border: 1px solid #5897fb; }
.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple {
border-top: none;
border-top-left-radius: 0;
border-top-right-radius: 0; }
.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple {
border-bottom: none;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0; }
.select2-container--classic .select2-search--dropdown .select2-search__field {
border: 1px solid #aaa;
outline: 0; }
.select2-container--classic .select2-search--inline .select2-search__field {
outline: 0; }
outline: 0;
box-shadow: none; }
.select2-container--classic .select2-dropdown {
background-color: white;
border: 1px solid transparent; }
.select2-container--classic .select2-dropdown--above {
border-bottom: none; }
.select2-container--classic .select2-dropdown--below {
border-top: none; }
.select2-container--classic .select2-results > .select2-results__options {
max-height: 200px;
overflow-y: auto; }
.select2-container--classic .select2-results__option[role=group] {
padding: 0; }
.select2-container--classic .select2-results__option[aria-disabled=true] {
color: grey; }
.select2-container--classic .select2-results__option--highlighted[aria-selected] {
background-color: #3875d7;
color: white; }
.select2-container--classic .select2-results__group {
cursor: default;
display: block;
padding: 6px; }
.select2-container--classic.select2-container--open .select2-dropdown {
border-color: #5897fb; }

File diff suppressed because it is too large Load Diff

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

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

View File

@ -7,8 +7,7 @@ if( ! class_exists('acf_cache') ) :
class acf_cache {
// vars
var $cache = array(),
$reference = array();
var $reference = array();
/*

View File

@ -19,7 +19,7 @@ class acf_json {
add_action('acf/untrash_field_group', array($this, 'update_field_group'), 10, 1);
add_action('acf/trash_field_group', array($this, 'delete_field_group'), 10, 1);
add_action('acf/delete_field_group', array($this, 'delete_field_group'), 10, 1);
add_action('acf/include_fields', array($this, 'include_fields'), 10, 0);
add_action('acf/include_fields', array($this, 'include_json_folders'), 10, 0);
}
@ -83,19 +83,19 @@ class acf_json {
/*
* include_fields
* include_json_folders
*
* This function will include any JSON files found in the active theme
* This function will include all registered .json files
*
* @type function
* @date 10/03/2014
* @since 5.0.0
*
* @param $version (int)
* @param n/a
* @return n/a
*/
function include_fields() {
function include_json_folders() {
// validate
if( !acf_get_setting('json') ) return;
@ -108,51 +108,74 @@ class acf_json {
// loop through and add to cache
foreach( $paths as $path ) {
// remove trailing slash
$path = untrailingslashit( $path );
// check that path exists
if( !file_exists( $path ) ) {
continue;
}
$dir = opendir( $path );
while(false !== ( $file = readdir($dir)) ) {
// validate type
if( pathinfo($file, PATHINFO_EXTENSION) !== 'json' ) continue;
// read json
$json = file_get_contents("{$path}/{$file}");
// validate json
if( empty($json) ) continue;
// decode
$json = json_decode($json, true);
// add local
$json['local'] = 'json';
// add field group
acf_add_local_field_group( $json );
}
$this->include_json_folder( $path );
}
}
/*
* include_json_folder
*
* This function will include all .json files within a folder
*
* @type function
* @date 1/5/17
* @since 5.5.13
*
* @param n/a
* @return n/a
*/
function include_json_folder( $path = '' ) {
// remove trailing slash
$path = untrailingslashit( $path );
// bail early if path does not exist
if( !is_dir($path) ) return false;
// open
$dir = opendir( $path );
// loop over files
while(false !== ( $file = readdir($dir)) ) {
// validate type
if( pathinfo($file, PATHINFO_EXTENSION) !== 'json' ) continue;
// read json
$json = file_get_contents("{$path}/{$file}");
// validate json
if( empty($json) ) continue;
// decode
$json = json_decode($json, true);
// add local
$json['local'] = 'json';
// add field group
acf_add_local_field_group( $json );
}
// return
return true;
}
}

View File

@ -6,6 +6,12 @@ if( ! class_exists('acf_updates') ) :
class acf_updates {
// vars
var $version = '2.0',
$plugins = array(),
$updates = false,
$dev = 0;
/*
* __construct
@ -22,23 +28,273 @@ class acf_updates {
function __construct() {
// append plugin information
// Note: is_admin() was used previously, however this prevents jetpack manage & ManageWP from working
add_filter('plugins_api', array($this, 'modify_plugin_details'), 20, 3);
// append update information
add_filter('pre_set_site_transient_update_plugins', array($this, 'modify_plugin_update'));
// append update information to transient
add_filter('pre_set_site_transient_update_plugins', array($this, 'modify_plugins_transient'), 10, 1);
// add custom message when PRO not activated but update available
add_action('in_plugin_update_message-' . acf_get_setting('basename'), array($this, 'modify_plugin_update_message'), 10, 2 );
// modify plugin data visible in the 'View details' popup
add_filter('plugins_api', array($this, 'modify_plugin_details'), 10, 3);
}
/*
* add_plugin
*
* This function will register a plugin
*
* @type function
* @date 8/4/17
* @since 5.5.10
*
* @param $plugin (array)
* @return n/a
*/
function add_plugin( $plugin ) {
// validate
$plugin = wp_parse_args($plugin, array(
'id' => '',
'key' => '',
'slug' => '',
'basename' => '',
'version' => '',
));
// Check if is_plugin_active() function exists. This is required on the front end of the
// site, since it is in a file that is normally only loaded in the admin.
if( !function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
// bail early if not active plugin (included in theme)
if( !is_plugin_active($plugin['basename']) ) return;
// add custom message in plugin update row
// removed: decided this message will have a negative impact on user
// if( is_admin() ) {
//
// add_action('in_plugin_update_message-' . $plugin['basename'], array($this, 'modify_plugin_update_message'), 10, 2 );
//
// }
// append
$this->plugins[ $plugin['basename'] ] = $plugin;
}
/*
* request
*
* This function will make a request to the ACF update server
*
* @type function
* @date 8/4/17
* @since 5.5.10
*
* @param $query (string)
* @param $body (array)
* @return (mixed)
*/
function request( $query = 'index.php', $body = array() ) {
// vars
$url = 'https://connect.advancedcustomfields.com/' . $query;
// test
if( $this->dev ) $url = 'http://connect/' . $query;
// log
//acf_log('acf connect: '. $url);
// post
$raw_response = wp_remote_post( $url, array(
'timeout' => 10,
'body' => $body
));
// wp error
if( is_wp_error($raw_response) ) {
return $raw_response;
// http error
} elseif( wp_remote_retrieve_response_code($raw_response) != 200 ) {
return new WP_Error( 'server_error', wp_remote_retrieve_response_message($raw_response) );
}
// decode response
$json = json_decode( wp_remote_retrieve_body($raw_response), true );
// allow non json value
if( $json === null ) {
return wp_remote_retrieve_body($raw_response);
}
// return
return $json;
}
/*
* modify_plugin_information
* get_plugin_info
*
* This function will get plugin info and save as transient
*
* @type function
* @date 9/4/17
* @since 5.5.10
*
* @param $id (string)
* @return (mixed)
*/
function get_plugin_info( $id = '' ) {
// var
$transient_name = 'acf_plugin_info_'.$id;
// delete transient (force-check is used to refresh)
if( !empty($_GET['force-check']) ) {
delete_transient($transient_name);
}
// try transient
$transient = get_transient($transient_name);
if( $transient !== false ) return $transient;
// connect
$response = $this->request('v2/plugins/get-info?p='.$id);
// update transient
set_transient($transient_name, $response, HOUR_IN_SECONDS );
// return
return $response;
}
/*
* refresh_plugins_transient
*
* This function will refresh plugin update info to the transient
*
* @type function
* @date 11/4/17
* @since 5.5.10
*
* @param n/a
* @return n/a
*/
function refresh_plugins_transient() {
// vars
$transient = get_site_transient('update_plugins');
// bail early if no transient
if( empty($transient) ) return;
// update (will trigger modify function)
set_site_transient( 'update_plugins', $transient );
}
/*
* modify_plugins_transient
*
* This function will connect to the ACF website and find update information
*
* @type function
* @date 16/01/2014
* @since 5.0.0
*
* @param $transient (object)
* @return $transient
*/
function modify_plugins_transient( $transient ) {
// bail early if no response (error)
if( !isset($transient->response) ) return $transient;
// fetch updates once (this filter is called multiple times during a single page load)
if( !$this->updates ) {
// vars
$plugins = $this->plugins;
$wp = array(
'wp_name' => get_bloginfo('name'),
'wp_url' => home_url(),
'wp_version' => get_bloginfo('version'),
'wp_language' => get_bloginfo('language'),
'wp_timezone' => get_option('timezone_string'),
);
$post = array(
'plugins' => wp_json_encode($plugins),
'wp' => wp_json_encode($wp),
);
// connect
$this->updates = $this->request('v2/plugins/update-check', $post);
}
// append
if( is_array($this->updates) ) {
foreach( $this->updates['plugins'] as $basename => $update ) {
$transient->response[ $basename ] = (object) $update;
}
}
// return
return $transient;
}
/*
* modify_plugin_details
*
* This function will populate the plugin data visible in the 'View details' popup
*
@ -55,88 +311,60 @@ class acf_updates {
function modify_plugin_details( $result, $action = null, $args = null ) {
// vars
$slug = acf_get_setting('slug');
$plugin = false;
// validate
if( isset($args->slug) && $args->slug === $slug && acf_is_plugin_active() ) {
// filter
$result = apply_filters('acf/updates/plugin_details', $result, $action, $args);
}
// only for 'plugin_information' action
if( $action !== 'plugin_information' ) return $result;
// find plugin via slug
foreach( $this->plugins as $p ) {
if( $args->slug == $p['slug'] ) $plugin = $p;
}
// bail early if plugin not found
if( !$plugin ) return $result;
// connect
$response = $this->get_plugin_info($plugin['id']);
// bail early if no response
if( !is_array($response) ) return $result;
// remove tags (different context)
unset($response['tags']);
// convert to object
$response = (object) $response;
// sections
$sections = array(
'description' => '',
'installation' => '',
'changelog' => '',
'upgrade_notice' => ''
);
foreach( $sections as $k => $v ) {
$sections[ $k ] = $response->$k;
}
$response->sections = $sections;
// return
return $result;
}
/*
* modify_plugin_update_information
*
* This function will connect to the ACF website and find release details
*
* @type function
* @date 16/01/2014
* @since 5.0.0
*
* @param $transient (object)
* @return $transient
*/
function modify_plugin_update( $transient ) {
// bail early if no response (dashboard showed an error)
if( !isset($transient->response) ) return $transient;
// vars
$basename = acf_get_setting('basename');
$show_updates = acf_get_setting('show_updates');
// bail early if not a plugin (included in theme)
if( !acf_is_plugin_active() ) $show_updates = false;
// bail early if no show_updates
if( !$show_updates ) {
// remove from transient
unset( $transient->response[ $basename ] );
// return
return $transient;
}
// get update
$update = acf_maybe_get( $transient->response, $basename );
// filter
$update = apply_filters('acf/updates/plugin_update', $update, $transient);
// update
if( $update ) {
$transient->response[ $basename ] = $update;
} else {
unset($transient->response[ $basename ]);
}
// return
return $transient;
return $response;
}
@ -156,255 +384,73 @@ class acf_updates {
* @return n/a
*/
function modify_plugin_update_message( $plugin_data, $r ) {
/*
function modify_plugin_update_message( $plugin_data, $response ) {
// vars
$message = '';
$info = acf_get_remote_plugin_info();
// check for upgrade notice
if( $info['upgrade_notice'] ) {
// show notice if exists in transient data
if( isset($response->notice) ) {
$message = '<div class="acf-plugin-upgrade-notice">' . $info['upgrade_notice'] . '</div>';
echo '<div class="acf-plugin-upgrade-notice">' . $response->notice . '</div>';
}
// filter
$message = apply_filters('acf/updates/plugin_update_message', $message, $plugin_data, $r );
// return
echo $message;
}
*/
}
// initialize
acf()->updates = new acf_updates();
endif; // class_exists check
/*
* acf_get_remote_plugin_info
* acf_updates
*
* This function will return an array of data from the plugin's readme.txt file (remote)
* The main function responsible for returning the one true acf_updates instance to functions everywhere.
* Use this function like you would a global variable, except without needing to declare the global.
*
* Example: <?php $acf_updates = acf_updates(); ?>
*
* @type function
* @date 8/06/2016
* @since 5.3.9
* @date 9/4/17
* @since 5.5.12
*
* @param n/a
* @return (array)
* @return (object)
*/
function acf_get_remote_plugin_info() {
// vars
$transient_name = 'acf_get_remote_plugin_info';
// clear transient if force check is enabled
if( !empty($_GET['force-check']) ) {
// only allow transient to be deleted once per page load
if( empty($_GET['acf-ignore-force-check']) ) {
delete_transient( 'acf_get_remote_plugin_info' );
}
// update $_GET
$_GET['acf-ignore-force-check'] = true;
}
// get transient
$transient = get_transient( $transient_name );
// fake
/*
if( $transient ) {
$transient['upgrade_notice'] .= '<h4>5.3.8.1</h4><ul><li>This update will do this</li><li>and that</li></ul>';
}
*/
// bail early if transiente exists
if( $transient !== false ) return $transient;
// allow bypass
$info = apply_filters( 'acf/get_remote_plugin_info', false );
function acf_updates() {
if( $info === false ) {
$info = acf_get_wporg_remote_plugin_info();
}
global $acf_updates;
if( !isset($acf_updates) ) {
// store only relevant changelog / upgrade notice
foreach( array('changelog', 'upgrade_notice') as $k ) {
// bail early if not set
if( empty($info[ $k ]) ) continue;
// vars
$new = '';
$orig = $info[ $k ];
// explode
$bits = array_filter( explode('<h4>', $orig) );
// loop
foreach( $bits as $bit ) {
// vars
$bit = explode('</h4>', $bit);
$version = trim($bit[0]);
$text = trim($bit[1]);
// is relevant?
if( version_compare($info['version'], $version, '==') ) {
$new = '<h4>' . $version . '</h4>' . $text;
break;
}
}
// update
$info[ $k ] = $new;
$acf_updates = new acf_updates();
}
// allow transient to save empty
if( empty($info) ) $info = 0;
// update transient
set_transient( $transient_name, $info, DAY_IN_SECONDS );
// return
return $info;
return $acf_updates;
}
/*
* acf_get_wporg_remote_plugin_info
* acf_register_plugin_update
*
* This function will return an array of data from the wordpress.org plugin's readme.txt file (remote)
* alias of acf_updates()->add_plugin()
*
* @type function
* @date 8/06/2016
* @since 5.3.9
*
* @param n/a
* @return (array)
*/
function acf_get_wporg_remote_plugin_info() {
// create basic version of plugin info.
// this should replicate the data available via plugin_api()
// doing so allows ACF PRO to load data from external source
$info = array(
'name' => acf_get_setting('name'),
'slug' => acf_get_setting('slug'),
'version' => acf_get_setting('version'),
'changelog' => '',
'upgrade_notice' => ''
);
// get readme
$response = wp_safe_remote_get('https://plugins.svn.wordpress.org/advanced-custom-fields/trunk/readme.txt');
// bail early if no response
if( is_wp_error($response) || empty($response['body']) ) return $info;
// use regex to find upgrade notice
$matches = null;
$regexp = '/(== Upgrade Notice ==)([\s\S]+?)(==|$)/';
// bail early if no match
if( !preg_match($regexp, $response['body'], $matches) ) return $info;
// convert to html
$text = wp_kses_post( trim($matches[2]) );
// pretify
$text = preg_replace('/^= (.*?) =/m', '<h4>$1</h4>', $text);
$text = preg_replace('/^[\*] (.*?)(\n|$)/m', '<li>$1</li>', $text);
$text = preg_replace('/\n<li>(.*?)/', "\n" . '<ul><li>$1', $text);
$text = preg_replace('/(<\/li>)(?!<li>)/', '$1</ul>' . "\n", $text);
// update
$info['upgrade_notice'] = $text;
// return
return $info;
}
/*
* acf_refresh_plugin_updates_transient
*
* This function will refresh teh WP transient containing plugin update data
*
* @type function
* @date 11/08/2016
* @since 5.4.0
* @date 12/4/17
* @since 5.5.10
*
* @param $post_id (int)
* @return $post_id (int)
*/
function acf_refresh_plugin_updates_transient() {
function acf_register_plugin_update( $plugin ) {
// vars
$transient = get_site_transient('update_plugins');
acf_updates()->add_plugin( $plugin );
// bail early if no transient
if( empty($transient) ) return;
// update transient
$transient = acf()->updates->modify_plugin_update( $transient );
// update
set_site_transient( 'update_plugins', $transient );
}
endif; // class_exists check
?>

View File

@ -211,6 +211,13 @@ class acf_field_date_picker extends acf_field {
global $wp_locale;
// vars
$d_m_Y = date_i18n('d/m/Y');
$m_d_Y = date_i18n('m/d/Y');
$F_j_Y = date_i18n('F j, Y');
$Ymd = date_i18n('Ymd');
// display_format
acf_render_field_setting( $field, array(
'label' => __('Display Format','acf'),
@ -219,9 +226,10 @@ class acf_field_date_picker extends acf_field {
'name' => 'display_format',
'other_choice' => 1,
'choices' => array(
'd/m/Y' => date_i18n('d/m/Y'),
'm/d/Y' => date_i18n('m/d/Y'),
'F j, Y' => date_i18n('F j, Y'),
'd/m/Y' => '<span>' . $d_m_Y . '</span><code>d/m/Y</code>',
'm/d/Y' => '<span>' . $m_d_Y . '</span><code>m/d/Y</code>',
'F j, Y' => '<span>' . $F_j_Y . '</span><code>F j, Y</code>',
'other' => '<span>' . __('Custom:','acf') . '</span>'
)
));
@ -248,10 +256,11 @@ class acf_field_date_picker extends acf_field {
'name' => 'return_format',
'other_choice' => 1,
'choices' => array(
'd/m/Y' => date_i18n('d/m/Y'),
'm/d/Y' => date_i18n('m/d/Y'),
'F j, Y' => date_i18n('F j, Y'),
'Ymd' => date_i18n('Ymd'),
'd/m/Y' => '<span>' . $d_m_Y . '</span><code>d/m/Y</code>',
'm/d/Y' => '<span>' . $m_d_Y . '</span><code>m/d/Y</code>',
'F j, Y' => '<span>' . $F_j_Y . '</span><code>F j, Y</code>',
'Ymd' => '<span>' . $Ymd . '</span><code>Ymd</code>',
'other' => '<span>' . __('Custom:','acf') . '</span>'
)
));

View File

@ -185,6 +185,13 @@ class acf_field_date_and_time_picker extends acf_field {
global $wp_locale;
// vars
$d_m_Y = date_i18n('d/m/Y g:i a');
$m_d_Y = date_i18n('m/d/Y g:i a');
$F_j_Y = date_i18n('F j, Y g:i a');
$Ymd = date_i18n('Y-m-d H:i:s');
// display_format
acf_render_field_setting( $field, array(
'label' => __('Display Format','acf'),
@ -193,10 +200,11 @@ class acf_field_date_and_time_picker extends acf_field {
'name' => 'display_format',
'other_choice' => 1,
'choices' => array(
'd/m/Y g:i a' => date_i18n('d/m/Y g:i a'),
'm/d/Y g:i a' => date_i18n('m/d/Y g:i a'),
'F j, Y g:i a' => date_i18n('F j, Y g:i a'),
'Y-m-d H:i:s' => date_i18n('Y-m-d H:i:s'),
'd/m/Y g:i a' => '<span>' . $d_m_Y . '</span><code>d/m/Y g:i a</code>',
'm/d/Y g:i a' => '<span>' . $m_d_Y . '</span><code>m/d/Y g:i a</code>',
'F j, Y g:i a' => '<span>' . $F_j_Y . '</span><code>F j, Y g:i a</code>',
'Y-m-d H:i:s' => '<span>' . $Ymd . '</span><code>Y-m-d H:i:s</code>',
'other' => '<span>' . __('Custom:','acf') . '</span>'
)
));
@ -209,10 +217,11 @@ class acf_field_date_and_time_picker extends acf_field {
'name' => 'return_format',
'other_choice' => 1,
'choices' => array(
'd/m/Y g:i a' => date_i18n('d/m/Y g:i a'),
'm/d/Y g:i a' => date_i18n('m/d/Y g:i a'),
'F j, Y g:i a' => date_i18n('F j, Y g:i a'),
'Y-m-d H:i:s' => date_i18n('Y-m-d H:i:s'),
'd/m/Y g:i a' => '<span>' . $d_m_Y . '</span><code>d/m/Y g:i a</code>',
'm/d/Y g:i a' => '<span>' . $m_d_Y . '</span><code>m/d/Y g:i a</code>',
'F j, Y g:i a' => '<span>' . $F_j_Y . '</span><code>F j, Y g:i a</code>',
'Y-m-d H:i:s' => '<span>' . $Ymd . '</span><code>Y-m-d H:i:s</code>',
'other' => '<span>' . __('Custom:','acf') . '</span>'
)
));

View File

@ -138,8 +138,16 @@ class acf_field_radio extends acf_field {
}
// allow custom 'other' choice to be defined
if( !isset($field['choices']['other']) ) {
$field['choices']['other'] = '';
}
// append other choice
$field['choices']['other'] = '</label><input type="text" ' . acf_esc_attr($input) . ' /><label>';
$field['choices']['other'] .= '</label><input type="text" ' . acf_esc_attr($input) . ' /><label>';
}

View File

@ -117,8 +117,9 @@ class acf_field_time_picker extends acf_field {
function render_field_settings( $field ) {
// global
global $wp_locale;
// vars
$g_i_a = date('g:i a');
$H_i_s = date('H:i:s');
// display_format
@ -129,8 +130,9 @@ class acf_field_time_picker extends acf_field {
'name' => 'display_format',
'other_choice' => 1,
'choices' => array(
'g:i a' => date('g:i a'),
'H:i:s' => date('H:i:s'),
'g:i a' => '<span>' . $g_i_a . '</span><code>g:i a</code>',
'H:i:s' => '<span>' . $H_i_s . '</span><code>H:i:s</code>',
'other' => '<span>' . __('Custom:','acf') . '</span>'
)
));
@ -143,8 +145,9 @@ class acf_field_time_picker extends acf_field {
'name' => 'return_format',
'other_choice' => 1,
'choices' => array(
'g:i a' => date('g:i a'),
'H:i:s' => date('H:i:s'),
'g:i a' => '<span>' . $g_i_a . '</span><code>g:i a</code>',
'H:i:s' => '<span>' . $H_i_s . '</span><code>H:i:s</code>',
'other' => '<span>' . __('Custom:','acf') . '</span>'
)
));

View File

@ -223,7 +223,15 @@ class acf_form_post {
add_action('edit_form_after_title', array($this, 'edit_form_after_title'));
// remove ACF from meta postbox
// remove postcustom metabox (removes expensive SQL query)
if( acf_get_setting('remove_wp_meta_box') ) {
remove_meta_box( 'postcustom', false, 'normal' );
}
// remove ACF values from meta postbox ()
add_filter('is_protected_meta', array($this, 'is_protected_meta'), 10, 3);
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,27 +19,22 @@ class acf_pro {
function __construct() {
// constants
acf()->define( 'ACF_PRO', true );
// update setting
acf_update_setting( 'pro', true );
acf_update_setting( 'name', __('Advanced Custom Fields PRO', 'acf') );
// api
acf_include('pro/api/api-pro.php');
// includes
acf_include('pro/api/api-options-page.php');
// updates
acf_include('pro/core/updates.php');
// admin
if( is_admin() ) {
// options page
acf_include('pro/admin/options-page.php');
// settings
acf_include('pro/admin/settings-updates.php');
}
@ -92,18 +87,19 @@ class acf_pro {
function register_assets() {
// min
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
// vars
$version = acf_get_setting('version');
$min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
// register scripts
wp_register_script( 'acf-pro-input', acf_get_dir( "pro/assets/js/acf-pro-input{$min}.js" ), array('acf-input'), acf_get_setting('version') );
wp_register_script( 'acf-pro-field-group', acf_get_dir( "pro/assets/js/acf-pro-field-group{$min}.js" ), array('acf-field-group'), acf_get_setting('version') );
wp_register_script( 'acf-pro-input', acf_get_dir( "pro/assets/js/acf-pro-input{$min}.js" ), array('acf-input'), $version );
wp_register_script( 'acf-pro-field-group', acf_get_dir( "pro/assets/js/acf-pro-field-group{$min}.js" ), array('acf-field-group'), $version );
// register styles
wp_register_style( 'acf-pro-input', acf_get_dir( 'pro/assets/css/acf-pro-input.css' ), false, acf_get_setting('version') );
wp_register_style( 'acf-pro-field-group', acf_get_dir( 'pro/assets/css/acf-pro-field-group.css' ), false, acf_get_setting('version') );
wp_register_style( 'acf-pro-input', acf_get_dir( 'pro/assets/css/acf-pro-input.css' ), array('acf-input'), $version );
wp_register_style( 'acf-pro-field-group', acf_get_dir( 'pro/assets/css/acf-pro-field-group.css' ), array('acf-input'), $version );
}
@ -123,11 +119,7 @@ class acf_pro {
function input_admin_enqueue_scripts() {
// scripts
wp_enqueue_script('acf-pro-input');
// styles
wp_enqueue_style('acf-pro-input');
}
@ -148,11 +140,7 @@ class acf_pro {
function field_group_admin_enqueue_scripts() {
// scripts
wp_enqueue_script('acf-pro-field-group');
// styles
wp_enqueue_style('acf-pro-field-group');
}

View File

@ -463,14 +463,8 @@ if( typeof acf !== 'undefined' ) {
function html() {
// vars
$view = array(
'page' => $this->page
);
// load view
acf_pro_get_view('options-page', $view);
acf_get_view(dirname(__FILE__) . '/views/options-page.php', $this->page);
}

View File

@ -1,8 +1,13 @@
<?php
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( ! class_exists('acf_settings_updates') ) :
class acf_settings_updates {
var $view;
// vars
var $view = array();
/*
@ -26,6 +31,106 @@ class acf_settings_updates {
}
/*
* show_notice
*
* This function will show a notice (only once)
*
* @type function
* @date 11/4/17
* @since 5.5.10
*
* @param $message (string)
* @param class (string)
* @return n/a
*/
function show_notice( $message = '', $class = '' ){
// only show one notice
if( acf_has_done('acf_settings_updates_notice') ) return false;
// add notice
acf_add_admin_notice( $message, $class );
}
/*
* show_error
*
* This function will show an error notice (only once)
*
* @type function
* @date 11/4/17
* @since 5.5.10
*
* @param $error (mixed)
* @return n/a
*/
function show_error( $error = '' ){
// error object
if( is_wp_error($error) ) {
$error = __('<b>Error</b>. Could not connect to update server', 'acf') . ' <span class="description">(' . $error->get_error_message() . ')</span>';
}
// add notice
$this->show_notice( $error, 'error' );
}
/*
* get_changelog_section
*
* This function will find and return a section of content from a plugin changelog
*
* @type function
* @date 11/4/17
* @since 5.5.10
*
* @param $changelog (string)
* @param $h4 (string)
* @return (string)
*/
function get_changelog_section( $changelog, $h4 = '' ) {
// explode
$bits = array_filter( explode('<h4>', $changelog) );
// loop
foreach( $bits as $bit ) {
// vars
$bit = explode('</h4>', $bit);
$version = trim($bit[0]);
$text = trim($bit[1]);
// is relevant?
if( version_compare($h4, $version, '==') ) {
return '<h4>' . $version . '</h4>' . $text;
}
}
// update
return '';
}
/*
* admin_menu
*
@ -54,7 +159,7 @@ class acf_settings_updates {
// add page
$page = add_submenu_page('edit.php?post_type=acf-field-group', __('Updates','acf'), __('Updates','acf'), acf_get_setting('capability'),'acf-settings-updates', array($this,'html') );
$page = add_submenu_page('edit.php?post_type=acf-field-group', __('Updates','acf'), __('Updates','acf'), acf_get_setting('capability'), 'acf-settings-updates', array($this,'html') );
// actions
@ -63,48 +168,6 @@ class acf_settings_updates {
}
/*
* show_remote_response_error
*
* This function will show an admin notice if server connection fails
*
* @type function
* @date 25/07/2016
* @since 5.4.0
*
* @param n/a
* @return n/a
*/
function show_remote_response_error() {
// only run once
if( acf_has_done('show_remote_response_error') ) return false;
// vars
$error = acf_get_setting('remote_response_error');
$notice = __('<b>Error</b>. Could not connect to update server', 'acf');
// append error
if( $error ) {
$notice .= ' <span class="description">(' . $error . ')</span>';
}
// add notice
acf_add_admin_notice( $notice, 'error' );
// return
return false;
}
/*
* load
*
@ -120,11 +183,12 @@ class acf_settings_updates {
function load() {
// $_POST
// activate
if( acf_verify_nonce('activate_pro_licence') ) {
$this->activate_pro_licence();
// deactivate
} elseif( acf_verify_nonce('deactivate_pro_licence') ) {
$this->deactivate_pro_licence();
@ -132,10 +196,11 @@ class acf_settings_updates {
}
// view
// vars
$license = acf_pro_get_license_key();
$this->view = array(
'license' => '',
'active' => 0,
'license' => $license,
'active' => $license ? 1 : 0,
'current_version' => acf_get_setting('version'),
'remote_version' => '',
'update_available' => false,
@ -144,25 +209,16 @@ class acf_settings_updates {
);
// license
if( acf_pro_is_license_active() ) {
// vars
$info = acf_updates()->get_plugin_info('pro');
$this->view['license'] = acf_pro_get_license_key();
$this->view['active'] = 1;
// error
if( is_wp_error($info) ) {
return $this->show_error( $info );
}
// vars
$info = acf_get_remote_plugin_info();
// validate
if( empty($info) ) {
return $this->show_remote_response_error();
}
// add info to view
@ -170,39 +226,29 @@ class acf_settings_updates {
// add changelog if the remote version is '>' than the current version
if( acf_pro_is_update_available() ) {
$version = acf_get_setting('version');
// check if remote version is higher than current version
if( version_compare($info['version'], $version, '>') ) {
// update view
$this->view['update_available'] = true;
$this->view['changelog'] = acf_maybe_get($info, 'changelog');
$this->view['upgrade_notice'] = acf_maybe_get($info, 'upgrade_notice');
$this->view['changelog'] = $this->get_changelog_section($info['changelog'], $info['version']);
$this->view['upgrade_notice'] = $this->get_changelog_section($info['upgrade_notice'], $info['version']);
// refresh transient
// - avoids new version not available in plugin update list
// - only request if license is active
if( $license ) {
acf_updates()->refresh_plugins_transient();
}
}
// update transient
acf_refresh_plugin_updates_transient();
}
/*
* html
*
* description
*
* @type function
* @date 7/01/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
function html() {
// load view
acf_pro_get_view('settings-updates', $this->view);
}
@ -222,9 +268,8 @@ class acf_settings_updates {
function activate_pro_licence() {
// connect
$args = array(
'_nonce' => wp_create_nonce('activate_pro_licence'),
'acf_license' => acf_extract_var($_POST, 'acf_pro_licence'),
$post = array(
'acf_license' => $_POST['acf_pro_licence'],
'acf_version' => acf_get_setting('version'),
'wp_name' => get_bloginfo('name'),
'wp_url' => home_url(),
@ -235,38 +280,31 @@ class acf_settings_updates {
// connect
$response = acf_pro_get_remote_response( 'activate-license', $args );
$response = acf_updates()->request('v2/plugins/activate?p=pro', $post);
// validate
if( empty($response) ) {
// error
if( is_wp_error($response) ) {
return $this->show_remote_response_error();
return $this->show_error( $response );
}
// vars
$response = json_decode($response, true);
$class = '';
// action
// success
if( $response['status'] == 1 ) {
acf_pro_update_license($response['license']);
// update license
acf_pro_update_license( $response['license'] );
// show message
$this->show_notice( $response['message'] );
} else {
$class = 'error';
}
// show message
if( $response['message'] ) {
acf_add_admin_notice($response['message'], $class);
// show error
$this->show_error( $response['message'] );
}
@ -288,61 +326,70 @@ class acf_settings_updates {
function deactivate_pro_licence() {
// validate
if( !acf_pro_is_license_active() ) {
return;
}
// vars
$license = acf_pro_get_license_key();
// bail early if no key
if( !$license ) return;
// connect
$args = array(
'_nonce' => wp_create_nonce('deactivate_pro_licence'),
'acf_license' => acf_pro_get_license_key(),
$post = array(
'acf_license' => $license,
'wp_url' => home_url(),
);
// connect
$response = acf_pro_get_remote_response( 'deactivate-license', $args );
$response = acf_updates()->request('v2/plugins/deactivate?p=pro', $post);
// validate
if( empty($response) ) {
return $this->show_remote_response_error();
// error
if( is_wp_error($response) ) {
return $this->show_error( $response );
}
// vars
$response = json_decode($response, true);
$class = '';
// allways clear DB
// clear DB
acf_pro_update_license('');
// action
// success
if( $response['status'] == 1 ) {
// show message
$this->show_notice( $response['message'] );
} else {
$class = 'error';
// show error
$this->show_error( $response['message'] );
}
}
/*
* html
*
* description
*
* @type function
* @date 7/01/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
function html() {
// show message
if( $response['message'] ) {
acf_add_admin_notice($response['message'], $class);
}
// load view
acf_get_view( dirname(__FILE__) . '/views/settings-updates.php', $this->view);
}
@ -352,4 +399,6 @@ class acf_settings_updates {
// initialize
new acf_settings_updates();
endif; // class_exists check
?>

View File

@ -6,7 +6,7 @@ extract($args);
?>
<div class="wrap acf-settings-wrap">
<h1><?php echo $page['page_title']; ?></h1>
<h1><?php echo $page_title; ?></h1>
<form id="post" method="post" name="post">
@ -14,7 +14,7 @@ extract($args);
// render post data
acf_form_data(array(
'post_id' => $page['post_id'],
'post_id' => $post_id,
'nonce' => 'options',
));

View File

@ -1,390 +0,0 @@
<?php
/*
* acf_pro_get_view
*
* This function will load in a file from the 'admin/views' folder and allow variables to be passed through
*
* @type function
* @date 28/09/13
* @since 5.0.0
*
* @param $view_name (string)
* @param $args (array)
* @return n/a
*/
function acf_pro_get_view( $view_name = '', $args = array() ) {
// vars
$path = acf_get_path("pro/admin/views/{$view_name}.php");
if( file_exists($path) ) {
include( $path );
}
}
/*
* acf_pro_get_remote_url
*
* description
*
* @type function
* @date 16/01/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
function acf_pro_get_remote_url( $action = '', $args = array() ) {
// defaults
$args['a'] = $action;
$args['p'] = 'pro';
// vars
$url = "https://connect.advancedcustomfields.com/index.php?" . build_query($args);
//$url = "http://connect/index.php?" . build_query($args);
// return
return $url;
}
/*
* acf_pro_get_remote_response
*
* description
*
* @type function
* @date 16/01/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
function acf_pro_get_remote_response( $action = '', $post = array() ) {
// vars
$url = acf_pro_get_remote_url( $action );
// connect
$request = wp_remote_post( $url, array(
'body' => $post
));
// error
if( is_wp_error($request) ) {
// loop
foreach( $request->errors as $k => $v ) {
// bail early if no error
if( empty($v[0]) ) continue;
// save
acf_update_setting('remote_response_error', $k . ': ' . $v[0]);
// only run once
break;
}
// success
} elseif( wp_remote_retrieve_response_code($request) === 200) {
return $request['body'];
}
// return
return 0;
}
/*
* acf_pro_is_update_available
*
* This function will return true if an update is available
*
* @type function
* @date 14/05/2014
* @since 5.0.0
*
* @param n/a
* @return (boolean)
*/
function acf_pro_is_update_available() {
// vars
$info = acf_get_remote_plugin_info();
$version = acf_get_setting('version');
// return false if no info
if( empty($info['version']) ) return false;
// return false if the external version is '<=' the current version
if( version_compare($info['version'], $version, '<=') ) {
return false;
}
// return
return true;
}
/*
* acf_pro_get_remote_info
*
* This function will return remote plugin data
*
* @type function
* @date 16/01/2014
* @since 5.0.0
*
* @param n/a
* @return (mixed)
*/
function acf_pro_get_remote_info() {
// clear transient if force check is enabled
if( !empty($_GET['force-check']) ) {
// only allow transient to be deleted once per page load
if( empty($_GET['acf-ignore-force-check']) ) {
delete_transient( 'acf_pro_get_remote_info' );
}
// update $_GET
$_GET['acf-ignore-force-check'] = true;
}
// get transient
$transient = get_transient( 'acf_pro_get_remote_info' );
if( $transient !== false ) {
return $transient;
}
// vars
$info = acf_pro_get_remote_response('get-info');
$timeout = 12 * HOUR_IN_SECONDS;
// decode
if( !empty($info) ) {
$info = json_decode($info, true);
// fake info version
//$info['version'] = '6.0.0';
} else {
$info = 0; // allow transient to be returned, but empty to validate
$timeout = 2 * HOUR_IN_SECONDS;
}
// update transient
set_transient('acf_pro_get_remote_info', $info, $timeout );
// return
return $info;
}
/*
* acf_pro_get_license
*
* This function will return the license
*
* @type function
* @date 20/09/2016
* @since 5.4.0
*
* @param n/a
* @return n/a
*/
function acf_pro_get_license() {
// get option
$license = get_option('acf_pro_license');
// bail early if no value
if( !$license ) return false;
// decode
$license = maybe_unserialize(base64_decode($license));
// bail early if corrupt
if( !acf_is_array( $license )) return false;
// return
return $license;
}
/*
* acf_pro_get_license_key
*
* This function will return the license key
*
* @type function
* @date 20/09/2016
* @since 5.4.0
*
* @param n/a
* @return n/a
*/
function acf_pro_get_license_key() {
// vars
$license = acf_pro_get_license();
// bail early if empty
if( !$license ) return false;
// return
return $license['key'];
}
/*
* acf_pro_is_license_active
*
* This function will return true if the current license is active
*
* @type function
* @date 20/09/2016
* @since 5.4.0
*
* @param n/a
* @return n/a
*/
function acf_pro_is_license_active() {
// vars
$license = acf_pro_get_license();
$url = home_url();
// bail early if empty
if( !$license ) return false;
// bail early if no key
if( !$license['key'] ) return false;
// strip proticol from urls
$license['url'] = acf_strip_protocol( $license['url'] );
$url = acf_strip_protocol( $url );
// bail early if url does not match
if( $license['url'] !== $url ) {
// add notice (only once) - removed due to feedback
// if( !acf_has_done('acf_pro_is_license_active_notice') ) {
//
// acf_add_admin_notice( __('Error validating ACF PRO license URL (website does not match). Please re-activate your license','acf'), 'error' );
//
// }
return false;
}
// return
return true;
}
/*
* acf_pro_update_license
*
* This function will update the DB license
*
* @type function
* @date 20/09/2016
* @since 5.4.0
*
* @param $key (string)
* @return n/a
*/
function acf_pro_update_license( $key = '' ) {
// vars
$value = '';
// key
if( $key ) {
// vars
$data = array(
'key' => $key,
'url' => home_url()
);
// encode
$value = base64_encode(maybe_serialize($data));
}
// update
return update_option('acf_pro_license', $value);
}
?>

View File

@ -377,7 +377,7 @@
// vars
this.$el = this.$field.find('.acf-flexible-content:first');
this.$input = this.$el.siblings('input');
this.$input = this.$el.children('input');
this.$values = this.$el.children('.values');
this.$clones = this.$el.children('.clones');
@ -461,28 +461,26 @@
render_layout_title: function( $layout ){
// vars
var ajax_data = acf.serialize( $layout );
var $input = $layout.children('input');
var prefix = $input.attr('name').replace('[acf_fc_layout]', '');
// append
ajax_data = acf.parse_args( ajax_data, {
// ajax data
var ajax_data = acf.prepare_for_ajax({
action: 'acf/fields/flexible_content/layout_title',
field_key: this.$field.data('key'),
i: $layout.index(),
layout: $layout.data('layout')
layout: $input.val(),
value: acf.serialize( $layout, prefix )
});
// prepare
ajax_data = acf.prepare_for_ajax(ajax_data);
// ajax get title HTML
$.ajax({
url : acf.get('ajaxurl'),
dataType : 'html',
type : 'post',
data : ajax_data,
url: acf.get('ajaxurl'),
dataType: 'html',
type: 'post',
data: ajax_data,
success: function( html ){
// bail early if no html

File diff suppressed because one or more lines are too long

View File

@ -22,166 +22,58 @@ class acf_pro_updates {
function __construct() {
// filters
add_filter('acf/get_remote_plugin_info', array($this, 'get_remote_plugin_info'), 10, 1);
add_filter('acf/updates/plugin_details', array($this, 'plugin_details'), 10, 3);
add_filter('acf/updates/plugin_update', array($this, 'plugin_update'), 10, 2);
add_filter('acf/updates/plugin_update_message', array($this, 'plugin_update_message'), 10, 3);
// actions
add_action('init', array($this, 'init'), 20);
}
/*
* init
*
* description
*
* @type function
* @date 10/4/17
* @since 5.5.10
*
* @param $post_id (int)
* @return $post_id (int)
*/
function init() {
// bail early if no show_updates
if( !acf_get_setting('show_updates') ) return;
// bail early if not a plugin (included in theme)
if( !acf_is_plugin_active() ) return;
// register update
acf_register_plugin_update(array(
'id' => 'pro',
'key' => acf_pro_get_license_key(),
'slug' => acf_get_setting('slug'),
'basename' => acf_get_setting('basename'),
'version' => acf_get_setting('version'),
));
// admin
if( is_admin() ) {
}
/*
* get_remote_plugin_info
*
* This function will return an array of data from the plugin's readme.txt file (remote)
* The data returned will be stored in a transient and used to display plugin update info
*
* @type function
* @date 8/06/2016
* @since 5.3.8
*
* @param $info (array)
* @return $info
*/
function get_remote_plugin_info( $info ) {
// vars
$info = acf_pro_get_remote_response('get-info');
// bail ealry if no info
if( empty($info) ) return 0;
// json decode
$info = json_decode($info, true);
// remove unused data to save DB transient space
unset( $info['description'] );
unset( $info['installation'] );
unset( $info['tags'] );
// return
return $info;
}
/*
* plugin_details
*
* This function will populate the plugin data visible in the 'View details' popup
*
* @type function
* @date 8/06/2016
* @since 5.3.8
*
* @param $result (bool|object)
* @param $action (string)
* @param $args (object)
* @return $result
*/
function plugin_details( $result = false, $action = null, $args = null ) {
// vars
$slug = acf_get_setting('slug');
$info = acf_pro_get_remote_response('get-info');
// bail ealry if no info
if( empty($info) ) return false;
// json decode
$info = json_decode($info);
// sections
$sections = array(
'description' => '',
'installation' => '',
'changelog' => '',
'upgrade_notice' => ''
);
foreach( $sections as $k => $v ) {
$sections[ $k ] = $info->$k;
unset( $info->$k );
}
$info->sections = $sections;
// return
return $info;
}
/*
* plugin_update
*
* This function will return an object of data saved in transient and used by WP do perform an update
*
* @type function
* @date 16/01/2014
* @since 5.0.0
*
* @param $update (object)
* @param $transient (object)
* @return $update
*/
function plugin_update( $update, $transient ) {
// bail early if no update available
if( !acf_pro_is_update_available() ) return false;
// vars
$info = acf_get_remote_plugin_info();
$basename = acf_get_setting('basename');
$slug = acf_get_setting('slug');
// create new object for update
$obj = new stdClass();
$obj->slug = $slug;
$obj->plugin = $basename;
$obj->new_version = $info['version'];
$obj->url = $info['homepage'];
$obj->package = '';
// license
if( acf_pro_is_license_active() ) {
add_action('in_plugin_update_message-' . acf_get_setting('basename'), array($this, 'modify_plugin_update_message'), 10, 2 );
$obj->package = acf_pro_get_remote_url('download', array(
'k' => acf_pro_get_license_key(),
'wp_url' => home_url(),
'acf_version' => acf_get_setting('version'),
'wp_version' => get_bloginfo('version'),
));
}
// return
return $obj;
}
/*
* plugin_update_message
* modify_plugin_update_message
*
* Displays an update message for plugin list screens.
*
@ -195,23 +87,14 @@ class acf_pro_updates {
* @return $message
*/
function plugin_update_message( $message, $plugin_data, $r ) {
function modify_plugin_update_message( $plugin_data, $response ) {
// validate
if( acf_pro_is_license_active() ) return $message;
// bail ealry if has key
if( acf_pro_get_license_key() ) return;
// vars
$activate_message = sprintf(
__('To enable updates, please enter your license key on the <a href="%s">Updates</a> page. If you don\'t have a licence key, please see <a href="%s">details & pricing</a>.', 'acf'),
admin_url('edit.php?post_type=acf-field-group&page=acf-settings-updates'),
'https://www.advancedcustomfields.com/pro'
);
// return
// override $message (if plugin is not active, there is no need to see upgrade_notice)
return '<br />' . $activate_message;
// display message
echo '<br />' . sprintf( __('To enable updates, please enter your license key on the <a href="%s">Updates</a> page. If you don\'t have a licence key, please see <a href="%s">details & pricing</a>.', 'acf'), admin_url('edit.php?post_type=acf-field-group&page=acf-settings-updates'), 'https://www.advancedcustomfields.com/pro' );
}
@ -223,4 +106,126 @@ new acf_pro_updates();
endif; // class_exists check
/*
* acf_pro_get_license
*
* This function will return the license
*
* @type function
* @date 20/09/2016
* @since 5.4.0
*
* @param n/a
* @return n/a
*/
function acf_pro_get_license() {
// get option
$license = get_option('acf_pro_license');
// bail early if no value
if( !$license ) return false;
// decode
$license = maybe_unserialize(base64_decode($license));
// bail early if corrupt
if( !is_array($license) ) return false;
// return
return $license;
}
/*
* acf_pro_get_license_key
*
* This function will return the license key
*
* @type function
* @date 20/09/2016
* @since 5.4.0
*
* @param n/a
* @return n/a
*/
function acf_pro_get_license_key() {
// vars
$license = acf_pro_get_license();
$home_url = home_url();
// bail early if empty
if( !$license || !$license['key'] ) return false;
// bail early if url has changed
if( acf_strip_protocol($license['url']) !== acf_strip_protocol($home_url) ) return false;
// return
return $license['key'];
}
/*
* acf_pro_update_license
*
* This function will update the DB license
*
* @type function
* @date 20/09/2016
* @since 5.4.0
*
* @param $key (string)
* @return n/a
*/
function acf_pro_update_license( $key = '' ) {
// vars
$value = '';
// key
if( $key ) {
// vars
$data = array(
'key' => $key,
'url' => home_url()
);
// encode
$value = base64_encode(maybe_serialize($data));
}
// re-register update (key has changed)
acf_register_plugin_update(array(
'id' => 'pro',
'key' => $key,
'slug' => acf_get_setting('slug'),
'basename' => acf_get_setting('basename'),
'version' => acf_get_setting('version'),
));
// update
return update_option('acf_pro_license', $value);
}
?>

View File

@ -1181,6 +1181,7 @@ class acf_field_clone extends acf_field {
// vars
$fields = false;
$ignore_s = false;
$data = array(
'text' => $field_group['title'],
'children' => array()
@ -1204,6 +1205,14 @@ class acf_field_clone extends acf_field {
if( !$fields ) continue;
// show all children for field group search match
if( $s !== false && stripos($data['text'], $s) !== false ) {
$ignore_s = true;
}
// populate children
$children = array();
$children[] = $field_group['key'];
@ -1222,7 +1231,7 @@ class acf_field_clone extends acf_field {
// bail early if is search, and $text does not contain $s
if( $s !== false ) {
if( $s !== false && !$ignore_s ) {
// get early
$text = $this->get_clone_setting_choice( $child );

View File

@ -276,11 +276,12 @@ class acf_field_flexible_content extends acf_field {
}
// hidden input
acf_hidden_input(array(
'type' => 'hidden',
'name' => $field['name'],
));
// vars
$div = array(
'class' => 'acf-flexible-content',
'data-min' => $field['min'],
'data-max' => $field['max']
);
// no value message
@ -288,7 +289,9 @@ class acf_field_flexible_content extends acf_field {
$no_value_message = apply_filters('acf/fields/flexible_content/no_value_message', $no_value_message, $field);
?>
<div <?php acf_esc_attr_e(array( 'class' => 'acf-flexible-content', 'data-min' => $field['min'], 'data-max' => $field['max'] )); ?>>
<div <?php acf_esc_attr_e( $div ); ?>>
<?php acf_hidden_input(array( 'name' => $field['name'] )); ?>
<div class="no-value-message" <?php if( $field['value'] ){ echo 'style="display:none;"'; } ?>>
<?php printf( $no_value_message, $field['button_label'] ); ?>
@ -301,22 +304,20 @@ class acf_field_flexible_content extends acf_field {
</div>
<div class="values">
<?php if( !empty($field['value']) ): ?>
<?php foreach( $field['value'] as $i => $value ): ?>
<?php
<?php if( !empty($field['value']) ):
foreach( $field['value'] as $i => $value ):
// validate
if( empty($layouts[ $value['acf_fc_layout'] ]) ) {
if( empty($layouts[ $value['acf_fc_layout'] ]) ) continue;
continue;
}
// render
$this->render_layout( $field, $layouts[ $value['acf_fc_layout'] ], $i, $value );
?>
<?php endforeach; ?>
<?php endif; ?>
endforeach;
endif; ?>
</div>
<ul class="acf-actions acf-hl">
@ -420,9 +421,7 @@ class acf_field_flexible_content extends acf_field {
?>
<div <?php echo acf_esc_attr($div); ?>>
<div class="acf-hidden">
<?php acf_hidden_input(array( 'name' => $prefix.'[acf_fc_layout]', 'value' => $layout['name'] )); ?>
</div>
<?php acf_hidden_input(array( 'name' => $prefix.'[acf_fc_layout]', 'value' => $layout['name'] )); ?>
<div class="acf-fc-layout-handle" title="<?php _e('Drag to reorder','acf'); ?>"><?php echo $title; ?></div>
@ -749,20 +748,14 @@ class acf_field_flexible_content extends acf_field {
$rows = array();
// populate $layouts
// sort layouts into names
$layouts = array();
foreach( $field['layouts'] as $k => $layout ) {
foreach( array_keys($field['layouts']) as $i ) {
// get layout
$layout = $field['layouts'][ $i ];
// append to $layouts
$layouts[ $layout['name'] ] = $layout['sub_fields'];
}
// loop through rows
foreach( $value as $i => $l ) {
@ -846,16 +839,10 @@ class acf_field_flexible_content extends acf_field {
}
// populate $layouts
// sort layouts into names
$layouts = array();
foreach( $field['layouts'] as $k => $layout ) {
foreach( array_keys($field['layouts']) as $i ) {
// get layout
$layout = $field['layouts'][ $i ];
// append to $layouts
$layouts[ $layout['name'] ] = $layout['sub_fields'];
}
@ -1367,26 +1354,13 @@ class acf_field_flexible_content extends acf_field {
function update_field( $field ) {
// vars
$layouts = acf_extract_var($field, 'layouts');
// update layouts
$field['layouts'] = array();
// loop through sub fields
if( !empty($layouts) ) {
// loop
if( !empty($field['layouts']) ) {
foreach( $layouts as $layout ) {
// remove sub fields
foreach( $field['layouts'] as &$layout ) {
unset($layout['sub_fields']);
// append to layouts
$field['layouts'][] = $layout;
}
}
@ -1518,61 +1492,22 @@ class acf_field_flexible_content extends acf_field {
'field_key' => '',
'nonce' => '',
'layout' => '',
'acf' => array()
'value' => array()
));
// load field
$field = acf_get_field( $options['field_key'] );
if( !$field ) die();
// vars
$layout = false;
foreach( $field['layouts'] as $k => $layout ) {
if( $layout['name'] === $options['layout'] ) break;
}
// bail ealry if no layout
$layout = $this->get_layout( $options['layout'], $field );
if( !$layout ) die();
// value
// this flexible content field may be a sub field so it is important to
// loop though all $_POST data to find thi's field's row value
$value = $options['acf'];
while( is_array($value) ) {
// move to end of array
// - avoids 'acf_fc_layout' value
end( $value );
// vars (step through array)
$key = key($value);
$value = current($value);
// stop looking if we have found the correct field's value
if( $key === $options['field_key'] ) {
// get row
$value = current($value);
break;
}
}
// title
$title = $this->get_layout_title( $field, $layout, $options['i'], $value );
$title = $this->get_layout_title( $field, $layout, $options['i'], $options['value'] );
// echo
@ -1675,15 +1610,15 @@ class acf_field_flexible_content extends acf_field {
function prepare_field_for_export( $field ) {
// bail early if no layouts
if( empty($field['layouts']) ) return $field;
// loop
foreach( $field['layouts'] as $i => $layout ) {
if( !empty($field['layouts']) ) {
$field['layouts'][ $i ]['sub_fields'] = acf_prepare_fields_for_export( $layout['sub_fields'] );
foreach( $field['layouts'] as &$layout ) {
$layout['sub_fields'] = acf_prepare_fields_for_export( $layout['sub_fields'] );
}
}
@ -1815,6 +1750,43 @@ class acf_field_flexible_content extends acf_field {
}
/*
* translate_field
*
* This function will translate field settings
*
* @type function
* @date 8/03/2016
* @since 5.3.2
*
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
// translate
$field['button_label'] = acf_translate( $field['button_label'] );
// loop
if( !empty($field['layouts']) ) {
foreach( $field['layouts'] as &$layout ) {
$layout['label'] = acf_translate($layout['label']);
}
}
// return
return $field;
}
}

View File

@ -106,6 +106,28 @@ http://support.advancedcustomfields.com/
== Changelog ==
= 5.5.14 =
* Core: Minor bug fixes
= 5.5.13 =
* Clone field: Improved 'Fields' setting to show all fields within a matching field group search
* Flexible Content field: Fixed bug causing 'layout_title' filter to fail when field is cloned
* Flexible Content field: Added missing 'translate_field' function
* WYSIWYG field: Fixed JS error when using CKEditor plugin
* Date Picker field: Improved 'Display Format' and 'Return Format' settings UI
* Time Picker field: Same as above
* Datetime Picker field: Same as above
* Core: Added new 'remove_wp_meta_box' setting
* Core: Added constants ACF, ACF_PRO, ACF_VERSION and ACF_PATH
* Core: Improved compatibility with Select2 v4 including sortable functionality
* Language: Updated Portuguese translation - thanks to Pedro Mendonça
= 5.5.12 =
* Tab field: Allowed HTML within field label to show in tab
* Core: Improved plugin update class
* Language: Updated Portuguese translation - thanks to Pedro Mendonça
* Language: Updated Brazilian Portuguese translation - thanks to Rafael Ribeiro
= 5.5.11 =
* Google Map field: Added new 'google_map_init' JS action
* Core: Minor fixes and improvements