Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin updates February 2025. #241

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
58 changes: 5 additions & 53 deletions wp-content/plugins/advanced-custom-fields-pro/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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

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 );
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
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
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
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 );
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