(int) $id ); } } } // Check if it is an array of arrays with term_id keys. // [{term_id: 123}, {term_id: 456}] if ( isset( $newsletter_categories[0] ) && is_array( $newsletter_categories[0] ) && isset( $newsletter_categories[0]['term_id'] ) ) { foreach ( $newsletter_categories as $category ) { if ( isset( $category['term_id'] ) && is_numeric( $category['term_id'] ) ) { $formatted_categories[] = array( 'term_id' => (int) $category['term_id'] ); } } } if ( empty( $formatted_categories ) ) { return false; } return update_option( self::NEWSLETTER_CATEGORIES_OPTION, $formatted_categories ) ? $formatted_categories : false; } }