*/ final class PresizedDivPushHandler implements PushEndpointHandlerInterface { /** * {@inheritDoc} * * @since 4.3.0 * @return string */ public function endpoint() { return 'presized-div'; } /** * {@inheritDoc} * * @since 4.3.0 * @return string */ public function event_type() { return 'wordpress.presized_div.updated'; // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledInText -- Actirise API event-type identifier. } /** * {@inheritDoc} * * @since 4.3.0 * @return int[] */ public function supported_versions() { return array( 1 ); } /** * Apply a full presized-div configuration. * * The payload must be a list of slot objects, each an array carrying a string * `slotName`; anything else is treated as a schema error and rejected with a * 400 by the controller. An empty list is a valid full replace โ€” it removes * every slot. The merge (reused by the polling fallback) preserves the * publisher's per-slot `active` toggles. * * @since 4.3.0 * @param mixed $data The full presized-div configuration array. * @return bool True when the configuration was applied. */ public function apply( $data ) { if ( ! is_array( $data ) ) { return false; } foreach ( $data as $slot ) { if ( ! is_array( $slot ) || ! isset( $slot['slotName'] ) || ! is_string( $slot['slotName'] ) ) { return false; } } Cron::merge_presized_div_config( $data ); return true; } }