Skip to content

Commit

Permalink
update plugins/advanced-custom-fields-pro
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleBlanchette committed Nov 27, 2024
1 parent e51c55d commit 0a6cfd3
Show file tree
Hide file tree
Showing 34 changed files with 445 additions and 472 deletions.
94 changes: 86 additions & 8 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.9
* Version: 6.3.11
* 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.9';
public $version = '6.3.11';

/**
* The plugin settings array.
Expand Down Expand Up @@ -130,6 +130,7 @@ public function initialize() {
'enable_shortcode' => true,
'enable_bidirection' => true,
'enable_block_bindings' => true,
'enable_meta_box_cb_edit' => true,
);

// Include utility functions.
Expand Down Expand Up @@ -227,15 +228,13 @@ public function initialize() {
// Include legacy.
acf_include( 'includes/legacy/legacy-locations.php' );

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

// Include PRO.
acf_include( 'pro/acf-pro.php' );

if ( is_admin() && function_exists( 'acf_is_pro' ) && ! acf_is_pro() ) {

// Include WPE update system.
acf_include( 'includes/class-PluginUpdater.php' );
acf_include( 'includes/acf-upgrades.php' );

acf_include( 'includes/admin/admin-options-pages-preview.php' );
}

Expand Down Expand Up @@ -396,12 +395,24 @@ public function init() {
*/
do_action( 'acf/include_taxonomies', ACF_MAJOR_VERSION );

// If we're on 6.5 or newer, load block bindings. This will move to an autoloader in 6.3.
// If we're on 6.5 or newer, load block bindings. This will move to an autoloader in 6.4.
if ( version_compare( get_bloginfo( 'version' ), '6.5-beta1', '>=' ) ) {
acf_include( 'includes/Blocks/Bindings.php' );
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 @@ -788,6 +799,73 @@ 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.
*
* @since 6.0.1
* @since 6.2.8 - Renamed to acf_pro_get_home_url to match pro exclusive function naming.
* @since 6.3.10 - Renamed to acf_get_home_url now updater logic applies to free.
*
* @return string $home_url The output from home_url, sans known third party filters which cause license activation issues.
*/
function acf_get_home_url() {
if ( acf_is_pro() ) {
// Disable WPML and TranslatePress's home url overrides for our license check.
add_filter( 'wpml_get_home_url', 'acf_pro_license_ml_intercept', 99, 2 );
add_filter( 'trp_home_url', 'acf_pro_license_ml_intercept', 99, 2 );

if ( acf_pro_is_legacy_multisite() && acf_is_multisite_sub_site() ) {
$home_url = get_home_url( get_main_site_id() );
} else {
$home_url = home_url();
}

// Re-enable WPML and TranslatePress's home url overrides.
remove_filter( 'wpml_get_home_url', 'acf_pro_license_ml_intercept', 99 );
remove_filter( 'trp_home_url', 'acf_pro_license_ml_intercept', 99 );
} else {
$home_url = home_url();
}

return $home_url;
}

/**
* The main function responsible for returning the one true acf Instance to functions everywhere.
* Use this function like you would a global variable, except without needing to declare the global.
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@
* @package ACF
*/

namespace ACF;

use WP_Error;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( ! class_exists( 'ACF_Updates' ) ) {
if ( ! class_exists( 'Updater' ) ) {

/**
* class for handling API services.
*/
class ACF_Updates {
class Updater {

/**
* The ACF_Updates version
* The Updater version
*
* @var string
*/
public $version = '2.4';
public $version = '3.0';

/**
* The array of registered plugins
Expand All @@ -45,8 +49,8 @@ class ACF_Updates {
*/
public function __construct() {

// disable showing updates if show updates is hidden.
if ( ! acf_pro_is_updates_page_visible() ) {
// disable showing PRO updates if show updates is hidden.
if ( acf_is_pro() && ! acf_pro_is_updates_page_visible() ) {
return;
}

Expand Down Expand Up @@ -120,7 +124,16 @@ public function get_plugin_by( $key = '', $value = null ) {
*/
public function request( $endpoint = '', $body = null ) {

// Determine URL.
$site_url = acf_get_home_url();
if ( empty( $site_url ) || ! is_string( $site_url ) ) {
$site_url = '';
}

$headers = array(
'X-ACF-Version' => ACF_VERSION,
'X-ACF-URL' => $site_url,
);

$url = "https://connect.advancedcustomfields.com/$endpoint";

// Staging environment.
Expand All @@ -129,27 +142,25 @@ public function request( $endpoint = '', $body = null ) {
acf_log( $url, $body );
}

$license_key = acf_pro_get_license_key();
if ( ! $license_key ) {
$license_key = '';
}

$site_url = acf_pro_get_home_url();
if ( ! $site_url ) {
$site_url = '';
// Determine URL.
if ( acf_is_pro() ) {
$license_key = acf_pro_get_license_key();
if ( empty( $license_key ) || ! is_string( $license_key ) ) {
$license_key = '';
}
$headers['X-ACF-License'] = $license_key;
$headers['X-ACF-Plugin'] = 'pro';
} else {
$headers['X-ACF-Plugin'] = 'acf';
}

// Make request.
$raw_response = wp_remote_post(
$url,
array(
'timeout' => 28,
'timeout' => 20,
'body' => $body,
'headers' => array(
'X-ACF-Version' => ACF_VERSION,
'X-ACF-License' => $license_key,
'X-ACF-URL' => $site_url,
),
'headers' => $headers,
)
);

Expand Down Expand Up @@ -298,7 +309,7 @@ public function get_plugin_updates( $force_check = false ) {
'wp' => wp_json_encode(
array(
'wp_name' => get_bloginfo( 'name' ),
'wp_url' => acf_pro_get_home_url(),
'wp_url' => acf_get_home_url(),
'wp_version' => get_bloginfo( 'version' ),
'wp_language' => get_bloginfo( 'language' ),
'wp_timezone' => get_option( 'timezone_string' ),
Expand All @@ -310,7 +321,7 @@ public function get_plugin_updates( $force_check = false ) {
array(
'acf_version' => get_option( 'acf_version' ),
'acf_pro' => acf_is_pro(),
'block_count' => acf_pro_get_registered_block_count(),
'block_count' => function_exists( 'acf_pro_get_registered_block_count' ) ? acf_pro_get_registered_block_count() : 0,
)
),
);
Expand Down Expand Up @@ -481,34 +492,4 @@ public function modify_plugin_details( $result, $action = null, $args = null ) {
}
}


/**
* 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_Updates The singleton instance of ACF_Updates.
*/
function acf_updates() {
global $acf_updates;
if ( ! isset( $acf_updates ) ) {
$acf_updates = new ACF_Updates();
}
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 );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// There are many ways to WordPress.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,15 @@ public function save_post( $post_id, $post ) {
$_POST['acf_post_type']['ID'] = $post_id;
$_POST['acf_post_type']['title'] = isset( $_POST['acf_post_type']['labels']['name'] ) ? $_POST['acf_post_type']['labels']['name'] : '';

if ( ! acf_get_setting( 'enable_meta_box_cb_edit' ) ) {
$_POST['acf_post_type']['register_meta_box_cb'] = '';

$existing_post = acf_maybe_unserialize( $post->post_content );
if ( ! empty( $existing_post['register_meta_box_cb'] ) ) {
$_POST['acf_post_type']['register_meta_box_cb'] = $existing_post['register_meta_box_cb'];
}
}

// Save the post type.
acf_update_internal_post_type( $_POST['acf_post_type'], $this->post_type ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Validated in verify_save_post
// phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,29 @@ public function save_post( $post_id, $post ) {
$_POST['acf_taxonomy']['ID'] = $post_id;
$_POST['acf_taxonomy']['title'] = isset( $_POST['acf_taxonomy']['labels']['name'] ) ? $_POST['acf_taxonomy']['labels']['name'] : '';

if ( ! acf_get_setting( 'enable_meta_box_cb_edit' ) ) {
$_POST['acf_taxonomy']['meta_box_cb'] = '';
$_POST['acf_taxonomy']['meta_box_sanitize_cb'] = '';

if ( ! empty( $_POST['acf_taxonomy']['meta_box'] ) && 'custom' === $_POST['acf_taxonomy']['meta_box'] ) {
$_POST['acf_taxonomy']['meta_box'] = 'default';
}

$existing_post = acf_maybe_unserialize( $post->post_content );

if ( ! empty( $existing_post['meta_box'] ) ) {
$_POST['acf_taxonomy']['meta_box'] = $existing_post['meta_box'];
}

if ( ! empty( $existing_post['meta_box_cb'] ) ) {
$_POST['acf_taxonomy']['meta_box_cb'] = $existing_post['meta_box_cb'];
}

if ( ! empty( $existing_post['meta_box_sanitize_cb'] ) ) {
$_POST['acf_taxonomy']['meta_box_sanitize_cb'] = $existing_post['meta_box_sanitize_cb'];
}
}

// Save the taxonomy.
acf_update_internal_post_type( $_POST['acf_taxonomy'], $this->post_type ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Validated in verify_save_post
// phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
?>
<div class="acf-field-settings-footer">
<a class="button close-field edit-field" title="<?php esc_attr_e( 'Close Field', 'acf' ); ?>" href="#"><?php esc_html_e( 'Close Field', 'acf' ); ?></a>
<a class="acf-btn acf-btn-secondary close-add-field" title="<?php esc_attr_e( 'Close and Add Field', 'acf' ); ?>" href="#"><?php esc_html_e( 'Close and Add Field', 'acf' ); ?></a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

<ul class="acf-hl acf-tfoot">
<li class="acf-fr">
<a href="#" class="acf-btn acf-btn-secondary add-field"><i class="acf-icon acf-icon-plus"></i><?php esc_html_e( 'Add Field', 'acf' ); ?></a>
<a href="#" class="acf-btn acf-btn-sm add-field"><i class="acf-icon acf-icon-plus"></i><?php esc_html_e( 'Add Field', 'acf' ); ?></a>
</li>
</ul>

Expand Down
Loading

0 comments on commit 0a6cfd3

Please sign in to comment.