<?php

if (!defined('ABSPATH')) {
    exit;
}

final class BBC_Db
{
    public static function update_post_content($post_id, $content)
    {
        global $wpdb;
        $post_id = intval($post_id);
        if ($post_id <= 0) {
            return new WP_Error('bbc_invalid_post', 'BBC target post id is invalid.', array('status' => 400));
        }
        $wpdb->update(
            $wpdb->posts,
            array('post_content' => (string) $content),
            array('ID' => $post_id),
            array('%s'),
            array('%d')
        );
        clean_post_cache($post_id);
        return true;
    }
}
