<?php
/**
 * Plugin Name: Blazemedia Offers Black Hole
 * Plugin URI: https://www.blazemedia.it/
 * Description: Removes old affiliation news and put them into the blackhole post-type
 * Version: 1.1.0
 * Author: Blazemedia
 * Author URI: https://blazemedia.it/
 * License: http://www.apache.org/licenses/LICENSE-2.0
 * Text Domain: blz-blackhole
 * Network: false
 *
 * @package blackhole
 *
 * Copyright 2023 Blazemedia (email: techteam@blazemedia.it)
 *
 */
define( 'BLAZE_BLACKHOLE_PATH'   , plugin_dir_path( __FILE__ ) );
define( 'BLAZE_BLACKHOLE_URI'    , plugin_dir_url( __FILE__ ) );
define( 'BLAZE_BLACKHOLE_VERSION', "1.1.0");

if( defined('DOING_CRON') ) return;


require_once BLAZE_BLACKHOLE_PATH . '/vendor/autoload.php';

// use Blazemedia\Blackhole\API;
use Blazemedia\Blackhole\CustomPostTypes;
use Blazemedia\Blackhole\Settings;

class Blackhole {

	public function __construct() {

		CustomPostTypes\Blackhole::init();
		/// Imposta ruolo Blackhole Manager e assegna le capability
		/// per quel ruolo e per gli amministratori
		Settings\Capability::getInstance( 'restrizioni_1' );
		/// aggiunge la pagina dei settings del plugin backend
		new Settings\SettingPage;

		if ( defined( 'WP_CLI' ) && WP_CLI ) {
			require_once __DIR__ . '/wp-cli/populate_post_offer_db.php';
			require_once __DIR__ . '/wp-cli/offers_2_blackhole.php';
		}

	}


	function is_wp_rest_api() {

		return str_contains( $_SERVER['REQUEST_URI'], 'wp-json' );
	}
}


new Blackhole;
