acf_unset_plugin_from_org_reporting()
Unsets ACF from reporting back to the WP.org API.
No Hooks.
Returns
Array|Mixed.
Usage
acf_unset_plugin_from_org_reporting( $args, $url );
- $args(array) (required)
- An array of HTTP request arguments.
- $url(string) (required)
- The request URL.
acf_unset_plugin_from_org_reporting() acf unset plugin from org reporting code ACF 6.8.8
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;
}