5.7.6
This commit is contained in:
parent
12bc8cc2f4
commit
538171721d
19
acf.php
19
acf.php
|
|
@ -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.7.3
|
||||
Version: 5.7.6
|
||||
Author: Elliot Condon
|
||||
Author URI: http://www.elliotcondon.com/
|
||||
Copyright: Elliot Condon
|
||||
|
|
@ -18,7 +18,7 @@ if( ! class_exists('ACF') ) :
|
|||
class ACF {
|
||||
|
||||
/** @var string The plugin version number */
|
||||
var $version = '5.7.3';
|
||||
var $version = '5.7.6';
|
||||
|
||||
/** @var array The plugin settings array */
|
||||
var $settings = array();
|
||||
|
|
@ -118,7 +118,7 @@ class ACF {
|
|||
$this->define( 'ACF', true );
|
||||
$this->define( 'ACF_VERSION', $version );
|
||||
$this->define( 'ACF_PATH', $path );
|
||||
|
||||
//$this->define( 'ACF_DEV', true );
|
||||
|
||||
// api
|
||||
include_once( ACF_PATH . 'includes/api/api-helpers.php');
|
||||
|
|
@ -151,12 +151,14 @@ class ACF {
|
|||
acf_include('includes/media.php');
|
||||
acf_include('includes/revisions.php');
|
||||
acf_include('includes/updates.php');
|
||||
acf_include('includes/upgrades.php');
|
||||
acf_include('includes/validation.php');
|
||||
|
||||
// ajax
|
||||
acf_include('includes/ajax/class-acf-ajax.php');
|
||||
acf_include('includes/ajax/class-acf-ajax-check-screen.php');
|
||||
acf_include('includes/ajax/class-acf-ajax-user-setting.php');
|
||||
acf_include('includes/ajax/class-acf-ajax-upgrade.php');
|
||||
acf_include('includes/ajax/class-acf-ajax-query.php');
|
||||
acf_include('includes/ajax/class-acf-ajax-query-terms.php');
|
||||
|
||||
|
|
@ -174,21 +176,12 @@ class ACF {
|
|||
|
||||
// admin
|
||||
if( is_admin() ) {
|
||||
|
||||
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/admin-tools.php');
|
||||
acf_include('includes/admin/admin-upgrade.php');
|
||||
acf_include('includes/admin/settings-info.php');
|
||||
|
||||
|
||||
// network
|
||||
if( is_network_admin() ) {
|
||||
|
||||
acf_include('includes/admin/install-network.php');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -563,28 +563,6 @@ a.acf-icon.-cancel.grey:hover {
|
|||
}
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Sprite
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
[class^="acf-sprite-"] {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: url(../images/sprite.png);
|
||||
}
|
||||
.acf-icon [class^="acf-sprite-"] {
|
||||
margin: 1px auto 0;
|
||||
}
|
||||
.acf-sprite-logo {
|
||||
background-position: 0 0;
|
||||
width: 100px;
|
||||
height: 46px;
|
||||
}
|
||||
.acf-icon .acf-sprite-logo {
|
||||
margin-top: 52px;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* acf-box
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
|
@ -1062,23 +1040,41 @@ html[dir="rtl"] #acf-popup .acf-popup-box .title .acf-icon {
|
|||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
#acf-upgrade-notice {
|
||||
margin-left: -20px;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
border-bottom: #E5E5E5 solid 1px;
|
||||
}
|
||||
#acf-upgrade-notice .inner {
|
||||
border-left: 4px solid #00a0d2;
|
||||
padding: 20px;
|
||||
}
|
||||
#acf-upgrade-notice .logo {
|
||||
position: relative;
|
||||
float: left;
|
||||
#acf-upgrade-notice:after {
|
||||
clear: both;
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
#acf-upgrade-notice .content {
|
||||
margin-left: 170px;
|
||||
max-width: 710px;
|
||||
#acf-upgrade-notice .col-content {
|
||||
float: left;
|
||||
width: 65%;
|
||||
}
|
||||
#acf-upgrade-notice .col-actions {
|
||||
float: right;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
}
|
||||
#acf-upgrade-notice img {
|
||||
float: left;
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
margin: 0 20px 0 0;
|
||||
}
|
||||
#acf-upgrade-notice h2 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
}
|
||||
#acf-upgrade-notice p {
|
||||
font-size: 14px;
|
||||
padding: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#acf-upgrade-notice .button:before {
|
||||
margin-top: 11px;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
|
|
@ -1101,34 +1097,10 @@ html[dir="rtl"] #acf-popup .acf-popup-box .title .acf-icon {
|
|||
text-align: center;
|
||||
}
|
||||
.acf-wrap .feature-section {
|
||||
margin-top: 40px;
|
||||
padding-bottom: 20px;
|
||||
padding: 40px 0;
|
||||
}
|
||||
.acf-three-col img {
|
||||
border: #DDDDDD solid 1px;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
.acf-three-col {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.acf-three-col > div {
|
||||
float: left;
|
||||
margin: 0 0 15px 5%;
|
||||
position: relative;
|
||||
width: 30%;
|
||||
}
|
||||
.acf-three-col > div:first-child,
|
||||
.acf-three-col > br + div {
|
||||
margin-left: 0;
|
||||
clear: left;
|
||||
}
|
||||
.acf-three-col > br {
|
||||
display: none;
|
||||
}
|
||||
.acf-wrap .acf-three-col h3,
|
||||
.acf-wrap .acf-three-col h4 {
|
||||
margin-top: 0;
|
||||
.acf-wrap .feature-section h2 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.acf-wrap .changelog {
|
||||
list-style: disc;
|
||||
|
|
@ -1137,6 +1109,40 @@ html[dir="rtl"] #acf-popup .acf-popup-box .title .acf-icon {
|
|||
.acf-wrap .changelog li {
|
||||
margin: 0 0 0.75em;
|
||||
}
|
||||
.acf-wrap .acf-three-col {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.acf-wrap .acf-three-col > div {
|
||||
flex: 1;
|
||||
align-self: flex-start;
|
||||
min-width: 31%;
|
||||
max-width: 31%;
|
||||
}
|
||||
@media screen and (max-width: 880px) {
|
||||
.acf-wrap .acf-three-col > div {
|
||||
min-width: 48%;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 640px) {
|
||||
.acf-wrap .acf-three-col > div {
|
||||
min-width: 100%;
|
||||
}
|
||||
}
|
||||
.acf-wrap .acf-three-col h3 .badge {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
border-radius: 5px;
|
||||
background: #fc9700;
|
||||
color: #fff;
|
||||
font-weight: normal;
|
||||
font-size: 12px;
|
||||
padding: 2px 5px;
|
||||
}
|
||||
.acf-wrap .acf-three-col img + h3 {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* acf-hl cols
|
||||
|
|
@ -1485,11 +1491,6 @@ html[dir="rtl"] .acf-table > tbody > tr > td.order + td {
|
|||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min--moz-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) {
|
||||
[class^="acf-sprite-"],
|
||||
[class*=" acf-sprite-"] {
|
||||
background-image: url(../images/sprite@2x.png);
|
||||
background-size: 250px 250px;
|
||||
}
|
||||
.acf-loading,
|
||||
.acf-spinner {
|
||||
background-image: url(../images/spinner@2x.gif);
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
|
|||
}
|
||||
.acf-postbox.seamless > .hndle,
|
||||
.acf-postbox.seamless > .handlediv {
|
||||
display: none;
|
||||
display: none !important;
|
||||
}
|
||||
.acf-postbox.seamless > .inside {
|
||||
display: block !important;
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB |
|
|
@ -38,7 +38,7 @@
|
|||
e.preventDefault();
|
||||
|
||||
// unlock form
|
||||
acf.validation.unlockForm( $el );
|
||||
acf.unlockForm( $el );
|
||||
|
||||
// alert
|
||||
alert( acf.__('Field group title is required') );
|
||||
|
|
@ -315,7 +315,6 @@
|
|||
|
||||
// get input value
|
||||
var $input = this.$input( name );
|
||||
//console.log($input );
|
||||
var value = $input.length ? $input.val() : null;
|
||||
|
||||
// set data silently (cache)
|
||||
|
|
@ -980,7 +979,7 @@
|
|||
// check parent
|
||||
var parent = this.getParent();
|
||||
if( parent ) {
|
||||
ID = parent.prop('ID') || parent.prop('key');
|
||||
ID = parseInt(parent.prop('ID')) || parent.prop('key');
|
||||
}
|
||||
|
||||
// update
|
||||
|
|
|
|||
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
|
|
@ -639,20 +639,16 @@ class acf_admin_field_group {
|
|||
// validate
|
||||
if( !acf_verify_ajax() ) die();
|
||||
|
||||
|
||||
// valid rule
|
||||
$rule = acf_get_valid_location_rule($_POST['rule']);
|
||||
|
||||
|
||||
// validate rule
|
||||
$rule = acf_validate_location_rule($_POST['rule']);
|
||||
|
||||
// view
|
||||
acf_get_view( 'html-location-rule', array(
|
||||
'rule' => $rule
|
||||
));
|
||||
|
||||
|
||||
// die
|
||||
die();
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,225 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('ACF_Admin_Upgrade') ) :
|
||||
|
||||
class ACF_Admin_Upgrade {
|
||||
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* Sets up the class functionality.
|
||||
*
|
||||
* @date 31/7/18
|
||||
* @since 5.7.2
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action( 'admin_menu', array($this,'admin_menu'), 20 );
|
||||
add_action( 'network_admin_menu', array($this,'network_admin_menu'), 20 );
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_menu
|
||||
*
|
||||
* Setus up logic if DB Upgrade is needed on a single site.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function admin_menu() {
|
||||
|
||||
// check if upgrade is avaialble
|
||||
if( acf_has_upgrade() ) {
|
||||
|
||||
// add notice
|
||||
add_action('admin_notices', array($this, 'admin_notices'));
|
||||
|
||||
// add page
|
||||
$page = add_submenu_page('index.php', __('Upgrade Database','acf'), __('Upgrade Database','acf'), acf_get_setting('capability'), 'acf-upgrade', array($this,'admin_html') );
|
||||
|
||||
// actions
|
||||
add_action('load-' . $page, array($this,'admin_load'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* network_admin_menu
|
||||
*
|
||||
* Setus up logic if DB Upgrade is needed on a multi site.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function network_admin_menu() {
|
||||
|
||||
// vars
|
||||
$has_upgrade = false;
|
||||
|
||||
// loop over sites
|
||||
$sites = acf_get_sites();
|
||||
if( $sites ) {
|
||||
foreach( $sites as $site ) {
|
||||
|
||||
// switch blog
|
||||
switch_to_blog( $site['blog_id'] );
|
||||
|
||||
// check for upgrade
|
||||
if( acf_has_upgrade() ) {
|
||||
$has_upgrade = true;
|
||||
}
|
||||
|
||||
// restore blog
|
||||
restore_current_blog();
|
||||
}}
|
||||
|
||||
// check if upgrade is avaialble
|
||||
if( $has_upgrade ) {
|
||||
|
||||
// add notice
|
||||
add_action('network_admin_notices', array($this, 'network_admin_notices'));
|
||||
|
||||
// add page
|
||||
$page = add_submenu_page('index.php', __('Upgrade Database','acf'), __('Upgrade Database','acf'), acf_get_setting('capability'), 'acf-upgrade-network', array($this,'network_admin_html'));
|
||||
|
||||
// actions
|
||||
add_action('load-' . $page, array($this,'network_admin_load'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_load
|
||||
*
|
||||
* Runs during the loading of the admin page.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
function admin_load() {
|
||||
|
||||
// remove prompt
|
||||
remove_action('admin_notices', array($this, 'admin_notices'));
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
}
|
||||
|
||||
/**
|
||||
* network_admin_load
|
||||
*
|
||||
* Runs during the loading of the network admin page.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
function network_admin_load() {
|
||||
|
||||
// remove prompt
|
||||
remove_action('network_admin_notices', array($this, 'network_admin_notices'));
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_notices
|
||||
*
|
||||
* Displays the DB Upgrade prompt.
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.3
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function admin_notices() {
|
||||
|
||||
// vars
|
||||
$view = array(
|
||||
'button_text' => __("Upgrade Database", 'acf'),
|
||||
'button_url' => admin_url('index.php?page=acf-upgrade'),
|
||||
'confirm' => true
|
||||
);
|
||||
|
||||
// view
|
||||
acf_get_view('html-notice-upgrade', $view);
|
||||
}
|
||||
|
||||
/**
|
||||
* network_admin_notices
|
||||
*
|
||||
* Displays the DB Upgrade prompt on a multi site.
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.3
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function network_admin_notices() {
|
||||
|
||||
// vars
|
||||
$view = array(
|
||||
'button_text' => __("Review sites & upgrade", 'acf'),
|
||||
'button_url' => network_admin_url('index.php?page=acf-upgrade-network'),
|
||||
'confirm' => false
|
||||
);
|
||||
|
||||
// view
|
||||
acf_get_view('html-notice-upgrade', $view);
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_html
|
||||
*
|
||||
* Displays the HTML for the admin page.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function admin_html() {
|
||||
acf_get_view('html-admin-page-upgrade');
|
||||
}
|
||||
|
||||
/**
|
||||
* network_admin_html
|
||||
*
|
||||
* Displays the HTML for the network upgrade admin page.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function network_admin_html() {
|
||||
acf_get_view('html-admin-page-upgrade-network');
|
||||
}
|
||||
}
|
||||
|
||||
// instantiate
|
||||
acf_new_instance('ACF_Admin_Upgrade');
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
|
|
@ -1,283 +0,0 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_admin_install_network') ) :
|
||||
|
||||
class acf_admin_install_network {
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* A good place to add actions / filters
|
||||
*
|
||||
* @type function
|
||||
* @date 11/08/13
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action('network_admin_menu', array($this,'network_admin_menu'), 20);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* network_admin_menu
|
||||
*
|
||||
* This function will chck for available updates and add actions if needed
|
||||
*
|
||||
* @type function
|
||||
* @date 2/04/2015
|
||||
* @since 5.1.5
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function network_admin_menu() {
|
||||
|
||||
// vars
|
||||
$prompt = false;
|
||||
|
||||
|
||||
// loop through sites and find updates
|
||||
$sites = acf_get_sites();
|
||||
|
||||
if( $sites ) {
|
||||
|
||||
foreach( $sites as $site ) {
|
||||
|
||||
// switch blog
|
||||
switch_to_blog( $site['blog_id'] );
|
||||
|
||||
|
||||
// get site updates
|
||||
$updates = acf_get_db_updates();
|
||||
|
||||
|
||||
// restore
|
||||
restore_current_blog();
|
||||
|
||||
|
||||
if( $updates ) {
|
||||
|
||||
$prompt = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail if no prompt
|
||||
if( !$prompt ) return;
|
||||
|
||||
|
||||
// actions
|
||||
add_action('network_admin_notices', array($this, 'network_admin_notices'), 1);
|
||||
|
||||
|
||||
// add page
|
||||
$page = add_submenu_page('index.php', __('Upgrade Database','acf'), __('Upgrade Database','acf'), acf_get_setting('capability'), 'acf-upgrade-network', array($this,'network_html'));
|
||||
|
||||
|
||||
// actions
|
||||
add_action('load-' . $page, array($this,'network_load'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* load
|
||||
*
|
||||
* This function will look at the $_POST data and run any functions if needed
|
||||
*
|
||||
* @type function
|
||||
* @date 7/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function network_load() {
|
||||
|
||||
// hide notice on this page
|
||||
remove_action('network_admin_notices', array($this, 'network_admin_notices'), 1);
|
||||
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* network_admin_notices
|
||||
*
|
||||
* This function will render the update notice
|
||||
*
|
||||
* @type function
|
||||
* @date 2/04/2015
|
||||
* @since 5.1.5
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function network_admin_notices() {
|
||||
|
||||
// view
|
||||
$view = array(
|
||||
'button_text' => __("Review sites & upgrade", 'acf'),
|
||||
'button_url' => network_admin_url('index.php?page=acf-upgrade-network'),
|
||||
'confirm' => false
|
||||
);
|
||||
|
||||
|
||||
// load view
|
||||
acf_get_view('install-notice', $view);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* network_html
|
||||
*
|
||||
* This function will render the HTML for the network upgrade page
|
||||
*
|
||||
* @type function
|
||||
* @date 19/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function network_html() {
|
||||
|
||||
// vars
|
||||
$plugin_version = acf_get_setting('version');
|
||||
|
||||
|
||||
// loop through sites and find updates
|
||||
$sites = acf_get_sites();
|
||||
|
||||
if( $sites ) {
|
||||
|
||||
foreach( $sites as $i => $site ) {
|
||||
|
||||
// switch blog
|
||||
switch_to_blog( $site['blog_id'] );
|
||||
|
||||
|
||||
// extra info
|
||||
$site['name'] = get_bloginfo('name');
|
||||
$site['url'] = home_url();
|
||||
|
||||
|
||||
// get site updates
|
||||
$site['updates'] = acf_get_db_updates();
|
||||
|
||||
|
||||
// get site version
|
||||
$site['acf_version'] = get_option('acf_version');
|
||||
|
||||
|
||||
// no value equals new instal
|
||||
if( !$site['acf_version'] ) {
|
||||
|
||||
$site['acf_version'] = $plugin_version;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update
|
||||
$sites[ $i ] = $site;
|
||||
|
||||
|
||||
// restore
|
||||
restore_current_blog();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// view
|
||||
$view = array(
|
||||
'sites' => $sites,
|
||||
'plugin_version' => $plugin_version
|
||||
);
|
||||
|
||||
|
||||
// load view
|
||||
acf_get_view('install-network', $view);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize
|
||||
new acf_admin_install_network();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_sites
|
||||
*
|
||||
* This function will return an array of site data
|
||||
*
|
||||
* @type function
|
||||
* @date 29/08/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_sites() {
|
||||
|
||||
// vars
|
||||
$sites = array();
|
||||
|
||||
|
||||
// WP >= 4.6
|
||||
if( function_exists('get_sites') ) {
|
||||
|
||||
$_sites = get_sites(array(
|
||||
'number' => 0
|
||||
));
|
||||
|
||||
foreach( $_sites as $_site ) {
|
||||
|
||||
$_site = get_site( $_site );
|
||||
$sites[] = $_site->to_array();
|
||||
|
||||
}
|
||||
|
||||
// WP < 4.6
|
||||
} else {
|
||||
|
||||
$sites = wp_get_sites(array(
|
||||
'limit' => 0
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $sites;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,499 +0,0 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
/*
|
||||
* acf_update_500
|
||||
*
|
||||
* These functions will update the DB for ACF v5.0.0
|
||||
*
|
||||
* @type function
|
||||
* @date 10/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_update_500() {
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/update_500');
|
||||
|
||||
|
||||
// field groups
|
||||
acf_update_500_field_groups();
|
||||
|
||||
|
||||
// version
|
||||
acf_update_db_version('5.0.0');
|
||||
|
||||
}
|
||||
|
||||
function acf_update_500_field_groups() {
|
||||
|
||||
// vars
|
||||
$ofgs = get_posts(array(
|
||||
'numberposts' => -1,
|
||||
'post_type' => 'acf',
|
||||
'orderby' => 'menu_order title',
|
||||
'order' => 'asc',
|
||||
'suppress_filters' => true,
|
||||
));
|
||||
|
||||
|
||||
// check
|
||||
if( !$ofgs ) return;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $ofgs as $ofg ){
|
||||
|
||||
acf_update_500_field_group( $ofg );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function acf_update_500_field_group( $ofg ) {
|
||||
|
||||
// global
|
||||
global $wpdb;
|
||||
|
||||
|
||||
// create new field group
|
||||
$nfg = array(
|
||||
'ID' => 0,
|
||||
'title' => $ofg->post_title,
|
||||
'menu_order' => $ofg->menu_order,
|
||||
);
|
||||
|
||||
|
||||
// location rules
|
||||
$groups = array();
|
||||
|
||||
|
||||
// get all rules
|
||||
$rules = get_post_meta($ofg->ID, 'rule', false);
|
||||
|
||||
if( is_array($rules) ) {
|
||||
|
||||
$group_no = 0;
|
||||
|
||||
foreach( $rules as $rule ) {
|
||||
|
||||
// if field group was duplicated, it may now be a serialized string!
|
||||
$rule = maybe_unserialize($rule);
|
||||
|
||||
|
||||
// does this rule have a group?
|
||||
// + groups were added in 4.0.4
|
||||
if( !isset($rule['group_no']) ) {
|
||||
|
||||
$rule['group_no'] = $group_no;
|
||||
|
||||
// sperate groups?
|
||||
if( get_post_meta($ofg->ID, 'allorany', true) == 'any' ) {
|
||||
|
||||
$group_no++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// extract vars
|
||||
$group = acf_extract_var( $rule, 'group_no' );
|
||||
$order = acf_extract_var( $rule, 'order_no' );
|
||||
|
||||
|
||||
// add to group
|
||||
$groups[ $group ][ $order ] = $rule;
|
||||
|
||||
|
||||
// sort rules
|
||||
ksort( $groups[ $group ] );
|
||||
|
||||
}
|
||||
|
||||
// sort groups
|
||||
ksort( $groups );
|
||||
}
|
||||
|
||||
$nfg['location'] = $groups;
|
||||
|
||||
|
||||
// settings
|
||||
if( $position = get_post_meta($ofg->ID, 'position', true) ) {
|
||||
|
||||
$nfg['position'] = $position;
|
||||
|
||||
}
|
||||
|
||||
if( $layout = get_post_meta($ofg->ID, 'layout', true) ) {
|
||||
|
||||
$nfg['layout'] = $layout;
|
||||
|
||||
}
|
||||
|
||||
if( $hide_on_screen = get_post_meta($ofg->ID, 'hide_on_screen', true) ) {
|
||||
|
||||
$nfg['hide_on_screen'] = maybe_unserialize($hide_on_screen);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Note: acf_update_field_group will call the acf_get_valid_field_group function and apply 'compatibility' changes
|
||||
|
||||
|
||||
// save field group
|
||||
$nfg = acf_update_field_group( $nfg );
|
||||
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/update_500_field_group', $nfg, $ofg);
|
||||
|
||||
|
||||
// trash?
|
||||
if( $ofg->post_status == 'trash' ) {
|
||||
|
||||
acf_trash_field_group( $nfg['ID'] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
// check
|
||||
if( $rows ) {
|
||||
|
||||
// loop
|
||||
foreach( $rows as $row ) {
|
||||
|
||||
// bail early if key already migrated (potential duplicates in DB)
|
||||
if( acf_has_done('update_500_field_group_' . $ofg->ID . '_' . $row['meta_key']) ) continue;
|
||||
|
||||
|
||||
// vars
|
||||
$field = $row['meta_value'];
|
||||
$field = maybe_unserialize( $field );
|
||||
$field = maybe_unserialize( $field ); // run again for WPML
|
||||
|
||||
|
||||
// add parent
|
||||
$field['parent'] = $nfg['ID'];
|
||||
|
||||
|
||||
// migrate field
|
||||
$field = acf_update_500_field( $field );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $nfg;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function acf_update_500_field( $field ) {
|
||||
|
||||
// orig
|
||||
$orig = $field;
|
||||
|
||||
|
||||
// order_no is now menu_order
|
||||
$field['menu_order'] = acf_extract_var( $field, 'order_no' );
|
||||
|
||||
|
||||
// correct very old field keys
|
||||
if( substr($field['key'], 0, 6) !== 'field_' ) {
|
||||
|
||||
$field['key'] = 'field_' . str_replace('field', '', $field['key']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// get valid field
|
||||
$field = acf_get_valid_field( $field );
|
||||
|
||||
|
||||
// save field
|
||||
$field = acf_update_field( $field );
|
||||
|
||||
|
||||
// sub fields
|
||||
if( $field['type'] == 'repeater' ) {
|
||||
|
||||
// get sub fields
|
||||
$sub_fields = acf_extract_var( $orig, 'sub_fields' );
|
||||
|
||||
|
||||
// save sub fields
|
||||
if( !empty($sub_fields) ) {
|
||||
|
||||
$keys = array_keys($sub_fields);
|
||||
|
||||
foreach( $keys as $key ) {
|
||||
|
||||
$sub_field = acf_extract_var($sub_fields, $key);
|
||||
$sub_field['parent'] = $field['ID'];
|
||||
|
||||
acf_update_500_field( $sub_field );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} elseif( $field['type'] == 'flexible_content' ) {
|
||||
|
||||
// get layouts
|
||||
$layouts = acf_extract_var( $orig, 'layouts' );
|
||||
|
||||
|
||||
// update layouts
|
||||
$field['layouts'] = array();
|
||||
|
||||
|
||||
// save sub fields
|
||||
if( !empty($layouts) ) {
|
||||
|
||||
foreach( $layouts as $layout ) {
|
||||
|
||||
// vars
|
||||
$layout_key = uniqid();
|
||||
|
||||
|
||||
// append layotu key
|
||||
$layout['key'] = $layout_key;
|
||||
|
||||
|
||||
// extract sub fields
|
||||
$sub_fields = acf_extract_var($layout, 'sub_fields');
|
||||
|
||||
|
||||
// save sub fields
|
||||
if( !empty($sub_fields) ) {
|
||||
|
||||
$keys = array_keys($sub_fields);
|
||||
|
||||
foreach( $keys as $key ) {
|
||||
|
||||
$sub_field = acf_extract_var($sub_fields, $key);
|
||||
$sub_field['parent'] = $field['ID'];
|
||||
$sub_field['parent_layout'] = $layout_key;
|
||||
|
||||
acf_update_500_field( $sub_field );
|
||||
|
||||
}
|
||||
// foreach
|
||||
|
||||
}
|
||||
// if
|
||||
|
||||
|
||||
// append layout
|
||||
$field['layouts'][] = $layout;
|
||||
|
||||
}
|
||||
// foreach
|
||||
|
||||
}
|
||||
// if
|
||||
|
||||
|
||||
// save field again with less sub field data
|
||||
$field = acf_update_field( $field );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/update_500_field', $field);
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_update_550
|
||||
*
|
||||
* These functions will update the DB for ACF v5.5.0
|
||||
*
|
||||
* @type function
|
||||
* @date 10/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_update_550() { //acf_log('acf_update_550');
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/update_550');
|
||||
|
||||
|
||||
// termmeta
|
||||
acf_update_550_termmeta();
|
||||
|
||||
|
||||
// version
|
||||
acf_update_db_version('5.5.0');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_update_550_termmeta
|
||||
*
|
||||
* This function will migrate all term meta
|
||||
*
|
||||
* @type function
|
||||
* @date 3/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
|
||||
function acf_update_550_termmeta() { //acf_log('acf_update_550_termmeta');
|
||||
|
||||
// bail early if no table
|
||||
if( !acf_isset_termmeta() ) {
|
||||
|
||||
update_option('acf_update_550_termmeta', 1); // no longer used
|
||||
//echo __('Term meta upgrade not possible (termmeta table does not exist)', 'acf');
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$taxonomies = get_taxonomies(false, 'objects');
|
||||
|
||||
|
||||
// bail early if no taxonomies
|
||||
if( !$taxonomies ) return;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $taxonomies as $taxonomy ) {
|
||||
|
||||
acf_update_550_taxonomy( $taxonomy->name );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// delete trigger
|
||||
delete_option('acf_update_550_termmeta');
|
||||
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/update_550_termmeta');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_update_550_taxonomy
|
||||
*
|
||||
* This function will migrate term meta for a specific taxonomy
|
||||
*
|
||||
* @type function
|
||||
* @date 3/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $taxonomy (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_update_550_taxonomy( $taxonomy ) { //acf_log('acf_update_550_taxonomy', $taxonomy);
|
||||
|
||||
// global
|
||||
global $wpdb;
|
||||
|
||||
|
||||
// vars
|
||||
$search = $taxonomy . '_%';
|
||||
$_search = '_' . $search;
|
||||
|
||||
|
||||
// escape '_'
|
||||
// http://stackoverflow.com/questions/2300285/how-do-i-escape-in-sql-server
|
||||
$search = str_replace('_', '\_', $search);
|
||||
$_search = str_replace('_', '\_', $_search);
|
||||
|
||||
|
||||
// search
|
||||
// results show faster query times using 2 LIKE vs 2 wildcards
|
||||
$rows = $wpdb->get_results($wpdb->prepare(
|
||||
"SELECT *
|
||||
FROM $wpdb->options
|
||||
WHERE option_name LIKE %s
|
||||
OR option_name LIKE %s",
|
||||
$search,
|
||||
$_search
|
||||
), ARRAY_A);
|
||||
|
||||
|
||||
// bail early if no rows
|
||||
if( empty($rows) ) return;
|
||||
|
||||
|
||||
// vars
|
||||
$search = $taxonomy . '_';
|
||||
$_search = '_' . $search;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $rows as $row ) {
|
||||
|
||||
// use regex to find (_)taxonomy_(term_id)_(field_name)
|
||||
$matches = null;
|
||||
$regexp = '/^(_?)' . $taxonomy . '_(\d+)_(.+)/';
|
||||
|
||||
|
||||
// bail early if no match
|
||||
if( !preg_match($regexp, $row['option_name'], $matches) ) continue;
|
||||
|
||||
|
||||
/*
|
||||
Array
|
||||
(
|
||||
[0] => category_3_color
|
||||
[1] =>
|
||||
[2] => 3
|
||||
[3] => color
|
||||
)
|
||||
*/
|
||||
|
||||
|
||||
// vars
|
||||
$term_id = $matches[2];
|
||||
$name = $matches[1] . $matches[3];
|
||||
$value = $row['option_value'];
|
||||
|
||||
|
||||
// update
|
||||
update_metadata( 'term', $term_id, $name, $value );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/update_550_taxonomy', $taxonomy);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,431 +0,0 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_admin_install') ) :
|
||||
|
||||
class acf_admin_install {
|
||||
|
||||
// vars
|
||||
var $db_updates = array(
|
||||
'5.0.0' => 'acf_update_500',
|
||||
'5.5.0' => 'acf_update_550'
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* __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_menu', array($this,'admin_menu'), 20);
|
||||
add_action('wp_upgrade', array($this,'wp_upgrade'), 10, 2);
|
||||
|
||||
|
||||
// ajax
|
||||
add_action('wp_ajax_acf/admin/db_update', array($this, 'ajax_db_update'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_menu
|
||||
*
|
||||
* This function will chck for available updates and add actions if needed
|
||||
*
|
||||
* @type function
|
||||
* @date 19/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
// vars
|
||||
$updates = acf_get_db_updates();
|
||||
|
||||
|
||||
// bail early if no updates available
|
||||
if( !$updates ) return;
|
||||
|
||||
|
||||
// actions
|
||||
add_action('admin_notices', array($this, 'admin_notices'), 1);
|
||||
|
||||
|
||||
// add page
|
||||
$page = add_submenu_page('index.php', __('Upgrade Database','acf'), __('Upgrade Database','acf'), acf_get_setting('capability'), 'acf-upgrade', array($this,'html') );
|
||||
|
||||
|
||||
// actions
|
||||
add_action('load-' . $page, array($this,'load'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* load
|
||||
*
|
||||
* This function will look at the $_POST data and run any functions if needed
|
||||
*
|
||||
* @type function
|
||||
* @date 7/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function load() {
|
||||
|
||||
// hide upgrade
|
||||
remove_action('admin_notices', array($this, 'admin_notices'), 1);
|
||||
|
||||
|
||||
// load acf scripts
|
||||
acf_enqueue_scripts();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_notices
|
||||
*
|
||||
* This function will render the DB Upgrade notice
|
||||
*
|
||||
* @type function
|
||||
* @date 17/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_notices() {
|
||||
|
||||
// view
|
||||
$view = array(
|
||||
'button_text' => __("Upgrade Database", 'acf'),
|
||||
'button_url' => admin_url('index.php?page=acf-upgrade'),
|
||||
'confirm' => true
|
||||
);
|
||||
|
||||
|
||||
// load view
|
||||
acf_get_view('install-notice', $view);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* html
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 19/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
// view
|
||||
$view = array(
|
||||
'updates' => acf_get_db_updates(),
|
||||
'plugin_version' => acf_get_setting('version')
|
||||
);
|
||||
|
||||
|
||||
// load view
|
||||
acf_get_view('install', $view);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ajax_db_update
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 24/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function ajax_db_update() {
|
||||
|
||||
// options
|
||||
$options = wp_parse_args( $_POST, array(
|
||||
'nonce' => '',
|
||||
'blog_id' => '',
|
||||
));
|
||||
|
||||
|
||||
// validate
|
||||
if( !wp_verify_nonce($options['nonce'], 'acf_db_update') ) {
|
||||
|
||||
wp_send_json_error(array(
|
||||
'message' => __('Error validating request', 'acf')
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// switch blog
|
||||
if( $options['blog_id'] ) {
|
||||
|
||||
switch_to_blog( $options['blog_id'] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$updates = acf_get_db_updates();
|
||||
$message = '';
|
||||
|
||||
|
||||
// bail early if no updates
|
||||
if( empty($updates) ) {
|
||||
|
||||
wp_send_json_error(array(
|
||||
'message' => __('No updates available.', 'acf')
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// install updates
|
||||
foreach( $updates as $version => $callback ) {
|
||||
|
||||
$message .= $this->run_update( $callback );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// updates complete
|
||||
acf_update_db_version();
|
||||
|
||||
|
||||
// return
|
||||
wp_send_json_success(array(
|
||||
'message' => $message
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* run_db_update
|
||||
*
|
||||
* This function will perform a db upgrade
|
||||
*
|
||||
* @type function
|
||||
* @date 10/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function run_update( $callback = '' ) {
|
||||
|
||||
// include update functions
|
||||
acf_include('includes/admin/install-updates.php');
|
||||
|
||||
|
||||
// bail early if not found
|
||||
if( !function_exists($callback) ) return false;
|
||||
|
||||
|
||||
// load any errors / feedback from update
|
||||
ob_start();
|
||||
|
||||
|
||||
// include
|
||||
call_user_func($callback);
|
||||
|
||||
|
||||
// get feedback
|
||||
$message = ob_get_clean();
|
||||
|
||||
|
||||
// return
|
||||
return $message;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* wp_upgrade
|
||||
*
|
||||
* This function will run when the WP database is updated
|
||||
*
|
||||
* @type function
|
||||
* @date 10/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $wp_db_version (string) The new $wp_db_version
|
||||
* @return $wp_current_db_version (string) The old (current) $wp_db_version
|
||||
*/
|
||||
|
||||
function wp_upgrade( $wp_db_version, $wp_current_db_version ) {
|
||||
|
||||
// vars
|
||||
$acf_db_version = acf_get_db_version();
|
||||
|
||||
|
||||
// termmeta was added in WP 4.4 (34370)
|
||||
// if website has already updated to ACF 5.5.0, termmeta will not have yet been migrated
|
||||
if( $wp_db_version >= 34370 && $wp_current_db_version < 34370 && acf_version_compare($acf_db_version, '>=', '5.5.0') ) {
|
||||
|
||||
$this->run_update('acf_update_550_termmeta');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
acf()->admin->install = new acf_admin_install();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_db_version
|
||||
*
|
||||
* This function will return the current ACF DB version
|
||||
*
|
||||
* @type function
|
||||
* @date 10/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_get_db_version() {
|
||||
|
||||
return get_option('acf_version');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_update_db_version
|
||||
*
|
||||
* This function will update the current ACF DB version
|
||||
*
|
||||
* @type function
|
||||
* @date 10/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_update_db_version( $version = '' ) {
|
||||
|
||||
// default to latest
|
||||
if( !$version ) {
|
||||
|
||||
$version = acf_get_setting('version');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update
|
||||
update_option('acf_version', $version );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_db_updates
|
||||
*
|
||||
* This function will return available db updates
|
||||
*
|
||||
* @type function
|
||||
* @date 12/05/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_get_db_updates() {
|
||||
|
||||
// vars
|
||||
$available = array();
|
||||
$db_updates = acf()->admin->install->db_updates;
|
||||
$acf_version = acf_get_setting('version');
|
||||
$db_version = acf_get_db_version();
|
||||
|
||||
|
||||
// bail early if is fresh install
|
||||
if( !$db_version ) {
|
||||
|
||||
acf_update_db_version($acf_version);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail early if is up to date
|
||||
if( acf_version_compare($db_version, '>=', $acf_version)) return false;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $db_updates as $version => $callback ) {
|
||||
|
||||
// ignore if update is for a future version (may exist for testing)
|
||||
if( acf_version_compare( $version, '>', $acf_version ) ) continue;
|
||||
|
||||
|
||||
// ignore if update has already been run
|
||||
if( acf_version_compare( $version, '<=', $db_version ) ) continue;
|
||||
|
||||
|
||||
// append
|
||||
$available[ $version ] = $callback;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail early if no updates available
|
||||
// - also update DB to current version
|
||||
if( empty($available) ) {
|
||||
|
||||
acf_update_db_version($acf_version);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $available;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Network Admin Database Upgrade
|
||||
*
|
||||
* Shows the databse upgrade process.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
* @param void
|
||||
*/
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
|
||||
/* hide steps */
|
||||
.show-on-complete {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
<h1><?php _e("Upgrade Database", 'acf'); ?></h1>
|
||||
|
||||
<p><?php echo sprintf( __("The following sites require a DB upgrade. Check the ones you want to update and then click %s.", 'acf'), '"' . __('Upgrade Sites', 'acf') . '"'); ?></p>
|
||||
<p><input type="submit" name="upgrade" value="<?php _e('Upgrade Sites', 'acf'); ?>" class="button" id="upgrade-sites"></p>
|
||||
|
||||
<table class="wp-list-table widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="manage-column check-column" scope="col">
|
||||
<input type="checkbox" id="sites-select-all">
|
||||
</td>
|
||||
<th class="manage-column" scope="col" style="width:33%;">
|
||||
<label for="sites-select-all"><?php _e("Site", 'acf'); ?></label>
|
||||
</th>
|
||||
<th><?php _e("Description", 'acf'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td class="manage-column check-column" scope="col">
|
||||
<input type="checkbox" id="sites-select-all-2">
|
||||
</td>
|
||||
<th class="manage-column" scope="col">
|
||||
<label for="sites-select-all-2"><?php _e("Site", 'acf'); ?></label>
|
||||
</th>
|
||||
<th><?php _e("Description", 'acf'); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody id="the-list">
|
||||
<?php
|
||||
|
||||
$sites = acf_get_sites();
|
||||
if( $sites ):
|
||||
foreach( $sites as $i => $site ):
|
||||
|
||||
// switch blog
|
||||
switch_to_blog( $site['blog_id'] );
|
||||
|
||||
?>
|
||||
<tr<?php if( $i % 2 == 0 ): ?> class="alternate"<?php endif; ?>>
|
||||
<th class="check-column" scope="row">
|
||||
<?php if( acf_has_upgrade() ): ?>
|
||||
<input type="checkbox" value="<?php echo $site['blog_id']; ?>" name="checked[]">
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td>
|
||||
<strong><?php echo get_bloginfo('name'); ?></strong><br /><?php echo home_url(); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if( acf_has_upgrade() ): ?>
|
||||
<span class="response"><?php printf(__('Site requires database upgrade from %s to %s', 'acf'), acf_get_db_version(), ACF_VERSION); ?></span>
|
||||
<?php else: ?>
|
||||
<?php _e("Site is up to date", 'acf'); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
// restore
|
||||
restore_current_blog();
|
||||
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><input type="submit" name="upgrade" value="<?php _e('Upgrade Sites', 'acf'); ?>" class="button" id="upgrade-sites-2"></p>
|
||||
<p class="show-on-complete"><?php echo sprintf( __('Database Upgrade complete. <a href="%s">Return to network dashboard</a>', 'acf'), network_admin_url() ); ?></p>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
var upgrader = new acf.Model({
|
||||
events: {
|
||||
'click #upgrade-sites': 'onClick',
|
||||
'click #upgrade-sites-2': 'onClick'
|
||||
},
|
||||
$inputs: function(){
|
||||
return $('#the-list input:checked');
|
||||
},
|
||||
onClick: function( e, $el ){
|
||||
|
||||
// prevent default
|
||||
e.preventDefault();
|
||||
|
||||
// bail early if no selection
|
||||
if( !this.$inputs().length ) {
|
||||
return alert('<?php _e('Please select at least one site to upgrade.', 'acf'); ?>');
|
||||
}
|
||||
|
||||
// confirm action
|
||||
if( !confirm("<?php _e('It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf'); ?>") ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// upgrade
|
||||
this.upgrade();
|
||||
},
|
||||
upgrade: function(){
|
||||
|
||||
// vars
|
||||
var $inputs = this.$inputs();
|
||||
|
||||
// bail early if no sites selected
|
||||
if( !$inputs.length ) {
|
||||
return this.complete();
|
||||
}
|
||||
|
||||
// disable buttons
|
||||
$('.button').prop('disabled', true);
|
||||
|
||||
// vars
|
||||
var $input = $inputs.first();
|
||||
var $row = $input.closest('tr');
|
||||
var text = '';
|
||||
var success = false;
|
||||
|
||||
// show loading
|
||||
$row.find('.response').html('<i class="acf-loading"></i></span> <?php printf(__('Upgrading data to version %s', 'acf'), ACF_VERSION); ?>');
|
||||
|
||||
// send ajax request to upgrade DB
|
||||
$.ajax({
|
||||
url: acf.get('ajaxurl'),
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
data: acf.prepareForAjax({
|
||||
action: 'acf/ajax/upgrade',
|
||||
blog_id: $input.val()
|
||||
}),
|
||||
success: function( json ){
|
||||
|
||||
// success
|
||||
if( acf.isAjaxSuccess(json) ) {
|
||||
|
||||
// update
|
||||
success = true;
|
||||
|
||||
// remove input
|
||||
$input.remove();
|
||||
|
||||
// set response text
|
||||
text = '<?php _e('Upgrade complete.', 'acf'); ?>';
|
||||
if( jsonText = acf.getAjaxMessage(json) ) {
|
||||
text = jsonText;
|
||||
}
|
||||
|
||||
// error
|
||||
} else {
|
||||
|
||||
// set response text
|
||||
text = '<?php _e('Upgrade failed.', 'acf'); ?>';
|
||||
if( jsonText = acf.getAjaxError(json) ) {
|
||||
text += ' <pre>' + jsonText + '</pre>';
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function( jqXHR, textStatus, errorThrown ){
|
||||
|
||||
// set response text
|
||||
text = '<?php _e('Upgrade failed.', 'acf'); ?>';
|
||||
if( errorThrown) {
|
||||
text += ' <pre>' + errorThrown + '</pre>';
|
||||
}
|
||||
},
|
||||
complete: this.proxy(function(){
|
||||
|
||||
// display text
|
||||
$row.find('.response').html( text );
|
||||
|
||||
// if successful upgrade, proceed to next site. Otherwise, skip to complete.
|
||||
if( success ) {
|
||||
this.upgrade();
|
||||
} else {
|
||||
this.complete();
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
complete: function(){
|
||||
|
||||
// enable buttons
|
||||
$('.button').prop('disabled', false);
|
||||
|
||||
// show message
|
||||
$('.show-on-complete').show();
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Admin Database Upgrade
|
||||
*
|
||||
* Shows the databse upgrade process.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
* @param void
|
||||
*/
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
|
||||
/* hide steps */
|
||||
.step-1,
|
||||
.step-2,
|
||||
.step-3 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
<h1><?php _e("Upgrade Database", 'acf'); ?></h1>
|
||||
|
||||
<?php if( acf_has_upgrade() ): ?>
|
||||
|
||||
<p><?php _e('Reading upgrade tasks...', 'acf'); ?></p>
|
||||
<p class="step-1"><i class="acf-loading"></i> <?php printf(__('Upgrading data to version %s', 'acf'), ACF_VERSION); ?></p>
|
||||
<p class="step-2"></p>
|
||||
<p class="step-3"><?php echo sprintf( __('Database upgrade complete. <a href="%s">See what\'s new</a>', 'acf' ), admin_url('edit.php?post_type=acf-field-group&page=acf-settings-info') ); ?></p>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
var upgrader = new acf.Model({
|
||||
initialize: function(){
|
||||
|
||||
// allow user to read message for 1 second
|
||||
this.setTimeout( this.upgrade, 1000 );
|
||||
},
|
||||
upgrade: function(){
|
||||
|
||||
// show step 1
|
||||
$('.step-1').show();
|
||||
|
||||
// vars
|
||||
var response = '';
|
||||
var success = false;
|
||||
|
||||
// send ajax request to upgrade DB
|
||||
$.ajax({
|
||||
url: acf.get('ajaxurl'),
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
data: acf.prepareForAjax({
|
||||
action: 'acf/ajax/upgrade'
|
||||
}),
|
||||
success: function( json ){
|
||||
|
||||
// success
|
||||
if( acf.isAjaxSuccess(json) ) {
|
||||
|
||||
// update
|
||||
success = true;
|
||||
|
||||
// set response text
|
||||
if( jsonText = acf.getAjaxMessage(json) ) {
|
||||
response = jsonText;
|
||||
}
|
||||
|
||||
// error
|
||||
} else {
|
||||
|
||||
// set response text
|
||||
response = '<?php _e('Upgrade failed.', 'acf'); ?>';
|
||||
if( jsonText = acf.getAjaxError(json) ) {
|
||||
response += ' <pre>' + jsonText + '</pre>';
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function( jqXHR, textStatus, errorThrown ){
|
||||
|
||||
// set response text
|
||||
response = '<?php _e('Upgrade failed.', 'acf'); ?>';
|
||||
if( errorThrown) {
|
||||
response += ' <pre>' + errorThrown + '</pre>';
|
||||
}
|
||||
},
|
||||
complete: this.proxy(function(){
|
||||
|
||||
// remove spinner
|
||||
$('.acf-loading').hide();
|
||||
|
||||
// display response
|
||||
if( response ) {
|
||||
$('.step-2').show().html( response );
|
||||
}
|
||||
|
||||
// display success
|
||||
if( success ) {
|
||||
$('.step-3').show();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<p><?php _e('No updates available.', 'acf'); ?></p>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
@ -6,15 +6,13 @@
|
|||
<tbody>
|
||||
<?php foreach( $group as $i => $rule ):
|
||||
|
||||
// append id
|
||||
// validate rule
|
||||
$rule = acf_validate_location_rule($rule);
|
||||
|
||||
// append id and group
|
||||
$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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
<?php
|
||||
|
||||
// vars
|
||||
$prefix = 'acf_field_group[location]['.$rule['group'].']['.$rule['id'].']';
|
||||
|
||||
?>
|
||||
<tr data-id="<?php echo $rule['id']; ?>">
|
||||
<td class="param">
|
||||
<?php
|
||||
|
|
@ -12,7 +18,7 @@
|
|||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'name' => 'param',
|
||||
'prefix' => $rule['prefix'],
|
||||
'prefix' => $prefix,
|
||||
'value' => $rule['param'],
|
||||
'choices' => $choices,
|
||||
'class' => 'refresh-location-rule'
|
||||
|
|
@ -35,7 +41,7 @@
|
|||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'name' => 'operator',
|
||||
'prefix' => $rule['prefix'],
|
||||
'prefix' => $prefix,
|
||||
'value' => $rule['operator'],
|
||||
'choices' => $choices
|
||||
));
|
||||
|
|
@ -62,7 +68,7 @@
|
|||
acf_render_field(array(
|
||||
'type' => 'select',
|
||||
'name' => 'value',
|
||||
'prefix' => $rule['prefix'],
|
||||
'prefix' => $prefix,
|
||||
'value' => $rule['value'],
|
||||
'choices' => $choices
|
||||
));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
// calculate add-ons (non pro only)
|
||||
$plugins = array();
|
||||
|
||||
if( !acf_get_setting('pro') ) {
|
||||
|
||||
if( is_plugin_active('acf-repeater/acf-repeater.php') ) $plugins[] = __("Repeater",'acf');
|
||||
if( is_plugin_active('acf-flexible-content/acf-flexible-content.php') ) $plugins[] = __("Flexible Content",'acf');
|
||||
if( is_plugin_active('acf-gallery/acf-gallery.php') ) $plugins[] = __("Gallery",'acf');
|
||||
if( is_plugin_active('acf-options-page/acf-options-page.php') ) $plugins[] = __("Options Page",'acf');
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="acf-upgrade-notice" class="notice">
|
||||
|
||||
<div class="col-content">
|
||||
|
||||
<img src="<?php echo acf_get_url('assets/images/acf-logo.png'); ?>" />
|
||||
<h2><?php _e("Database Upgrade Required",'acf'); ?></h2>
|
||||
<p><?php printf(__("Thank you for updating to %s v%s!", 'acf'), acf_get_setting('name'), acf_get_setting('version') ); ?><br /><?php _e("This version contains improvements to your database and requires an upgrade.", 'acf'); ?></p>
|
||||
<?php if( !empty($plugins) ): ?>
|
||||
<p><?php printf(__("Please also ensure any premium add-ons (%s) have first been updated to the latest version.", 'acf'), implode(', ', $plugins) ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="col-actions">
|
||||
<a id="acf-upgrade-button" href="<?php echo $button_url; ?>" class="button button-primary button-hero"><?php echo $button_text; ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php if( $confirm ): ?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
$("#acf-upgrade-button").on("click", function(){
|
||||
return confirm("<?php _e( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf' ); ?>");
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
|
@ -1,233 +0,0 @@
|
|||
<?php
|
||||
|
||||
// vars
|
||||
$button = __('Upgrade Sites');
|
||||
|
||||
?>
|
||||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
<h1><?php _e("Advanced Custom Fields Database Upgrade",'acf'); ?></h1>
|
||||
|
||||
<p><?php echo sprintf( __("The following sites require a DB upgrade. Check the ones you want to update and then click %s.", 'acf'), '"' . $button . '"'); ?></p>
|
||||
|
||||
<p><input type="submit" name="upgrade" value="<?php echo $button; ?>" class="button" id="upgrade-sites"></p>
|
||||
|
||||
<table class="wp-list-table widefat">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="manage-column check-column" scope="col"><input type="checkbox" id="sites-select-all"></td>
|
||||
<th class="manage-column" scope="col" style="width:33%;"><label for="sites-select-all"><?php _e("Site", 'acf'); ?></label></th>
|
||||
<th><?php _e("Description", 'acf'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td class="manage-column check-column" scope="col"><input type="checkbox" id="sites-select-all-2"></td>
|
||||
<th class="manage-column" scope="col"><label for="sites-select-all-2"><?php _e("Site", 'acf'); ?></label></th>
|
||||
<th><?php _e("Description", 'acf'); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="the-list">
|
||||
|
||||
<?php foreach( $sites as $i => $site ): ?>
|
||||
|
||||
<tr<?php if( $i % 2 == 0 ): ?> class="alternate"<?php endif; ?>>
|
||||
<th class="check-column" scope="row">
|
||||
<?php if( $site['updates'] ): ?>
|
||||
<input type="checkbox" value="<?php echo $site['blog_id']; ?>" name="checked[]">
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td>
|
||||
<strong><?php echo $site['name']; ?></strong><br /><?php echo $site['url']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if( $site['updates'] ): ?>
|
||||
<span class="response"><?php printf(__('Site requires database upgrade from %s to %s', 'acf'), $site['acf_version'], $plugin_version); ?></span>
|
||||
<?php else: ?>
|
||||
<?php _e("Site is up to date", 'acf'); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
<p><input type="submit" name="upgrade" value="<?php echo $button; ?>" class="button" id="upgrade-sites-2"></p>
|
||||
|
||||
<p class="show-on-complete"><?php echo sprintf( __('Database Upgrade complete. <a href="%s">Return to network dashboard</a>', 'acf'), network_admin_url() ); ?></p>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* hide show */
|
||||
.show-on-complete {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
var upgrader = {
|
||||
|
||||
$buttons: null,
|
||||
|
||||
$inputs: null,
|
||||
i: 0,
|
||||
|
||||
init : function(){
|
||||
|
||||
// reference
|
||||
var self = this;
|
||||
|
||||
|
||||
// vars
|
||||
this.$buttons = $('#upgrade-sites, #upgrade-sites-2');
|
||||
|
||||
|
||||
// events
|
||||
this.$buttons.on('click', function( e ){
|
||||
|
||||
// prevent default
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
// confirm
|
||||
var answer = confirm("<?php _e('It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf'); ?>");
|
||||
|
||||
|
||||
// bail early if no confirm
|
||||
if( !answer ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// populate inputs
|
||||
self.$inputs = $('#the-list input:checked');
|
||||
|
||||
|
||||
// upgrade
|
||||
self.upgrade();
|
||||
|
||||
});
|
||||
|
||||
|
||||
// return
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
upgrade: function(){
|
||||
|
||||
// reference
|
||||
var self = this;
|
||||
|
||||
|
||||
// bail early if no sites
|
||||
if( !this.$inputs.length ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// complete
|
||||
if( this.i >= this.$inputs.length ) {
|
||||
|
||||
this.complete();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// disable buttons
|
||||
this.$buttons.attr('disabled', 'disabled');
|
||||
|
||||
|
||||
// vars
|
||||
var $input = this.$inputs.eq( this.i ),
|
||||
$tr = $input.closest('tr'),
|
||||
text = '<?php _e('Upgrade complete', 'acf'); ?>';
|
||||
|
||||
|
||||
// add loading
|
||||
$tr.find('.response').html('<i class="acf-loading"></i></span> <?php printf(__('Upgrading data to version %s', 'acf'), $plugin_version); ?>');
|
||||
|
||||
|
||||
// get results
|
||||
var xhr = $.ajax({
|
||||
url: '<?php echo admin_url('admin-ajax.php'); ?>',
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
data: {
|
||||
action: 'acf/admin/db_update',
|
||||
nonce: '<?php echo wp_create_nonce('acf_db_update'); ?>',
|
||||
blog_id: $input.val(),
|
||||
},
|
||||
success: function( json ){
|
||||
|
||||
// remove input
|
||||
$input.prop('checked', false);
|
||||
$input.remove();
|
||||
|
||||
// vars
|
||||
var response = '';
|
||||
|
||||
// success
|
||||
if( acf.isAjaxSuccess(json) ) {
|
||||
response = acf.getAjaxMessage(json);
|
||||
} else {
|
||||
response = acf.getAjaxError(json);
|
||||
}
|
||||
|
||||
// update text
|
||||
if( response ) {
|
||||
text = '<pre>' + response + '</pre>';
|
||||
}
|
||||
},
|
||||
complete: function(){
|
||||
|
||||
$tr.find('.response').html( text );
|
||||
|
||||
|
||||
// upgrade next site
|
||||
self.next();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
next: function(){
|
||||
|
||||
this.i++;
|
||||
|
||||
this.upgrade();
|
||||
|
||||
},
|
||||
|
||||
complete: function(){
|
||||
|
||||
// enable buttons
|
||||
this.$buttons.removeAttr('disabled');
|
||||
|
||||
|
||||
// show message
|
||||
$('.show-on-complete').show();
|
||||
|
||||
}
|
||||
|
||||
}.init();
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
// calculate add-ons (non pro only)
|
||||
$plugins = array();
|
||||
|
||||
if( !acf_get_setting('pro') ) {
|
||||
|
||||
if( is_plugin_active('acf-repeater/acf-repeater.php') ) $plugins[] = __("Repeater",'acf');
|
||||
if( is_plugin_active('acf-flexible-content/acf-flexible-content.php') ) $plugins[] = __("Flexible Content",'acf');
|
||||
if( is_plugin_active('acf-gallery/acf-gallery.php') ) $plugins[] = __("Gallery",'acf');
|
||||
if( is_plugin_active('acf-options-page/acf-options-page.php') ) $plugins[] = __("Options Page",'acf');
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="acf-upgrade-notice">
|
||||
|
||||
<div class="inner">
|
||||
|
||||
<div class="acf-icon logo">
|
||||
<i class="acf-sprite-logo"></i>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
|
||||
<h2><?php _e("Database Upgrade Required",'acf'); ?></h2>
|
||||
|
||||
<p><?php printf(__("Thank you for updating to %s v%s!", 'acf'), acf_get_setting('name'), acf_get_setting('version') ); ?><br /><?php _e("Before you start using the new awesome features, please update your database to the newest version.", 'acf'); ?></p>
|
||||
|
||||
<?php if( !empty($plugins) ): ?>
|
||||
<p><?php printf(__("Please also ensure any premium add-ons (%s) have first been updated to the latest version.", 'acf'), implode(', ', $plugins) ); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p><a id="acf-notice-action" href="<?php echo $button_url; ?>" class="button button-primary"><?php echo $button_text; ?></a></p>
|
||||
|
||||
<?php if( $confirm ): ?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
$("#acf-notice-action").on("click", function(){
|
||||
|
||||
var answer = confirm("<?php _e( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf' ); ?>");
|
||||
return answer;
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
<div id="acf-upgrade-wrap" class="wrap">
|
||||
|
||||
<h1><?php _e("Advanced Custom Fields Database Upgrade",'acf'); ?></h1>
|
||||
|
||||
<?php if( $updates ): ?>
|
||||
|
||||
<p><?php _e('Reading upgrade tasks...', 'acf'); ?></p>
|
||||
|
||||
<p class="show-on-ajax"><i class="acf-loading"></i> <?php printf(__('Upgrading data to version %s', 'acf'), $plugin_version); ?></p>
|
||||
|
||||
<p class="show-on-complete"><?php echo sprintf( __('Database Upgrade complete. <a href="%s">See what\'s new</a>', 'acf' ), admin_url('edit.php?post_type=acf-field-group&page=acf-settings-info') ); ?></p>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* hide show */
|
||||
.show-on-ajax,
|
||||
.show-on-complete {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
var upgrader = {
|
||||
|
||||
init: function(){
|
||||
|
||||
// reference
|
||||
var self = this;
|
||||
|
||||
|
||||
// allow user to read message for 1 second
|
||||
setTimeout(function(){
|
||||
|
||||
self.upgrade();
|
||||
|
||||
}, 1000);
|
||||
|
||||
|
||||
// return
|
||||
return this;
|
||||
},
|
||||
|
||||
upgrade: function(){
|
||||
|
||||
// reference
|
||||
var self = this;
|
||||
|
||||
|
||||
// show message
|
||||
$('.show-on-ajax').show();
|
||||
|
||||
|
||||
// get results
|
||||
var xhr = $.ajax({
|
||||
url: '<?php echo admin_url('admin-ajax.php'); ?>',
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
data: {
|
||||
action: 'acf/admin/db_update',
|
||||
nonce: '<?php echo wp_create_nonce('acf_db_update'); ?>'
|
||||
},
|
||||
success: function( json ){
|
||||
|
||||
// vars
|
||||
var response = '';
|
||||
|
||||
// success
|
||||
if( acf.isAjaxSuccess(json) ) {
|
||||
response = acf.getAjaxMessage(json);
|
||||
} else {
|
||||
response = acf.getAjaxError(json);
|
||||
}
|
||||
|
||||
// bail early if no message text
|
||||
if( response ) {
|
||||
$('.show-on-ajax').html( response );
|
||||
}
|
||||
},
|
||||
complete: function( json ){
|
||||
|
||||
// remove spinner
|
||||
$('.acf-loading').hide();
|
||||
|
||||
|
||||
// show complete
|
||||
$('.show-on-complete').show();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}.init();
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<p><?php _e('No updates available.', 'acf'); ?></p>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
<h1><?php _e("Welcome to Advanced Custom Fields",'acf'); ?> <?php echo $version; ?></h1>
|
||||
<div class="about-text"><?php printf(__("Thank you for updating! ACF %s is bigger and better than ever before. We hope you like it.", 'acf'), $version); ?></div>
|
||||
<div class="acf-icon logo">
|
||||
<i class="acf-sprite-logo"></i>
|
||||
</div>
|
||||
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<?php foreach( $tabs as $tab_slug => $tab_title ): ?>
|
||||
|
|
@ -14,142 +11,134 @@
|
|||
|
||||
<?php if( $active == 'new' ): ?>
|
||||
|
||||
<h2 class="about-headline-callout"><?php _e("A smoother custom field experience", 'acf'); ?></h2>
|
||||
|
||||
<div class="feature-section acf-three-col">
|
||||
<div>
|
||||
<img src="https://assets.advancedcustomfields.com/info/5.0.0/select2.png">
|
||||
<h3><?php _e("Improved Usability", 'acf'); ?></h3>
|
||||
<p><?php _e("Including the popular Select2 library has improved both usability and speed across a number of field types including post object, page link, taxonomy and select.", 'acf'); ?></p>
|
||||
</div>
|
||||
<div>
|
||||
<img src="https://assets.advancedcustomfields.com/info/5.0.0/design.png">
|
||||
<h3><?php _e("Improved Design", 'acf'); ?></h3>
|
||||
<p><?php _e("Many fields have undergone a visual refresh to make ACF look better than ever! Noticeable changes are seen on the gallery, relationship and oEmbed (new) fields!", 'acf'); ?></p>
|
||||
</div>
|
||||
<div>
|
||||
<img src="https://assets.advancedcustomfields.com/info/5.0.0/sub-fields.png">
|
||||
<h3><?php _e("Improved Data", 'acf'); ?></h3>
|
||||
<p><?php _e("Redesigning the data architecture has allowed sub fields to live independently from their parents. This allows you to drag and drop fields in and out of parent fields!", 'acf'); ?></p>
|
||||
<div class="feature-section">
|
||||
<h2><?php _e("A Smoother Experience", 'acf'); ?> </h2>
|
||||
<div class="acf-three-col">
|
||||
<div>
|
||||
<p><img src="https://assets.advancedcustomfields.com/info/5.0.0/select2.png" /></p>
|
||||
<h3><?php _e("Improved Usability", 'acf'); ?></h3>
|
||||
<p><?php _e("Including the popular Select2 library has improved both usability and speed across a number of field types including post object, page link, taxonomy and select.", 'acf'); ?></p>
|
||||
</div>
|
||||
<div>
|
||||
<p><img src="https://assets.advancedcustomfields.com/info/5.0.0/design.png" /></p>
|
||||
<h3><?php _e("Improved Design", 'acf'); ?></h3>
|
||||
<p><?php _e("Many fields have undergone a visual refresh to make ACF look better than ever! Noticeable changes are seen on the gallery, relationship and oEmbed (new) fields!", 'acf'); ?></p>
|
||||
</div>
|
||||
<div>
|
||||
<p><img src="https://assets.advancedcustomfields.com/info/5.0.0/sub-fields.png" /></p>
|
||||
<h3><?php _e("Improved Data", 'acf'); ?></h3>
|
||||
<p><?php _e("Redesigning the data architecture has allowed sub fields to live independently from their parents. This allows you to drag and drop fields in and out of parent fields!", 'acf'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2 class="about-headline-callout"><?php _e("Goodbye Add-ons. Hello PRO", 'acf'); ?></h2>
|
||||
<div class="feature-section">
|
||||
<h2><?php _e("Goodbye Add-ons. Hello PRO", 'acf'); ?> 👋</h2>
|
||||
<div class="acf-three-col">
|
||||
<div>
|
||||
<h3><?php _e("Introducing ACF PRO", 'acf'); ?></h3>
|
||||
<p><?php _e("We're changing the way premium functionality is delivered in an exciting way!", 'acf'); ?></p>
|
||||
<p><?php printf(__('All 4 premium add-ons have been combined into a new <a href="%s">Pro version of ACF</a>. With both personal and developer licenses available, premium functionality is more affordable and accessible than ever before!', 'acf'), esc_url('https://www.advancedcustomfields.com/pro')); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Powerful Features", 'acf'); ?></h3>
|
||||
<p><?php _e("ACF PRO contains powerful features such as repeatable data, flexible content layouts, a beautiful gallery field and the ability to create extra admin options pages!", 'acf'); ?></p>
|
||||
<p><?php printf(__('Read more about <a href="%s">ACF PRO features</a>.', 'acf'), esc_url('https://www.advancedcustomfields.com/pro')); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Easy Upgrading", 'acf'); ?></h3>
|
||||
<p><?php _e('Upgrading to ACF PRO is easy. Simply purchase a license online and download the plugin!', 'acf'); ?></p>
|
||||
<p><?php printf(__('We also wrote an <a href="%s">upgrade guide</a> to answer any questions, but if you do have one, please contact our support team via the <a href="%s">help desk</a>.', 'acf'), esc_url('https://www.advancedcustomfields.com/resources/upgrade-guide-acf-pro/'), esc_url('https://www.advancedcustomfields.com/support/')); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feature-section acf-three-col">
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Introducing ACF PRO", 'acf'); ?></h3>
|
||||
<p><?php _e("We're changing the way premium functionality is delivered in an exciting way!", 'acf'); ?></p>
|
||||
<p><?php printf(__('All 4 premium add-ons have been combined into a new <a href="%s">Pro version of ACF</a>. With both personal and developer licenses available, premium functionality is more affordable and accessible than ever before!', 'acf'), esc_url('https://www.advancedcustomfields.com/pro')); ?></p>
|
||||
</div>
|
||||
<div class="feature-section">
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Powerful Features", 'acf'); ?></h3>
|
||||
<p><?php _e("ACF PRO contains powerful features such as repeatable data, flexible content layouts, a beautiful gallery field and the ability to create extra admin options pages!", 'acf'); ?></p>
|
||||
<p><?php printf(__('Read more about <a href="%s">ACF PRO features</a>.', 'acf'), esc_url('https://www.advancedcustomfields.com/pro')); ?></p>
|
||||
</div>
|
||||
<h2><?php _e("New Features", 'acf'); ?> 🎉</h2>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Easy Upgrading", 'acf'); ?></h3>
|
||||
<p><?php printf(__('To help make upgrading easy, <a href="%s">login to your store account</a> and claim a free copy of ACF PRO!', 'acf'), esc_url('https://www.advancedcustomfields.com/my-account/')); ?></p>
|
||||
<p><?php printf(__('We also wrote an <a href="%s">upgrade guide</a> to answer any questions, but if you do have one, please contact our support team via the <a href="%s">help desk</a>', 'acf'), esc_url('https://www.advancedcustomfields.com/resources/updates/upgrading-v4-v5/'), esc_url('https://support.advancedcustomfields.com')); ?>
|
||||
<div class="acf-three-col">
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Link Field", 'acf'); ?></h3>
|
||||
<p><?php _e("The Link field provides a simple way to select or define a link (url, title, target).", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Group Field", 'acf'); ?></h3>
|
||||
<p><?php _e("The Group field provides a simple way to create a group of fields.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("oEmbed Field", 'acf'); ?></h3>
|
||||
<p><?php _e("The oEmbed field allows an easy way to embed videos, images, tweets, audio, and other content.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Clone Field", 'acf'); ?> <span class="badge"><?php _e('Pro', 'acf'); ?></span></h3>
|
||||
<p><?php _e("The clone field allows you to select and display existing fields.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("More AJAX", 'acf'); ?></h3>
|
||||
<p><?php _e("More fields use AJAX powered search to speed up page loading.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Local JSON", 'acf'); ?></h3>
|
||||
<p><?php _e("New auto export to JSON feature improves speed and allows for syncronisation.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Easy Import / Export", 'acf'); ?></h3>
|
||||
<p><?php _e("Both import and export can easily be done through a new tools page.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("New Form Locations", 'acf'); ?></h3>
|
||||
<p><?php _e("Fields can now be mapped to menus, menu items, comments, widgets and all user forms!", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("More Customization", 'acf'); ?></h3>
|
||||
<p><?php _e("New PHP (and JS) actions and filters have been added to allow for more customization.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Fresh UI", 'acf'); ?></h3>
|
||||
<p><?php _e("The entire plugin has had a design refresh including new field types, settings and design!", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("New Settings", 'acf'); ?></h3>
|
||||
<p><?php _e("Field group settings have been added for Active, Label Placement, Instructions Placement and Description.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Better Front End Forms", 'acf'); ?></h3>
|
||||
<p><?php _e("acf_form() can now create a new post on submission with lots of new settings.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Better Validation", 'acf'); ?></h3>
|
||||
<p><?php _e("Form validation is now done via PHP + AJAX in favour of only JS.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3><?php _e("Moving Fields", 'acf'); ?></h3>
|
||||
<p><?php _e("New field group functionality allows you to move a field between groups & parents.", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div><?php // intentional empty div for flex alignment ?></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2 class="about-headline-callout"><?php _e("Under the Hood", 'acf'); ?></h2>
|
||||
|
||||
<div class="feature-section acf-three-col">
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Smarter field settings", 'acf'); ?></h4>
|
||||
<p><?php _e("ACF now saves its field settings as individual post objects", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("More AJAX", 'acf'); ?></h4>
|
||||
<p><?php _e("More fields use AJAX powered search to speed up page loading", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Local JSON", 'acf'); ?></h4>
|
||||
<p><?php _e("New auto export to JSON feature improves speed", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Better version control", 'acf'); ?></h4>
|
||||
<p><?php _e("New auto export to JSON feature allows field settings to be version controlled", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Swapped XML for JSON", 'acf'); ?></h4>
|
||||
<p><?php _e("Import / Export now uses JSON in favour of XML", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("New Forms", 'acf'); ?></h4>
|
||||
<p><?php _e("Fields can now be mapped to comments, widgets and all user forms!", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div>
|
||||
<h4><?php _e("New Field", 'acf'); ?></h4>
|
||||
<p><?php _e("A new field for embedding content has been added", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("New Gallery", 'acf'); ?></h4>
|
||||
<p><?php _e("The gallery field has undergone a much needed facelift", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("New Settings", 'acf'); ?></h4>
|
||||
<p><?php _e("Field group settings have been added for label placement and instruction placement", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Better Front End Forms", 'acf'); ?></h4>
|
||||
<p><?php _e("acf_form() can now create a new post on submission", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Better Validation", 'acf'); ?></h4>
|
||||
<p><?php _e("Form validation is now done via PHP + AJAX in favour of only JS", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Relationship Field", 'acf'); ?></h4>
|
||||
<p><?php _e("New Relationship field setting for 'Filters' (Search, Post Type, Taxonomy)", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Moving Fields", 'acf'); ?></h4>
|
||||
<p><?php _e("New field group functionality allows you to move a field between groups & parents", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Page Link", 'acf'); ?></h4>
|
||||
<p><?php _e("New archives group in page_link field selection", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4><?php _e("Better Options Pages", 'acf'); ?></h4>
|
||||
<p><?php _e("New functions for options page allow creation of both parent and child menu pages", 'acf'); ?></p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<?php elseif( $active == 'changelog' ): ?>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('ACF_Ajax_Upgrade') ) :
|
||||
|
||||
class ACF_Ajax_Upgrade extends ACF_Ajax {
|
||||
|
||||
/** @var string The AJAX action name */
|
||||
var $action = 'acf/ajax/upgrade';
|
||||
|
||||
/**
|
||||
* get_response
|
||||
*
|
||||
* The actual logic for this AJAX request.
|
||||
*
|
||||
* @date 31/7/18
|
||||
* @since 5.7.2
|
||||
*
|
||||
* @param void
|
||||
* @return mixed The response data to send back or WP_Error.
|
||||
*/
|
||||
|
||||
function response() {
|
||||
|
||||
// switch blog
|
||||
if( $this->has('blog_id') ) {
|
||||
switch_to_blog( $this->get('blog_id') );
|
||||
}
|
||||
|
||||
// bail early if no upgrade avaiable
|
||||
if( !acf_has_upgrade() ) {
|
||||
return new WP_Error( 'upgrade_error', __('No updates available.', 'acf') );
|
||||
}
|
||||
|
||||
// listen for output
|
||||
ob_start();
|
||||
|
||||
// run upgrades
|
||||
acf_upgrade_all();
|
||||
|
||||
// store output
|
||||
$error = ob_get_clean();
|
||||
|
||||
// return error if output
|
||||
if( $error ) {
|
||||
return new WP_Error( 'upgrade_error', $error );
|
||||
}
|
||||
|
||||
// return
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
acf_new_instance('ACF_Ajax_Upgrade');
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
|
|
@ -97,11 +97,18 @@ function acf_get_valid_field( $field = false ) {
|
|||
$field['_valid'] = 1;
|
||||
|
||||
|
||||
// field specific defaults
|
||||
$field = apply_filters( "acf/validate_field", $field );
|
||||
/**
|
||||
* Filters the $field array to validate settings.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$field = apply_filters( "acf/validate_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/validate_field", $field );
|
||||
|
||||
|
||||
|
||||
// translate
|
||||
$field = acf_translate_field( $field );
|
||||
|
||||
|
|
@ -140,10 +147,17 @@ function acf_translate_field( $field ) {
|
|||
$field['instructions'] = acf_translate( $field['instructions'] );
|
||||
|
||||
|
||||
// filters
|
||||
$field = apply_filters( "acf/translate_field", $field );
|
||||
/**
|
||||
* Filters the $field array to translate strings.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$field = apply_filters( "acf/translate_field/type={$field['type']}", $field );
|
||||
|
||||
$field = apply_filters( "acf/translate_field", $field );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -173,9 +187,17 @@ function acf_clone_field( $field, $clone_field ) {
|
|||
$field['_clone'] = $clone_field['key'];
|
||||
|
||||
|
||||
// filters
|
||||
$field = apply_filters( "acf/clone_field", $field, $clone_field );
|
||||
/**
|
||||
* Filters the $field array when it is being cloned.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
* @param array $clone_field The clone field array.
|
||||
*/
|
||||
$field = apply_filters( "acf/clone_field/type={$field['type']}", $field, $clone_field );
|
||||
$field = apply_filters( "acf/clone_field", $field, $clone_field );
|
||||
|
||||
|
||||
// return
|
||||
|
|
@ -215,11 +237,20 @@ function acf_prepare_field( $field ) {
|
|||
$field['_prepare'] = 1;
|
||||
|
||||
|
||||
// filter to 3rd party customization
|
||||
$field = apply_filters( "acf/prepare_field", $field );
|
||||
$field = apply_filters( "acf/prepare_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/prepare_field/name={$field['_name']}", $field );
|
||||
$field = apply_filters( "acf/prepare_field/key={$field['key']}", $field );
|
||||
/**
|
||||
* Filters the $field array.
|
||||
*
|
||||
* Allows developers to modify field settings or return false to remove field.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$field = apply_filters( "acf/prepare_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/prepare_field/name={$field['_name']}", $field );
|
||||
$field = apply_filters( "acf/prepare_field/key={$field['key']}", $field );
|
||||
$field = apply_filters( "acf/prepare_field", $field );
|
||||
|
||||
|
||||
// bail ealry if no field
|
||||
|
|
@ -391,10 +422,18 @@ function acf_render_field( $field = false ) {
|
|||
if( !$field ) return;
|
||||
|
||||
|
||||
// create field specific html
|
||||
do_action( "acf/render_field", $field );
|
||||
do_action( "acf/render_field/type={$field['type']}", $field );
|
||||
|
||||
/**
|
||||
* Fires when rendering a field.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
do_action( "acf/render_field/type={$field['type']}", $field );
|
||||
do_action( "acf/render_field/name={$field['_name']}", $field );
|
||||
do_action( "acf/render_field/key={$field['key']}", $field );
|
||||
do_action( "acf/render_field", $field );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -894,11 +933,18 @@ function acf_get_field( $selector = null, $db_only = false ) {
|
|||
if( $db_only ) return $field;
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$field = apply_filters( "acf/load_field", $field);
|
||||
$field = apply_filters( "acf/load_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/load_field/name={$field['name']}", $field );
|
||||
$field = apply_filters( "acf/load_field/key={$field['key']}", $field );
|
||||
/**
|
||||
* Filters the $field array after it has been loaded.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$field = apply_filters( "acf/load_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/load_field/name={$field['_name']}", $field );
|
||||
$field = apply_filters( "acf/load_field/key={$field['key']}", $field );
|
||||
$field = apply_filters( "acf/load_field", $field );
|
||||
|
||||
|
||||
// update cache
|
||||
|
|
@ -1244,11 +1290,18 @@ function acf_update_field( $field = false, $specific = false ) {
|
|||
}
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$field = apply_filters( "acf/update_field", $field);
|
||||
$field = apply_filters( "acf/update_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/update_field/name={$field['name']}", $field );
|
||||
$field = apply_filters( "acf/update_field/key={$field['key']}", $field );
|
||||
/**
|
||||
* Filters the $field array before it is updated.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$field = apply_filters( "acf/update_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/update_field/name={$field['_name']}", $field );
|
||||
$field = apply_filters( "acf/update_field/key={$field['key']}", $field );
|
||||
$field = apply_filters( "acf/update_field", $field );
|
||||
|
||||
|
||||
// store origional field for return
|
||||
|
|
@ -1506,9 +1559,16 @@ function acf_duplicate_field( $selector = 0, $new_parent = 0 ){
|
|||
}
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$field = apply_filters( "acf/duplicate_field", $field);
|
||||
/**
|
||||
* Filters the $field array after it has been duplicated.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$field = apply_filters( "acf/duplicate_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/duplicate_field", $field);
|
||||
|
||||
|
||||
// save
|
||||
|
|
@ -1548,9 +1608,18 @@ function acf_delete_field( $selector = 0 ) {
|
|||
wp_delete_post( $field['ID'], true );
|
||||
|
||||
|
||||
// action for 3rd party customisation
|
||||
do_action( "acf/delete_field", $field);
|
||||
do_action( "acf/delete_field/type={$field['type']}", $field );
|
||||
/**
|
||||
* Fires immediately after a field has been deleted.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
do_action( "acf/delete_field/type={$field['type']}", $field );
|
||||
do_action( "acf/delete_field/name={$field['_name']}", $field );
|
||||
do_action( "acf/delete_field/key={$field['key']}", $field );
|
||||
do_action( "acf/delete_field", $field );
|
||||
|
||||
|
||||
// clear cache
|
||||
|
|
@ -1708,9 +1777,16 @@ function acf_prepare_field_for_export( $field ) {
|
|||
));
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$field = apply_filters( "acf/prepare_field_for_export", $field );
|
||||
/**
|
||||
* Filters the $field array before being returned to the export tool.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$field = apply_filters( "acf/prepare_field_for_export/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/prepare_field_for_export", $field );
|
||||
|
||||
|
||||
// return
|
||||
|
|
@ -1803,9 +1879,16 @@ function acf_prepare_field_for_import( $field ) {
|
|||
));
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$field = apply_filters( "acf/prepare_field_for_import", $field );
|
||||
/**
|
||||
* Filters the $field array before being returned to the import tool.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$field = apply_filters( "acf/prepare_field_for_import/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/prepare_field_for_import", $field );
|
||||
|
||||
|
||||
// return
|
||||
|
|
@ -1852,9 +1935,18 @@ function acf_get_sub_field( $selector, $field ) {
|
|||
}
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$sub_field = apply_filters( "acf/get_sub_field", $sub_field, $selector, $field );
|
||||
/**
|
||||
* Filters the $sub_field found.
|
||||
*
|
||||
* @date 12/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $sub_field The found sub field array.
|
||||
* @param string $selector The selector used to search.
|
||||
* @param array $field The parent field array.
|
||||
*/
|
||||
$sub_field = apply_filters( "acf/get_sub_field/type={$field['type']}", $sub_field, $selector, $field );
|
||||
$sub_field = apply_filters( "acf/get_sub_field", $sub_field, $selector, $field );
|
||||
|
||||
|
||||
// return
|
||||
|
|
@ -2029,4 +2121,57 @@ function acf_prefix_fields( &$fields, $prefix = 'acf' ) {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_apply_field_filters
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 11/9/18
|
||||
* @since 5.7.6
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
/*
|
||||
function acf_apply_field_filters( $value ) {
|
||||
|
||||
// get function args
|
||||
$args = func_get_args();
|
||||
|
||||
// find field in $args
|
||||
$field = false;
|
||||
foreach( $args as $arg ) {
|
||||
if( is_array($arg) && isset($arg['key'], $arg['type'], $arg['_name']) ) {
|
||||
$field = $arg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// vars
|
||||
$filter = current_filter();
|
||||
|
||||
// unshift tag to args
|
||||
array_unshift($args, $filter);
|
||||
|
||||
// apply field filters
|
||||
if( $field ) {
|
||||
|
||||
// $filter/type=$type
|
||||
$args[0] = "{$filter}/type={$field['type']}";
|
||||
$value = call_user_func_array('apply_filters', $args);
|
||||
|
||||
// $filter/name=$name
|
||||
$args[0] = "{$filter}/name={$field['_name']}";
|
||||
$value = call_user_func_array('apply_filters', $args);
|
||||
|
||||
// $filter/key=$key
|
||||
$args[0] = "{$filter}/key={$field['key']}";
|
||||
$value = call_user_func_array('apply_filters', $args);
|
||||
}
|
||||
|
||||
// return
|
||||
return $value;
|
||||
}
|
||||
*/
|
||||
|
||||
?>
|
||||
|
|
@ -431,6 +431,24 @@ function acf_include( $file ) {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_include_once
|
||||
*
|
||||
* Includes a file one time only.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param string $file The relative file path.
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function acf_include_once( $file = '' ) {
|
||||
$path = acf_get_path( $file );
|
||||
if( file_exists($path) ) {
|
||||
include_once( $path );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* acf_get_external_path
|
||||
|
|
@ -1210,30 +1228,20 @@ function acf_get_locale() {
|
|||
|
||||
function acf_get_terms( $args ) {
|
||||
|
||||
// global
|
||||
global $wp_version;
|
||||
|
||||
|
||||
// vars
|
||||
$terms = array();
|
||||
|
||||
|
||||
// WP 4.5+
|
||||
if( version_compare($wp_version, '4.5', '>=' ) ) {
|
||||
|
||||
$terms = get_terms( $args );
|
||||
|
||||
// WP < 4.5
|
||||
} else {
|
||||
|
||||
$terms = get_terms( $args['taxonomy'], $args );
|
||||
// defaults
|
||||
$args = wp_parse_args($args, array(
|
||||
'taxonomy' => null,
|
||||
'hide_empty' => false,
|
||||
'update_term_meta_cache' => false,
|
||||
));
|
||||
|
||||
// parameters changed in version 4.5
|
||||
if( acf_version_compare('wp', '<', '4.5') ) {
|
||||
return get_terms( $args['taxonomy'], $args );
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $terms;
|
||||
|
||||
return get_terms( $args );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1309,36 +1317,6 @@ function acf_get_taxonomy_terms( $taxonomies = array() ) {
|
|||
}
|
||||
|
||||
|
||||
function acf_get_term_title( $term ) {
|
||||
|
||||
// title
|
||||
$title = $term->name;
|
||||
|
||||
|
||||
// empty
|
||||
if( $title === '' ) {
|
||||
|
||||
$title = __('(no title)', 'acf');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ancestors
|
||||
if( is_taxonomy_hierarchical($term->taxonomy) ) {
|
||||
|
||||
$ancestors = get_ancestors( $term->term_id, $term->taxonomy );
|
||||
|
||||
$title = str_repeat('- ', count($ancestors)) . $title;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $title;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_decode_taxonomy_terms
|
||||
*
|
||||
|
|
@ -4063,11 +4041,22 @@ function acf_validate_attachment( $attachment, $field, $context = 'prepare' ) {
|
|||
}
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$errors = apply_filters("acf/validate_attachment", $errors, $file, $attachment, $field, $context);
|
||||
$errors = apply_filters("acf/validate_attachment/type={$field['type']}", $errors, $file, $attachment, $field, $context );
|
||||
$errors = apply_filters("acf/validate_attachment/name={$field['name']}", $errors, $file, $attachment, $field, $context );
|
||||
$errors = apply_filters("acf/validate_attachment/key={$field['key']}", $errors, $file, $attachment, $field, $context );
|
||||
/**
|
||||
* Filters the errors for a file before it is uploaded or displayed in the media modal.
|
||||
*
|
||||
* @date 3/07/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param array $errors An array of errors.
|
||||
* @param array $file An array of data for a single file.
|
||||
* @param array $attachment An array of attachment data which differs based on the context.
|
||||
* @param array $field The field array.
|
||||
* @param string $context The curent context (uploading, preparing)
|
||||
*/
|
||||
$errors = apply_filters( "acf/validate_attachment/type={$field['type']}", $errors, $file, $attachment, $field, $context );
|
||||
$errors = apply_filters( "acf/validate_attachment/name={$field['_name']}", $errors, $file, $attachment, $field, $context );
|
||||
$errors = apply_filters( "acf/validate_attachment/key={$field['key']}", $errors, $file, $attachment, $field, $context );
|
||||
$errors = apply_filters( "acf/validate_attachment", $errors, $file, $attachment, $field, $context );
|
||||
|
||||
|
||||
// return
|
||||
|
|
@ -4537,33 +4526,43 @@ function acf_format_date( $value, $format ) {
|
|||
function acf_log() {
|
||||
|
||||
// vars
|
||||
$log = '';
|
||||
$args = func_get_args();
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $args as $i => $arg ) {
|
||||
|
||||
// array | object
|
||||
if( is_array($arg) || is_object($arg) ) {
|
||||
|
||||
$arg = print_r($arg, true);
|
||||
|
||||
} elseif( is_bool($arg) ) {
|
||||
|
||||
$arg = ( $arg ? 'true' : 'false' ) . ' (bool)';
|
||||
|
||||
}
|
||||
|
||||
// bool
|
||||
} elseif( is_bool($arg) ) {
|
||||
$arg = 'bool(' . ( $arg ? 'true' : 'false' ) . ')';
|
||||
}
|
||||
|
||||
// update
|
||||
$args[ $i ] = $arg;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// log
|
||||
error_log( implode(' ', $args) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_dev_log
|
||||
*
|
||||
* Used to log variables only if ACF_DEV is defined
|
||||
*
|
||||
* @date 25/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param mixed
|
||||
* @return void
|
||||
*/
|
||||
function acf_dev_log() {
|
||||
if( defined('ACF_DEV') && ACF_DEV ) {
|
||||
call_user_func_array('acf_log', func_get_args());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -5267,4 +5266,98 @@ function acf_parse_markdown( $text = '' ) {
|
|||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_sites
|
||||
*
|
||||
* Returns an array of sites for a network.
|
||||
*
|
||||
* @date 29/08/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param void
|
||||
* @return array
|
||||
*/
|
||||
function acf_get_sites() {
|
||||
|
||||
// vars
|
||||
$results = array();
|
||||
|
||||
// function get_sites() was added in WP 4.6
|
||||
if( function_exists('get_sites') ) {
|
||||
|
||||
$_sites = get_sites(array(
|
||||
'number' => 0
|
||||
));
|
||||
|
||||
if( $_sites ) {
|
||||
foreach( $_sites as $_site ) {
|
||||
$_site = get_site( $_site );
|
||||
$results[] = $_site->to_array();
|
||||
}}
|
||||
|
||||
// function wp_get_sites() returns in the desired output
|
||||
} else {
|
||||
$results = wp_get_sites(array(
|
||||
'limit' => 0
|
||||
));
|
||||
}
|
||||
|
||||
// return
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_convert_rules_to_groups
|
||||
*
|
||||
* Converts an array of rules from ACF4 to an array of groups for ACF5
|
||||
*
|
||||
* @date 25/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param array $rules An array of rules.
|
||||
* @param string $anyorall The anyorall setting used in ACF4. Defaults to 'any'.
|
||||
* @return array
|
||||
*/
|
||||
function acf_convert_rules_to_groups( $rules, $anyorall = 'any' ) {
|
||||
|
||||
// vars
|
||||
$groups = array();
|
||||
$index = 0;
|
||||
|
||||
// loop
|
||||
foreach( $rules as $rule ) {
|
||||
|
||||
// extract vars
|
||||
$group = acf_extract_var( $rule, 'group_no' );
|
||||
$order = acf_extract_var( $rule, 'order_no' );
|
||||
|
||||
// calculate group if not defined
|
||||
if( $group === null ) {
|
||||
$group = $index;
|
||||
|
||||
// use $anyorall to determine if a new group is needed
|
||||
if( $anyorall == 'any' ) {
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
// calculate order if not defined
|
||||
if( $order === null ) {
|
||||
$order = isset($groups[ $group ]) ? count($groups[ $group ]) : 0;
|
||||
}
|
||||
|
||||
// append to group
|
||||
$groups[ $group ][ $order ] = $rule;
|
||||
|
||||
// sort groups
|
||||
ksort( $groups[ $group ] );
|
||||
}
|
||||
|
||||
// sort groups
|
||||
ksort( $groups );
|
||||
|
||||
// return
|
||||
return $groups;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -31,6 +31,11 @@ function acf_get_taxonomies( $args = array() ) {
|
|||
$taxonomies[] = $i;
|
||||
}
|
||||
|
||||
// custom post_type arg which does not yet exist in core
|
||||
if( isset($args['post_type']) ) {
|
||||
$taxonomies = acf_get_taxonomies_for_post_type($args['post_type']);
|
||||
}
|
||||
|
||||
// filter
|
||||
$taxonomies = apply_filters('acf/get_taxonomies', $taxonomies, $args);
|
||||
|
||||
|
|
@ -38,6 +43,37 @@ function acf_get_taxonomies( $args = array() ) {
|
|||
return $taxonomies;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_taxonomies_for_post_type
|
||||
*
|
||||
* Returns an array of taxonomies for a given post type(s)
|
||||
*
|
||||
* @date 7/9/18
|
||||
* @since 5.7.5
|
||||
*
|
||||
* @param string|array $post_types The post types to compare against.
|
||||
* @return array
|
||||
*/
|
||||
function acf_get_taxonomies_for_post_type( $post_types = 'post' ) {
|
||||
|
||||
// vars
|
||||
$taxonomies = array();
|
||||
|
||||
// loop
|
||||
foreach( (array) $post_types as $post_type ) {
|
||||
$object_taxonomies = get_object_taxonomies( $post_type );
|
||||
foreach( (array) $object_taxonomies as $taxonomy ) {
|
||||
$taxonomies[] = $taxonomy;
|
||||
}
|
||||
}
|
||||
|
||||
// remove duplicates
|
||||
$taxonomies = array_unique($taxonomies);
|
||||
|
||||
// return
|
||||
return $taxonomies;
|
||||
}
|
||||
|
||||
/*
|
||||
* acf_get_taxonomy_labels
|
||||
*
|
||||
|
|
@ -89,6 +125,38 @@ function acf_get_taxonomy_labels( $taxonomies = array() ) {
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_term_title
|
||||
*
|
||||
* Returns the title for this term object.
|
||||
*
|
||||
* @date 10/9/18
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param object $term The WP_Term object.
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function acf_get_term_title( $term ) {
|
||||
|
||||
// set to term name
|
||||
$title = $term->name;
|
||||
|
||||
// allow for empty name
|
||||
if( $title === '' ) {
|
||||
$title = __('(no title)', 'acf');
|
||||
}
|
||||
|
||||
// prepent ancestors indentation
|
||||
if( is_taxonomy_hierarchical($term->taxonomy) ) {
|
||||
$ancestors = get_ancestors( $term->term_id, $term->taxonomy );
|
||||
$title = str_repeat('- ', count($ancestors)) . $title;
|
||||
}
|
||||
|
||||
// return
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_grouped_terms
|
||||
*
|
||||
|
|
@ -108,7 +176,7 @@ function acf_get_grouped_terms( $args ) {
|
|||
|
||||
// defaults
|
||||
$args = wp_parse_args($args, array(
|
||||
'taxonomy' => 'category',
|
||||
'taxonomy' => null,
|
||||
'hide_empty' => false,
|
||||
'update_term_meta_cache' => false,
|
||||
));
|
||||
|
|
@ -117,6 +185,9 @@ function acf_get_grouped_terms( $args ) {
|
|||
$taxonomies = acf_get_taxonomy_labels( acf_get_array($args['taxonomy']) );
|
||||
$is_single = (count($taxonomies) == 1);
|
||||
|
||||
// specify exact taxonomies required for _acf_terms_clauses() to work.
|
||||
$args['taxonomy'] = array_keys($taxonomies);
|
||||
|
||||
// add filter to group results by taxonomy
|
||||
if( !$is_single ) {
|
||||
add_filter('terms_clauses', '_acf_terms_clauses', 10, 3);
|
||||
|
|
@ -241,14 +312,14 @@ function acf_get_pretty_taxonomies( $taxonomies = array() ) {
|
|||
* @date 19/8/18
|
||||
* @since 5.7.3
|
||||
*
|
||||
* @param mixed $term_id The term ID or a string of "slug:taxonomy".
|
||||
* @param mixed $term_id The term ID or a string of "taxonomy:slug".
|
||||
* @param string $taxonomy The taxonomyname.
|
||||
* @return WP_Term
|
||||
*/
|
||||
|
||||
function acf_get_term( $term_id, $taxonomy = '' ) {
|
||||
|
||||
// allow $term_id parameter to be a string of "slug:taxonomy" of "slug:id"
|
||||
// allow $term_id parameter to be a string of "taxonomy:slug" or "taxonomy:id"
|
||||
if( is_string($term_id) && strpos($term_id, ':') ) {
|
||||
list( $taxonomy, $term_id ) = explode(':', $term_id);
|
||||
$term = get_term_by( 'slug', $term_id, $taxonomy );
|
||||
|
|
@ -259,5 +330,172 @@ function acf_get_term( $term_id, $taxonomy = '' ) {
|
|||
return get_term( $term_id, $taxonomy );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_encode_term
|
||||
*
|
||||
* Returns a "taxonomy:slug" string for a given WP_Term.
|
||||
*
|
||||
* @date 27/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param WP_Term $term The term object.
|
||||
* @return string
|
||||
*/
|
||||
function acf_encode_term( $term ) {
|
||||
return "{$term->taxonomy}:{$term->slug}";
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_decode_term
|
||||
*
|
||||
* Decodes a "taxonomy:slug" string into an array of taxonomy and slug.
|
||||
*
|
||||
* @date 27/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param WP_Term $term The term object.
|
||||
* @return string
|
||||
*/
|
||||
function acf_decode_term( $string ) {
|
||||
if( is_string($string) && strpos($string, ':') ) {
|
||||
list( $taxonomy, $slug ) = explode(':', $string);
|
||||
return array(
|
||||
'taxonomy' => $taxonomy,
|
||||
'slug' => $slug
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_encoded_terms
|
||||
*
|
||||
* Returns an array of WP_Term objects from an array of encoded strings
|
||||
*
|
||||
* @date 9/9/18
|
||||
* @since 5.7.5
|
||||
*
|
||||
* @param array $values The array of encoded strings.
|
||||
* @return array
|
||||
*/
|
||||
function acf_get_encoded_terms( $values ) {
|
||||
|
||||
// vars
|
||||
$terms = array();
|
||||
|
||||
// loop over values
|
||||
foreach( (array) $values as $value ) {
|
||||
|
||||
// find term from string
|
||||
$term = acf_get_term( $value );
|
||||
|
||||
// append
|
||||
if( $term instanceof WP_Term ) {
|
||||
$terms[] = $term;
|
||||
}
|
||||
}
|
||||
|
||||
// return
|
||||
return $terms;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_choices_from_terms
|
||||
*
|
||||
* Returns an array of choices from the terms provided.
|
||||
*
|
||||
* @date 8/9/18
|
||||
* @since 5.7.5
|
||||
*
|
||||
* @param array $values and array of WP_Terms objects or encoded strings.
|
||||
* @param string $format The value format (term_id, slug).
|
||||
* @return array
|
||||
*/
|
||||
function acf_get_choices_from_terms( $terms, $format = 'term_id' ) {
|
||||
|
||||
// vars
|
||||
$groups = array();
|
||||
|
||||
// get taxonomy lables
|
||||
$labels = acf_get_taxonomy_labels();
|
||||
|
||||
// convert array of encoded strings to terms
|
||||
$term = reset($terms);
|
||||
if( !$term instanceof WP_Term ) {
|
||||
$terms = acf_get_encoded_terms( $terms );
|
||||
}
|
||||
|
||||
// loop over terms
|
||||
foreach( $terms as $term ) {
|
||||
$group = $labels[ $term->taxonomy ];
|
||||
$choice = acf_get_choice_from_term( $term, $format );
|
||||
$groups[ $group ][ $choice['id'] ] = $choice['text'];
|
||||
}
|
||||
|
||||
// return
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_choices_from_grouped_terms
|
||||
*
|
||||
* Returns an array of choices from the grouped terms provided.
|
||||
*
|
||||
* @date 8/9/18
|
||||
* @since 5.7.5
|
||||
*
|
||||
* @param array $value A grouped array of WP_Terms objects.
|
||||
* @param string $format The value format (term_id, slug).
|
||||
* @return array
|
||||
*/
|
||||
function acf_get_choices_from_grouped_terms( $value, $format = 'term_id' ) {
|
||||
|
||||
// vars
|
||||
$groups = array();
|
||||
|
||||
// loop over values
|
||||
foreach( $value as $group => $terms ) {
|
||||
$groups[ $group ] = array();
|
||||
foreach( $terms as $term_id => $term ) {
|
||||
$choice = acf_get_choice_from_term( $term, $format );
|
||||
$groups[ $group ][ $choice['id'] ] = $choice['text'];
|
||||
}
|
||||
}
|
||||
|
||||
// return
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_choice_from_term
|
||||
*
|
||||
* Returns an array containing the id and text for this item.
|
||||
*
|
||||
* @date 10/9/18
|
||||
* @since 5.7.6
|
||||
*
|
||||
* @param object $item The item object such as WP_Post or WP_Term.
|
||||
* @param string $format The value format (term_id, slug)
|
||||
* @return array
|
||||
*/
|
||||
function acf_get_choice_from_term( $term, $format = 'term_id' ) {
|
||||
|
||||
// vars
|
||||
$id = $term->term_id;
|
||||
$text = acf_get_term_title( $term );
|
||||
|
||||
// return format
|
||||
if( $format == 'slug' ) {
|
||||
$id = acf_encode_term($term);
|
||||
}
|
||||
|
||||
// return
|
||||
return array(
|
||||
'id' => $id,
|
||||
'text' => $text
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -299,12 +299,21 @@ function acf_get_value( $post_id = 0, $field ) {
|
|||
$value = $field['default_value'];
|
||||
}
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$value = apply_filters( "acf/load_value", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/load_value/type={$field['type']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/load_value/name={$field['_name']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/load_value/key={$field['key']}", $value, $post_id, $field );
|
||||
|
||||
/**
|
||||
* Filters the $value after it has been loaded.
|
||||
*
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param mixed $value The value to preview.
|
||||
* @param string $post_id The post ID for this value.
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$value = apply_filters( "acf/load_value/type={$field['type']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/load_value/name={$field['_name']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/load_value/key={$field['key']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/load_value", $value, $post_id, $field );
|
||||
|
||||
|
||||
// update cache
|
||||
|
|
@ -345,12 +354,21 @@ function acf_format_value( $value, $post_id, $field ) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
// apply filters
|
||||
$value = apply_filters( "acf/format_value", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/format_value/type={$field['type']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/format_value/name={$field['_name']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/format_value/key={$field['key']}", $value, $post_id, $field );
|
||||
|
||||
/**
|
||||
* Filters the $value for use in a template function.
|
||||
*
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param mixed $value The value to preview.
|
||||
* @param string $post_id The post ID for this value.
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$value = apply_filters( "acf/format_value/type={$field['type']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/format_value/name={$field['_name']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/format_value/key={$field['key']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/format_value", $value, $post_id, $field );
|
||||
|
||||
|
||||
// update cache
|
||||
|
|
@ -385,18 +403,40 @@ function acf_update_value( $value = null, $post_id = 0, $field ) {
|
|||
}
|
||||
|
||||
|
||||
// allow filter to short-circuit update_value logic
|
||||
/**
|
||||
* Allows developers to run a custom update function.
|
||||
*
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param null $check Return a non null value to prevent default.
|
||||
* @param mixed $value The value to update.
|
||||
* @param string $post_id The post ID for this value.
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$check = apply_filters( "acf/pre_update_value", null, $value, $post_id, $field );
|
||||
if( $check !== null ) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$value = apply_filters( "acf/update_value", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/update_value/type={$field['type']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/update_value/name={$field['_name']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/update_value/key={$field['key']}", $value, $post_id, $field );
|
||||
/**
|
||||
* Filters the $value before it is saved.
|
||||
*
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
* @since 5.7.6 Added $_value parameter.
|
||||
*
|
||||
* @param mixed $value The value to update.
|
||||
* @param string $post_id The post ID for this value.
|
||||
* @param array $field The field array.
|
||||
* @param mixed $_value The original value before modification.
|
||||
*/
|
||||
$_value = $value;
|
||||
$value = apply_filters( "acf/update_value/type={$field['type']}", $value, $post_id, $field, $_value );
|
||||
$value = apply_filters( "acf/update_value/name={$field['_name']}", $value, $post_id, $field, $_value );
|
||||
$value = apply_filters( "acf/update_value/key={$field['key']}", $value, $post_id, $field, $_value );
|
||||
$value = apply_filters( "acf/update_value", $value, $post_id, $field, $_value );
|
||||
|
||||
|
||||
// allow null to delete
|
||||
|
|
@ -442,11 +482,20 @@ function acf_update_value( $value = null, $post_id = 0, $field ) {
|
|||
|
||||
function acf_delete_value( $post_id = 0, $field ) {
|
||||
|
||||
// action for 3rd party customization
|
||||
do_action("acf/delete_value", $post_id, $field['name'], $field);
|
||||
do_action("acf/delete_value/type={$field['type']}", $post_id, $field['name'], $field);
|
||||
do_action("acf/delete_value/name={$field['_name']}", $post_id, $field['name'], $field);
|
||||
do_action("acf/delete_value/key={$field['key']}", $post_id, $field['name'], $field);
|
||||
/**
|
||||
* Fires before a value is deleted.
|
||||
*
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param string $post_id The post ID for this value.
|
||||
* @param mixed $name The meta name.
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
do_action( "acf/delete_value/type={$field['type']}", $post_id, $field['name'], $field );
|
||||
do_action( "acf/delete_value/name={$field['_name']}", $post_id, $field['name'], $field );
|
||||
do_action( "acf/delete_value/key={$field['key']}", $post_id, $field['name'], $field );
|
||||
do_action( "acf/delete_value", $post_id, $field['name'], $field );
|
||||
|
||||
|
||||
// delete value
|
||||
|
|
@ -553,16 +602,23 @@ function acf_copy_postmeta( $from_post_id, $to_post_id ) {
|
|||
|
||||
function acf_preview_value( $value, $post_id, $field ) {
|
||||
|
||||
// apply filters
|
||||
$value = apply_filters( "acf/preview_value", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/preview_value/type={$field['type']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/preview_value/name={$field['_name']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/preview_value/key={$field['key']}", $value, $post_id, $field );
|
||||
|
||||
/**
|
||||
* Filters the $value before used in HTML.
|
||||
*
|
||||
* @date 24/10/16
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param mixed $value The value to preview.
|
||||
* @param string $post_id The post ID for this value.
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$value = apply_filters( "acf/preview_value/type={$field['type']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/preview_value/name={$field['_name']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/preview_value/key={$field['key']}", $value, $post_id, $field );
|
||||
$value = apply_filters( "acf/preview_value", $value, $post_id, $field );
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,282 +1,194 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
class acf_compatibility {
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('ACF_Compatibility') ) :
|
||||
|
||||
class ACF_Compatibility {
|
||||
|
||||
/*
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* description
|
||||
* Sets up the class functionality.
|
||||
*
|
||||
* @type function
|
||||
* @date 30/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// fields
|
||||
add_filter('acf/validate_field', array($this, 'validate_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=textarea', array($this, 'validate_textarea_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=relationship', array($this, 'validate_relationship_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=post_object', array($this, 'validate_relationship_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=page_link', array($this, 'validate_relationship_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=image', array($this, 'validate_image_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=file', array($this, 'validate_image_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=wysiwyg', array($this, 'validate_wysiwyg_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=date_picker', array($this, 'validate_date_picker_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=taxonomy', array($this, 'validate_taxonomy_field'), 20, 1);
|
||||
// actions
|
||||
add_filter('acf/validate_field', array($this, 'validate_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=textarea', array($this, 'validate_textarea_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=relationship', array($this, 'validate_relationship_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=post_object', array($this, 'validate_relationship_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=page_link', array($this, 'validate_relationship_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=image', array($this, 'validate_image_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=file', array($this, 'validate_image_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=wysiwyg', array($this, 'validate_wysiwyg_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=date_picker', array($this, 'validate_date_picker_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=taxonomy', array($this, 'validate_taxonomy_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=date_time_picker', array($this, 'validate_date_time_picker_field'), 20, 1);
|
||||
add_filter('acf/validate_field/type=user', array($this, 'validate_user_field'), 20, 1);
|
||||
|
||||
|
||||
// field groups
|
||||
add_filter('acf/validate_field_group', array($this, 'validate_field_group'), 20, 1);
|
||||
add_filter('acf/validate_field/type=user', array($this, 'validate_user_field'), 20, 1);
|
||||
add_filter('acf/validate_field_group', array($this, 'validate_field_group'), 20, 1);
|
||||
|
||||
// location
|
||||
add_filter('acf/location/validate_rule/type=post_taxonomy', array($this, 'validate_post_taxonomy_location_rule'), 20, 1);
|
||||
add_filter('acf/location/validate_rule/type=post_category', array($this, 'validate_post_taxonomy_location_rule'), 20, 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* validate_field
|
||||
*
|
||||
* This function will provide compatibility with ACF4 fields
|
||||
* Adds compatibility with deprecated settings
|
||||
*
|
||||
* @type function
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
* @param array $field The field array.
|
||||
* @return array $field
|
||||
*/
|
||||
|
||||
function validate_field( $field ) {
|
||||
|
||||
// conditional logic has changed
|
||||
// conditional logic data structure changed to groups in version 5.0.0
|
||||
// convert previous data (status, rules, allorany) into groups
|
||||
if( isset($field['conditional_logic']['status']) ) {
|
||||
|
||||
// extract logic
|
||||
$logic = acf_extract_var( $field, 'conditional_logic' );
|
||||
|
||||
|
||||
// disabled
|
||||
if( !empty($logic['status']) ) {
|
||||
|
||||
// reset
|
||||
$field['conditional_logic'] = array();
|
||||
|
||||
|
||||
// vars
|
||||
$group = 0;
|
||||
$all_or_any = $logic['allorany'];
|
||||
|
||||
|
||||
// loop over rules
|
||||
if( !empty($logic['rules']) ) {
|
||||
|
||||
foreach( $logic['rules'] as $rule ) {
|
||||
|
||||
// sperate groups?
|
||||
if( $all_or_any == 'any' ) {
|
||||
|
||||
$group++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add to group
|
||||
$field['conditional_logic'][ $group ][] = $rule;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// reset keys
|
||||
$field['conditional_logic'] = array_values($field['conditional_logic']);
|
||||
|
||||
|
||||
// check status
|
||||
if( $field['conditional_logic']['status'] ) {
|
||||
$field['conditional_logic'] = acf_convert_rules_to_groups($field['conditional_logic']['rules'], $field['conditional_logic']['allorany']);
|
||||
} else {
|
||||
|
||||
$field['conditional_logic'] = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* validate_relationship_field
|
||||
*
|
||||
* This function will provide compatibility with ACF4 fields
|
||||
*
|
||||
* @type function
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
*/
|
||||
|
||||
function validate_relationship_field( $field ) {
|
||||
|
||||
// force array
|
||||
$field['post_type'] = acf_get_array($field['post_type']);
|
||||
$field['taxonomy'] = acf_get_array($field['taxonomy']);
|
||||
|
||||
|
||||
// remove 'all' from post_type
|
||||
if( acf_in_array('all', $field['post_type']) ) {
|
||||
|
||||
$field['post_type'] = array();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// remove 'all' from taxonomy
|
||||
if( acf_in_array('all', $field['taxonomy']) ) {
|
||||
|
||||
$field['taxonomy'] = array();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// save_format is now return_format
|
||||
if( !empty($field['result_elements']) ) {
|
||||
|
||||
$field['elements'] = acf_extract_var( $field, 'result_elements' );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* validate_textarea_field
|
||||
*
|
||||
* This function will provide compatibility with ACF4 fields
|
||||
* Adds compatibility with deprecated settings
|
||||
*
|
||||
* @type function
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
* @param array $field The field array.
|
||||
* @return array $field
|
||||
*/
|
||||
|
||||
function validate_textarea_field( $field ) {
|
||||
|
||||
// formatting has been removed
|
||||
$formatting = acf_extract_var( $field, 'formatting' );
|
||||
|
||||
if( $formatting === 'br' ) {
|
||||
|
||||
$field['new_lines'] = 'br';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* validate_image_field
|
||||
/**
|
||||
* validate_relationship_field
|
||||
*
|
||||
* This function will provide compatibility with ACF4 fields
|
||||
* Adds compatibility with deprecated settings
|
||||
*
|
||||
* @type function
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
* @param array $field The field array.
|
||||
* @return array $field
|
||||
*/
|
||||
function validate_relationship_field( $field ) {
|
||||
|
||||
// remove 'all' from post_type
|
||||
if( acf_in_array('all', $field['post_type']) ) {
|
||||
$field['post_type'] = array();
|
||||
}
|
||||
|
||||
// remove 'all' from taxonomy
|
||||
if( acf_in_array('all', $field['taxonomy']) ) {
|
||||
$field['taxonomy'] = array();
|
||||
}
|
||||
|
||||
// result_elements is now elements
|
||||
if( isset($field['result_elements']) ) {
|
||||
$field['elements'] = acf_extract_var( $field, 'result_elements' );
|
||||
}
|
||||
|
||||
// return
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* validate_image_field
|
||||
*
|
||||
* Adds compatibility with deprecated settings
|
||||
*
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param array $field The field array.
|
||||
* @return array $field
|
||||
*/
|
||||
function validate_image_field( $field ) {
|
||||
|
||||
// save_format is now return_format
|
||||
if( !empty($field['save_format']) ) {
|
||||
|
||||
if( isset($field['save_format']) ) {
|
||||
$field['return_format'] = acf_extract_var( $field, 'save_format' );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// object is now array
|
||||
if( $field['return_format'] == 'object' ) {
|
||||
|
||||
$field['return_format'] = 'array';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* validate_wysiwyg_field
|
||||
*
|
||||
* This function will provide compatibility with ACF4 fields
|
||||
* Adds compatibility with deprecated settings
|
||||
*
|
||||
* @type function
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
* @param array $field The field array.
|
||||
* @return array $field
|
||||
*/
|
||||
|
||||
function validate_wysiwyg_field( $field ) {
|
||||
|
||||
// media_upload is now numeric
|
||||
if( $field['media_upload'] === 'yes' ) {
|
||||
|
||||
$field['media_upload'] = 1;
|
||||
|
||||
} elseif( $field['media_upload'] === 'no' ) {
|
||||
|
||||
$field['media_upload'] = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* validate_date_picker_field
|
||||
*
|
||||
* This function will provide compatibility with ACF4 fields
|
||||
* Adds compatibility with deprecated settings
|
||||
*
|
||||
* @type function
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
* @param array $field The field array.
|
||||
* @return array $field
|
||||
*/
|
||||
|
||||
function validate_date_picker_field( $field ) {
|
||||
|
||||
// v4 used date_format
|
||||
if( !empty($field['date_format']) ) {
|
||||
// date_format has changed to display_format
|
||||
if( isset($field['date_format']) ) {
|
||||
|
||||
// extract vars
|
||||
$date_format = $field['date_format'];
|
||||
|
|
@ -293,55 +205,43 @@ class acf_compatibility {
|
|||
unset($field['date_format']);
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* validate_taxonomy_field
|
||||
*
|
||||
* This function will provide compatibility with ACF4 fields
|
||||
* Adds compatibility with deprecated settings
|
||||
*
|
||||
* @type function
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
* @since 5.2.7
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
* @param array $field The field array.
|
||||
* @return array $field
|
||||
*/
|
||||
|
||||
function validate_taxonomy_field( $field ) {
|
||||
|
||||
// 5.2.7
|
||||
// load_save_terms deprecated in favour of separate save_terms
|
||||
if( isset($field['load_save_terms']) ) {
|
||||
|
||||
$field['save_terms'] = $field['load_save_terms'];
|
||||
|
||||
$field['save_terms'] = acf_extract_var( $field, 'load_save_terms' );
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* validate_date_time_picker_field
|
||||
*
|
||||
* This function will provide compatibility with existing 3rd party fields
|
||||
* Adds compatibility with deprecated settings
|
||||
*
|
||||
* @type function
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
* @since 5.2.7
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
* @param array $field The field array.
|
||||
* @return array $field
|
||||
*/
|
||||
|
||||
function validate_date_time_picker_field( $field ) {
|
||||
|
||||
// 3rd party date time picker
|
||||
|
|
@ -353,78 +253,58 @@ class acf_compatibility {
|
|||
$date_format = acf_extract_var( $field, 'date_format' );
|
||||
$get_as_timestamp = acf_extract_var( $field, 'get_as_timestamp' );
|
||||
|
||||
|
||||
// convert from js to php
|
||||
$time_format = acf_convert_time_to_php( $time_format );
|
||||
$date_format = acf_convert_date_to_php( $date_format );
|
||||
|
||||
|
||||
// append settings
|
||||
$field['return_format'] = $date_format . ' ' . $time_format;
|
||||
$field['display_format'] = $date_format . ' ' . $time_format;
|
||||
|
||||
|
||||
// timestamp
|
||||
if( $get_as_timestamp === 'true' ) {
|
||||
|
||||
$field['return_format'] = 'U';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* validate_user_field
|
||||
*
|
||||
* This function will provide compatibility with ACF4 fields
|
||||
* Adds compatibility with deprecated settings
|
||||
*
|
||||
* @type function
|
||||
* @date 23/04/2014
|
||||
* @since 5.0.0
|
||||
* @since 5.2.7
|
||||
*
|
||||
* @param $field (array)
|
||||
* @return $field
|
||||
* @param array $field The field array.
|
||||
* @return array $field
|
||||
*/
|
||||
|
||||
function validate_user_field( $field ) {
|
||||
|
||||
// remove 'all' from roles
|
||||
if( acf_in_array('all', $field['role']) ) {
|
||||
|
||||
$field['role'] = '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// field_type removed in favour of multiple
|
||||
if( !empty($field['field_type']) ) {
|
||||
if( isset($field['field_type']) ) {
|
||||
|
||||
// extract vars
|
||||
$field_type = acf_extract_var( $field, 'field_type' );
|
||||
|
||||
|
||||
// multiple
|
||||
if( $field_type === 'multi_select' ) {
|
||||
|
||||
$field['multiple'] = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* validate_field_group
|
||||
*
|
||||
|
|
@ -437,150 +317,105 @@ class acf_compatibility {
|
|||
* @param $field_group (array)
|
||||
* @return $field_group
|
||||
*/
|
||||
|
||||
function validate_field_group( $field_group ) {
|
||||
|
||||
// vars
|
||||
$version = 5;
|
||||
|
||||
|
||||
// add missing 'key' (v5.0.0)
|
||||
if( empty($field_group['key']) ) {
|
||||
|
||||
// update version
|
||||
// field group key was added in version 5.0.0
|
||||
// detect ACF4 data and generate key
|
||||
if( !$field_group['key'] ) {
|
||||
$version = 4;
|
||||
|
||||
|
||||
// add missing key
|
||||
$field_group['key'] = empty($field_group['id']) ? uniqid('group_') : 'group_' . $field_group['id'];
|
||||
|
||||
$field_group['key'] = uniqid('group_');
|
||||
}
|
||||
|
||||
|
||||
// extract options (v5.0.0)
|
||||
if( !empty($field_group['options']) ) {
|
||||
|
||||
// prior to version 5.0.0, settings were saved in an 'options' array
|
||||
// extract and merge options into the field group
|
||||
if( isset($field_group['options']) ) {
|
||||
$options = acf_extract_var($field_group, 'options');
|
||||
$field_group = array_merge($field_group, $options);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// location rules changed to groups (v5.0.0)
|
||||
if( !empty($field_group['location']['rules']) ) {
|
||||
|
||||
// extract location
|
||||
$location = acf_extract_var( $field_group, 'location' );
|
||||
|
||||
|
||||
// reset location
|
||||
$field_group['location'] = array();
|
||||
|
||||
|
||||
// vars
|
||||
$group = 0;
|
||||
$all_or_any = $location['allorany'];
|
||||
|
||||
|
||||
// loop over rules
|
||||
if( !empty($location['rules']) ) {
|
||||
|
||||
foreach( $location['rules'] as $rule ) {
|
||||
|
||||
// sperate groups?
|
||||
if( $all_or_any == 'any' ) $group++;
|
||||
|
||||
|
||||
// add to group
|
||||
$field_group['location'][ $group ][] = $rule;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// reset keys
|
||||
$field_group['location'] = array_values($field_group['location']);
|
||||
|
||||
// location data structure changed to groups in version 4.1.0
|
||||
// convert previous data (rules, allorany) into groups
|
||||
if( isset($field_group['location']['rules']) ) {
|
||||
$field_group['location'] = acf_convert_rules_to_groups($field_group['location']['rules'], $field_group['location']['allorany']);
|
||||
}
|
||||
|
||||
|
||||
// some location rules have changed (v5.0.0)
|
||||
if( !empty($field_group['location']) ) {
|
||||
// some location rule names have changed in version 5.0.0
|
||||
// loop over location data and modify rules
|
||||
$replace = array(
|
||||
'taxonomy' => 'post_taxonomy',
|
||||
'ef_media' => 'attachment',
|
||||
'ef_taxonomy' => 'taxonomy',
|
||||
'ef_user' => 'user_role',
|
||||
'user_type' => 'current_user_role' // 5.2.0
|
||||
);
|
||||
|
||||
// only replace 'taxonomy' rule if is an ACF4 field group
|
||||
if( $version > 4 ) {
|
||||
unset($replace['taxonomy']);
|
||||
}
|
||||
|
||||
// loop over location groups
|
||||
if( $field_group['location'] ) {
|
||||
foreach( $field_group['location'] as $i => $group ) {
|
||||
|
||||
// param changes
|
||||
$replace = array(
|
||||
'taxonomy' => 'post_taxonomy',
|
||||
'ef_media' => 'attachment',
|
||||
'ef_taxonomy' => 'taxonomy',
|
||||
'ef_user' => 'user_role',
|
||||
'user_type' => 'current_user_role' // 5.2.0
|
||||
);
|
||||
|
||||
|
||||
// remove conflicting param
|
||||
if( $version == 5 ) {
|
||||
|
||||
unset($replace['taxonomy']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// loop over location groups
|
||||
foreach( $field_group['location'] as $i => $group ) {
|
||||
// loop over group rules
|
||||
if( $group ) {
|
||||
foreach( $group as $j => $rule ) {
|
||||
|
||||
// bail early if group is empty
|
||||
if( empty($group) ) continue;
|
||||
|
||||
|
||||
// loop over group rules
|
||||
foreach( $group as $ii => $rule ) {
|
||||
|
||||
// migrate param
|
||||
if( isset($replace[ $rule['param'] ]) ) {
|
||||
|
||||
$rule['param'] = $replace[ $rule['param'] ];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update
|
||||
$group[ $ii ] = $rule;
|
||||
|
||||
// migrate param
|
||||
if( isset($replace[ $rule['param'] ]) ) {
|
||||
$field_group['location'][ $i ][ $j ]['param'] = $replace[ $rule['param'] ];
|
||||
}
|
||||
|
||||
|
||||
// update
|
||||
$field_group['location'][ $i ] = $group;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}}
|
||||
}}
|
||||
|
||||
// change layout to style (v5.0.0)
|
||||
if( !empty($field_group['layout']) ) {
|
||||
|
||||
if( isset($field_group['layout']) ) {
|
||||
$field_group['style'] = acf_extract_var($field_group, 'layout');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// change no_box to seamless (v5.0.0)
|
||||
if( $field_group['style'] === 'no_box' ) {
|
||||
|
||||
$field_group['style'] = 'seamless';
|
||||
|
||||
}
|
||||
|
||||
|
||||
//return
|
||||
return $field_group;
|
||||
}
|
||||
|
||||
/**
|
||||
* validate_post_taxonomy_location_rule
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 27/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
function validate_post_taxonomy_location_rule( $rule ) {
|
||||
|
||||
// previous versions of ACF (v4.4.12) saved value as term_id
|
||||
// convert term_id into "taxonomy:slug" string
|
||||
if( is_numeric($rule['value']) ) {
|
||||
$term = acf_get_term( $rule['value'] );
|
||||
if( $term ) {
|
||||
$rule['value'] = acf_encode_term($term);
|
||||
}
|
||||
}
|
||||
|
||||
// return
|
||||
return $rule;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new acf_compatibility();
|
||||
acf_new_instance('ACF_Compatibility');
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
|
|
@ -162,8 +162,8 @@ class acf_deprecated {
|
|||
function acf_validate_field( $field ) {
|
||||
|
||||
// 5.5.6 - changed filter name
|
||||
$field = apply_filters( "acf/get_valid_field", $field );
|
||||
$field = apply_filters( "acf/get_valid_field/type={$field['type']}", $field );
|
||||
$field = apply_filters( "acf/get_valid_field", $field );
|
||||
|
||||
|
||||
// return
|
||||
|
|
|
|||
|
|
@ -221,10 +221,9 @@ class acf_field_post_object extends acf_field {
|
|||
|
||||
|
||||
// optgroup or single
|
||||
if( count($args['post_type']) == 1 ) {
|
||||
|
||||
$post_type = acf_get_array( $args['post_type'] );
|
||||
if( count($post_type) == 1 ) {
|
||||
$results = $results[0]['children'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,9 @@ class acf_field_relationship extends acf_field {
|
|||
|
||||
|
||||
// append to $args
|
||||
$args['tax_query'] = array();
|
||||
$args['tax_query'] = array(
|
||||
'relation' => 'OR',
|
||||
);
|
||||
|
||||
|
||||
// now create the tax queries
|
||||
|
|
@ -393,151 +395,69 @@ class acf_field_relationship extends acf_field {
|
|||
function render_field( $field ) {
|
||||
|
||||
// vars
|
||||
$values = array();
|
||||
$post_type = acf_get_array( $field['post_type'] );
|
||||
$taxonomy = acf_get_array( $field['taxonomy'] );
|
||||
$filters = acf_get_array( $field['filters'] );
|
||||
|
||||
// filters
|
||||
$filter_count = count($filters);
|
||||
$filter_post_type_choices = array();
|
||||
$filter_taxonomy_choices = array();
|
||||
|
||||
// post_type filter
|
||||
if( in_array('post_type', $filters) ) {
|
||||
|
||||
$filter_post_type_choices = array(
|
||||
'' => __('Select post type', 'acf')
|
||||
) + acf_get_pretty_post_types( $post_type );
|
||||
}
|
||||
|
||||
// taxonomy filter
|
||||
if( in_array('taxonomy', $filters) ) {
|
||||
|
||||
$term_choices = array();
|
||||
$filter_taxonomy_choices = array(
|
||||
'' => __('Select taxonomy', 'acf')
|
||||
);
|
||||
|
||||
// check for specific taxonomy setting
|
||||
if( $taxonomy ) {
|
||||
$terms = acf_get_encoded_terms( $taxonomy );
|
||||
$term_choices = acf_get_choices_from_terms( $terms, 'slug' );
|
||||
|
||||
// if no terms were specified, find all terms
|
||||
} else {
|
||||
|
||||
// restrict taxonomies by the post_type selected
|
||||
$term_args = array();
|
||||
if( $post_type ) {
|
||||
$term_args['taxonomy'] = acf_get_taxonomies(array(
|
||||
'post_type' => $post_type
|
||||
));
|
||||
}
|
||||
|
||||
// get terms
|
||||
$terms = acf_get_grouped_terms( $term_args );
|
||||
$term_choices = acf_get_choices_from_grouped_terms( $terms, 'slug' );
|
||||
}
|
||||
|
||||
// append term choices
|
||||
$filter_taxonomy_choices = $filter_taxonomy_choices + $term_choices;
|
||||
|
||||
}
|
||||
|
||||
// div attributes
|
||||
$atts = array(
|
||||
'id' => $field['id'],
|
||||
'class' => "acf-relationship {$field['class']}",
|
||||
'data-min' => $field['min'],
|
||||
'data-max' => $field['max'],
|
||||
'data-s' => '',
|
||||
'data-paged' => 1,
|
||||
'data-post_type' => '',
|
||||
'data-taxonomy' => '',
|
||||
'data-paged' => 1,
|
||||
);
|
||||
|
||||
|
||||
// Lang
|
||||
if( defined('ICL_LANGUAGE_CODE') ) {
|
||||
|
||||
$atts['data-lang'] = ICL_LANGUAGE_CODE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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'] );
|
||||
|
||||
|
||||
// filters
|
||||
$filters = array(
|
||||
'count' => count($field['filters']),
|
||||
'search' => false,
|
||||
'post_type' => false,
|
||||
'taxonomy' => false
|
||||
);
|
||||
|
||||
foreach( $field['filters'] as $filter ) {
|
||||
$filters[ $filter ] = true;
|
||||
}
|
||||
|
||||
|
||||
// filter - post_type
|
||||
if( $filters['post_type'] ) {
|
||||
|
||||
// choices
|
||||
$choices = array(
|
||||
'' => __('Select post type', 'acf')
|
||||
);
|
||||
|
||||
|
||||
// get post types
|
||||
$post_types = acf_get_pretty_post_types($field['post_type']);
|
||||
|
||||
|
||||
// append
|
||||
$choices = $choices + $post_types;
|
||||
|
||||
|
||||
// set filter
|
||||
$filters['post_type'] = $choices;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// taxonomy filter
|
||||
if( $filters['taxonomy'] ) {
|
||||
|
||||
// vars
|
||||
$groups = array();
|
||||
$taxonomies = array();
|
||||
$choices = array(
|
||||
'' => __('Select taxonomy', 'acf')
|
||||
);
|
||||
|
||||
|
||||
// get taxonomies from setting
|
||||
if( !empty($field['taxonomy']) ) {
|
||||
|
||||
$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
|
||||
foreach( $field['post_type'] as $post_type ) {
|
||||
|
||||
// get connected taxonomies
|
||||
$post_taxonomies = get_object_taxonomies( $post_type );
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $post_taxonomies as $name ) {
|
||||
$taxonomies[ $name ] = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// convert back to array
|
||||
$taxonomies = array_keys($taxonomies);
|
||||
|
||||
// check empty
|
||||
$taxonomies = empty($taxonomies) ? false : $taxonomies;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// terms
|
||||
if( $taxonomies !== false ) {
|
||||
$groups = acf_get_taxonomy_terms( $taxonomies );
|
||||
}
|
||||
|
||||
|
||||
// update $term_groups with specific terms
|
||||
if( !empty($field['taxonomy']) ) {
|
||||
|
||||
foreach( $groups as $taxonomy => $terms ) {
|
||||
|
||||
foreach( $terms as $slug => $name ) {
|
||||
|
||||
if( !in_array($slug, $field['taxonomy']) ) {
|
||||
|
||||
unset($groups[ $taxonomy ][ $slug ]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// append
|
||||
$choices = $choices + $groups;
|
||||
|
||||
|
||||
// set filter
|
||||
$filters['taxonomy'] = $choices;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<div <?php acf_esc_attr_e($atts); ?>>
|
||||
|
||||
|
|
@ -546,12 +466,12 @@ class acf_field_relationship extends acf_field {
|
|||
<?php
|
||||
|
||||
/* filters */
|
||||
if( $filters['count'] ): ?>
|
||||
<div class="filters -f<?php echo esc_attr($filters['count']); ?>">
|
||||
if( $filter_count ): ?>
|
||||
<div class="filters -f<?php echo esc_attr($filter_count); ?>">
|
||||
<?php
|
||||
|
||||
/* search */
|
||||
if( $filters['search'] ): ?>
|
||||
if( in_array('search', $filters) ): ?>
|
||||
<div class="filter -search">
|
||||
<span>
|
||||
<?php acf_text_input( array('placeholder' => __("Search...",'acf'), 'data-filter' => 's') ); ?>
|
||||
|
|
@ -561,20 +481,20 @@ class acf_field_relationship extends acf_field {
|
|||
|
||||
|
||||
/* post_type */
|
||||
if( $filters['post_type'] ): ?>
|
||||
if( in_array('post_type', $filters) ): ?>
|
||||
<div class="filter -post_type">
|
||||
<span>
|
||||
<?php acf_select_input( array('choices' => $filters['post_type'], 'data-filter' => 'post_type') ); ?>
|
||||
<?php acf_select_input( array('choices' => $filter_post_type_choices, 'data-filter' => 'post_type') ); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif;
|
||||
|
||||
|
||||
/* post_type */
|
||||
if( $filters['taxonomy'] ): ?>
|
||||
if( in_array('taxonomy', $filters) ): ?>
|
||||
<div class="filter -taxonomy">
|
||||
<span>
|
||||
<?php acf_select_input( array('choices' => $filters['taxonomy'], 'data-filter' => 'taxonomy') ); ?>
|
||||
<?php acf_select_input( array('choices' => $filter_taxonomy_choices, 'data-filter' => 'taxonomy') ); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
|
@ -614,7 +534,6 @@ class acf_field_relationship extends acf_field {
|
|||
<?php
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* render_field_settings()
|
||||
|
|
|
|||
|
|
@ -83,7 +83,9 @@ class acf_form_nav_menu {
|
|||
|
||||
// get field groups
|
||||
$field_groups = acf_get_field_groups(array(
|
||||
'nav_menu_item' => $item->type
|
||||
'nav_menu_item' => $item->type,
|
||||
'nav_menu_item_id' => $item_id,
|
||||
'nav_menu_item_depth' => $depth
|
||||
));
|
||||
|
||||
// render
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ if( $this->view == 'add' ): ?>
|
|||
var valid = acf.validateForm({
|
||||
form: $form,
|
||||
event: e,
|
||||
lock: false
|
||||
reset: true
|
||||
});
|
||||
|
||||
// if not valid, stop event and allow validation to continue
|
||||
|
|
|
|||
|
|
@ -264,16 +264,16 @@ class acf_form_widget {
|
|||
acf.set('post_id', 'widgets');
|
||||
|
||||
// Only initialize visible fields.
|
||||
// - check for #widgets-right as this does not exist in accessibility mode
|
||||
acf.addFilter('find_fields_args', function( args ){
|
||||
acf.addFilter('find_fields', function( $fields ){
|
||||
|
||||
// add parent
|
||||
if( !args.parent && $('#widgets-right').length ) {
|
||||
args.parent = $('#widgets-right');
|
||||
}
|
||||
// not templates
|
||||
$fields = $fields.not('#available-widgets .acf-field');
|
||||
|
||||
// not widget dragging in
|
||||
$fields = $fields.not('.widget.ui-draggable-dragging .acf-field');
|
||||
|
||||
// return
|
||||
return args;
|
||||
return $fields;
|
||||
});
|
||||
|
||||
// on publish
|
||||
|
|
@ -287,7 +287,7 @@ class acf_form_widget {
|
|||
var valid = acf.validateForm({
|
||||
form: $form,
|
||||
event: e,
|
||||
lock: false
|
||||
reset: true
|
||||
});
|
||||
|
||||
// if not valid, stop event and allow validation to continue
|
||||
|
|
|
|||
|
|
@ -192,20 +192,19 @@ function acf_get_location_rule_types() {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_valid_location_rule
|
||||
/**
|
||||
* acf_validate_location_rule
|
||||
*
|
||||
* This function will return a valid location rule array
|
||||
* Returns a valid location rule array.
|
||||
*
|
||||
* @type function
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
* @date 28/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param $rule (array)
|
||||
* @return (array)
|
||||
* @param $rule array The rule array.
|
||||
* @return array
|
||||
*/
|
||||
|
||||
function acf_get_valid_location_rule( $rule ) {
|
||||
function acf_validate_location_rule( $rule = false ) {
|
||||
|
||||
// defaults
|
||||
$rule = wp_parse_args( $rule, array(
|
||||
|
|
@ -216,17 +215,14 @@ function acf_get_valid_location_rule( $rule ) {
|
|||
'value' => '',
|
||||
));
|
||||
|
||||
|
||||
// prefix for inputs
|
||||
$rule['prefix'] = 'acf_field_group[location]['.$rule['group'].']['.$rule['id'].']';
|
||||
|
||||
// filter
|
||||
$rule = apply_filters( "acf/location/validate_rule/type={$rule['param']}", $rule );
|
||||
$rule = apply_filters( "acf/location/validate_rule", $rule);
|
||||
|
||||
// return
|
||||
return $rule;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_location_rule_operators
|
||||
*
|
||||
|
|
@ -250,6 +246,7 @@ function acf_get_location_rule_operators( $rule ) {
|
|||
|
||||
|
||||
// filter
|
||||
$operators = apply_filters( "acf/location/rule_operators/type={$rule['param']}", $operators, $rule );
|
||||
$operators = apply_filters( "acf/location/rule_operators/{$rule['param']}", $operators, $rule );
|
||||
$operators = apply_filters( "acf/location/rule_operators", $operators, $rule );
|
||||
|
||||
|
|
@ -280,6 +277,7 @@ function acf_get_location_rule_values( $rule ) {
|
|||
|
||||
|
||||
// filter
|
||||
$values = apply_filters( "acf/location/rule_values/type={$rule['param']}", $values, $rule );
|
||||
$values = apply_filters( "acf/location/rule_values/{$rule['param']}", $values, $rule );
|
||||
$values = apply_filters( "acf/location/rule_values", $values, $rule );
|
||||
|
||||
|
|
@ -311,6 +309,8 @@ function acf_match_location_rule( $rule, $screen ) {
|
|||
|
||||
|
||||
// filter
|
||||
$result = apply_filters( "acf/location/match_rule/type={$rule['param']}", $result, $rule, $screen );
|
||||
$result = apply_filters( "acf/location/match_rule", $result, $rule, $screen );
|
||||
$result = apply_filters( "acf/location/rule_match/{$rule['param']}", $result, $rule, $screen );
|
||||
$result = apply_filters( "acf/location/rule_match", $result, $rule, $screen );
|
||||
|
||||
|
|
@ -353,4 +353,20 @@ function acf_get_location_screen( $screen, $field_group ) {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_valid_location_rule
|
||||
*
|
||||
* Deprecated in 5.7.4. Use acf_validate_location_rule() instead.
|
||||
*
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $rule array The rule array.
|
||||
* @return array
|
||||
*/
|
||||
|
||||
function acf_get_valid_location_rule( $rule ) {
|
||||
return acf_validate_location_rule( $rule );
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -90,11 +90,20 @@ class ACF_Media {
|
|||
$errors = acf_validate_attachment( $file, $field, 'upload' );
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$errors = apply_filters("acf/upload_prefilter", $errors, $file, $field);
|
||||
$errors = apply_filters("acf/upload_prefilter/type={$field['type']}", $errors, $file, $field );
|
||||
$errors = apply_filters("acf/upload_prefilter/name={$field['name']}", $errors, $file, $field );
|
||||
$errors = apply_filters("acf/upload_prefilter/key={$field['key']}", $errors, $file, $field );
|
||||
/**
|
||||
* Filters the errors for a file before it is uploaded to WordPress.
|
||||
*
|
||||
* @date 16/02/2015
|
||||
* @since 5.1.5
|
||||
*
|
||||
* @param array $errors An array of errors.
|
||||
* @param array $file An array of data for a single file.
|
||||
* @param array $field The field array.
|
||||
*/
|
||||
$errors = apply_filters( "acf/upload_prefilter/type={$field['type']}", $errors, $file, $field );
|
||||
$errors = apply_filters( "acf/upload_prefilter/name={$field['_name']}", $errors, $file, $field );
|
||||
$errors = apply_filters( "acf/upload_prefilter/key={$field['key']}", $errors, $file, $field );
|
||||
$errors = apply_filters( "acf/upload_prefilter", $errors, $file, $field );
|
||||
|
||||
|
||||
// append error
|
||||
|
|
|
|||
|
|
@ -0,0 +1,507 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* acf_has_upgrade
|
||||
*
|
||||
* Returns true if this site has an upgrade avaialble.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return bool
|
||||
*/
|
||||
function acf_has_upgrade() {
|
||||
|
||||
// vars
|
||||
$db_version = acf_get_db_version();
|
||||
|
||||
// return true if DB version is < latest upgrade version
|
||||
if( $db_version && acf_version_compare($db_version, '<', '5.5.0') ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// update DB version if needed
|
||||
if( $db_version !== ACF_VERSION ) {
|
||||
acf_update_db_version( ACF_VERSION );
|
||||
}
|
||||
|
||||
// return
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_upgrade_all
|
||||
*
|
||||
* Returns true if this site has an upgrade avaialble.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return bool
|
||||
*/
|
||||
function acf_upgrade_all() {
|
||||
|
||||
// log
|
||||
acf_dev_log('acf_upgrade_all');
|
||||
|
||||
// vars
|
||||
$db_version = acf_get_db_version();
|
||||
|
||||
// 5.0.0
|
||||
if( acf_version_compare($db_version, '<', '5.0.0') ) {
|
||||
acf_upgrade_500();
|
||||
}
|
||||
|
||||
// 5.5.0
|
||||
if( acf_version_compare($db_version, '<', '5.5.0') ) {
|
||||
acf_upgrade_550();
|
||||
}
|
||||
|
||||
// upgrade DB version once all updates are complete
|
||||
acf_update_db_version( ACF_VERSION );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_get_db_version
|
||||
*
|
||||
* Returns the ACF DB version.
|
||||
*
|
||||
* @date 10/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param void
|
||||
* @return string
|
||||
*/
|
||||
function acf_get_db_version() {
|
||||
return get_option('acf_version');
|
||||
}
|
||||
|
||||
/*
|
||||
* acf_update_db_version
|
||||
*
|
||||
* Updates the ACF DB version.
|
||||
*
|
||||
* @date 10/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param string $version The new version.
|
||||
* @return void
|
||||
*/
|
||||
function acf_update_db_version( $version = '' ) {
|
||||
update_option('acf_version', $version );
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_upgrade_500
|
||||
*
|
||||
* Version 5 introduces new post types for field groups and fields.
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function acf_upgrade_500() {
|
||||
|
||||
// log
|
||||
acf_dev_log('acf_upgrade_500');
|
||||
|
||||
// action
|
||||
do_action('acf/upgrade_500');
|
||||
|
||||
// do tasks
|
||||
acf_upgrade_500_field_groups();
|
||||
|
||||
// update version
|
||||
acf_update_db_version('5.0.0');
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_upgrade_500_field_groups
|
||||
*
|
||||
* Upgrades all ACF4 field groups to ACF5
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function acf_upgrade_500_field_groups() {
|
||||
|
||||
// log
|
||||
acf_dev_log('acf_upgrade_500_field_groups');
|
||||
|
||||
// get old field groups
|
||||
$ofgs = get_posts(array(
|
||||
'numberposts' => -1,
|
||||
'post_type' => 'acf',
|
||||
'orderby' => 'menu_order title',
|
||||
'order' => 'asc',
|
||||
'suppress_filters' => true,
|
||||
));
|
||||
|
||||
// loop
|
||||
if( $ofgs ) {
|
||||
foreach( $ofgs as $ofg ){
|
||||
acf_upgrade_500_field_group( $ofg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_upgrade_500_field_group
|
||||
*
|
||||
* Upgrades a ACF4 field group to ACF5
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param object $ofg The old field group post object.
|
||||
* @return array $nfg The new field group array.
|
||||
*/
|
||||
function acf_upgrade_500_field_group( $ofg ) {
|
||||
|
||||
// vars
|
||||
$nfg = array(
|
||||
'ID' => 0,
|
||||
'title' => $ofg->post_title,
|
||||
'menu_order' => $ofg->menu_order,
|
||||
);
|
||||
|
||||
// construct the location rules
|
||||
$rules = get_post_meta($ofg->ID, 'rule', false);
|
||||
$anyorall = get_post_meta($ofg->ID, 'allorany', true);
|
||||
if( is_array($rules) ) {
|
||||
|
||||
// if field group was duplicated, rules may be a serialized string!
|
||||
$rules = array_map('maybe_unserialize', $rules);
|
||||
|
||||
// convert rules to groups
|
||||
$nfg['location'] = acf_convert_rules_to_groups( $rules, $anyorall );
|
||||
}
|
||||
|
||||
// settings
|
||||
if( $position = get_post_meta($ofg->ID, 'position', true) ) {
|
||||
$nfg['position'] = $position;
|
||||
}
|
||||
|
||||
if( $layout = get_post_meta($ofg->ID, 'layout', true) ) {
|
||||
$nfg['layout'] = $layout;
|
||||
}
|
||||
|
||||
if( $hide_on_screen = get_post_meta($ofg->ID, 'hide_on_screen', true) ) {
|
||||
$nfg['hide_on_screen'] = maybe_unserialize($hide_on_screen);
|
||||
}
|
||||
|
||||
// save field group
|
||||
// acf_upgrade_field_group will call the acf_get_valid_field_group function and apply 'compatibility' changes
|
||||
$nfg = acf_update_field_group( $nfg );
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/upgrade_500_field_group', $nfg, $ofg);
|
||||
|
||||
// log
|
||||
acf_dev_log('acf_upgrade_500_field_group', $ofg, $nfg);
|
||||
|
||||
// upgrade fields
|
||||
acf_upgrade_500_fields( $ofg, $nfg );
|
||||
|
||||
// trash?
|
||||
if( $ofg->post_status == 'trash' ) {
|
||||
acf_trash_field_group( $nfg['ID'] );
|
||||
}
|
||||
|
||||
// return
|
||||
return $nfg;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_upgrade_500_fields
|
||||
*
|
||||
* Upgrades all ACF4 fields to ACF5 from a specific field group
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param object $ofg The old field group post object.
|
||||
* @param array $nfg The new field group array.
|
||||
* @return void
|
||||
*/
|
||||
function acf_upgrade_500_fields( $ofg, $nfg ) {
|
||||
|
||||
// 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);
|
||||
|
||||
// check
|
||||
if( $rows ) {
|
||||
|
||||
// vars
|
||||
$checked = array();
|
||||
|
||||
// loop
|
||||
foreach( $rows as $row ) {
|
||||
|
||||
// vars
|
||||
$field = $row['meta_value'];
|
||||
$field = maybe_unserialize( $field );
|
||||
$field = maybe_unserialize( $field ); // run again for WPML
|
||||
|
||||
// bail early if key already migrated (potential duplicates in DB)
|
||||
if( isset($checked[ $field['key'] ]) ) continue;
|
||||
$checked[ $field['key'] ] = 1;
|
||||
|
||||
// add parent
|
||||
$field['parent'] = $nfg['ID'];
|
||||
|
||||
// migrate field
|
||||
$field = acf_upgrade_500_field( $field );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_upgrade_500_field
|
||||
*
|
||||
* Upgrades a ACF4 field to ACF5
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param array $field The old field.
|
||||
* @return array $field The new field.
|
||||
*/
|
||||
function acf_upgrade_500_field( $field ) {
|
||||
|
||||
// order_no is now menu_order
|
||||
$field['menu_order'] = acf_extract_var( $field, 'order_no', 0 );
|
||||
|
||||
// correct very old field keys (field2 => field_2)
|
||||
if( substr($field['key'], 0, 6) !== 'field_' ) {
|
||||
$field['key'] = 'field_' . str_replace('field', '', $field['key']);
|
||||
}
|
||||
|
||||
// extract sub fields
|
||||
$sub_fields = array();
|
||||
if( $field['type'] == 'repeater' ) {
|
||||
|
||||
// loop over sub fields
|
||||
if( !empty($field['sub_fields']) ) {
|
||||
foreach( $field['sub_fields'] as $sub_field ) {
|
||||
$sub_fields[] = $sub_field;
|
||||
}
|
||||
}
|
||||
|
||||
// remove sub fields from field
|
||||
unset( $field['sub_fields'] );
|
||||
|
||||
} elseif( $field['type'] == 'flexible_content' ) {
|
||||
|
||||
// loop over layouts
|
||||
if( is_array($field['layouts']) ) {
|
||||
foreach( $field['layouts'] as $i => $layout ) {
|
||||
|
||||
// generate key
|
||||
$layout['key'] = uniqid('layout_');
|
||||
|
||||
// loop over sub fields
|
||||
if( !empty($layout['sub_fields']) ) {
|
||||
foreach( $layout['sub_fields'] as $sub_field ) {
|
||||
$sub_field['parent_layout'] = $layout['key'];
|
||||
$sub_fields[] = $sub_field;
|
||||
}
|
||||
}
|
||||
|
||||
// remove sub fields from layout
|
||||
unset( $layout['sub_fields'] );
|
||||
|
||||
// update
|
||||
$field['layouts'][ $i ] = $layout;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// save field
|
||||
$field = acf_update_field( $field );
|
||||
|
||||
// log
|
||||
acf_dev_log('acf_upgrade_500_field', $field);
|
||||
|
||||
// sub fields
|
||||
if( $sub_fields ) {
|
||||
foreach( $sub_fields as $sub_field ) {
|
||||
$sub_field['parent'] = $field['ID'];
|
||||
acf_upgrade_500_field($sub_field);
|
||||
}
|
||||
}
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/update_500_field', $field);
|
||||
|
||||
// return
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_upgrade_550
|
||||
*
|
||||
* Version 5.5 adds support for the wp_termmeta table added in WP 4.4.
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function acf_upgrade_550() {
|
||||
|
||||
// log
|
||||
acf_dev_log('acf_upgrade_550');
|
||||
|
||||
// action
|
||||
do_action('acf/upgrade_550');
|
||||
|
||||
// do tasks
|
||||
acf_upgrade_550_termmeta();
|
||||
|
||||
// update version
|
||||
acf_update_db_version('5.5.0');
|
||||
}
|
||||
|
||||
/**
|
||||
* acf_upgrade_550_termmeta
|
||||
*
|
||||
* Upgrades all ACF4 termmeta saved in wp_options to the wp_termmeta table.
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
function acf_upgrade_550_termmeta() {
|
||||
|
||||
// log
|
||||
acf_dev_log('acf_upgrade_550_termmeta');
|
||||
|
||||
// bail early if no wp_termmeta table
|
||||
if( get_option('db_version') < 34370 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get all taxonomies
|
||||
$taxonomies = get_taxonomies(false, 'objects');
|
||||
|
||||
// loop
|
||||
if( $taxonomies ) {
|
||||
foreach( $taxonomies as $taxonomy ) {
|
||||
acf_upgrade_550_taxonomy( $taxonomy->name );
|
||||
}}
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/upgrade_550_termmeta');
|
||||
}
|
||||
|
||||
/*
|
||||
* acf_wp_upgrade_550_termmeta
|
||||
*
|
||||
* When the database is updated to support term meta, migrate ACF term meta data across.
|
||||
*
|
||||
* @date 23/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param string $wp_db_version The new $wp_db_version.
|
||||
* @param string $wp_current_db_version The old (current) $wp_db_version.
|
||||
* @return void
|
||||
*/
|
||||
function acf_wp_upgrade_550_termmeta( $wp_db_version, $wp_current_db_version ) {
|
||||
if( $wp_db_version >= 34370 && $wp_current_db_version < 34370 ) {
|
||||
if( acf_version_compare(acf_get_db_version(), '>', '5.5.0') ) {
|
||||
acf_upgrade_550_termmeta();
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'wp_upgrade', 'acf_wp_upgrade_550_termmeta', 10, 2 );
|
||||
|
||||
/**
|
||||
* acf_upgrade_550_taxonomy
|
||||
*
|
||||
* Upgrades all ACF4 termmeta for a specific taxonomy.
|
||||
*
|
||||
* @date 24/8/18
|
||||
* @since 5.7.4
|
||||
*
|
||||
* @param string $taxonomy The taxonomy name.
|
||||
* @return void
|
||||
*/
|
||||
function acf_upgrade_550_taxonomy( $taxonomy ) {
|
||||
|
||||
// log
|
||||
acf_dev_log('acf_upgrade_550_taxonomy', $taxonomy);
|
||||
|
||||
// global
|
||||
global $wpdb;
|
||||
|
||||
// vars
|
||||
$search = $taxonomy . '_%';
|
||||
$_search = '_' . $search;
|
||||
|
||||
// escape '_'
|
||||
// http://stackoverflow.com/questions/2300285/how-do-i-escape-in-sql-server
|
||||
$search = str_replace('_', '\_', $search);
|
||||
$_search = str_replace('_', '\_', $_search);
|
||||
|
||||
// search
|
||||
// results show faster query times using 2 LIKE vs 2 wildcards
|
||||
$rows = $wpdb->get_results($wpdb->prepare(
|
||||
"SELECT *
|
||||
FROM $wpdb->options
|
||||
WHERE option_name LIKE %s
|
||||
OR option_name LIKE %s",
|
||||
$search,
|
||||
$_search
|
||||
), ARRAY_A);
|
||||
|
||||
// loop
|
||||
if( $rows ) {
|
||||
foreach( $rows as $row ) {
|
||||
|
||||
/*
|
||||
Use regex to find "(_)taxonomy_(term_id)_(field_name)" and populate $matches:
|
||||
Array
|
||||
(
|
||||
[0] => _category_3_color
|
||||
[1] => _
|
||||
[2] => 3
|
||||
[3] => color
|
||||
)
|
||||
*/
|
||||
if( !preg_match("/^(_?){$taxonomy}_(\d+)_(.+)/", $row['option_name'], $matches) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// vars
|
||||
$term_id = $matches[2];
|
||||
$meta_name = $matches[1] . $matches[3];
|
||||
$meta_value = $row['option_value'];
|
||||
|
||||
// log
|
||||
acf_dev_log('acf_upgrade_550_term', $term_id, $meta_name, $meta_value);
|
||||
|
||||
// update
|
||||
update_metadata( 'term', $term_id, $meta_name, $meta_value );
|
||||
}}
|
||||
|
||||
// action for 3rd party
|
||||
do_action('acf/upgrade_550_taxonomy', $taxonomy);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -377,11 +377,21 @@ function acf_validate_value( $value, $field, $input ) {
|
|||
}
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$valid = apply_filters( "acf/validate_value", $valid, $value, $field, $input );
|
||||
$valid = apply_filters( "acf/validate_value/type={$field['type']}", $valid, $value, $field, $input );
|
||||
$valid = apply_filters( "acf/validate_value/name={$field['name']}", $valid, $value, $field, $input );
|
||||
$valid = apply_filters( "acf/validate_value/key={$field['key']}", $valid, $value, $field, $input );
|
||||
/**
|
||||
* Filters whether the value is valid.
|
||||
*
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param bool $valid The valid status. Return a string to display a custom error message.
|
||||
* @param mixed $value The value.
|
||||
* @param array $field The field array.
|
||||
* @param string $input The input element's name attribute.
|
||||
*/
|
||||
$valid = apply_filters( "acf/validate_value/type={$field['type']}", $valid, $value, $field, $input );
|
||||
$valid = apply_filters( "acf/validate_value/name={$field['_name']}", $valid, $value, $field, $input );
|
||||
$valid = apply_filters( "acf/validate_value/key={$field['key']}", $valid, $value, $field, $input );
|
||||
$valid = apply_filters( "acf/validate_value", $valid, $value, $field, $input );
|
||||
|
||||
|
||||
// allow $valid to be a custom error message
|
||||
|
|
|
|||
|
|
@ -1,176 +1,119 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
class acf_wpml_compatibility {
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('ACF_WPML_Compatibility') ) :
|
||||
|
||||
class ACF_WPML_Compatibility {
|
||||
|
||||
var $lang = '';
|
||||
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* This function will construct all the neccessary actions and filters
|
||||
* Sets up the class functionality.
|
||||
*
|
||||
* @type function
|
||||
* @date 23/06/12
|
||||
* @since 3.1.8
|
||||
*
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// global
|
||||
global $sitepress;
|
||||
|
||||
|
||||
// vars
|
||||
$this->lang = acf_maybe_get_POST('_acf_lang', ICL_LANGUAGE_CODE);
|
||||
|
||||
|
||||
// update settings
|
||||
acf_update_setting('default_language', $sitepress->get_default_language());
|
||||
acf_update_setting('current_language', $this->lang);
|
||||
acf_update_setting('current_language', $sitepress->get_current_language());
|
||||
|
||||
// localize data
|
||||
acf_localize_data(array(
|
||||
'language' => $sitepress->get_current_language()
|
||||
));
|
||||
|
||||
// actions
|
||||
add_action('acf/verify_ajax', array($this, 'verify_ajax'));
|
||||
add_action('acf/input/admin_footer', array($this, 'admin_footer'));
|
||||
add_action('acf/input/form_data', array($this, 'acf_input_form_data'), 10, 1);
|
||||
// switch lang during AJAX action
|
||||
add_action('acf/verify_ajax', array($this, 'verify_ajax'));
|
||||
|
||||
// prevent 'acf-field' from being translated
|
||||
add_filter('get_translatable_documents', array($this, 'get_translatable_documents'));
|
||||
|
||||
// always prevent 'acf-field' from being translated
|
||||
add_filter('get_translatable_documents', array($this, 'get_translatable_documents'));
|
||||
|
||||
|
||||
// bail early if not transaltable
|
||||
if( !$this->is_translatable() ) return;
|
||||
|
||||
|
||||
// actions
|
||||
add_action('acf/update_500', array($this, 'update_500'), 10);
|
||||
add_action('acf/update_500_field_group', array($this, 'update_500_field_group'), 10, 2);
|
||||
add_action('acf/update_field_group', array($this, 'update_field_group'), 2, 1);
|
||||
add_action('icl_make_duplicate', array($this, 'icl_make_duplicate'), 10, 4);
|
||||
|
||||
|
||||
// filters
|
||||
add_filter('acf/settings/save_json', array($this, 'settings_save_json'));
|
||||
add_filter('acf/settings/load_json', array($this, 'settings_load_json'));
|
||||
|
||||
// check if 'acf-field-group' is translatable
|
||||
if( $this->is_translatable() ) {
|
||||
|
||||
// actions
|
||||
add_action('acf/upgrade_500_field_group', array($this, 'upgrade_500_field_group'), 10, 2);
|
||||
add_action('icl_make_duplicate', array($this, 'icl_make_duplicate'), 10, 4);
|
||||
|
||||
// filters
|
||||
add_filter('acf/settings/save_json', array($this, 'settings_save_json'));
|
||||
add_filter('acf/settings/load_json', array($this, 'settings_load_json'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* is_translatable
|
||||
*
|
||||
* This fucntion will return true if the acf-field-group post type is translatable
|
||||
* Returns true if the acf-field-group post type is translatable.
|
||||
* Also adds compatibility with ACF4 settings
|
||||
*
|
||||
* @type function
|
||||
* @date 10/04/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
* @param void
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
function is_translatable() {
|
||||
|
||||
// global
|
||||
global $sitepress;
|
||||
|
||||
|
||||
// vars
|
||||
$post_types = $sitepress->get_setting('custom_posts_sync_option');
|
||||
|
||||
// return false if no post types
|
||||
if( !acf_is_array($post_types) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// bail early if no post types
|
||||
if( !acf_is_array($post_types) ) return false;
|
||||
|
||||
|
||||
// always prevent 'acf-field' from being translated
|
||||
$post_types['acf-field'] = 0;
|
||||
$sitepress->set_setting('custom_posts_sync_option', $post_types);
|
||||
// prevent 'acf-field' from being translated
|
||||
if( !empty($post_types['acf-field']) ) {
|
||||
$post_types['acf-field'] = 0;
|
||||
$sitepress->set_setting('custom_posts_sync_option', $post_types);
|
||||
}
|
||||
|
||||
// when upgrading to version 5, review 'acf' setting
|
||||
// update 'acf-field-group' if 'acf' is translatable, and 'acf-field-group' does not yet exist
|
||||
if( !empty($post_types['acf']) && !isset($post_types['acf-field-group']) ) {
|
||||
$post_types['acf-field-group'] = 1;
|
||||
$sitepress->set_setting('custom_posts_sync_option', $post_types);
|
||||
}
|
||||
|
||||
// return true if acf-field-group is translatable
|
||||
if( !empty($post_types['acf-field-group']) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// return true if acf is translatable, and acf-field-group does not yet exist
|
||||
if( !empty($post_types['acf']) && !isset($post_types['acf-field-group']) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_500
|
||||
/**
|
||||
* upgrade_500_field_group
|
||||
*
|
||||
* This function will update the WPML settings to allow 'acf-field-group' to be translatable
|
||||
* Update the icl_translations table data when creating the field groups.
|
||||
*
|
||||
* @type function
|
||||
* @date 10/04/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
* @param array $field_group The new field group array.
|
||||
* @param object $ofg The old field group WP_Post object.
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function update_500() {
|
||||
|
||||
// global
|
||||
global $sitepress;
|
||||
|
||||
|
||||
// vars
|
||||
$post_types = $sitepress->get_setting('custom_posts_sync_option');
|
||||
|
||||
|
||||
// bail early if no post types
|
||||
if( !acf_is_array($post_types) ) return false;
|
||||
|
||||
|
||||
// post type has changed from 'acf' to 'acf-field-group'
|
||||
if( !empty($post_types['acf']) ) {
|
||||
|
||||
$post_types['acf-field-group'] = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update
|
||||
$sitepress->set_setting('custom_posts_sync_option', $post_types);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_500_field_group
|
||||
*
|
||||
* This function will update the icl_translations table data when creating the fiedl groups
|
||||
*
|
||||
* @type function
|
||||
* @date 10/04/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $field_group (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function update_500_field_group($field_group, $ofg) {
|
||||
function upgrade_500_field_group($field_group, $ofg) {
|
||||
|
||||
// global
|
||||
global $wpdb;
|
||||
|
||||
|
||||
// get translation rows (old acf4 and new acf5)
|
||||
$old_row = $wpdb->get_row($wpdb->prepare(
|
||||
"SELECT * FROM {$wpdb->prefix}icl_translations WHERE element_type=%s AND element_id=%d",
|
||||
|
|
@ -182,38 +125,28 @@ class acf_wpml_compatibility {
|
|||
'post_acf-field-group', $field_group['ID']
|
||||
), ARRAY_A);
|
||||
|
||||
|
||||
// bail ealry if no rows
|
||||
if( !$old_row || !$new_row ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// create reference of old trid to new trid
|
||||
// trid is a simple int used to find associated objects
|
||||
if( empty($this->trid_ref) ) {
|
||||
|
||||
$this->trid_ref = array();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update trid
|
||||
if( isset($this->trid_ref[ $old_row['trid'] ]) ) {
|
||||
|
||||
// this field group is a translation of another, update it's trid to match the previously inserted group
|
||||
$new_row['trid'] = $this->trid_ref[ $old_row['trid'] ];
|
||||
|
||||
} else {
|
||||
|
||||
// this field group is the first of it's translations, update the reference for future groups
|
||||
$this->trid_ref[ $old_row['trid'] ] = $new_row['trid'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update icl_translations
|
||||
// Row is created by WPML, and much easier to tweak it here due to the very complicated and nonsensical WPML logic
|
||||
$table = "{$wpdb->prefix}icl_translations";
|
||||
|
|
@ -222,292 +155,148 @@ class acf_wpml_compatibility {
|
|||
$data_format = array( '%d', '%s' );
|
||||
$where_format = array( '%d' );
|
||||
|
||||
|
||||
// allow source_language_code to equal NULL
|
||||
if( $old_row['source_language_code'] ) {
|
||||
|
||||
$data['source_language_code'] = $old_row['source_language_code'];
|
||||
$data_format[] = '%s';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update wpdb
|
||||
$result = $wpdb->update( $table, $data, $where, $data_format, $where_format );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_field_group
|
||||
*
|
||||
* This function will update the lang when saving a field group
|
||||
*
|
||||
* @type function
|
||||
* @date 10/03/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $field_group (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function update_field_group( $field_group ) {
|
||||
|
||||
global $sitepress;
|
||||
|
||||
$this->lang = $sitepress->get_language_for_element($field_group['ID'], 'post_acf-field-group');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* settings_save_json
|
||||
*
|
||||
* This function is hooked into the acf/update_field_group action and will save all field group data to a .json file
|
||||
* Modifies the json path.
|
||||
*
|
||||
* @type function
|
||||
* @date 19/05/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
* @param string $path The json save path.
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function settings_save_json( $path ) {
|
||||
|
||||
|
||||
// bail early if dir does not exist
|
||||
if( !is_writable($path) ) {
|
||||
|
||||
return $path;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// remove trailing slash
|
||||
$path = untrailingslashit( $path );
|
||||
|
||||
|
||||
// ammend
|
||||
$path = $path . '/' . $this->lang;
|
||||
|
||||
$path = untrailingslashit($path) . '/' . acf_get_setting('current_language');
|
||||
|
||||
// make dir if does not exist
|
||||
if( !file_exists($path) ) {
|
||||
|
||||
mkdir($path, 0777, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $path;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* settings_load_json
|
||||
*
|
||||
* description
|
||||
* Modifies the json path.
|
||||
*
|
||||
* @type function
|
||||
* @date 19/05/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
* @param string $path The json save path.
|
||||
* @return string
|
||||
*/
|
||||
function settings_load_json( $paths ) {
|
||||
|
||||
if( !empty($paths) ) {
|
||||
|
||||
foreach( $paths as $i => $path ) {
|
||||
|
||||
// remove trailing slash
|
||||
$path = untrailingslashit( $path );
|
||||
|
||||
|
||||
// ammend
|
||||
$paths[ $i ] = $path . '/' . $this->lang;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// loop
|
||||
if( $paths ) {
|
||||
foreach( $paths as $i => $path ) {
|
||||
$paths[ $i ] = untrailingslashit($path) . '/' . acf_get_setting('current_language');
|
||||
}}
|
||||
|
||||
// return
|
||||
return $paths;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* icl_make_duplicate
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 26/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function icl_make_duplicate( $master_post_id, $lang, $postarr, $id ) {
|
||||
|
||||
// validate
|
||||
// bail early if not acf-field-group
|
||||
if( $postarr['post_type'] != 'acf-field-group' ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// update the lang
|
||||
acf_update_setting('current_language', $lang);
|
||||
|
||||
// duplicate field group
|
||||
// duplicate field group specifying the $post_id
|
||||
acf_duplicate_field_group( $master_post_id, $id );
|
||||
|
||||
|
||||
// always translate independately to avoid many many bugs!
|
||||
// - translation post gets a new key (post_name) when origional post is saved
|
||||
// - local json creates new files due to changed key
|
||||
global $iclTranslationManagement;
|
||||
|
||||
$iclTranslationManagement->reset_duplicate_flag( $id );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_footer
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 27/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function admin_footer() {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
|
||||
// add filter
|
||||
acf.add_filter('prepare_for_ajax', function( args ){
|
||||
|
||||
// append
|
||||
args.lang = '<?php echo $this->lang; ?>';
|
||||
|
||||
|
||||
// return
|
||||
return args;
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* verify_ajax
|
||||
*
|
||||
* This function will help avoid WPML conflicts when performing an ACF ajax request
|
||||
* Sets the correct language during AJAX requests.
|
||||
*
|
||||
* @type function
|
||||
* @date 7/08/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function verify_ajax() {
|
||||
|
||||
// globals
|
||||
global $sitepress;
|
||||
|
||||
|
||||
// vars
|
||||
$lang = acf_maybe_get($_POST, 'lang');
|
||||
|
||||
|
||||
// bail early if no lang
|
||||
if( !$lang ) return;
|
||||
|
||||
|
||||
// switch lang
|
||||
// set the language for this AJAX request
|
||||
// this will allow get_posts to work as expected (load posts from the correct language)
|
||||
$sitepress->switch_lang( $_REQUEST['lang'] );
|
||||
|
||||
|
||||
// remove post_id
|
||||
// this will prevent WPML from setting the current language based on the current post being edited
|
||||
// in theory, WPML is correct, however, when adding a new post, the post's lang is not found and will default to 'en'
|
||||
unset( $_REQUEST['post_id'] );
|
||||
|
||||
if( isset($_REQUEST['lang']) ) {
|
||||
global $sitepress;
|
||||
$sitepress->switch_lang( $_REQUEST['lang'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_input_form_data
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 16/12/16
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function acf_input_form_data( $data ) {
|
||||
|
||||
// bail early if not options
|
||||
if( $data['nonce'] !== 'options' ) return;
|
||||
|
||||
|
||||
// add hidden input
|
||||
acf_hidden_input(array('id' => '_acf_lang', 'name' => '_acf_lang', 'value' => $this->lang));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* get_translatable_documents
|
||||
*
|
||||
* This filter will remove 'acf-field' from the available post types for translation
|
||||
* Removes 'acf-field' from the available post types for translation.
|
||||
*
|
||||
* @type function
|
||||
* @date 17/8/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
* @param array $icl_post_types The array of post types.
|
||||
* @return array
|
||||
*/
|
||||
|
||||
function get_translatable_documents( $icl_post_types ) {
|
||||
|
||||
// unset
|
||||
unset( $icl_post_types['acf-field'] );
|
||||
|
||||
|
||||
// return
|
||||
return $icl_post_types;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new acf_wpml_compatibility();
|
||||
acf_new_instance('ACF_WPML_Compatibility');
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
Binary file not shown.
1823
lang/acf-de_DE.po
1823
lang/acf-de_DE.po
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
1938
lang/acf-fa_IR.po
1938
lang/acf-fa_IR.po
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
|
@ -3,15 +3,15 @@ msgstr ""
|
|||
"Project-Id-Version: Advanced Custom Fields Pro v5.2.9\n"
|
||||
"Report-Msgid-Bugs-To: http://support.advancedcustomfields.com\n"
|
||||
"POT-Creation-Date: 2018-02-06 10:08+1000\n"
|
||||
"PO-Revision-Date: 2018-02-22 18:04+0100\n"
|
||||
"Last-Translator: Maxime BERNARD-JACQUET <maxime@dysign.fr>\n"
|
||||
"PO-Revision-Date: 2018-09-10 13:39-0400\n"
|
||||
"Last-Translator: David Lapointe <info@dlg.pw>\n"
|
||||
"Language-Team: Dysign <maxime@dysign.fr>\n"
|
||||
"Language: fr_FR\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
"X-Generator: Poedit 2.0.4\n"
|
||||
"X-Generator: Poedit 2.1.1\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
||||
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
||||
|
|
@ -571,7 +571,7 @@ msgstr "Aucun fichier sélectionné"
|
|||
|
||||
#: includes/admin/tools/class-acf-admin-tool-import.php:113
|
||||
msgid "Error uploading file. Please try again"
|
||||
msgstr "Echec de l'import du fichier. Merci de réessayer"
|
||||
msgstr "Échec de l'import du fichier. Merci de réessayer"
|
||||
|
||||
#: includes/admin/tools/class-acf-admin-tool-import.php:122
|
||||
msgid "Incorrect file type"
|
||||
|
|
@ -2556,7 +2556,7 @@ msgstr "Recherche en cours…"
|
|||
#: includes/fields/class-acf-field-select.php:49
|
||||
msgctxt "Select2 JS load_fail"
|
||||
msgid "Loading failed"
|
||||
msgstr "Echec du chargement"
|
||||
msgstr "Échec du chargement"
|
||||
|
||||
#: includes/fields/class-acf-field-select.php:255 includes/media.php:54
|
||||
msgctxt "verb"
|
||||
|
|
@ -2878,7 +2878,7 @@ msgstr "Validé avec succès"
|
|||
#: includes/input.php:262 includes/validation.php:285
|
||||
#: includes/validation.php:296
|
||||
msgid "Validation failed"
|
||||
msgstr "Echec de la validation"
|
||||
msgstr "Échec de la validation"
|
||||
|
||||
#: includes/input.php:263
|
||||
msgid "1 field requires attention"
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
1749
lang/acf-ru_RU.po
1749
lang/acf-ru_RU.po
File diff suppressed because it is too large
Load Diff
521
lang/acf.pot
521
lang/acf.pot
File diff suppressed because it is too large
Load Diff
27
readme.txt
27
readme.txt
|
|
@ -66,6 +66,33 @@ From your WordPress dashboard
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 5.7.6 =
|
||||
*Release Date - 12 September 2018*
|
||||
|
||||
* Fix - Fixed unload prompt not working.
|
||||
* Dev - Reduced number of queries needed to populate the relationship field taxonomy filter.
|
||||
* Dev - Added 'nav_menu_item_id' and 'nav_menu_item_depth' to get_field_groups() query.
|
||||
* Dev - Reordered various actions and filters for more usefulness.
|
||||
* i18n - Updated Polish language thanks to Dariusz Zielonka
|
||||
|
||||
= 5.7.5 =
|
||||
*Release Date - 6 September 2018*
|
||||
|
||||
* Fix - Fixed bug causing multisite login redirect issues.
|
||||
* Fix - Fixed bug causing validation issues in older versions of Firefox.
|
||||
* Fix - Fixed bug causing duplicate Select2 instances when adding a widget via drag/drop.
|
||||
* Dev - Improved WPML compatibility by using `$sitepress->get_current_language()` instead of `ICL_LANGUAGE_CODE`.
|
||||
* Dev - Improved validation JS with new Validator model and logic.
|
||||
|
||||
= 5.7.4 =
|
||||
*Release Date - 30 August 2018*
|
||||
|
||||
* Fix - Fixed bug causing field groups to disappear when selecting a taxonomy term with WPML active.
|
||||
* Tweak - Added more Dark Mode styles.
|
||||
* Tweak - Improved DB upgrade prompt, functions and AJAX logic.
|
||||
* Tweak - Improved the "What's New" admin page seen after DB Upgrade.
|
||||
* Dev - Added new location rules filters.
|
||||
|
||||
= 5.7.3 =
|
||||
*Release Date - 20 August 2018*
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue