0 ? $port : ( 'https' === wp_parse_url( $url, PHP_URL_SCHEME ) ? 443 : 80 ); $pin = static function ( $handle ) use ( $host, $port ) { curl_setopt( $handle, CURLOPT_RESOLVE, array( $host . ':' . $port . ':127.0.0.1' ) ); return $handle; }; add_filter( 'http_api_curl', $pin ); $response = wp_remote_post( $url, array( 'timeout' => 5, 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), 'body' => array( 'action' => self::ACTION, 'what' => $what, 'ts' => $ts, 'sig' => self::signature( $ts, $what ), ), ) ); remove_filter( 'http_api_curl', $pin ); $answer = is_wp_error( $response ) ? null : json_decode( (string) wp_remote_retrieve_body( $response ), true ); $done = is_array( $answer ) && ! empty( $answer['success'] ) ? implode( ',', (array) ( $answer['data']['dropped'] ?? array() ) ) : ''; if ( defined( 'WP_CLI' ) && WP_CLI ) { if ( '' !== $done ) { WP_CLI::debug( 'The web server dropped its cached copies: ' . $done . '.', 'aieo' ); } else { WP_CLI::warning( 'Rooster One could not reach the web server to drop its cached copies (' . $what . '); they expire on their own.' ); } } } public static function handle() { $what = isset( $_POST['what'] ) ? sanitize_text_field( wp_unslash( $_POST['what'] ) ) : ''; $ts = isset( $_POST['ts'] ) ? absint( $_POST['ts'] ) : 0; $sig = isset( $_POST['sig'] ) ? sanitize_text_field( wp_unslash( $_POST['sig'] ) ) : ''; if ( abs( time() - $ts ) > 120 || ! hash_equals( self::signature( (string) $ts, $what ), $sig ) ) { wp_send_json_error( null, 403 ); } $dropped = array(); foreach ( explode( ',', $what ) as $part ) { if ( 'settings' === $part ) { wp_cache_delete( 'aieo_dmm_settings', 'options' ); wp_cache_delete( 'alloptions', 'options' ); wp_cache_delete( 'notoptions', 'options' ); if ( class_exists( 'AIEO_DMM_Settings' ) ) { AIEO_DMM_Settings::flush_memo(); } $dropped[] = 'settings'; } elseif ( 'seo' === $part && class_exists( 'AIEO_SEO_Head' ) && function_exists( 'wp_cache_supports' ) && wp_cache_supports( 'flush_group' ) ) { wp_cache_flush_group( AIEO_SEO_Head::CACHE_GROUP ); $dropped[] = 'seo'; } } wp_send_json_success( array( 'dropped' => $dropped ) ); } } AIEO_Web_Cache_Sync::init();