<?php
namespace Wpupgrader\Libraries\WordPress\Plugins\Core;

\defined('ABSPATH') || die('ABSPATH is undefined? Please check your WordPress installation.');

use Wpupgrader\Libraries\WordPress\Plugins\Core\Factory\Blocks;

abstract class Core extends Singleton implements PluginBaseInterface
{
    use ConfigTrait;

    public function __construct(BaseConfig &$config)
    {
        $this->setConfig($config);

        include_once ABSPATH.'wp-admin/includes/plugin.php';

        $this->dependent_check();

        /* Exclude Multiple Content Types From Yoast SEO */
        \add_action('add_meta_boxes', function() {
            \remove_meta_box('wpseo_meta', ["gdprc_consent", "gdprc_script"], 'normal');
        }, 100);

        /* Exclude Multiple Content Types From Yoast SEO Sitemap */
        \add_filter('wpseo_sitemap_exclude_post_type', function($value, $post_type) {
            if (\in_array($post_type, ["gdprc_consent", "gdprc_script"])) {
                return true;
            }
        }, 10, 2);
    }

    abstract protected function dependent_check();

    public function getBlock($name)
    {
        $blockFactory = new Blocks($this->config);
        return $blockFactory->getBlock($name);
    }
}
