<?php
/**
 * @package edoobox
 */

namespace Edoobox\Api;

class PostApi
{
    public static function all() {
        return get_posts([
            'numberposts' => -1,
            'post_type'   => ['post', 'page', 'et_pb_layout', 'angebote'],
            'post_status' => ['publish', 'draft', 'pending', 'private', 'inherit'],
        ]);
    }

    public static function allWithShortcode(string $shortcode) : array {
        ShortcodeApi::registerShortcode($shortcode);
        return array_filter(self::all(), function ($post) use ($shortcode) {
            return strpos($post->post_content, "[$shortcode") !== false; // don't change to !! strpos;
        });
    }
}