Skip to content

Commit

Permalink
Updates to 6.3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ACF committed Jan 23, 2025
1 parent 71ccf95 commit 9fa1872
Show file tree
Hide file tree
Showing 145 changed files with 28,129 additions and 16,077 deletions.
58 changes: 5 additions & 53 deletions acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Plugin Name: Advanced Custom Fields PRO
* Plugin URI: https://www.advancedcustomfields.com
* Description: Customize WordPress with powerful, professional and intuitive fields.
* Version: 6.3.11
* Version: 6.3.12
* Author: WP Engine
* Author URI: https://wpengine.com/?utm_source=wordpress.org&utm_medium=referral&utm_campaign=plugin_directory&utm_content=advanced_custom_fields
* Update URI: false
Expand All @@ -36,7 +36,7 @@ class ACF {
*
* @var string
*/
public $version = '6.3.11';
public $version = '6.3.12';

/**
* The plugin settings array.
Expand Down Expand Up @@ -228,10 +228,10 @@ public function initialize() {
// Include legacy.
acf_include( 'includes/legacy/legacy-locations.php' );

// Include updater.
acf_include( 'includes/Updater/Updater.php' );
// Include updater if included with this build.
acf_include( 'includes/Updater/init.php' );

// Include PRO.
// Include PRO if included with this build.
acf_include( 'pro/acf-pro.php' );

if ( is_admin() && function_exists( 'acf_is_pro' ) && ! acf_is_pro() ) {
Expand Down Expand Up @@ -401,18 +401,6 @@ public function init() {
new ACF\Blocks\Bindings();
}

// If we're ACF free, register the updater.
if ( function_exists( 'acf_is_pro' ) && ! acf_is_pro() ) {
acf_register_plugin_update(
array(
'id' => 'acf',
'slug' => acf_get_setting( 'slug' ),
'basename' => acf_get_setting( 'basename' ),
'version' => acf_get_setting( 'version' ),
)
);
}

/**
* Fires after ACF is completely "initialized".
*
Expand Down Expand Up @@ -799,42 +787,6 @@ public function acf_plugin_activated() {
}
}

if ( ! class_exists( 'ACF_Updates' ) ) {
/**
* The main function responsible for returning the acf_updates singleton.
* Use this function like you would a global variable, except without needing to declare the global.
*
* Example: <?php $acf_updates = acf_updates(); ?>
*
* @since 5.5.12
*
* @return ACF\Updater The singleton instance of Updater.
*/
function acf_updates() {
global $acf_updates;
if ( ! isset( $acf_updates ) ) {
$acf_updates = new ACF\Updater();
}
return $acf_updates;
}

/**
* Alias of acf_updates()->add_plugin().
*
* @since 5.5.10
*
* @param array $plugin Plugin data array.
*/
function acf_register_plugin_update( $plugin ) {
acf_updates()->add_plugin( $plugin );
}

/**
* Register a dummy ACF_Updates class for back compat.
*/
class ACF_Updates {} //phpcs:ignore -- Back compat.
}

/**
* An ACF specific getter to replace `home_url` in our license checks to ensure we can avoid third party filters.
*
Expand Down
2 changes: 1 addition & 1 deletion assets/build/js/acf-input.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/build/js/pro/acf-pro-blocks.min.js

Large diffs are not rendered by default.

126 changes: 126 additions & 0 deletions includes/Updater/init.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php
/**
* Initializes ACF updater logic and logic specific to ACF direct downloads.
*
* @package ACF
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// Include updater.
acf_include( 'includes/Updater/Updater.php' );

if ( ! class_exists( 'ACF_Updates' ) ) {
/**
* The main function responsible for returning the acf_updates singleton.
* Use this function like you would a global variable, except without needing to declare the global.
*
* Example: <?php $acf_updates = acf_updates(); ?>
*
* @since 5.5.12
*
* @return ACF\Updater The singleton instance of Updater.
*/
function acf_updates() {
global $acf_updates;
if ( ! isset( $acf_updates ) ) {
$acf_updates = new ACF\Updater();
}
return $acf_updates;
}

/**
* Alias of acf_updates()->add_plugin().
*
* @since 5.5.10
*
* @param array $plugin Plugin data array.
*/
function acf_register_plugin_update( $plugin ) {
acf_updates()->add_plugin( $plugin );
}

/**
* Register a dummy ACF_Updates class for back compat.
*/
class ACF_Updates {} //phpcs:ignore -- Back compat.
}

/**
* Registers updates for the free version of ACF hosted on connect.
*
* @return void
*/
function acf_register_free_updates() {
// If we're ACF free, register the updater.
if ( function_exists( 'acf_is_pro' ) && ! acf_is_pro() ) {
acf_register_plugin_update(
array(
'id' => 'acf',
'slug' => acf_get_setting( 'slug' ),
'basename' => acf_get_setting( 'basename' ),
'version' => acf_get_setting( 'version' ),
)
);
}
}
add_action( 'acf/init', 'acf_register_free_updates' );

/**
* Filters the "Update Source" param in the ACF site health.
*
* @since 6.3.11.1
*
* @param string $update_source The original update source.
* @return string
*/
function acf_direct_update_source( $update_source ) {
return __( 'ACF Direct', 'acf' );
}
add_filter( 'acf/site_health/update_source', 'acf_direct_update_source' );

/**
* Unsets ACF from reporting back to the WP.org API.
*
* @param array $args An array of HTTP request arguments.
* @param string $url The request URL.
* @return array|mixed
*/
function acf_unset_plugin_from_org_reporting( $args, $url ) {
// Bail if not a plugins request.
if ( empty( $args['body']['plugins'] ) ) {
return $args;
}

// Bail if not a request to the wp.org API.
$parsed_url = wp_parse_url( $url );
if ( empty( $parsed_url['host'] ) || 'api.wordpress.org' !== $parsed_url['host'] ) {
return $args;
}

$plugins = json_decode( $args['body']['plugins'], true );
if ( empty( $plugins ) ) {
return $args;
}

// Remove ACF from reporting.
if ( ! empty( $plugins['plugins'][ ACF_BASENAME ] ) ) {
unset( $plugins['plugins'][ ACF_BASENAME ] );
}

if ( ! empty( $plugins['active'] ) && is_array( $plugins['active'] ) ) {
$is_active = array_search( ACF_BASENAME, $plugins['active'], true );
if ( $is_active !== false ) {
unset( $plugins['active'][ $is_active ] );
$plugins['active'] = array_values( $plugins['active'] );
}
}

// Add the plugins list (minus ACF) back to $args.
$args['body']['plugins'] = wp_json_encode( $plugins );

return $args;
}
add_filter( 'http_request_args', 'acf_unset_plugin_from_org_reporting', 10, 2 );
11 changes: 10 additions & 1 deletion includes/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,18 @@ public function admin_footer_text( $text ) {
$wp_engine_link = acf_add_url_utm_tags( 'https://wpengine.com/', 'bx_prod_referral', acf_is_pro() ? 'acf_pro_plugin_footer_text' : 'acf_free_plugin_footer_text', false, 'acf_plugin', 'referral' );
$acf_link = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/', 'footer', 'footer' );

if ( acf_is_pro() ) {
return sprintf(
/* translators: This text is prepended by a link to ACF's website, and appended by a link to WP Engine's website. */
'<a href="%1$s" target="_blank">ACF&#174;</a> and <a href="%1$s" target="_blank">ACF&#174; PRO</a> ' . __( 'are developed and maintained by', 'acf' ) . ' <a href="%2$s" target="_blank">WP Engine</a>.',
$acf_link,
$wp_engine_link
);
}

return sprintf(
/* translators: This text is prepended by a link to ACF's website, and appended by a link to WP Engine's website. */
'<a href="%1$s" target="_blank">' . ( acf_is_pro() ? 'ACF PRO' : 'ACF' ) . '</a> ' . __( 'is developed and maintained by', 'acf' ) . ' <a href="%2$s" target="_blank">WP Engine</a>.',
'<a href="%1$s" target="_blank">ACF&#174;</a> ' . __( 'is developed and maintained by', 'acf' ) . ' <a href="%2$s" target="_blank">WP Engine</a>.',
$acf_link,
$wp_engine_link
);
Expand Down
1 change: 1 addition & 0 deletions includes/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ public function print_footer_scripts() {
'editor' => acf_is_block_editor() ? 'block' : 'classic',
'is_pro' => acf_is_pro(),
'debug' => acf_is_beta() || ( defined( 'ACF_DEVELOPMENT_MODE' ) && ACF_DEVELOPMENT_MODE ),
'StrictMode' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && version_compare( $wp_version, '6.6', '>=' ),
);

acf_localize_data( $data_to_localize );
Expand Down
2 changes: 1 addition & 1 deletion includes/class-acf-site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function get_site_health_values(): array {

$fields['update_source'] = array(
'label' => __( 'Update Source', 'acf' ),
'value' => __( 'ACF Direct', 'acf' ),
'value' => apply_filters( 'acf/site_health/update_source', __( 'wordpress.org', 'acf' ) ),
);

if ( $is_pro ) {
Expand Down
44 changes: 0 additions & 44 deletions includes/upgrades.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,47 +537,3 @@ function acf_upgrade_550_taxonomy( $taxonomy ) {
// action for 3rd party
do_action( 'acf/upgrade_550_taxonomy', $taxonomy );
}

/**
* Unsets ACF from reporting back to the WP.org API.
*
* @param array $args An array of HTTP request arguments.
* @param string $url The request URL.
* @return array|mixed
*/
function acf_unset_plugin_from_org_reporting( $args, $url ) {
// Bail if not a plugins request.
if ( empty( $args['body']['plugins'] ) ) {
return $args;
}

// Bail if not a request to the wp.org API.
$parsed_url = wp_parse_url( $url );
if ( empty( $parsed_url['host'] ) || 'api.wordpress.org' !== $parsed_url['host'] ) {
return $args;
}

$plugins = json_decode( $args['body']['plugins'], true );
if ( empty( $plugins ) ) {
return $args;
}

// Remove ACF from reporting.
if ( ! empty( $plugins['plugins'][ ACF_BASENAME ] ) ) {
unset( $plugins['plugins'][ ACF_BASENAME ] );
}

if ( ! empty( $plugins['active'] ) && is_array( $plugins['active'] ) ) {
$is_active = array_search( ACF_BASENAME, $plugins['active'], true );
if ( $is_active !== false ) {
unset( $plugins['active'][ $is_active ] );
$plugins['active'] = array_values( $plugins['active'] );
}
}

// Add the plugins list (minus ACF) back to $args.
$args['body']['plugins'] = wp_json_encode( $plugins );

return $args;
}
add_filter( 'http_request_args', 'acf_unset_plugin_from_org_reporting', 10, 2 );
12 changes: 11 additions & 1 deletion includes/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,23 @@ function reset_errors() {
*/
public function ajax_validate_save_post() {
if ( ! acf_verify_ajax() ) {
if ( empty( $_REQUEST['nonce'] ) ) {
$nonce_error = __( 'ACF was unable to perform validation because no nonce was received by the server.', 'acf' );
} else {
$nonce_error = __( 'ACF was unable to perform validation because the provided nonce failed verification.', 'acf' );
}

wp_send_json_success(
array(
'valid' => 0,
'errors' => array(
array(
'input' => false,
'message' => __( 'ACF was unable to perform validation due to an invalid security nonce being provided.', 'acf' ),
'message' => $nonce_error,
'action' => array(
'label' => __( 'Learn more', 'acf' ),
'url' => acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/validation-nonce-errors/', 'docs', 'validation-nonce' ),
),
),
),
)
Expand Down
Loading

0 comments on commit 9fa1872

Please sign in to comment.